0N/A/*
2362N/A * Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation.
0N/A *
2362N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
0N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
0N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
2362N/A */
2362N/A
0N/Aimport java.lang.reflect.*;
0N/A
0N/A/*
0N/A * Debuggee which exercises various types of method calls which throw
0N/A * Exceptions, including some done via Reflection,
0N/A * This was written while investigating Bug ID 4359606
0N/A */
0N/A
0N/Aclass MethodCallsReflection {
0N/A
0N/A public static void main(String args[]) throws Exception {
0N/A (new MethodCallsReflection()).go();
0N/A }
0N/A
0N/A static void staticCaller1(MethodCallsReflection mc) throws Exception {
0N/A System.out.println("Called staticCaller1");
0N/A staticExceptionCallee();
0N/A }
0N/A static void staticCaller2(MethodCallsReflection mc) throws Exception {
0N/A System.out.println("Called staticCaller2");
0N/A mc.instanceExceptionCallee();
0N/A }
0N/A static void staticCaller3(MethodCallsReflection mc) throws Exception {
0N/A System.out.println("Called staticCaller3");
0N/A /*
0N/A * Invocation by reflection. This also exercises native method calls
0N/A * since Method.invoke is a native method.
0N/A */
0N/A Method m = MethodCallsReflection.class.getDeclaredMethod("staticExceptionCallee", new Class[0]);
0N/A m.invoke(mc, new Object[0]);
0N/A }
0N/A
0N/A void instanceCaller1() throws Exception {
0N/A System.out.println("Called instanceCaller1");
0N/A staticExceptionCallee();
0N/A }
0N/A
0N/A void instanceCaller2() throws Exception {
0N/A System.out.println("Called instanceCaller2");
0N/A instanceExceptionCallee();
0N/A }
0N/A
0N/A void instanceCaller3() throws Exception {
0N/A System.out.println("Called instanceCaller3");
0N/A
0N/A /*
0N/A * Invocation by reflection. This also exercises native method calls
0N/A * since Method.invoke is a native method.
0N/A */
0N/A Method m = getClass().getDeclaredMethod("instanceExceptionCallee", new Class[0]);
0N/A m.invoke(this, new Object[0]);
0N/A }
0N/A
0N/A static void staticExceptionCallee() throws Exception {
0N/A System.out.println("Called staticExceptionCallee");
0N/A throw new IndexOutOfBoundsException ("staticExceptionCallee");
0N/A }
0N/A
0N/A void instanceExceptionCallee() throws Exception {
0N/A System.out.println("Called instanceExceptionCallee");
0N/A throw new IndexOutOfBoundsException ("instanceExceptionCallee");
0N/A }
0N/A
0N/A void go() throws Exception {
0N/A try {
0N/A instanceCaller1();
0N/A } catch (IndexOutOfBoundsException ex) {
0N/A System.out.println("Caught expected IndexOutOfBoundsException from instanceCaller1()");
0N/A }
0N/A
0N/A try {
0N/A instanceCaller2();
0N/A } catch (IndexOutOfBoundsException ex) {
0N/A System.out.println("Caught expected IndexOutOfBoundsException from instanceCaller2()");
0N/A }
0N/A
0N/A try {
0N/A instanceCaller3();
0N/A } catch (InvocationTargetException ex) {
0N/A System.out.println("Caught expected InvocationTargetException from instanceCaller3()");
0N/A }
0N/A
0N/A try {
0N/A staticCaller1(this);
0N/A } catch (IndexOutOfBoundsException ex) {
0N/A System.out.println("Caught expected IndexOutOfBoundsException from staticCaller1()");
0N/A }
0N/A
0N/A try {
0N/A staticCaller2(this);
0N/A } catch (IndexOutOfBoundsException ex) {
0N/A System.out.println("Caught expected IndexOutOfBoundsException from staticCaller2()");
0N/A }
0N/A try {
0N/A staticCaller3(this);
0N/A } catch (InvocationTargetException ex) {
0N/A System.out.println("Caught expected InvocationTargetException from staticCaller3()");
0N/A }
0N/A }
0N/A}
0N/A