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

Use CLASSPATH for scanning java9 system classes #1933

Closed
gregw opened this issue Nov 1, 2017 · 3 comments
Closed

Use CLASSPATH for scanning java9 system classes #1933

gregw opened this issue Nov 1, 2017 · 3 comments
Assignees
Milestone

Comments

@gregw
Copy link
Contributor

gregw commented Nov 1, 2017

In java8, the system classloader is a URLClassloader, so jar locations could be discovered when scanning for annotations. In java9, the classloader is no longer a URLClassloader, so when scanning system jars if a non URLClassloader parent loader is discovered, the System.property classpath should be used to find jars to scan.

This problem should be raised with the appropriate java mailing list to ask how are system jars meant to be scanned for discovered annotations?

@gregw gregw added the jdk9 label Nov 1, 2017
@gregw gregw added this to the 9.4.x milestone Nov 1, 2017
@gregw
Copy link
Contributor Author

gregw commented Nov 1, 2017

Alternately use something like:

        Optional<ModuleReference> moduleRef = ModuleFinder.ofSystem().find("java.base");
        if (moduleRef.isPresent())
        {
            ModuleReader reader = moduleRef.get().open();
            String collect = reader.list()
                    .sorted()
                    .collect(Collectors.joining(System.lineSeparator()));
            System.err.println(collect);
        }

@janbartel
Copy link
Contributor

I don't think these are mutually exclusive alternatives. According to "java --help" , -cp is still a valid argument, but they have also added:

  • --module-path
  • --upgrade-module-path

According to the javadoc, you can retrieve these as system properties:

  • java.class.path
  • jdk.module.path
  • jdk.module.upgrade.path

So IIUC, one must examine both the classpath and the module path in order to discover annotations.

janbartel added a commit that referenced this issue Nov 15, 2017
Signed-off-by: Jan Bartel <janb@webtide.com>
janbartel added a commit that referenced this issue Nov 16, 2017
Add some comments, changes from code review.

Signed-off-by: Jan Bartel <janb@webtide.com>
@janbartel
Copy link
Contributor

Committed to jetty-9.4.x and master branches.

janbartel added a commit that referenced this issue Nov 21, 2017
Do not set java.class.path when running with the distro.
janbartel added a commit that referenced this issue Nov 22, 2017
Cherry-pick of 29373c6 and 44d170e
@sbordet sbordet mentioned this issue Aug 27, 2018
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

No branches or pull requests

2 participants