3rd attempt to get Groovy++ to work, please help

17 views
Skip to first unread message

Kyle

unread,
May 16, 2011, 11:49:10 AM5/16/11
to Groovy++
I tried a couple times last year to get it to work, and am trying
again now, please help me out, I really want it to work this time.

I have a mixed groovy and java project in intellij. It is using
Groovy 1.8.0. I downloaded groovypp-0.4.232_1.8.0.jar and added it to
my module's dependencies. Just doing that, caused me to get an error
when I rebuilt my project.

Here is the error it caused:
java.lang.VerifyError: (class: AC/model/CCategory, method: getDesc
signature: ()Ljava/lang/String;) Incompatible type for getting or
setting field
at java.lang.Class.getDeclaredFields0(Native Method)
at java.lang.Class.privateGetDeclaredFields(Class.java:2291)
...

The getDesc method is just an auto generated getter for the CCategory
class's String desc field.

Alex Tkachman

unread,
May 16, 2011, 11:57:47 AM5/16/11
to groovyp...@googlegroups.com
It is really hard to say anything without seeing method getDesc. If
you can share code of this particular method it will help a lot.

Kyle

unread,
May 16, 2011, 12:00:00 PM5/16/11
to Groovy++
Relevent part of the class

public class CCategory implements Comparable<CCategory>, Serializable
{

private static final long serialVersionUID = 1L;



public final static int CAT_NOCAT = 0;
public final static int CAT_META = 1;
public final static int CAT_OTHER = 2;
static TreeNode cats;
private static Map<Long, TreeNode> idToTreeNode


Long id
String name
String desc
Long parent

.....

}

The getDesc is just the standard getter that groovy generates for the
desc field.

Alex Tkachman

unread,
May 16, 2011, 12:03:18 PM5/16/11
to groovyp...@googlegroups.com
Do you have compilation error when compiling only this "relevant part"?

Alex Tkachman

unread,
May 16, 2011, 12:10:15 PM5/16/11
to groovyp...@googlegroups.com
Could you btw annotate the class with @Typed(debug=true), compile from
command line and and share what you can share from debug output

On Mon, May 16, 2011 at 4:00 PM, Kyle <kwst...@gmail.com> wrote:

Kyle

unread,
May 16, 2011, 12:16:31 PM5/16/11
to Groovy++
If I just compile CCategory.groovy by itself, then there is no error.
If I choose "Rebuild project", then I get the error. If, after
compiling CCategory.groovy by itself, I choose "Make project", I get a
similar error, except for a different class.

Alex Tkachman

unread,
May 16, 2011, 12:19:59 PM5/16/11
to groovyp...@googlegroups.com
And project is jointly compiled? Meaning you have both Java and Groovy
and compile both together?

Kyle

unread,
May 16, 2011, 12:27:30 PM5/16/11
to Groovy++
Yes

Alex Tkachman

unread,
May 16, 2011, 12:35:17 PM5/16/11
to groovyp...@googlegroups.com
One sec. Are you saying that you have problems without using .gpp or
@Typed at all? Just adding jar in to classpath?

Kyle

unread,
May 16, 2011, 12:41:34 PM5/16/11
to Groovy++
Yes, this error happens without using @Typed at all.

Alex Tkachman

unread,
May 16, 2011, 12:45:21 PM5/16/11
to groovyp...@googlegroups.com
Could you please share with me bytecode of method getDesc

Kyle

unread,
May 16, 2011, 12:53:58 PM5/16/11
to Groovy++
0 aload_0
1 getfield #449 <AC/model/CCategory.desc>
4 areturn

Alex Tkachman

unread,
May 16, 2011, 12:58:15 PM5/16/11
to groovyp...@googlegroups.com
Seems to be very correct

Alex Tkachman

unread,
May 16, 2011, 12:58:56 PM5/16/11
to groovyp...@googlegroups.com
Are you building with IDEA or you have some build script like ant or
gradle as well?

Kyle

unread,
May 16, 2011, 1:10:47 PM5/16/11
to Groovy++
Just with IDEA. It also runs an ant script that compiles SASS to CSS,
but that shouldn't affect anything.

