Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassLoaderReference/definedClasses/definedclasses001a.java
41161 views
/*1* Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223package nsk.jdi.ClassLoaderReference.definedClasses;2425import nsk.share.*;26import nsk.share.jpda.*;27import nsk.share.jdi.*;2829import java.net.URLClassLoader;30import java.net.URL;3132/**33* This class is used as debuggee application for the definedclasses001 JDI test.34*/3536public class definedclasses001a {3738//----------------------------------------------------- templete section3940static final int PASSED = 0;41static final int FAILED = 2;42static final int PASS_BASE = 95;4344static ArgumentHandler argHandler;45static Log log;4647//-------------------------------------------------- log procedures4849private static void log1(String message) {50log.display("**> debuggee: " + message);51}5253private static void logErr(String message) {54log.complain("**> debuggee: " + message);55}5657//====================================================== test program5859static ClassLoader classLoader = null;6061static String urlString = "http://download.java.net/java/jdk10/docs/api/overview-summary.html";6263//------------------------------------------------------ common section64static int instruction = 1;65static int end = 0;66// static int quit = 0;67// static int continue = 2;68static int maxInstr = 1; // 2;6970static int lineForComm = 2;7172private static void methodForCommunication() {73int i1 = instruction;74int i2 = i1;75int i3 = i2;76}77//---------------------------------------------------- main method7879public static void main (String argv[]) {8081argHandler = new ArgumentHandler(argv);82log = argHandler.createDebugeeLog();8384log1("debuggee started!");8586int exitCode = PASSED;878889label0:90for (int i = 0; ; i++) {9192if (instruction > maxInstr) {93logErr("ERROR: unexpected instruction: " + instruction);94exitCode = FAILED;95break ;96}9798switch (i) {99100//------------------------------------------------------ section tested101102case 0:103try {104URL[] url = { new URL(urlString) } ;105classLoader = new URLClassLoader(url);106} catch ( Exception e ) {107log1("Exception : " + e);108}109110methodForCommunication();111break ;112113//------------------------------------------------- standard end section114115default:116instruction = end;117methodForCommunication();118break label0;119}120}121122System.exit(exitCode + PASS_BASE);123}124}125126127