GCC checked out on 2005-01-03 compiles the following code without complaint, using the command line "gcj -C -Wall -W -pedantic ArrayLength.java":
class ArrayLength { static int extend(int[] array) { /* array.length = 1; */ array.length++; return array.length; } } It generates the following bytecode for the method: 0: aload_0 1: dup 2: getfield <Field [I.length int> 5: iconst_1 6: iadd 7: putfield <Field [I.length int> 10: aload_0 11: arraylength 12: ireturn However, if I uncomment the first assignment, I get this error: ArrayLength.java: In class 'ArrayLength': ArrayLength.java: In method 'ArrayLength.extend(int[])': ArrayLength.java:3: error: Can't reassign a value to the final variable 'length'. array.length = 1; ^ 1 error I think it is inconsistent to allow ++ if the field is final. -- Summary: allows array.length++ although it is final Product: gcc Version: 4.0.0 Status: UNCONFIRMED Severity: minor Priority: P2 Component: java AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: kon at iki dot fi CC: gcc-bugs at gcc dot gnu dot org,java-prs at gcc dot gnu dot org GCC build triplet: i386-pc-linux-gnu GCC host triplet: i386-pc-linux-gnu GCC target triplet: i386-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19277