I tested out getting rid of the global transformations by removing the
org.codehaus.groovy.transform.ASTTransformation file, and the error
went away, and I was able to add @Typed to a few of my methods and
from looking at the bytecode I could see that it worked. However, I
could only successfully add @Typed to a few small methods. When adding
it to another methods I would get this error when I try to compile:

java.lang.NullPointerException
at org.codehaus.groovy.ast.ClassNode.addTransform(ClassNode.java:
1385)
at
org.codehaus.groovy.transform.ASTTransformationCollectorCodeVisitor.verifyClassAndAddTransform(ASTTransformationCollectorCodeVisitor.java:
114)
...

Alex Tkachman

unread,
May 16, 2011, 1:14:44 PM5/16/11
to groovyp...@googlegroups.com
Stupid question - do you have the same problem with Groovy 1.7.10?

Kyle

unread,
May 16, 2011, 1:32:48 PM5/16/11
to Groovy++
With groovy 1.7.10 and groovypp-0.4.232_1.7.10.jar I get the same
VerifyError. With groovy 1.7.10 and groovypp-0.4.232_1.8.0.jar, I get
a NoClassDefFoundError for
org.codehaus.groovy.ast.stmt.LoopingStatement.

With groovy 1.8 and groovypp-all-0.4.232_1.8.0.jar, I get a
NoClassDefFoundError for groovyjarjarasm.asm.Opcodes. With
groovy-1.8-all and groovypp-all-0.4.232_1.8.0.jar, I get the same
VerifyError.

Alex Tkachman

unread,
May 16, 2011, 1:37:03 PM5/16/11
to groovyp...@googlegroups.com
I am almost sure that root of the problem lies in joint compilation.
How big is your project? Can you compile Java and Groovy separately?
I assume you can not share the code even outside of public mailing
list. May be some small project which reproduce the problem?

Kyle

unread,
May 16, 2011, 1:55:54 PM5/16/11
to Groovy++
Don't know why I didn't think of this earlier, but I have my own AST
transformations too. After disabling all of them, I don't get the
error anymore, and I'm even able to successfully use @Typed.

Unfortunately, my project won't work correctly without my AST
transformations enabled. Do you have any ideas on why something
would go wrong when I use groovy++ and have my own AST
transformations? I'm not using @Typed, so the conflict might be with
something Groovy++'s global transformations do.

Do Groovy++'s global transformations need to touch every class even if
the class doesn't use @Typed at all?

Kyle

unread,
May 16, 2011, 2:10:22 PM5/16/11
to Groovy++
More details: Enabling any of my AST transformations causes the
problem. Even just enabling my simplest AST transformation,
@PerfTrace, doesn't work. All that does is just wraps the method in:

long time = System.nanoTime()
try{
...method code.....
} finally {
println methodnode.getName() + (System.nanoTime() - time).toString() +
"ms"

Alex Tkachman

unread,
May 16, 2011, 2:13:00 PM5/16/11
to groovyp...@googlegroups.com
On what stage are you doing your transforms?

Kyle

unread,
May 16, 2011, 2:14:14 PM5/16/11
to Groovy++
They are all done in CompilePhase.SEMANTIC_ANALYSIS

Alex Tkachman

unread,
May 16, 2011, 2:22:13 PM5/16/11
to groovyp...@googlegroups.com
what happens if you move it to CANONICALIZATION?

Kyle

unread,
May 16, 2011, 2:48:42 PM5/16/11
to Groovy++
CANONICALIZATION didn't work, but putting my transforms in
INSTRUCTION_SELECTION did work, except for one of my transforms. One
of my transforms changes the type of a field to a String, among other
things.

This single line of the transform:
"field.setType(ClassHelper.STRING_TYPE)", when commented out, groovy++
works fine, but when it isn't commented out, I get the VerifyError.

Alex Tkachman

unread,
May 16, 2011, 3:04:01 PM5/16/11
to groovyp...@googlegroups.com
On INSTRUCTION_SELECTION you aggressively compete with Groovy++
itself. What you try is to make sure that your transform lives early
in classpath than g++ jar

Kyle

unread,
May 16, 2011, 3:27:18 PM5/16/11
to Groovy++
Thanks for your help, I think I've got it working now for the most
part. I'll just have to work around the problem with that one
transform of mine for now.
Reply all
Reply to author
Forward
0 new messages