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