Name: viR10068 Date: 01/14/2004
The spec for autoboxing says:
"JLS 5.1.8. Unboxing conversion
Unboxing conversion converts values of reference type to corresponding values
of primitive type. The precise rules are as follows:
- If r is a reference of type Boolean, then unboxing conversion converts r
into r.booleanValue(). ...
And:
"If an array initializer is provided, the newly allocated array will be
initialized with the values provided by the array initializer as described in 10.6."
The compiler successfully generates code for the unboxing the Boolean value
in the array initializer. But the JVM rejects this code with the VerifyError.
The source:
------------------ Test.java -------------------
class Test {
public static void main(String args[]) {
final boolean [] a = {Boolean.FALSE};
}
}
------------------------------------------------
The output:
% jdk1.5.0-b33/solaris-sparc/bin/javac -source 1.5 -target 1.5 Test.java &&
jdk1.5.0-b33/solaris-sparc/bin/java -Xfuture -showversion Test
java version "1.5.0-beta2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta2-b33)
Java HotSpot(TM) Client VM (build 1.5.0-beta2-b33, mixed mode)
Exception in thread "main" java.lang.VerifyError: (class: Test, method: main signature:
([Ljava/lang/String;)V) Expecting to find integer on stack
%
======================================================================
- duplicates
-
JDK-4965701 unboxing versus array index results in verify error
-
- Resolved
-
- relates to
-
JDK-4975565 VerifyError with compound assignment and unboxing
-
- Resolved
-