groovy

error running groovyc from ant

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.0-JSR-4
  • Fix Version/s: 1.0-JSR-6
  • Component/s: class generator
  • Labels:
    None
  • Number of attachments :
    0

Description

Our groovy project compiles on JSR-03 and fails to compile on JSR-04. Below are the details.

GROOVY-1.0-JSR-03
-----------------------------------------------
environment:

  • no groovy files in the ANT_HOME/lib
  • no groovy jars on the default classpath
  • all files groovy-1.0-jsr-03/lib reside in project ${dir.lib}

    excerpts from ant file:
    <path id="project.classpath">
    <!-- include the classes in this project -->
    <pathelement location="${dir.build}"/>
    <pathelement location="${dir.src}"/>
    <!-- include external libraries -->
    <fileset dir="${dir.lib}" includes="*/.jar"/>
    </path>

<taskdef name="groovyc" classpathref="project.classpath" classname="org.codehaus.groovy.ant.Groovyc">

<java classname="org.codehaus.groovy.ant.Groovyc" fork="yes" maxmemory="512m">
<classpath refid="project.classpath"/>
<arg value="${dir.build}"/>
<arg value="${dir.src}"/>
</java>

<groovyc destdir="${dir.build}" srcdir="${dir.src}" classpathref="project.classpath" stacktrace="true"/>

With JSR-03, Everything compiles successfully running Groovyc from a java task.

With JSR-03, compiling our groovy scripts with the task groovyc fails with the following error:

BUILD FAILED
C:\gsapworkspace\GAP_RATING\build.xml:72: General error during class generation: No such class: [Lcom.mutualofomaha.gsa.gap.rating.data.AgeSlopeBean; in cast for class: com.mutualofomaha.gsa.gap.rating.calc.ltd.LtdRateCalc. At [256:21] C:\gsapworkspace\GAP_RATING\src\com\mutualofomaha\gsa\gap\rating\calc\ltd\LtdRateCalc.groovy

groovy.lang.MissingClassException: No such class: [Lcom.mutualofomaha.gsa.gap.rating.data.AgeSlopeBean; in cast for class: com.mutualofomaha.gsa.gap.rating.calc.ltd.LtdRateCalc. At [256:21] C:\gsapworkspace\GAP_RATING\src\com\mutualofomaha\gsa\gap\rating\calc\ltd\LtdRateCalc.groovy
at org.codehaus.groovy.classgen.AsmClassGenerator.checkValidType(AsmClassGenerator.java:4837)
at org.codehaus.groovy.classgen.AsmClassGenerator.visitCastExpression(AsmClassGenerator.java:1885)
at org.codehaus.groovy.ast.expr.CastExpression.visit(CastExpression.java:97)
at org.codehaus.groovy.classgen.AsmClassGenerator.visitAndAutoboxBoolean(AsmClassGenerator.java:4273)
at org.codehaus.groovy.classgen.AsmClassGenerator.evaluateEqual(AsmClassGenerator.java:4117)
at org.codehaus.groovy.classgen.AsmClassGenerator.visitBinaryExpression(AsmClassGenerator.java:1154)
at org.codehaus.groovy.ast.expr.BinaryExpression.visit(BinaryExpression.java:343)
at org.codehaus.groovy.classgen.AsmClassGenerator.visitAndAutoboxBoolean(AsmClassGenerator.java:4273)
at org.codehaus.groovy.classgen.AsmClassGenerator.visitExpressionStatement(AsmClassGenerator.java:1140)
at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:70)
at org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:83)
at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:79)
at org.codehaus.groovy.classgen.AsmClassGenerator.visitMethod(AsmClassGenerator.java:401)
at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:808)
at org.codehaus.groovy.classgen.AsmClassGenerator.visitClass(AsmClassGenerator.java:297)
at org.codehaus.groovy.control.CompilationUnit$5.call(CompilationUnit.java:610)
at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:840)
at org.codehaus.groovy.control.CompilationUnit.classgen(CompilationUnit.java:556)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:461)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:423)
at org.codehaus.groovy.ant.Groovyc.compile(Groovyc.java:471)
at org.codehaus.groovy.ant.Groovyc.execute(Groovyc.java:376)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
at org.apache.tools.ant.Task.perform(Task.java:364)
at org.apache.tools.ant.Target.execute(Target.java:341)
at org.apache.tools.ant.Target.performTasks(Target.java:369)
at org.apache.tools.ant.Project.executeTarget(Project.java:1214)
at org.apache.tools.ant.Project.executeTargets(Project.java:1062)
at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:423)
at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:137)

