Home | History | Annotate | Download | only in invoke_super
      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_super;
     18 
     19 import dot.junit.DxTestCase;
     20 import dot.junit.DxUtil;
     21 import dot.junit.opcodes.invoke_super.d.T_invoke_super_1;
     22 import dot.junit.opcodes.invoke_super.d.T_invoke_super_10;
     23 import dot.junit.opcodes.invoke_super.d.T_invoke_super_14;
     24 import dot.junit.opcodes.invoke_super.d.T_invoke_super_15;
     25 import dot.junit.opcodes.invoke_super.d.T_invoke_super_17;
     26 import dot.junit.opcodes.invoke_super.d.T_invoke_super_18;
     27 import dot.junit.opcodes.invoke_super.d.T_invoke_super_19;
     28 import dot.junit.opcodes.invoke_super.d.T_invoke_super_2;
     29 import dot.junit.opcodes.invoke_super.d.T_invoke_super_20;
     30 import dot.junit.opcodes.invoke_super.d.T_invoke_super_24;
     31 import dot.junit.opcodes.invoke_super.d.T_invoke_super_26;
     32 import dot.junit.opcodes.invoke_super.d.T_invoke_super_27;
     33 import dot.junit.opcodes.invoke_super.d.T_invoke_super_28;
     34 import dot.junit.opcodes.invoke_super.d.T_invoke_super_4;
     35 import dot.junit.opcodes.invoke_super.d.T_invoke_super_5;
     36 import dot.junit.opcodes.invoke_super.d.T_invoke_super_6;
     37 import dot.junit.opcodes.invoke_super.d.T_invoke_super_7;
     38 
     39 public class Test_invoke_super extends DxTestCase {
     40 
     41     /**
     42      * @title invoke method of superclass
     43      */
     44     public void testN1() {
     45         //@uses dot.junit.opcodes.invoke_super.d.T_invoke_super_1
     46         //@uses dot.junit.opcodes.invoke_super.d.TSuper
     47         T_invoke_super_1 t = new T_invoke_super_1();
     48         assertEquals(5, t.run());
     49     }
     50 
     51 
     52     /**
     53      * @title Invoke protected method of superclass
     54      */
     55     public void testN3() {
     56         //@uses dot.junit.opcodes.invoke_super.d.T_invoke_super_7
     57         //@uses dot.junit.opcodes.invoke_super.d.TSuper
     58         T_invoke_super_7 t = new T_invoke_super_7();
     59         assertEquals(5, t.run());
     60     }
     61 
     62     /**
     63      * @title Check that new frame is created by invoke_super and
     64      * arguments are passed to method
     65      */
     66     public void testN5() {
     67         //@uses dot.junit.opcodes.invoke_super.d.T_invoke_super_14
     68         //@uses dot.junit.opcodes.invoke_super.d.TSuper
     69         T_invoke_super_14 t = new T_invoke_super_14();
     70         assertTrue(t.run());
     71     }
     72 
     73     /**
     74      * @title Recursion of method lookup procedure
     75      */
     76     public void testN6() {
     77         //@uses dot.junit.opcodes.invoke_super.d.T_invoke_super_17
     78         //@uses dot.junit.opcodes.invoke_super.d.TSuper
     79         //@uses dot.junit.opcodes.invoke_super.d.TSuper2
     80         T_invoke_super_17 t = new T_invoke_super_17();
     81         assertEquals(5, t.run());
     82     }
     83 
     84     /**
     85      * @title invoke-super in conflict class
     86      */
     87     public void testN7() {
     88         loadAndRun("dot.junit.opcodes.invoke_super.d.T_invoke_super_26", null);
     89     }
     90 
     91     /**
     92      * @title obj ref is null
     93      */
     94     public void testE1() {
     95         //@uses dot.junit.opcodes.invoke_super.d.TSuper
     96         loadAndRun("dot.junit.opcodes.invoke_super.d.T_invoke_super_2", NullPointerException.class);
     97         T_invoke_super_2 t = new T_invoke_super_2();
     98     }
     99 
    100     /**
    101      * @title Native method can't be linked
    102      */
    103     public void testE2() {
    104         //@uses dot.junit.opcodes.invoke_super.d.TSuper
    105         loadAndRun("dot.junit.opcodes.invoke_super.d.T_invoke_super_4", UnsatisfiedLinkError.class);
    106     }
    107 
    108     /**
    109      * @title Attempt to invoke abstract method
    110      */
    111     public void testE4() {
    112         //@uses dot.junit.opcodes.invoke_super.ATest
    113         loadAndRun("dot.junit.opcodes.invoke_super.d.T_invoke_super_6", AbstractMethodError.class);
    114     }
    115 
    116     /**
    117      * @title Attempt to invoke abstract interface method
    118      */
    119     public void testE5() {
    120         loadAndRun("dot.junit.opcodes.invoke_super.d.T_invoke_super_27", AbstractMethodError.class);
    121     }
    122 
    123     /**
    124      * @title Attempt to invoke abstract interface method
    125      */
    126     public void testE6() {
    127         loadAndRun("dot.junit.opcodes.invoke_super.d.T_invoke_super_28",
    128                    IncompatibleClassChangeError.class);
    129     }
    130 
    131     /**
    132      * @constraint A13
    133      * @title invalid constant pool index
    134      */
    135     public void testVFE1() {
    136         load("dot.junit.opcodes.invoke_super.d.T_invoke_super_8", ClassNotFoundException.class);
    137     }
    138 
    139     /**
    140      * @constraint A15
    141      * @title <clinit> may not be called using invoke-super
    142      */
    143     public void testVFE3() {
    144         load("dot.junit.opcodes.invoke_super.d.T_invoke_super_10", VerifyError.class);
    145     }
    146 
    147     /**
    148      * @constraint B1
    149      * @title number of arguments passed to method
    150      */
    151     public void testVFE4() {
    152         load("dot.junit.opcodes.invoke_super.d.T_invoke_super_11", VerifyError.class);
    153     }
    154 
    155     /**
    156      * @constraint B9
    157      * @title types of arguments passed to method.
    158      */
    159     public void testVFE5() {
    160         //@uses dot.junit.opcodes.invoke_super.d.TSuper
    161         load("dot.junit.opcodes.invoke_super.d.T_invoke_super_12", VerifyError.class);
    162     }
    163 
    164     /**
    165      * @constraint A15
    166      * @title <init> may not be called using invoke_super
    167      */
    168     public void testVFE6() {
    169         load("dot.junit.opcodes.invoke_super.d.T_invoke_super_16", VerifyError.class);
    170     }
    171 
    172     /**
    173      * @constraint B10
    174      * @title assignment incompatible references when accessing
    175      *                  protected method
    176      */
    177     public void testVFE8() {
    178         //@uses dot.junit.opcodes.invoke_super.d.TSuper
    179         //@uses dot.junit.opcodes.invoke_super.d.TPlain
    180         load("dot.junit.opcodes.invoke_super.d.T_invoke_super_22", VerifyError.class);
    181     }
    182 
    183     /**
    184      * @constraint B10
    185      * @title assignment incompatible references when accessing
    186      *                  public method
    187      */
    188     public void testVFE9() {
    189         //@uses dot.junit.opcodes.invoke_super.d.TSuper
    190         //@uses dot.junit.opcodes.invoke_super.d.TSuper2
    191         load("dot.junit.opcodes.invoke_super.d.T_invoke_super_23", VerifyError.class);
    192     }
    193 
    194     /**
    195      * @constraint n/a
    196      * @title Attempt to call static method.
    197      */
    198     public void testVFE10() {
    199         //@uses dot.junit.opcodes.invoke_super.d.TSuper
    200         loadAndRun("dot.junit.opcodes.invoke_super.d.T_invoke_super_5",
    201                    IncompatibleClassChangeError.class);
    202     }
    203 
    204 
    205     /**
    206      * @constraint n/a
    207      * @title Attempt to invoke non-existing method.
    208      */
    209     public void testVFE12() {
    210         loadAndRun("dot.junit.opcodes.invoke_super.d.T_invoke_super_15", NoSuchMethodError.class);
    211     }
    212 
    213     /**
    214      * @constraint n/a
    215      * @title Attempt to invoke private method of other class.
    216      */
    217     public void testVFE13() {
    218         //@uses dot.junit.opcodes.invoke_super.TestStubs
    219         loadAndRun("dot.junit.opcodes.invoke_super.d.T_invoke_super_18", IllegalAccessError.class,
    220                    new TestStubs());
    221     }
    222 
    223     /**
    224      * @constraint B12
    225      * @title Attempt to invoke protected method of unrelated class.
    226      */
    227     public void testVFE14() {
    228         //@uses dot.junit.opcodes.invoke_super.TestStubs
    229         loadAndRun("dot.junit.opcodes.invoke_super.d.T_invoke_super_20", IllegalAccessError.class,
    230                    new TestStubs());
    231     }
    232 
    233     /**
    234      * @constraint n/a
    235      * @title Method has different signature.
    236      */
    237     public void testVFE15() {
    238         //@uses dot.junit.opcodes.invoke_super.d.TSuper
    239         loadAndRun("dot.junit.opcodes.invoke_super.d.T_invoke_super_19", NoSuchMethodError.class);
    240     }
    241 
    242     /**
    243      * @constraint n/a
    244      * @title invoke-super shall be used to invoke private methods
    245      */
    246     public void testVFE16() {
    247         //@uses dot.junit.opcodes.invoke_super.d.TSuper
    248         load("dot.junit.opcodes.invoke_super.d.T_invoke_super_13", VerifyError.class);
    249     }
    250 
    251     /**
    252      * @constraint A23
    253      * @title number of registers
    254      */
    255     public void testVFE17() {
    256         load("dot.junit.opcodes.invoke_super.d.T_invoke_super_9", VerifyError.class);
    257     }
    258 
    259     /**
    260      * @constraint A13
    261      * @title attempt to invoke interface method
    262      */
    263     public void testVFE18() {
    264         loadAndRun("dot.junit.opcodes.invoke_super.d.T_invoke_super_24",
    265                    AbstractMethodError.class);
    266     }
    267 
    268     /**
    269      * @constraint B6
    270      * @title instance methods may only be invoked on already initialized instances.
    271      */
    272     public void testVFE19() {
    273         //@uses dot.junit.opcodes.invoke_super.d.TSuper
    274         load("dot.junit.opcodes.invoke_super.d.T_invoke_super_25", VerifyError.class);
    275     }
    276 }
    277