Name: rmT116609 Date: 09/10/2002
FULL PRODUCT VERSION :
java version "1.4.1-rc"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-rc-b19)
Java HotSpot(TM) Client VM (build 1.4.1-rc-b19, mixed mode)
FULL OPERATING SYSTEM VERSION :
glibc-2.2.4-19.3
Linux quaffle 2.4.9-31smp #1 SMP Tue Feb 26 06:55:00 EST 2002 i686 unknown
/etc/redhat-release
A DESCRIPTION OF THE PROBLEM :
Since at least 1.3.1, the JDK virtual machine has incorrectly thrown a VerifyError for valid code involving implicit widening casts to arrays of Cloneable and Serializable. This is legal Java, and is produced by javac, so it must be supported. This is a problem with field assignment, and with parameter assignment during method invocation.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Compile this file:
$ cat Foo.java
// Foo.java
class Foo {
static Cloneable[] c;
public static void main(String[] args) {
c = new String[1][]; // legal, widening conversion
}
}
$ javac Foo.java
$
2. Attempt to execute.
$ java Foo
Exception in thread "main" java.lang.VerifyError: (class: Foo, method: main signature:
([Ljava/lang/String;)V) Bad type in putfield/putstatic
$
EXPECTED VERSUS ACTUAL BEHAVIOR :
The program should compile and execute without problems. According to JVMS 2.6.4, widening reference conversions should be implicit, and never cause a VM error. The VerifyError is incorrect.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "main" java.lang.VerifyError: (class: Foo, method: main signature: ([Ljava/lang/String;)V) Bad type in putfield/putstatic
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
// Foo.java
class Foo {
static Cloneable[] c;
public static void main(String[] args) {
c = new String[1][]; // legal, widening conversion
}
}
---------- END SOURCE ----------
CUSTOMER WORKAROUND :
The user can work around the bug by explicitly casting, instead of using the implicit widening conversion. In addition, javac could be hacked to do this explicit cast automatically, even though it is not necessary if the VM were not buggy.
(Review ID: 164311)
======================================================================