1 /* 2 * Copyright (C) 2007 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 import java.lang.reflect.Type; 18 19 /** 20 * Throw a few things at the verifier, all of which are expected to pass. 21 */ 22 public class Main { 23 static public void main(String[] args) { 24 tryBlah(1); 25 26 System.out.println("Zorch."); 27 } 28 29 /* 30 * Make sure the verifier is handling type merge of arrays of 31 * references correctly. 32 */ 33 static Object[] arrayCheck1(int wanted) { 34 String[] arrayOne; 35 Integer[] arrayTwo; 36 37 arrayOne = new String[1]; 38 arrayTwo = new Integer[1]; 39 40 switch (wanted) { 41 case 0: return arrayOne; 42 case 1: return arrayTwo; 43 default: return null; 44 } 45 } 46 47 static Object arrayCheck1b(int wanted) { 48 String[] arrayOne; 49 Integer[] arrayTwo; 50 int[] arrayThree; 51 52 arrayOne = new String[1]; 53 arrayTwo = new Integer[1]; 54 arrayThree = new int[1]; 55 56 switch (wanted) { 57 case 0: return arrayOne; 58 case 1: return arrayTwo; 59 case 2: return arrayThree; 60 default: return null; 61 } 62 } 63 64 static Object[] arrayCheck2(int wanted) { 65 String[][] arrayOne; 66 String[][] arrayTwo; 67 Integer[][] arrayThree; 68 69 arrayOne = new String[1][]; 70 arrayTwo = new String[1][]; 71 arrayThree = new Integer[1][]; 72 73 switch (wanted) { 74 case 0: return arrayOne; 75 case 1: return arrayTwo; 76 case 2: return arrayThree; 77 default: return null; 78 } 79 } 80 81 static Object[] arrayCheck3(int wanted) { 82 String[][] arrayTwo; 83 String[][][][] arrayFour; 84 85 arrayTwo = new String[1][]; 86 arrayFour = new String[1][][][]; 87 88 switch (wanted) { 89 case 0: return arrayTwo; 90 case 1: return arrayFour; 91 default: return null; 92 } 93 } 94 95 /* 96 * Check return type merge. 97 */ 98 private Type[] typeTest() { 99 if(this == null) { 100 return (Class<?>[])null; 101 } 102 return (Type[])null; 103 } 104 105 106 /* 107 * Exercise the blahs. 108 */ 109 static void tryBlah(int num) { 110 BlahFeature feature = null; // interface ref 111 112 switch (num) { 113 case 1: 114 feature = new BlahOne(); 115 break; 116 default: 117 feature = new BlahTwo(); 118 break; 119 } 120 121 feature.doStuff(); 122 } 123 } 124