12faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes/* 22faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * Copyright (C) 2006 The Android Open Source Project 32faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * 42faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * Licensed under the Apache License, Version 2.0 (the "License"); 52faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * you may not use this file except in compliance with the License. 62faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * You may obtain a copy of the License at 72faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * 82faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * http://www.apache.org/licenses/LICENSE-2.0 92faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * 102faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * Unless required by applicable law or agreed to in writing, software 112faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * distributed under the License is distributed on an "AS IS" BASIS, 122faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 132faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * See the License for the specific language governing permissions and 142faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * limitations under the License. 152faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes */ 165d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao 17201803fb1acd15b9daae51d816e1b08aededdc41Jeff Haoimport java.lang.reflect.Method; 18201803fb1acd15b9daae51d816e1b08aededdc41Jeff Hao 195d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao/** 205d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao * Miranda testing. 215d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao */ 225d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhaopublic class Main { 235d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao public static void main(String[] args) { 245d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao MirandaClass mir = new MirandaClass(); 255d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao System.out.println("MirandaClass:"); 265d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao System.out.println(" inInterface: " + mir.inInterface()); 275d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao System.out.println(" inInterface2: " + mir.inInterface2()); 285d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao System.out.println(" inAbstract: " + mir.inAbstract()); 295d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao 305d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao /* try again through abstract class; results should be identical */ 315d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao MirandaAbstract mira = mir; 325d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao System.out.println("MirandaAbstract / MirandaClass:"); 335d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao System.out.println(" inInterface: " + mira.inInterface()); 345d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao System.out.println(" inInterface2: " + mira.inInterface2()); 355d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao System.out.println(" inAbstract: " + mira.inAbstract()); 365d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao 375d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao MirandaAbstract mira2 = new MirandaClass2(); 385d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao System.out.println("MirandaAbstract / MirandaClass2:"); 395d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao System.out.println(" inInterface: " + mira2.inInterface()); 405d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao System.out.println(" inInterface2: " + mira2.inInterface2()); 415d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao System.out.println(" inAbstract: " + mira2.inAbstract()); 42201803fb1acd15b9daae51d816e1b08aededdc41Jeff Hao 43201803fb1acd15b9daae51d816e1b08aededdc41Jeff Hao System.out.println("Test getting miranda method via reflection:"); 44201803fb1acd15b9daae51d816e1b08aededdc41Jeff Hao try { 45201803fb1acd15b9daae51d816e1b08aededdc41Jeff Hao Class mirandaClass = Class.forName("MirandaAbstract"); 46201803fb1acd15b9daae51d816e1b08aededdc41Jeff Hao Method mirandaMethod = mirandaClass.getDeclaredMethod("inInterface", (Class[]) null); 47201803fb1acd15b9daae51d816e1b08aededdc41Jeff Hao System.out.println(" did not expect to find miranda method"); 48201803fb1acd15b9daae51d816e1b08aededdc41Jeff Hao } catch (NoSuchMethodException nsme) { 49201803fb1acd15b9daae51d816e1b08aededdc41Jeff Hao System.out.println(" caught expected NoSuchMethodException"); 50201803fb1acd15b9daae51d816e1b08aededdc41Jeff Hao } catch (Exception e) { 51201803fb1acd15b9daae51d816e1b08aededdc41Jeff Hao System.out.println(" caught unexpected exception " + e); 52201803fb1acd15b9daae51d816e1b08aededdc41Jeff Hao } 535d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao } 545d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao} 55