Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/com/sun/jdi/ClassesByName.java
38855 views
/*1* Copyright (c) 1999, 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*/2223/**24* @test25* @bug 428799226* @author Robert Field27*28* @run build JDIScaffold VMConnection29* @run compile -g HelloWorld.java30* @run build ClassesByName31*32* @summary ClassesByName verifies that all the classes in the33* loaded class list can be found with classesByName..34*35* @run main ClassesByName HelloWorld36*/37import com.sun.jdi.*;38import com.sun.jdi.event.*;39import com.sun.jdi.request.*;4041import java.util.List;42import java.util.Iterator;4344public class ClassesByName extends JDIScaffold {45final String[] args;4647public static void main(String args[]) throws Exception {48new ClassesByName(args).startTests();49}5051ClassesByName(String args[]) throws Exception {52super();53this.args = args;54}5556protected void runTests() throws Exception {57connect(args);58waitForVMStart();5960List all = vm().allClasses();61for (Iterator it = all.iterator(); it.hasNext(); ) {62ReferenceType cls = (ReferenceType)it.next();63String name = cls.name();64List found = vm().classesByName(name);65if (found.contains(cls)) {66System.out.println("Found class: " + name);67} else {68System.out.println("CLASS NOT FOUND: " + name);69throw new Exception("CLASS NOT FOUND (by classesByName): " + name);70}71}7273// Allow application to complete74resumeToVMDeath();75}76}777879