173a9bfc045ae62ef74fcbdce45eb0a19d120eb94Sebastien Hertz/* 273a9bfc045ae62ef74fcbdce45eb0a19d120eb94Sebastien Hertz * Licensed to the Apache Software Foundation (ASF) under one or more 373a9bfc045ae62ef74fcbdce45eb0a19d120eb94Sebastien Hertz * contributor license agreements. See the NOTICE file distributed with 473a9bfc045ae62ef74fcbdce45eb0a19d120eb94Sebastien Hertz * this work for additional information regarding copyright ownership. 573a9bfc045ae62ef74fcbdce45eb0a19d120eb94Sebastien Hertz * The ASF licenses this file to You under the Apache License, Version 2.0 673a9bfc045ae62ef74fcbdce45eb0a19d120eb94Sebastien Hertz * (the "License"); you may not use this file except in compliance with 773a9bfc045ae62ef74fcbdce45eb0a19d120eb94Sebastien Hertz * the License. You may obtain a copy of the License at 873a9bfc045ae62ef74fcbdce45eb0a19d120eb94Sebastien Hertz * 973a9bfc045ae62ef74fcbdce45eb0a19d120eb94Sebastien Hertz * http://www.apache.org/licenses/LICENSE-2.0 1073a9bfc045ae62ef74fcbdce45eb0a19d120eb94Sebastien Hertz * 1173a9bfc045ae62ef74fcbdce45eb0a19d120eb94Sebastien Hertz * Unless required by applicable law or agreed to in writing, software 1273a9bfc045ae62ef74fcbdce45eb0a19d120eb94Sebastien Hertz * distributed under the License is distributed on an "AS IS" BASIS, 1373a9bfc045ae62ef74fcbdce45eb0a19d120eb94Sebastien Hertz * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1473a9bfc045ae62ef74fcbdce45eb0a19d120eb94Sebastien Hertz * 1573a9bfc045ae62ef74fcbdce45eb0a19d120eb94Sebastien Hertz * See the License for the specific language governing permissions and 1673a9bfc045ae62ef74fcbdce45eb0a19d120eb94Sebastien Hertz * limitations under the License. 1773a9bfc045ae62ef74fcbdce45eb0a19d120eb94Sebastien Hertz */ 1873a9bfc045ae62ef74fcbdce45eb0a19d120eb94Sebastien Hertz 1973a9bfc045ae62ef74fcbdce45eb0a19d120eb94Sebastien Hertzpackage org.apache.harmony.jpda.tests.jdwp.ClassType; 2073a9bfc045ae62ef74fcbdce45eb0a19d120eb94Sebastien Hertz 2173a9bfc045ae62ef74fcbdce45eb0a19d120eb94Sebastien Hertzimport org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer; 2273a9bfc045ae62ef74fcbdce45eb0a19d120eb94Sebastien Hertzimport org.apache.harmony.jpda.tests.share.SyncDebuggee; 2373a9bfc045ae62ef74fcbdce45eb0a19d120eb94Sebastien Hertz 2473a9bfc045ae62ef74fcbdce45eb0a19d120eb94Sebastien Hertzpublic class NewInstance002Debuggee extends SyncDebuggee { 2573a9bfc045ae62ef74fcbdce45eb0a19d120eb94Sebastien Hertz 2673a9bfc045ae62ef74fcbdce45eb0a19d120eb94Sebastien Hertz static class TestClass { 2773a9bfc045ae62ef74fcbdce45eb0a19d120eb94Sebastien Hertz // Field used to check correct execution of constructor. 28e1833aa2673d4f975ad35e7a39317feeea922fe1Sebastien Hertz @SuppressWarnings("unused") 2973a9bfc045ae62ef74fcbdce45eb0a19d120eb94Sebastien Hertz private final int checkField; 3073a9bfc045ae62ef74fcbdce45eb0a19d120eb94Sebastien Hertz 3173a9bfc045ae62ef74fcbdce45eb0a19d120eb94Sebastien Hertz // Constructor invoked from JDWP ClassType.NewInstance command. 3273a9bfc045ae62ef74fcbdce45eb0a19d120eb94Sebastien Hertz public TestClass(Object obj) { 3373a9bfc045ae62ef74fcbdce45eb0a19d120eb94Sebastien Hertz if (obj == null) { 3473a9bfc045ae62ef74fcbdce45eb0a19d120eb94Sebastien Hertz checkField = 123; 3573a9bfc045ae62ef74fcbdce45eb0a19d120eb94Sebastien Hertz } else { 3673a9bfc045ae62ef74fcbdce45eb0a19d120eb94Sebastien Hertz checkField = 456; 3773a9bfc045ae62ef74fcbdce45eb0a19d120eb94Sebastien Hertz } 3873a9bfc045ae62ef74fcbdce45eb0a19d120eb94Sebastien Hertz } 3973a9bfc045ae62ef74fcbdce45eb0a19d120eb94Sebastien Hertz } 4073a9bfc045ae62ef74fcbdce45eb0a19d120eb94Sebastien Hertz 4173a9bfc045ae62ef74fcbdce45eb0a19d120eb94Sebastien Hertz void execMethod() { 4273a9bfc045ae62ef74fcbdce45eb0a19d120eb94Sebastien Hertz logWriter.println("NewInstance002Debuggee.execMethod()"); 4373a9bfc045ae62ef74fcbdce45eb0a19d120eb94Sebastien Hertz } 4473a9bfc045ae62ef74fcbdce45eb0a19d120eb94Sebastien Hertz 45e1833aa2673d4f975ad35e7a39317feeea922fe1Sebastien Hertz @Override 4673a9bfc045ae62ef74fcbdce45eb0a19d120eb94Sebastien Hertz public void run() { 4773a9bfc045ae62ef74fcbdce45eb0a19d120eb94Sebastien Hertz // Preload TestClass so it is available during the test. 48e1833aa2673d4f975ad35e7a39317feeea922fe1Sebastien Hertz @SuppressWarnings("unused") 49e1833aa2673d4f975ad35e7a39317feeea922fe1Sebastien Hertz Class<?> c = null; 5073a9bfc045ae62ef74fcbdce45eb0a19d120eb94Sebastien Hertz try { 5173a9bfc045ae62ef74fcbdce45eb0a19d120eb94Sebastien Hertz c = Class.forName("org.apache.harmony.jpda.tests.jdwp.ClassType.NewInstance002Debuggee$TestClass"); 5273a9bfc045ae62ef74fcbdce45eb0a19d120eb94Sebastien Hertz } catch (ClassNotFoundException e) { 5373a9bfc045ae62ef74fcbdce45eb0a19d120eb94Sebastien Hertz e.printStackTrace(); 5473a9bfc045ae62ef74fcbdce45eb0a19d120eb94Sebastien Hertz } 5573a9bfc045ae62ef74fcbdce45eb0a19d120eb94Sebastien Hertz synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY); 5673a9bfc045ae62ef74fcbdce45eb0a19d120eb94Sebastien Hertz logWriter.println("InvokeMethod002Debuggee"); 5773a9bfc045ae62ef74fcbdce45eb0a19d120eb94Sebastien Hertz synchronizer.receiveMessageWithoutException("org.apache.harmony.jpda.tests.jdwp.ClassType.NewInstance002Debuggee(#1)"); 5873a9bfc045ae62ef74fcbdce45eb0a19d120eb94Sebastien Hertz execMethod(); 5973a9bfc045ae62ef74fcbdce45eb0a19d120eb94Sebastien Hertz synchronizer.receiveMessageWithoutException("org.apache.harmony.jpda.tests.jdwp.ClassType.NewInstance002Debuggee(#2)"); 6073a9bfc045ae62ef74fcbdce45eb0a19d120eb94Sebastien Hertz } 6173a9bfc045ae62ef74fcbdce45eb0a19d120eb94Sebastien Hertz 6273a9bfc045ae62ef74fcbdce45eb0a19d120eb94Sebastien Hertz public static void main(String[] args) { 6373a9bfc045ae62ef74fcbdce45eb0a19d120eb94Sebastien Hertz runDebuggee(NewInstance002Debuggee.class); 6473a9bfc045ae62ef74fcbdce45eb0a19d120eb94Sebastien Hertz } 6573a9bfc045ae62ef74fcbdce45eb0a19d120eb94Sebastien Hertz} 6673a9bfc045ae62ef74fcbdce45eb0a19d120eb94Sebastien Hertz 67