You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2021/07/16 16:49:00 UTC

[jira] [Resolved] (GROOVY-10164) RootLoader cannot be set as system class loader in Java 12+

     [ https://issues.apache.org/jira/browse/GROOVY-10164?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Eric Milles resolved GROOVY-10164.
----------------------------------
    Fix Version/s: 4.0.0-beta-1
       Resolution: Fixed

> RootLoader cannot be set as system class loader in Java 12+
> -----------------------------------------------------------
>
>                 Key: GROOVY-10164
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10164
>             Project: Groovy
>          Issue Type: Bug
>            Reporter: Eric Milles
>            Assignee: Eric Milles
>            Priority: Minor
>             Fix For: 4.0.0-beta-1
>
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> Support for {{-Djava.system.class.loader=org.codehaus.groovy.tools.RootLoader}} is missing for Java 12+.  The constructor that accepts {{ClassLoader}} is private.  See code excerpt below that tries to call this constructor using reflection.
> java.lang.ClassLoader
> {code:java}
>     static synchronized ClassLoader initSystemClassLoader() {
>         // ...
>         String cn = System.getProperty("java.system.class.loader");
>         if (cn != null) {
>             try {
>                 // custom class loader is only supported to be loaded from unnamed module
>                 Constructor<?> ctor = Class.forName(cn, false, builtinLoader)
>                                            .getDeclaredConstructor(ClassLoader.class);
>                 scl = (ClassLoader) ctor.newInstance(builtinLoader);
> {code}
> {code}
> java.lang.Error: class java.lang.ClassLoader (in module java.base) cannot access a member of class org.codehaus.groovy.tools.RootLoader with modifiers "private"
> 	at java.lang.ClassLoader.initSystemClassLoader(java.base@12.0.2/ClassLoader.java:1989)
> 	at java.lang.System.initPhase3(java.base@12.0.2/System.java:2132)
> Caused by: java.lang.IllegalAccessException: class java.lang.ClassLoader (in module java.base) cannot access a member of class org.codehaus.groovy.tools.RootLoader with modifiers "private"
> 	at jdk.internal.reflect.Reflection.newIllegalAccessException(java.base@12.0.2/Reflection.java:376)
> 	at java.lang.reflect.AccessibleObject.checkAccess(java.base@12.0.2/AccessibleObject.java:639)
> 	at java.lang.reflect.Constructor.newInstanceWithCaller(java.base@12.0.2/Constructor.java:490)
> 	at java.lang.reflect.Constructor.newInstance(java.base@12.0.2/Constructor.java:481)
> 	at java.lang.ClassLoader.initSystemClassLoader(java.base@12.0.2/ClassLoader.java:1977)
> 	at java.lang.System.initPhase3(java.base@12.0.2/System.java:2132)
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)