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 dxc.junit.opcodes.jsr; 18 19 import dxc.junit.DxTestCase; 20 import dxc.junit.DxUtil; 21 import dxc.junit.opcodes.jsr.jm.T_jsr_1; 22 import dxc.junit.opcodes.jsr.jm.T_jsr_2; 23 24 public class Test_jsr extends DxTestCase { 25 26 /** 27 * @title normal test 28 */ 29 public void testN1() { 30 T_jsr_1 t = new T_jsr_1(); 31 assertTrue(t.run()); 32 } 33 34 /** 35 * @title nested jsrs 36 */ 37 public void testN2() { 38 T_jsr_2 t = new T_jsr_2(); 39 assertTrue(t.run()); 40 } 41 42 /** 43 * @constraint 4.8.2.23 44 * @title recursion of jsr 45 */ 46 public void testVFE1() { 47 try { 48 Class.forName("dxc.junit.opcodes.jsr.jm.T_jsr_4"); 49 fail("expected a verification exception"); 50 } catch (Throwable t) { 51 DxUtil.checkVerifyException(t); 52 } 53 } 54 55 /** 56 * @constraint 4.8.1.7 57 * @title branch target shall be inside the 58 * method 59 */ 60 public void testVFE2() { 61 try { 62 Class.forName("dxc.junit.opcodes.jsr.jm.T_jsr_5"); 63 fail("expected a verification exception"); 64 } catch (Throwable t) { 65 DxUtil.checkVerifyException(t); 66 } 67 } 68 69 /** 70 * @constraint 4.8.1.7 71 * @title branch target inside wide instruction 72 */ 73 public void testVFE3() { 74 try { 75 Class.forName("dxc.junit.opcodes.jsr.jm.T_jsr_3"); 76 fail("expected a verification exception"); 77 } catch (Throwable t) { 78 DxUtil.checkVerifyException(t); 79 } 80 } 81 82 } 83