From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7514 invoked by alias); 5 Jan 2005 19:50:02 -0000 Mailing-List: contact java-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: java-prs-owner@gcc.gnu.org Received: (qmail 7448 invoked by uid 48); 5 Jan 2005 19:49:58 -0000 Date: Wed, 05 Jan 2005 19:50:00 -0000 From: "kon at iki dot fi" To: java-prs@gcc.gnu.org Message-ID: <20050105194957.19277.kon@iki.fi> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug java/19277] New: allows array.length++ although it is final X-Bugzilla-Reason: CC X-SW-Source: 2005-q1/txt/msg00009.txt.bz2 List-Id: 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 5: iconst_1 6: iadd 7: putfield 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