Most Java code is also syntactically valid Groovy code. However, there are a few exceptions which leads me to my question:
Which constructs/features in Java are syn
Ok, heres one point:
int[] i = { 0, 1, 2 };
That is good syntax in java, bad in groovy.
I don't think you want to assume any given java code will be equivalent in groovy. This site describes some of the differences, which includes things as basic as == not meaning the same thing in both languages. Also, static array initialization is different, and there are no anonymous inner classes.
This compiles fine in Java 1.6
public class Test2 {
int[] i = { 0, 1, 2 };
private class Class1 {
public void method1() {
if (i[2] == 2) {
System.out.println("this works");
}
}
}
public void method1() {
Class1 class1 = new Class1();
class1.method1();
}
}
But is so wrong in Groovy. It gives the following errors in Groovy 1.6:
unexpected token: 1 @ line 2, column 14.
Class definition not expected here. Possible attempt to use inner class. Inner classes not supported, perhaps try using a closure instead. at line: 4 column: 2.
If you fix those things, it does print what you expect, though.
If you're looking for newer language syntax issues, like generics or annotations, Groovy supports both of those, though not fully.