Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-10164

RootLoader cannot be set as system class loader in Java 12+

Agile BoardAttach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 4.0.0-beta-1, 3.0.9, 2.5.16
    • None
    • None

    Description

      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

          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);
      
      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)
      

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            emilles Eric Milles
            emilles Eric Milles
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - Not Specified
              Not Specified
              Remaining:
              Remaining Estimate - 0h
              0h
              Logged:
              Time Spent - 20m
              20m

              Slack

                Issue deployment