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

Add explicit module-info class file, to prevent resolving all automatic modules #17

Closed
VISTALL opened this issue Oct 19, 2020 · 4 comments

Comments

@VISTALL
Copy link

VISTALL commented Oct 19, 2020

Is your feature request related to a problem? Please describe.
At current moment jakarta-inject library have Automatic-Module-Name attribute, if we using boot classloader it's ok.

But when multi-classloader env, resolving automatic modules have problem. Problem in this jdk code https://github.com/openjdk/jdk/blob/master/src/java.base/share/classes/java/lang/module/Resolver.java#L160

For example:

  • App-Container start with self modules (which resolved by default due, java start with -p/-m arguments)
  • App-Container want initialize app1 in own classloader, and create ModuleLayer for it.
  • App-Container load all jars from app1 and want resolve it by Resolver. But due some limitation - not all jars must be initialized as modules (java.lang.module.Configuration#resolve parameter roots, what modules must be resolved).
  • And then we try to resolve jakarta-inject inside app1 which for now automatic-module. And jdk will resolve ALL automatic modules (https://github.com/openjdk/jdk/blob/master/src/java.base/share/classes/java/lang/module/Resolver.java#L160) and it will resolve all not targeted modules

Describe the solution you'd like
Add module-info class file to jar file. It can be placed in jar root, or in META-INF/versions/9/, old jvms skip this file anyway.

There many ways how generate it. Check gson library or log4j2.

Also up release to 9 target.

I use own maven-plugin which generate module-info, and place it to target directory (https://github.com/consulo/java9-maven-plugin)

Describe alternatives you've considered
Leave as is Automatic-Module-Name

Thanks

@msgilligan
Copy link

msgilligan commented Jan 12, 2021

Would there be interest in a PR to do this? If so, which of @VISTALL's suggested approaches would be preferred?

UPDATE: There is a PR now: #19 (which bumps the target JDK 11, which may not be the most popular approach)

@rbygrave
Copy link
Contributor

rbygrave commented Oct 4, 2021

FYI: This issue will be resolved with #20 which has been just merged.

@Ladicek
Copy link
Contributor

Ladicek commented Oct 5, 2021

As mentioned, fixed in #20.

@Ladicek Ladicek closed this as completed Oct 5, 2021
@VISTALL
Copy link
Author

VISTALL commented Oct 5, 2021

Hello. New build pushed to public maven repository? If not - when it will be pushed

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 a pull request may close this issue.

4 participants