JDK-8055146 : Split Verifier incorrectly throws VerifyError for getstatic of an array field
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 9
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2014-08-14
  • Updated: 2016-01-29
  • Resolved: 2015-01-14
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.
JDK 9
9 b49Fixed
Related Reports
Relates :  
Description
The split verifier incorrectly throws VerifyError for a getstatic bytecode whose field reference is an array.

For example, the verifier throws:
% $JAVA_HOME/bin/java foo
Exception in thread "main" java.lang.VerifyError: Expecting reference to class in class foo at constant pool index 10
Exception Details:
  Location:
    foo.main([Ljava/lang/String;)V @0: getstatic
  Reason:
    Invalid type: '[C' (constant pool 10)

For this:

Constant pool:

   #3 = Fieldref                  #36.#37      // "[C".out:Ljava/io/PrintStream;
                     ...
  #36 = Class                    #55            // "[C"
  #37 = NameAndType        #57:#58     // out:Ljava/io/PrintStream;
                      ...
  #55 = Utf8               [C
                       ...
  #57 = Utf8               out
  #58 = Utf8               Ljava/io/PrintStream;

Code:
         0: getstatic     #3                  // Field "[C".out:Ljava/io/PrintStream;

The old verifier does not throw a VerifyError for this case.

See attached test case foo.jasm

Comments
The old verifier does not throw VerifyError for getstatic of an array.
13-10-2014

Bytecode getfield explicitly disallows arrays, but getstatic does not: http://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.10.1.9.getfield: A getfield instruction with operand CP is type safe iff CP refers to a constant pool entry denoting a field whose declared type is FieldType, declared in a class FieldClass, and one can validly replace a type matching FieldClass with type FieldType on the incoming operand stack yielding the outgoing type state. FieldClass must not be an array type.
14-08-2014