001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: *
015: * See the License for the specific language governing permissions and
016: * limitations under the License.
017: */
018:
019: /**
020: * @author Vitaly A. Provodin
021: * @version $Revision: 1.4 $
022: */
023:
024: /**
025: * Created on 10.03.2005
026: */package org.apache.harmony.jpda.tests.jdwp.share.debuggee;
027:
028: import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
029: import org.apache.harmony.jpda.tests.share.SyncDebuggee;
030:
031: /**
032: * This class provides common debuggee class for InvokeMethod tests.
033: *
034: */
035: public class InvokeMethodDebuggee extends SyncDebuggee {
036:
037: public class testClass1 {
038: public testClass1() {
039: logWriter.println("constructor testClass1 invoked");
040: }
041: }
042:
043: public int testMethod1(boolean needThrow) throws Throwable {
044: logWriter.println("method testClass1 invoked");
045: if (needThrow) {
046: throw new Throwable("test exception");
047: }
048: return 123;
049: }
050:
051: public static int testMethod2(boolean needThrow) throws Throwable {
052: if (needThrow) {
053: throw new Throwable("test exception");
054: }
055: return 234;
056: }
057:
058: static int checkInt = 1;
059: static int[] checkIntArray = { 1, 2 };
060: static int[][] checkIntArray2 = { { 123 }, { 23, 34 },
061: { 2, 4, 6, 8 } };
062: static String checkString = "text 1";
063: static String[] checkStringArray = { "text 2" };
064: static String[][] checkStringArray2 = { { "text 3" }, { "text 4" } };
065: static testClass checkClass = new testClass();
066: static testClass[] checkClassArray = { new testClass() };
067: static testClass[][] checkClassArray2 = { { new testClass() },
068: { new testClass() } };
069:
070: public static String testMethod3(int i, int[] ai, int[][] aai,
071: String s, String[] as, String[][] aas, testClass tc,
072: testClass[] atc, testClass[][] aatc) {
073: return "qwerty";
074: }
075:
076: void execMethod() {
077: logWriter.println("InvokeMethodDebuggee.execMethod()");
078: }
079:
080: public void run() {
081: Class c = null;
082: try {
083: c = Class
084: .forName("org.apache.harmony.jpda.tests.jdwp.share.debuggee.InvokeMethodDebuggee$testClass1");
085: c = Class
086: .forName("org.apache.harmony.jpda.tests.jdwp.share.debuggee.testClass2");
087: c = Class
088: .forName("org.apache.harmony.jpda.tests.jdwp.share.debuggee.testClass3");
089: } catch (ClassNotFoundException e) {
090: e.printStackTrace();
091: }
092: synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);
093: logWriter.println("InvokeMethodDebuggee");
094: // synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
095: synchronizer
096: .receiveMessageWithoutException("org.apache.harmony.jpda.tests.jdwp.share.debuggee.InvokeMethodDebuggee(#1)");
097: execMethod();
098: // synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
099: synchronizer
100: .receiveMessageWithoutException("org.apache.harmony.jpda.tests.jdwp.share.debuggee.InvokeMethodDebuggee(#2)");
101: logWriter.println("DUMP{" + c + "}");
102: }
103:
104: public static void main(String[] args) {
105: runDebuggee(InvokeMethodDebuggee.class);
106: }
107: }
108:
109: class testClass {
110: }
111:
112: class testClass2 {
113: public testClass2(boolean needThrow) throws Throwable {
114: if (needThrow) {
115: throw new Throwable("test exception");
116: }
117: }
118:
119: public int testMethod3(boolean needThrow) throws Throwable {
120: if (needThrow) {
121: throw new Throwable("test exception");
122: }
123: return 345;
124: }
125: }
126:
127: class testClass3 extends testClass2 {
128: public testClass3() throws Throwable {
129: super (false);
130: }
131:
132: public int testMethod3(boolean needThrow) throws Throwable {
133: if (needThrow) {
134: throw new Throwable("test exception");
135: }
136: return 456;
137: }
138: }
|