This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 271883 - Class package-info.class not loaded by ProxyClassLoader when running on Java 9 SE
Summary: Class package-info.class not loaded by ProxyClassLoader when running on Java ...
Status: NEW
Alias: None
Product: platform
Classification: Unclassified
Component: Module System (show other bugs)
Version: Dev
Hardware: PC Windows 10 x64
: P3 normal (vote)
Assignee: Tomas Hurka
Depends on:
Reported: 2017-12-04 23:41 UTC by adik
Modified: 2017-12-05 11:30 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:

Basic findClass implementation for JarClassLoader (944 bytes, patch)
2017-12-05 11:30 UTC, adik
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description adik 2017-12-04 23:41:20 UTC
A package-info.class is not loaded from an NB module in Java 9 anymore. The internal implementaiton of Package.getAnnotation changed in Java 9 in order to support modules. In Java 9, the class package-info.class is loaded using a module name. When running old (Java 8) code an unnamed module is used and the ClassLoader's (Java 9) method loadClass(Module module, String name) delegates to findClass(String name) which is not overriden by ProxyClassLoader.

As can be seen, the loadClass(String mame) method is bypassed when using Java 9.
Comment 1 adik 2017-12-05 11:30:13 UTC
Created attachment 165536 [details]
Basic findClass implementation for JarClassLoader

This patch modifies JarClassLoader such that it overrides ClassLoader#findClass(String name) method. The findClass employs doLoadClass directly.

This implementation seems to be correct w.r.t. the Reflection API, since when a class is explored a class loader which loaded it is used. In the platform, this should be the class loader of the module to which the class belongs. Also the relevant package-info should belong to the same module.

This implementation will probably break when the platform is modularized using Java 9 modules. But in this case, the ProxyClassLoader will break anyway since then the loading will not take code path through ProxyClassLoader#loadClass(String, boolean).