From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25065 invoked by alias); 13 Sep 2002 21:56:02 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 25034 invoked by uid 71); 13 Sep 2002 21:56:01 -0000 Resent-Date: 13 Sep 2002 21:56:01 -0000 Resent-Message-ID: <20020913215601.25033.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org, java-prs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, Eric Blake Received: (qmail 24981 invoked from network); 13 Sep 2002 21:55:28 -0000 Received: from unknown (HELO quaffle.ee.byu.edu) (128.187.114.165) by sources.redhat.com with SMTP; 13 Sep 2002 21:55:28 -0000 Received: (from eblake@localhost) by quaffle.ee.byu.edu (8.11.6/8.11.6) id g8DLtSb21854; Fri, 13 Sep 2002 15:55:28 -0600 Message-Id: <200209132155.g8DLtSb21854@quaffle.ee.byu.edu> Date: Fri, 13 Sep 2002 14:56:00 -0000 From: Eric Blake To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: 3.113 Subject: java/7912: invalid verification error for arrays X-SW-Source: 2002-09/txt/msg00283.txt.bz2 List-Id: >Number: 7912 >Category: java >Synopsis: invalid verification error for arrays >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: rejects-legal >Submitter-Id: net >Arrival-Date: Fri Sep 13 14:56:01 PDT 2002 >Closed-Date: >Last-Modified: >Originator: Eric Blake >Release: 3.1 20020501 (prerelease) >Organization: >Environment: System: Linux quaffle 2.4.9-31smp #1 SMP Tue Feb 26 06:55:00 EST 2002 i686 unknown Architecture: i686 host: i686-pc-linux-gnu build: i686-pc-linux-gnu target: i686-pc-linux-gnu configured with: ../gcc/configure --enable-languages=c,c++,java --prefix=/fpga3/users/eblake/gcc >Description: The bytecode verifier is choking on legal widening casts from multi-dimensioned arrays to smaller dimensions of Cloneable or Serializable. However, it is correctly allowing similar casts to arrays of Object. This is also a recently discovered bug in Sun's VM verifier. It appears to be a problem for verifying putstatic, putfield, invokestatic, invokespecial, invokevirtual, and invokeinterface, but not with checkcast or instanceof. >How-To-Repeat: $ cat Foo.java class Foo { static Cloneable[] c; public static void main(String[] args) { c = new int[1][][]; } } $ gcj -C Foo.java $ gcj -o Foo --main=Foo Foo.class Foo.java: In class `Foo': Foo.java: In method `Foo.main(java.lang.String[])': Foo.java:6: verification error at PC=11 Foo.java:6: expected type 'java.lang.Cloneable[]' but stack contains 'int[][][]' $ sed -e "s/Cloneable/Object/" Foo.java > Foo1.java $ mv Foo1.java Foo.java $ gcj -C Foo.java $ gcj -o Foo --main=Foo Foo.class $ >Fix: In the user code, create a temporary Object variable to widen the original array into, then downcast that variable to the desired Cloneable[] or Serializable[]. That forces the bytecode compiler to use the checkcast bytecode, which passes verification. Object o = new int[1][][]; c = (Cloneable[]) o; >Release-Note: >Audit-Trail: >Unformatted: