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

Improve @WebParam class loading in JsonRpcBasicServer #314

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

cyb3r4nt
Copy link
Contributor

@cyb3r4nt cyb3r4nt commented Jun 13, 2023

Improve @WebParam class loading in JsonRpcBasicServer

javax.jws.WebParam class is part of JDK in Java 1.8, and it is always present.
If Jakarta variant is also present in classpath, then needs to be loaded first,
otherwise it will be overridden by javax.jws.WebParam from JDK 1.8.
Tests are successful when JDK 11+ is used, because javax.jws.WebParam is no longer present by default,
and proper class is loaded.

There may be applications where both javax.jws.WebParam and jakarta.jws.WebParam are present.
This new implementation tries to load both classes and use them in the detection of method parameters.
This means that older code, which uses javax.jws.WebParam, should be fine even if application has newer dependency versions, where jakarta.jws.WebParam is also included.
When JDK 11+ is used and there are jakarta.jws.WebParam annotated parameters present in the application,
then a jar containing javax.jws.WebParam class should be explicitly included into classpath.

This probably fixes problems in issue #310
Test issues in #310 can be reproduced with JDK 1.8.

javax.jws.WebParam class is part of JDK in Java 1.8, and it is always present.
If Jakarta variant is present in classpath,
then needs to be loaded first,
otherwise it will be overridden with javax.jws.WebParam from JDK 1.8

The drawback is that it changes previous behavior and expectations.
If jakarta.jws.WebParam is in classpath,
then methods annotated with javax.jws.WebParam may no longer work.


Signed-off-by: cyb3r4nt <[email protected]>
…e time

Previous class loading solution assumed that there is only one @WebParam class.
Both of these annotation classes may be used in some applications.

This current change tries to load both classes if these are available from classpath.
Then both classes are used in detection of method parameters.


Signed-off-by: cyb3r4nt <[email protected]>
@cyb3r4nt cyb3r4nt marked this pull request as ready for review June 13, 2023 16:05
@cyb3r4nt cyb3r4nt changed the title Reorder @WebParam class loading in JsonRpcBasicServer Improve @WebParam class loading in JsonRpcBasicServer Jun 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant