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.Method;
18 
19 /**
20  * Test insertion of an abstract method in a superclass.
21  */
22 public class ConcreteSub extends AbstractBase {
callBase(AbstractBase abs)23     private static void callBase(AbstractBase abs) {
24         System.out.println("calling abs.doStuff()");
25         abs.doStuff();
26     }
27 
main()28     public static void main() {
29         ConcreteSub sub = new ConcreteSub();
30 
31         try {
32             callBase(sub);
33         } catch (AbstractMethodError ame) {
34             System.out.println("Got expected exception from abs.doStuff().");
35         }
36 
37         /*
38          * Check reflection stuff.
39          */
40         Class absClass = AbstractBase.class;
41         Method meth;
42 
43         System.out.println("class modifiers=" + absClass.getModifiers());
44 
45         try {
46             meth = absClass.getMethod("redefineMe", (Class[]) null);
47         } catch (NoSuchMethodException nsme) {
48             nsme.printStackTrace();
49             return;
50         }
51         System.out.println("meth modifiers=" + meth.getModifiers());
52     }
53 }
54