Uploaded image for project: 'Commons BCEL'
  1. Commons BCEL
  2. BCEL-193

aastore instruction should not raise a verify error if an assignment compatiblity error is detected


    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 6.0
    • Fix Version/s: 6.0
    • Component/s: Verifier
    • Labels:


      The following valid code raises a verify error:

      public class TestArrayAccess01 extends XTestArray01{
          public static void test(){
              XTestArray01[] array = new TestArrayAccess01[1];
              array[0] = new XTestArray01();
      class XTestArray01 {}

      The code above will throw an ArrayStoreException at runtime but the generated bytecode is valid.

      The Java Virtual Machine Specification Second Edition is ambigous about this kind of issue. It states in §4.8.2 Structural Constraints (http://docs.oracle.com/javase/specs/jvms/se5.0/html/ClassFile.doc.html#9308):

      The type of every value stored into an array of type reference by an aastore instruction must be assignment compatible (§2.6.7) with the component type of the array.

      But in the aastore opcode description, there is no reference to any kind of linking or verification error. The assignment compatiblity error is a runtime exception.

      In the Java SE 7 Edition of _The Java Virtual Machine Specification, the §4 has been modified (http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.9.2):

      The type of every value stored into an array by an aastore instruction must be a reference type.
      The component type of the array being stored into by the aastore instruction must also be a reference type.

      The assignment compatibility check must not be done during the verification of the bytecode but during its execution.


        1. BCEL-193.patch
          9 kB
          Jérôme Leroux
        2. BCEL-193.zip
          2 kB
          Jérôme Leroux



            • Assignee:
              jejecool Jérôme Leroux
            • Votes:
              0 Vote for this issue
              1 Start watching this issue


              • Created: