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

Replace ModulesUtil in test #483

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jbescos
Copy link
Member

@jbescos jbescos commented Mar 16, 2021

There are many failures in test when publicLookup is used.

I added a test class to replace existing classes in test-runtime:

  • src/main/java/org/eclipse/yasson/internal/model/ModulesUtil.java
  • src/main/java9/org/eclipse/yasson/internal/model/ModulesUtil.java

When tests are executed with maven-surefire-plugin the content of
'classes' is in a different module-path than 'test-classes'.

This causes the MethodHandles#publicLookup to fail. The reason is that
test classes to serialize/deserialize are coming from module 'test-classes'
and the module 'classes' has no access to it. The 'publicLookup' makes some
validations and because different modules, it fails.

This class is a workaround to bypass this issue, as it is happening in test only.

It should work if 'classes' and 'test-classes' are merged in one unique module. Probably you are questioning now, - why we don't merge both modules in one?. I actually tried it here:
https://github.com/jbescos/yasson/tree/publicLookupFix1

The problem is that we need to introduce a module-info in the test-classes and this brings a new set of problems. Currently I'm having the next issue and I don't know how to fix it:

[ERROR] WARNING: Unknown module: org.junit.platform.commons specified to --add-opens
[ERROR] WARNING: Unknown module: org.junit.platform.commons specified to --add-opens
[ERROR] java.lang.NoClassDefFoundError: org/junit/platform/commons/util/Preconditions

Signed-off-by: Jorge Bescos Gascon <[email protected]>
@jbescos jbescos force-pushed the publicLookupReplaced branch from 44167ae to 036f319 Compare March 16, 2021 15:13
@Verdent Verdent self-requested a review May 26, 2021 08:28
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.

1 participant