groovy

Joint compiler incorrectly assumes that subclass is a Java class

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.5.4
  • Fix Version/s: 1.5.5, 1.6-beta-1
  • Component/s: None
  • Labels:
    None
  • Environment:
    Running under JDK 5 or 6
  • Number of attachments :
    0

Description

NoClassDefFoundError is thrown when compiling source - FooClass is a Groovy class that extends a Java class. This happens when an incremental build is done, never on a full build.

[groovyc] Compiling 6 source files to /workspace/myproject/build/classes
[groovyc] /workspace/myproject/com/myproject/internals/SomeClass.groovy
[groovyc]
/workspace/myproject/com/myproject/internals/SomeOtherClass.groovy
[groovyc]
/workspace/myproject/com/myproject/internals/YetAnotherClass.groovy
[groovyc] /workspace/myproject/com/myproject/mode/FooClass.groovy
[groovyc] /workspace/myproject/com/myproject/mode/DonkeyClass.groovy
[groovyc] /workspace/myproject/com/myproject/mode/BarClass.groovy
[groovyc] Exception in thread "main" java.lang.NoClassDefFoundError:
com/myproject/mode/FooClass
[groovyc] at java.lang.Class.getDeclaredFields0(Native Method)
[groovyc] at java.lang.Class.privateGetDeclaredFields(Class.java:2259)
[groovyc] at java.lang.Class.getDeclaredFields(Class.java:1715)
[groovyc] at
org.codehaus.groovy.ast.ClassNode.lazyClassInit(ClassNode.java:213)
[groovyc] at
org.codehaus.groovy.ast.ClassNode.getUnresolvedSuperClass(ClassNode.java:766)
[groovyc] at
org.codehaus.groovy.ast.ClassNode.getUnresolvedSuperClass(ClassNode.java:760)
[groovyc] at
org.codehaus.groovy.ast.ClassNode.getSuperClass(ClassNode.java:754)
[groovyc] at
org.codehaus.groovy.control.CompilationUnit.sortClasses(CompilationUnit.java:480)
[groovyc] at
org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:453)
[groovyc] at
org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:417)
[groovyc] at org.codehaus.groovy.ant.Groovyc.compile(Groovyc.java:685)
[groovyc] at org.codehaus.groovy.ant.Groovyc.execute(Groovyc.java:541)
[groovyc] at org.codehaus.groovy.ant.Groovyc.main(Groovyc.java:841)

Activity

Hide
blackdrag blackdrag added a comment -

when the super class in lazy init is intialized we need to ask the class cache in the CompilationUnit for the class instead of simply creating it. The parent class might undergo recompilation even if it is a parent of a precompiled class.

The scenario above happens only in joint compilation mode, as in a normal compilation we have either all or no classes. In the first case the java class would be used and in the second case the compilation would fail due to a missing class. But then the failure would be normal... not like here

Show
blackdrag blackdrag added a comment - when the super class in lazy init is intialized we need to ask the class cache in the CompilationUnit for the class instead of simply creating it. The parent class might undergo recompilation even if it is a parent of a precompiled class. The scenario above happens only in joint compilation mode, as in a normal compilation we have either all or no classes. In the first case the java class would be used and in the second case the compilation would fail due to a missing class. But then the failure would be normal... not like here
Hide
blackdrag blackdrag added a comment -

fixed now by looking up the class in the compilationUnit now

Show
blackdrag blackdrag added a comment - fixed now by looking up the class in the compilationUnit now

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: