Home | History | Annotate | Download | only in invoke_direct_range
      1 /*
      2  * Copyright (C) 2008 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package dot.junit.opcodes.invoke_direct_range;
     18 
     19 import dot.junit.DxTestCase;
     20 import dot.junit.DxUtil;
     21 import dot.junit.opcodes.invoke_direct_range.d.T_invoke_direct_range_12;
     22 import dot.junit.opcodes.invoke_direct_range.d.T_invoke_direct_range_13;
     23 import dot.junit.opcodes.invoke_direct_range.d.T_invoke_direct_range_16;
     24 import dot.junit.opcodes.invoke_direct_range.d.T_invoke_direct_range_2;
     25 import dot.junit.opcodes.invoke_direct_range.d.T_invoke_direct_range_21;
     26 import dot.junit.opcodes.invoke_direct_range.d.T_invoke_direct_range_26;
     27 import dot.junit.opcodes.invoke_direct_range.d.T_invoke_direct_range_6;
     28 import dot.junit.opcodes.invoke_direct_range.d.T_invoke_direct_range_7;
     29 import dot.junit.opcodes.invoke_direct_range.d.T_invoke_direct_range_8;
     30 import dot.junit.opcodes.invoke_direct_range.d.T_invoke_direct_range_9;
     31 
     32 public class Test_invoke_direct_range extends DxTestCase {
     33 
     34     /**
     35      * @title private method call
     36      */
     37     public void testN2() {
     38         T_invoke_direct_range_2 t = new T_invoke_direct_range_2();
     39         assertEquals(345, t.run());
     40     }
     41 
     42 
     43     /**
     44      * @title Check that new frame is created by invoke_direct_range
     45      */
     46     public void testN7() {
     47         T_invoke_direct_range_21 t = new T_invoke_direct_range_21();
     48         assertEquals(1, t.run());
     49     }
     50 
     51 
     52 
     53     /**
     54      * @title objref is null
     55      */
     56     public void testE3() {
     57         loadAndRun("dot.junit.opcodes.invoke_direct_range.d.T_invoke_direct_range_8",
     58                    NullPointerException.class);
     59     }
     60 
     61     /**
     62      * @title Native method can't be linked
     63      */
     64     public void testE5() {
     65         loadAndRun("dot.junit.opcodes.invoke_direct_range.d.T_invoke_direct_range_9",
     66                    UnsatisfiedLinkError.class);
     67     }
     68 
     69     /**
     70      * @constraint A14
     71      * @title invalid constant pool index
     72      */
     73     public void testVFE1() {
     74         load("dot.junit.opcodes.invoke_direct_range.d.T_invoke_direct_range_3", VerifyError.class);
     75     }
     76 
     77     /**
     78      * @constraint A15
     79      * @title invoke-direct may not be used to invoke <clinit>
     80      */
     81     public void testVFE3() {
     82         load("dot.junit.opcodes.invoke_direct_range.d.T_invoke_direct_range_4", VerifyError.class);
     83     }
     84 
     85     /**
     86      * @constraint B4
     87      * @title invoke-direct target must be in self or superclass
     88      */
     89     public void testVFE4() {
     90         //@uses dot.junit.opcodes.invoke_direct_range.TSuper
     91         load("dot.junit.opcodes.invoke_direct_range.d.T_invoke_direct_range_6", VerifyError.class);
     92     }
     93 
     94     /**
     95      * @constraint B1
     96      * @title number of arguments
     97      */
     98     public void testVFE5() {
     99         load("dot.junit.opcodes.invoke_direct_range.d.T_invoke_direct_range_5", VerifyError.class);
    100     }
    101 
    102     /**
    103      * @constraint B1
    104      * @title int is passed instead of obj ref
    105      */
    106     public void testVFE6() {
    107         load("dot.junit.opcodes.invoke_direct_range.d.T_invoke_direct_range_10", VerifyError.class);
    108     }
    109 
    110 
    111     /**
    112      * @constraint B9
    113      * @title number of arguments passed to method
    114      */
    115     public void testVFE8() {
    116         load("dot.junit.opcodes.invoke_direct_range.d.T_invoke_direct_range_14", VerifyError.class);
    117     }
    118 
    119     /**
    120      * @constraint B9
    121      * @title types of arguments passed to method
    122      */
    123     public void testVFE9() {
    124         load("dot.junit.opcodes.invoke_direct_range.d.T_invoke_direct_range_24", VerifyError.class);
    125     }
    126 
    127     /**
    128      * @constraint B10
    129      * @title assignment incompatible references when accessing protected method
    130      */
    131     public void testVFE10() {
    132         //@uses dot.junit.opcodes.invoke_direct_range.TPlain
    133         //@uses dot.junit.opcodes.invoke_direct_range.TSuper
    134         load("dot.junit.opcodes.invoke_direct_range.d.T_invoke_direct_range_25", VerifyError.class);
    135     }
    136 
    137     /**
    138      * @constraint B5
    139      * @title  Superclass' method call
    140      */
    141     public void testVFE11() {
    142         //@uses dot.junit.opcodes.invoke_direct_range.TSuper
    143         loadAndRun("dot.junit.opcodes.invoke_direct_range.d.T_invoke_direct_range_1",
    144                    IncompatibleClassChangeError.class);
    145     }
    146 
    147     /**
    148      * @constraint A23
    149      * @title number of registers
    150      */
    151     public void testVFE12() {
    152         load("dot.junit.opcodes.invoke_direct_range.d.T_invoke_direct_range_15", VerifyError.class);
    153     }
    154 
    155 
    156     /**
    157      * @constraint n/a
    158      * @title Attempt to call undefined method.
    159      */
    160     public void testVFE13() {
    161         loadAndRun("dot.junit.opcodes.invoke_direct_range.d.T_invoke_direct_range_7",
    162                    NoSuchMethodError.class);
    163     }
    164 
    165     /**
    166      * @constraint n/a
    167      * @title Method has different signature.
    168      */
    169     public void testVFE14() {
    170         loadAndRun("dot.junit.opcodes.invoke_direct_range.d.T_invoke_direct_range_16",
    171                    NoSuchMethodError.class);
    172     }
    173 
    174     /**
    175      * @constraint n/a
    176      * @title Attempt to invoke static method. Java throws IncompatibleClassChangeError
    177      * on first access. Dalvik threw VerifyError on class loading.
    178      */
    179     public void testVFE15() {
    180         loadAndRun("dot.junit.opcodes.invoke_direct_range.d.T_invoke_direct_range_11",
    181                    IncompatibleClassChangeError.class);
    182     }
    183 
    184 
    185     /**
    186      * @constraint n/a
    187      * @title Attempt to invoke private method of superclass. Java throws IllegalAccessError
    188      * on first access but Dalvik throws VerifyError on class loading.
    189      */
    190     public void testVFE16() {
    191         //@uses dot.junit.opcodes.invoke_direct_range.TSuper
    192         loadAndRun("dot.junit.opcodes.invoke_direct_range.d.T_invoke_direct_range_12",
    193                    IllegalAccessError.class);
    194     }
    195 
    196 
    197     /**
    198      * @constraint n/a
    199      * @title Attempt to invoke abstract method
    200      */
    201     public void testVFE17() {
    202         //@uses dot.junit.opcodes.invoke_direct_range.TAbstract
    203         loadAndRun("dot.junit.opcodes.invoke_direct_range.d.T_invoke_direct_range_13",
    204                    IncompatibleClassChangeError.class);
    205     }
    206 
    207     /**
    208      * @constraint B5
    209      * @title An instance initializer must only be invoked on an uninitialized instance.
    210      */
    211     public void testVFE18() {
    212         load("dot.junit.opcodes.invoke_direct_range.d.T_invoke_direct_range_17", VerifyError.class);
    213     }
    214 
    215     /**
    216      * @constraint B8
    217      * @title attempt to access inherited instance field before <init> is called
    218      */
    219     public void testVFE19() {
    220         //@uses dot.junit.opcodes.invoke_direct_range.TSuper
    221         load("dot.junit.opcodes.invoke_direct_range.d.T_invoke_direct_range_18", VerifyError.class);
    222     }
    223 
    224     /**
    225      * @constraint A14
    226      * @title attempt to invoke interface method
    227      */
    228     public void testVFE20() {
    229         loadAndRun("dot.junit.opcodes.invoke_direct_range.d.T_invoke_direct_range_26",
    230                    IncompatibleClassChangeError.class);
    231     }
    232 
    233     /**
    234      * @constraint B6
    235      * @title instance methods may only be invoked on already initialized instances.
    236      */
    237     public void testVFE21() {
    238         load("dot.junit.opcodes.invoke_direct_range.d.T_invoke_direct_range_27", VerifyError.class);
    239     }
    240 }
    241