You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Irina Arkhipets (JIRA)" <ji...@apache.org> on 2006/10/16 10:57:36 UTC

[jira] Updated: (HARMONY-1874) [drlvm][jit] Jitrino/OPT does not reject class which contains aastore instruction with incorrect argument on Linux EM-64T

     [ http://issues.apache.org/jira/browse/HARMONY-1874?page=all ]

Irina Arkhipets updated HARMONY-1874:
-------------------------------------

    Attachment: test.java

test.java source file

> [drlvm][jit] Jitrino/OPT does not reject class which contains aastore instruction with incorrect argument on Linux EM-64T
> -------------------------------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-1874
>                 URL: http://issues.apache.org/jira/browse/HARMONY-1874
>             Project: Harmony
>          Issue Type: Bug
>          Components: DRLVM
>         Environment: Linux EM-64T
>            Reporter: Irina Arkhipets
>         Attachments: cases.j, test.java
>
>
> J2SE VM Specification reads about the aastore instruction:
> ...
> The type of value must be assignment compatible (§2.6.6) with the type of the components of the array referenced by arrayref. Assignment of a value of reference type S (source) to a variable of reference type T (target) is allowed only when the type S supports all the operations defined on type T. The detailed rules follow:
>     - If S is a class type, then: 
>         * If T is a class type, then S must be the same class (§2.8.1) as T, or S must be a subclass of T; 
>         * If T is an interface type, S must implement (§2.13) interface T. 
>     - If S is an array type, namely the type SC[], that is, an array of components of type SC, then: 
>         * If T is a class type, T must be Object (§2.4.6), or: 
>             ** If T is an array type, namely the type TC[], an array of components of type TC, then eitherTC and SC must be the same primitive type, or 
>             ** TC and SC must both be reference types with type SC assignable to TC, by these rules. 
> S cannot be an interface type, because there are no instances of interfaces, only instances of classes and arrays.
> ...
> However,  VM does not reject class which contains incorrect aastore instructions:
>      - when T is class but it is  superclass of S
>      - when T is interface but S is not implemented T
>      - if S is interface and T is not Object class
>      - if T and S are different interfaces
> This bug is reproducible on Linux EM-64T with jitrino OPT only.
> It is not reproducible with interpreter and JET.
> Please, compile the following sources and run the test class with "-Xem:opt" switch on Linux EM-64T server to reproduce this bug:
> --------- test.java ---------
> public class test {    
>     public static void main (String [] args)  throws InterruptedException {
>         /* T is class but it is  superclass of S */
>         try {
>             new cases().test1();
>             System.out.println("Case 1: FAILED");
>         } catch (ArrayStoreException e) {
>             System.out.println("Case 1: PASSED");
>         }
>         /* T is interface but S is not implemented T */
>         try {
>             new cases().test2();
>             System.out.println("Case 2: FAILED");
>         } catch (ArrayStoreException e) {
>             System.out.println("Case 2: PASSED");
>         }
>         /* S is interface and T is not Object class */
>         try {
>             new cases().test3();
>             System.out.println("Case3: FAILED");
>         } catch (ArrayStoreException e) {
>             System.out.println("Case 3: PASSED");
>         }
>         /* if T and S are different interfaces */
>         try {
>             new cases().test4();
>             System.out.println("Case3: FAILED");
>         } catch (ArrayStoreException e) {
>             System.out.println("Case 3: PASSED");
>         }
>    }
> }
> class MyClass extends MySuperClass {}
> class MySuperClass {}
> interface MyInterface {}
> interface MyInterface1 {}
> class MyImplClass implements MyInterface {}
> --------- cases.j ---------
> .class public cases
> .super java/lang/Object
> .field public testField LMyInterface;
> .method public <init>()V
>     aload_0
>     invokespecial java/lang/Object/<init>()V
>     return
> .end method 
> .method public test1()V
>     .limit locals 3
>     .limit stack 4
>     iconst_4
>     anewarray MyClass
>     astore_1
>     aload_1
>     iconst_1
>     new MySuperClass
>     dup
>     invokespecial MySuperClass/<init>()V
>     aastore 
>     return
> .end method
> .method public test2()V
>     .limit locals 3
>     .limit stack 4
>     iconst_4
>     anewarray MyInterface
>     astore_1 
>     aload_1
>     iconst_1
>     new MyClass
>     dup
>     invokespecial MyClass/<init>()V
>     aastore 
>     return
> .end method
> .method public test3()V
>     .limit locals 3
>     .limit stack 4
>     iconst_4
>     anewarray MyClass
>     astore_1 
>     aload_0
>     new MyImplClass
>     dup
>     invokespecial MyImplClass/<init>()V
>     putfield cases/testField LMyInterface;
>     aload_1
>     iconst_1
>     aload_0
>     getfield cases/testField LMyInterface;
>     aastore ; must throw java/lang/ArrayStoreException
>     return
> .end method
> .method public test4()V
>     .limit locals 3
>     .limit stack 4
>     iconst_4
>     anewarray MyInterface1
>     astore_1
>     aload_0
>     new MyImplClass
>     dup
>     invokespecial MyImplClass/<init>()V
>     putfield cases/testField LMyInterface;
>     aload_1
>     iconst_1
>     aload_0
>     getfield cases/testField LMyInterface;
>     aastore 
>     return
> .end method
> ------------------------------
> Sample output is:
> ...
> Case 1: FAILED
> Case 2: FAILED
> Case3: FAILED
> Case3: FAILED
> ...

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira