You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Hervé Boutemy (JIRA)" <ji...@apache.org> on 2019/03/24 03:01:00 UTC

[jira] [Comment Edited] (MNG-6506) Mojos are unable to load package annotations on Java >= 9

    [ https://issues.apache.org/jira/browse/MNG-6506?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16799741#comment-16799741 ] 

Hervé Boutemy edited comment on MNG-6506 at 3/24/19 3:00 AM:
-------------------------------------------------------------

thank you Andreas
anybody to transform that minimal test case into a Core IT?
see https://maven.apache.org/core-its/core-it-suite/
- https://github.com/apache/maven-integration-testing/tree/master/core-it-suite/src/test/java/org/apache/maven/it for the IT launcher
- https://github.com/apache/maven-integration-testing/tree/master/core-it-suite/src/test/resources for the test project


was (Author: hboutemy):
thank you Andreas
anybody to transform that minimal test case into a Core IT?

> Mojos are unable to load package annotations on Java >= 9
> ---------------------------------------------------------
>
>                 Key: MNG-6506
>                 URL: https://issues.apache.org/jira/browse/MNG-6506
>             Project: Maven
>          Issue Type: Bug
>          Components: Class Loading
>    Affects Versions: 3.6.0
>            Reporter: Andreas Veithen
>            Assignee: Sylwester Lachiewicz
>            Priority: Major
>              Labels: up-for-grabs
>             Fix For: 3.6.1
>
>
> 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.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)