blob: 1667d2d55b348c9b7de48b9ccde54cb5df578dae [file] [log] [blame]
Brian Carlstrom3d434d42014-10-14 00:06:31 -07001/*
2 * Copyright (C) 2011 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
17public final class Main {
18
19 public static void main(String[] args) throws Exception {
20 System.out.println("Test Started");
21 testMissingFieldType();
22 testMissingMethodReturnType();
23 testMissingMethodParameterType();
24 testMissingInnerClass();
25 System.out.println("Test Finished");
26 }
27
28 private static class ClassWithMissingFieldType {
29 MissingClass field;
30 }
31
32 private static void testMissingFieldType() throws Exception {
33 try {
34 ClassWithMissingFieldType.class.getDeclaredFields();
35 throw new AssertionError();
36 } catch (NoClassDefFoundError e) {
37 System.out.println("testMissingFieldType caught NoClassDefFoundError");
38 }
39 }
40
41 private static class ClassWithMissingMethodReturnType {
42 MissingClass method() {
43 return null;
44 }
45 }
46
47 private static void testMissingMethodReturnType() throws Exception {
48 try {
49 ClassWithMissingMethodReturnType.class.getDeclaredMethods();
50 throw new AssertionError();
51 } catch (NoClassDefFoundError e) {
52 System.out.println("testMissingMethodReturnType caught NoClassDefFoundError");
53 }
54 }
55
56 private static class ClassWithMissingMethodParameterType {
57 void method(MissingClass arg) {}
58 }
59
60 private static void testMissingMethodParameterType() throws Exception {
61 try {
62 ClassWithMissingMethodParameterType.class.getDeclaredMethods();
63 throw new AssertionError();
64 } catch (NoClassDefFoundError e) {
65 System.out.println("testMissingMethodParameterType caught NoClassDefFoundError");
66 }
67 }
68
69 private static final class MissingInnerClass {
70 }
71
72 private static void testMissingInnerClass() throws Exception {
73 try {
74 Main.class.getDeclaredClasses();
75 throw new AssertionError();
76 } catch (NoClassDefFoundError e) {
77 System.out.println("testMissingInnerClass caught NoClassDefFoundError");
78 }
79 }
80}