Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
3.6.0
Description
On Java 9 and above, calls to java.lang.Package.getAnnotation(Class) from within a Mojo always return null (unless the package-info class has been loaded by some other means before).
The reason appears to be an incompatibility between Java 9 and Plexus Classworlds:
- Java 9 ultimately calls findClass (instead of loadClass) to get the package-info class.
- The findClass implementation in ClassRealm always throws ClassNotFoundException: https://github.com/codehaus-plexus/plexus-classworlds/blob/master/src/main/java/org/codehaus/plexus/classworlds/realm/ClassRealm.java#L275.
This in particular affects plugins that interact with the JAXB API because it relies on package annotations.
A workaround is to preload the required package-info classes using loadClass; see e.g. http://svn.apache.org/viewvc?rev=1845026&view=rev.
Attachments
Issue Links
- is duplicated by
-
MNG-6543 Upgrade plexus classworld to support java 9+ ClassLoader.findClass(String moduleName, String name) in Mojos
- Closed
- links to