JDK-4745054 : VM bug: VerifyError with Cloneable[]
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 1.4.0,1.4.1
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: linux,solaris_8
  • CPU: generic,x86
  • Submitted: 2002-09-10
  • Updated: 2012-10-08
  • Resolved: 2002-10-26
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.4.2 mantisFixed
Description
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) 
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: mantis FIXED IN: mantis INTEGRATED IN: mantis mantis-b05
14-06-2004

EVALUATION This bug can be reproduced in jdk 1.2 and later versions. It should be platform independent. ###@###.### 2002-09-11
11-09-2002

SUGGESTED FIX In method merge_fullinfo_types(), a special case should be added when two array types with different dimensions are merged. Instead of returning java.lang.Object array, the verifier should return java.lang.Cloneable or java.io.Serializable array if the array type with less dimension has base type of java.lang.Cloneable or java.io.Serializable. ###@###.### 2002-09-11 Thu Oct 03 11:46:40 MDT 2002 wtao
11-09-2002