1 Error

JSR-04
----------------------------------------------------------------------

  • deleted all groovy files out of our project lib
  • replaced all groovy jars in our project lib directory with the jars in groovy-1.0-jsr-04/lib
  • delete SNAPSHOT
  • made sure there weren't any duplicate asm*.jars

Build fails with the following trying to run Groovyc as an ant java task:
[java] null

[java] at org.codehaus.groovy.ant.Groovyc.compile(Groovyc.java:480)
[java] at org.codehaus.groovy.ant.Groovyc.execute(Groovyc.java:376)
[java] at org.codehaus.groovy.ant.Groovyc.main(Groovyc.java:131)
[java] Caused by: java.lang.NullPointerException
[java] at org.objectweb.asm.Type.getInternalName(Unknown Source)
[java] at org.codehaus.groovy.classgen.BytecodeHelper.getClassInternalName(BytecodeHelper.java:227)
[java] at org.codehaus.groovy.classgen.BytecodeHelper.getClassInternalName(BytecodeHelper.java:223)
[java] at org.codehaus.groovy.classgen.AsmClassGenerator.getStaticFieldName(AsmClassGenerator.java:1706)
[java] at org.codehaus.groovy.classgen.AsmClassGenerator.visitClassExpression(AsmClassGenerator.java:2322)
[java] at org.codehaus.groovy.classgen.AsmClassGenerator.doConvertAndCast(AsmClassGenerator.java:2724)
[java] at org.codehaus.groovy.classgen.AsmClassGenerator.doConvertAndCast(AsmClassGenerator.java:1014)
[java] at org.codehaus.groovy.classgen.AsmClassGenerator.visitCastExpression(AsmClassGenerator.java:1427)
[java] at org.codehaus.groovy.ast.expr.CastExpression.visit(CastExpression.java:96)
[java] at org.codehaus.groovy.classgen.AsmClassGenerator.visitAndAutoboxBoolean(AsmClassGenerator.java:2961)

Activity

Hide
blackdrag blackdrag added a comment -

about the first trace:
checkValidType is uncommented since version 1.41, see http://cvs.groovy.codehaus.org/viewrep/groovy/groovy/groovy-core/src/main/org/codehaus/groovy/classgen/AsmClassGenerator.java?r=1.58#l2314

1.41 was the first change to ACG after JSR-03, so it seems that jsr-04 wasn't used. Looks like classpath problems

Show
blackdrag blackdrag added a comment - about the first trace: checkValidType is uncommented since version 1.41, see http://cvs.groovy.codehaus.org/viewrep/groovy/groovy/groovy-core/src/main/org/codehaus/groovy/classgen/AsmClassGenerator.java?r=1.58#l2314 1.41 was the first change to ACG after JSR-03, so it seems that jsr-04 wasn't used. Looks like classpath problems
Hide
Scott Hickey added a comment -

I'm sorry if I didn't make what I posted very clear. The first stack trace is from JSR-03 trying to use groovyc Ant task. The second stack trace from from JSR-04. I included both in case it might help.

I should have been more concise. I couldn't get the groovyc ant task to work using JSR-03 or JSR-04. I can compile our project with the java ant task, as described in the wiki, with JSR-03. I cannot compile with the java ant task, as described on the wiki, using JSR-04.

