From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12391 invoked by alias); 25 Oct 2004 18:46:30 -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 12375 invoked by uid 48); 25 Oct 2004 18:46:29 -0000 Date: Mon, 25 Oct 2004 18:46:00 -0000 From: "csm at gnu dot org" To: java-prs@gcc.gnu.org Message-ID: <20041025184625.18147.csm@gnu.org> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug java/18147] New: Objects in instance initializer blocks are scoped too widely X-Bugzilla-Reason: CC X-SW-Source: 2004-q4/txt/msg00218.txt.bz2 List-Id: If you declare an object within an instance initializer, you cannot declare another object of the same name in a different instance initializer. This description seems pretty opaque, so an example of correct code that GCJ rejects is probably better: -- init.java -- import java.util.HashMap; class init { private final HashMap _map1 = new HashMap(); { Object foo = new Object(); _map1.put ("foo!", foo); } private final HashMap _map2 = new HashMap(); { Object foo = new Object(); _map2.put ("bar!", foo); } } -- init.java -- GCJ exits with this error: init.java:13: error: Variable `foo' is already defined in this method and was declared `Object foo' at line 7. Object foo = new Object(); ^ 1 error -- Summary: Objects in instance initializer blocks are scoped too widely Product: gcc Version: 3.4.2 Status: UNCONFIRMED Severity: normal Priority: P2 Component: java AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: csm at gnu dot org CC: gcc-bugs at gcc dot gnu dot org,java-prs at gcc dot gnu dot org GCC build triplet: i686-pc-linux-gnu GCC host triplet: i686-pc-linux-gnu GCC target triplet: i686-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18147