public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: Eric Blake <ebb9@email.byu.edu> To: gcc-gnats@gcc.gnu.org Subject: java/7912: invalid verification error for arrays Date: Fri, 13 Sep 2002 14:56:00 -0000 [thread overview] Message-ID: <200209132155.g8DLtSb21854@quaffle.ee.byu.edu> (raw) >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: <When reporting a compiler error, preprocessor output must be included> $ 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:
next reply other threads:[~2002-09-13 21:56 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2002-09-13 14:56 Eric Blake [this message] 2002-11-03 16:42 tromey 2002-11-23 0:26 tromey
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=200209132155.g8DLtSb21854@quaffle.ee.byu.edu \ --to=ebb9@email.byu.edu \ --cc=gcc-gnats@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).