Show
Scott Hickey added a comment - I'm sorry if I didn't make what I posted very clear. The first stack trace is from JSR-03 trying to use groovyc Ant task. The second stack trace from from JSR-04. I included both in case it might help. I should have been more concise. I couldn't get the groovyc ant task to work using JSR-03 or JSR-04. I can compile our project with the java ant task, as described in the wiki, with JSR-03. I cannot compile with the java ant task, as described on the wiki, using JSR-04.
Hide
blackdrag blackdrag added a comment -

about trace number two:
ByteCodeHelper#getClassInternalName:223 is:

public static String getClassInternalName(ClassNode t){
if (t.isPrimaryClassNode()){ return getClassInternalName(t.getName()); }
return getClassInternalName(t.getTypeClass());
}

or more precesly, the return number two there. This means getTypeClass is called:

public Class getTypeClass(){
Class c = redirect().clazz;
if (c!=null) return c;
ClassNode component = redirect().componentType;
if (component!=null && component.isResolved()){ ClassNode cn = component.makeArray(); setRedirect(cn); return redirect().clazz; }
throw new GroovyBugError("ClassNode#getTypeClass for "getName()" is called before the type class is set ");
}

so what I expect is that we try to resolve an array, which means compoent is not null. Then it has to be a resolvedType or the bug error would have been thrown... but then makeArray hits in and does produce the missing class. So this has to mean, that the clazz returned here is not null.

This leads us to BytecodeHelper.java:227

public static String getClassInternalName(Class t) { return org.objectweb.asm.Type.getInternalName(t); }

and to the code from the asm library:

public static String getInternalName(final Class c) { return c.getName().replace('.', '/'); }

so c has to be null, or the name returned by c... but the latter is very unlikely. I am a bit clueless what exactly is wrong. The only possibility I see is that the ClassNode is really a primary Classnode which means that is a class that has to be compiled... or more exactly an array of that. I found an error when looking if a classnode is a primary class node if that classnode is an array. So maybe that's the reason. But I am not sure.

I made this little change here:
http://cvs.codehaus.org/changelog/groovy?cs=MAIN:blackdrag:20051220205455&csize=1

so taking the newest snapshot to test the outcome may be a good idea

Show
blackdrag blackdrag added a comment - about trace number two: ByteCodeHelper#getClassInternalName:223 is: public static String getClassInternalName(ClassNode t){ if (t.isPrimaryClassNode()){ return getClassInternalName(t.getName()); } return getClassInternalName(t.getTypeClass()); } or more precesly, the return number two there. This means getTypeClass is called: public Class getTypeClass(){ Class c = redirect().clazz; if (c!=null) return c; ClassNode component = redirect().componentType; if (component!=null && component.isResolved()){ ClassNode cn = component.makeArray(); setRedirect(cn); return redirect().clazz; } throw new GroovyBugError("ClassNode#getTypeClass for "getName()" is called before the type class is set "); } so what I expect is that we try to resolve an array, which means compoent is not null. Then it has to be a resolvedType or the bug error would have been thrown... but then makeArray hits in and does produce the missing class. So this has to mean, that the clazz returned here is not null. This leads us to BytecodeHelper.java:227 public static String getClassInternalName(Class t) { return org.objectweb.asm.Type.getInternalName(t); } and to the code from the asm library: public static String getInternalName(final Class c) { return c.getName().replace('.', '/'); } so c has to be null, or the name returned by c... but the latter is very unlikely. I am a bit clueless what exactly is wrong. The only possibility I see is that the ClassNode is really a primary Classnode which means that is a class that has to be compiled... or more exactly an array of that. I found an error when looking if a classnode is a primary class node if that classnode is an array. So maybe that's the reason. But I am not sure. I made this little change here: http://cvs.codehaus.org/changelog/groovy?cs=MAIN:blackdrag:20051220205455&csize=1 so taking the newest snapshot to test the outcome may be a good idea
Hide
blackdrag blackdrag added a comment -

can you please tell me what the current state of the problem here is? I think it was fixed, or not?

Show
blackdrag blackdrag added a comment - can you please tell me what the current state of the problem here is? I think it was fixed, or not?
Hide
Scott Hickey added a comment -

It is fixed, thanks.

Show
Scott Hickey added a comment - It is fixed, thanks.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: