Hi I have a set of java classes which worked very fine when I compile them with javac command:
javac -g -nowarn -classpath /usr/class/cs143/cool/lib:.:/usr/java/lib/rt.jar ASTConstants.java ASTParser.java cool-tree.java
I installed groovy on the same machine and tried to execute the following:
groovyc -classpath /usr/class/cs143/cool/lib:.:/usr/java/lib/rt.jar ASTConstants.java ASTParser.java cool-tree.java
It seems that groovy doesn’t able to understand the java file and its throwing error like:
ASTParser.java: 21: unexpected token: protected @ line 21, column 3.
protected static final short _production_table[][] =
^
I’m bit confused. Does that all java programs are valid groovy code? Only the viceversa isn’t true right?
Where I’m making the mistake?
Thanks in advance.
There are some quirks. Used to be some issues with inner classes (may be resolved by now in 2.x), and you may have to watch what’s in your String literals (stray dollar signs, for e.g,). Using a literal for an array definition can be a problem (e.g.,
int [] ary = {};won’t fly in groovy). Also, doesn’t come up often, but scope braces used by themselves confuse groovy.In your particular case, just change the
short _production_table [][]to beshort [][] _production_table. I believe that should clear your issue up.BTW, some other “gotchas” here.