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

groovy:execute on Java 11 gives WARNING: Illegal reflective access #18

Open
bobtiernay-okta opened this issue Aug 11, 2019 · 2 comments

Comments

@bobtiernay-okta
Copy link

bobtiernay-okta commented Aug 11, 2019

Using:

$java -version
openjdk version "11.0.4" 2019-07-16 LTS
OpenJDK Runtime Environment Corretto-11.0.4.11.1 (build 11.0.4+11-LTS)
OpenJDK 64-Bit Server VM Corretto-11.0.4.11.1 (build 11.0.4+11-LTS, mixed mode)

executing the following:

$ mvn -N groovy:execute

with:

<plugin>
    <groupId>org.codehaus.gmaven</groupId>
    <artifactId>groovy-maven-plugin</artifactId>
    <version>2.1.1</version>
    <executions>
        <execution>
            <id>default-cli</id>
            <configuration>
                <source>${root.dir}/src/main/groovy/project.groovy</source>
                <scriptpath>
                    <path>${root.dir}/src/main/groovy</path>
                </scriptpath>
            </configuration>
        </execution>
    </executions>
</plugin>

gives:

[INFO] Scanning for projects...
...
[INFO]
[INFO] --- groovy-maven-plugin:2.1.1:execute (default-cli) @ lake ---
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.codehaus.groovy.reflection.CachedClass (file:/Users/btiernay/.m2/repository/org/codehaus/groovy/groovy-all/2.4.9/groovy-all-2.4.9.jar) to method java.lang.Object.finalize()
WARNING: Please consider reporting this to the maintainers of org.codehaus.groovy.reflection.CachedClass
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
...

Which is likely related to https://issues.apache.org/jira/browse/GROOVY-8339.

I'm wondering if there is a way to pass the --illegal-access=warn compiler option to prevent this, perhaps with a new plugin configuration?

@jdillon
Copy link
Member

jdillon commented Aug 13, 2019

I am not really sure how Java 11 works in this respect, mostly only know that Java 11 breaks a lot of things so I am still mostly using Java 8. But I can probably get some time to take a closer look and maybe look at what a more modern groovy version has in terms of compiler flags.

@jbliznak
Copy link

As @bobtiernay-okta identified the root cause is groovy issue so the workaround is to override groovy-all version in plugin declaration with version 3.0.0-beta-1 or newer, following https://github.com/groovy/gmaven/blob/gmaven-2.x/groovy-maven-plugin/src/site/markdown/index.md :

<plugin>
    <groupId>org.codehaus.gmaven</groupId>
    <artifactId>groovy-maven-plugin</artifactId>
    <version>2.1.1</version>
    <executions>
        <execution>
            ...
        </execution>
    </executions>
    <dependencies>
        <dependency>
            <groupId>org.codehaus.groovy</groupId>
            <artifactId>groovy-all</artifactId>
            <version>3.0.0-beta-3</version>
            <type>pom</type>
        </dependency>
    </dependencies>
</plugin>

@jdillon probably just update the version and change type to pom at https://github.com/groovy/gmaven/blob/gmaven-2.x/gmaven-adapter-impl/pom.xml#L58 but as I don't have much insight in groovy I can't tell whether it could break something else or not, however, the warning is gone.

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

3 participants