Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove a compile time reference to com.sun.jndi.ldap.LdapCtxFactory #568

Closed
wants to merge 1 commit into from
Closed

Remove a compile time reference to com.sun.jndi.ldap.LdapCtxFactory #568

wants to merge 1 commit into from

Conversation

iherasymenko
Copy link
Contributor

Fixes #543

com.sun.jndi.ldap.LdapCtxFactory is not supposed to be used by anyone but the 'java.naming' module in post Java 8 world.

Having the hard-reference leads to a class loading error when used with --illegal-access=deny or when simply put on module path.

java.lang.IllegalAccessError: class org.springframework.ldap.core.support.AbstractContextSource (in unnamed module @0x38952512) cannot access class com.sun.jndi.ldap.LdapCtxFactory (in module java.naming) because module java.naming does not export com.sun.jndi.ldap to unnamed module @0x38952512
	at org.springframework.ldap.core.support.AbstractContextSource.<clinit>(AbstractContextSource.java:77)

com.sun.jndi.ldap.LdapCtxFactory is not supposed to be used by anyone but the 'java.naming' module in post Java 8 world.

Fixes #543
@iherasymenko
Copy link
Contributor Author

iherasymenko commented Feb 4, 2021

@rwinch I would appreciate if you could provide your feedback. I did not come up with a way to cover this change with a meaningful integration test because building the project on Java 9+ will require Gradle version upgrade. However, I did test this change locally by building the library and consuming it in a project that is run with Java 15 + --illegal-access=deny flag.

@jzheaux
Copy link
Contributor

jzheaux commented Feb 23, 2021

Thanks, @iherasymenko! This is now merged into master.

@jzheaux jzheaux closed this Feb 23, 2021
@jzheaux jzheaux self-assigned this Feb 23, 2021
@jzheaux jzheaux added this to the 2.3.4 milestone Feb 23, 2021
@iherasymenko
Copy link
Contributor Author

Thank you @jzheaux for reviewing and merging this. Do you have any idea how soon 2.3.4 will be released?

@mnhock
Copy link

mnhock commented Mar 17, 2021

Will the version 2.3.4 part of the 2.4.4 Spring Boot version? Due to the Java 16 issue?

@rosti-il
Copy link

rosti-il commented Apr 9, 2021

With this change the public Class<?> getContextFactory() method may return null although the DEFAULT_CONTEXT_FACTORY is in use. This is a change of behavior. Who uses this method? If nobody uses it, could it be [1] removed or [2] return String instead of Class<?>? In both cases the type of the contextFactory field might also be changed from Class<?> to String and initialized as DEFAULT_CONTEXT_FACTORY.

I think this PR is good as a workaround that provides compatibility with recently released Java 16 to Spring LDAP 2.3.x, so please release 2.3.4 with it. Consider to do changes I proposed above in Spring LDAP 2.4.0.

@iherasymenko
Copy link
Contributor Author

@rosti-il nice catch! Using org.springframework.util.ClassUtils.resolveClassName("com.sun.jndi.ldap.LdapCtxFactory", null); will allow to preserve the existing behavior of public Class<?> getContextFactory(). @jzheaux please let us know your thoughts on this. I can prepare a PR with these changes if you'd prefer.

@rwinch
Copy link
Member

rwinch commented Apr 13, 2021

@iherasymenko Thanks for the offer. Can you please prepare a PR for the changes?

@iherasymenko
Copy link
Contributor Author

@rwinch here it is #579

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Java modules error with ldap core
5 participants