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

GroovyResourceLoader not used when loading Groovy class from .groovy source

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.0-JSR-3
    • 1.0-JSR-5
    • None
    • None

    Description

      It looks like GroovyResourceLoader is not used when attempting to load a .groovy class when parsing a .groovy source.

      Consider the followowing .groovy sources:

      <snip filename="/Test.groovy">
      class Test
      extends TestSupport
      {
      }
      </snip>

      <snip filename="/TestSupport.groovy">
      class TestSupport
      {
      void test()

      { System.out.println("Testing") }

      }
      </snip>

      Creating a new GCL, and attaching a GRL that prints the attempt to load the source URL, and then parsing /Test.groovy does not show the GRL being asked to load the "Test" class.

      Instead an exception is thrown:

      <snip>
      Caused by: java.lang.ClassNotFoundException: Failed to parse groovy file: Test
      at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:679)
      at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:705)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
      at org.codehaus.plexus.component.factory.groovy.GroovyComponentFactory.newInstance(GroovyComponentFactory.java:110)
      ... 51 more
      Caused by: script1132538786147.groovy: 1: unable to resolve class TestSupport
      @ line 1, column 1.
      1 Error

      at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:325)
      at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:895)
      at org.codehaus.groovy.control.CompilationUnit.semanticAnalysis(CompilationUnit.java:626)
      at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:470)
      at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:286)
      at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:248)
      at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:243)
      at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:229)
      at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:674)
      ... 54 more
      </snip>

      The GRL does print the request to load /Test.groovy, but does not show the attempt to load /TestSupport.groovy.

      If instead asking to just parse the /Test.groovy resource, the GRL does not show any output.

      I also tried installing the GCL w/ the custom GRL as the TCL before parseClass() or loadClass() with the same results.

      It appears that classes discovered in a .groovy source that are being attempted to be loaded do not go through the same GCL and thus do not get passed through the attached GRL for resource resolution.

      I don't have any leads as to how to fix this, but I'd imagine that some GCL created during parsing the .groovy should probably delegate loading of the resource to its parent if its parent is a GCL... but I'm not sure.

      W/o this working correctly to load sources... GRL is not very usable IMO.

      I will dig somemore but if someone who knows this code better could take a look I would appreciate it.

      Attachments

        1. groovy-1149.tar.gz
          1 kB
          Jason Dillon

        Activity

          People

            Unassigned Unassigned
            jason@planet57.com Jason Dillon
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: