You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Jérôme Leroux (JIRA)" <ji...@apache.org> on 2015/01/13 12:33:34 UTC

[jira] [Created] (BCEL-193) aastore instruction should not raise a verify error if an assignement compatiblity error is detected

Jérôme Leroux created BCEL-193:
----------------------------------

             Summary: aastore instruction should not raise a verify error if an assignement compatiblity error is detected
                 Key: BCEL-193
                 URL: https://issues.apache.org/jira/browse/BCEL-193
             Project: Commons BCEL
          Issue Type: Bug
          Components: Verifier
    Affects Versions: 6.0
            Reporter: Jérôme Leroux


The following valid code raises a verify error:
{code:java}
public class TestArrayAccess01 extends XTestArray01{
    public static void test(){
        XTestArray01[] array = new TestArrayAccess01[1];
        array[0] = new XTestArray01();
    }   
}

class XTestArray01 {}
{code}

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):
{quote}
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.
{quote}
But in the {{aastore}} opcode description, there is no reference to any kind of linking or verification error. The assignement 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):
{quote}
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. 
{quote}

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



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)