Path: blob/master/test/jdk/com/sun/jdi/ClassesByName.java
41152 views
/*1* Copyright (c) 1999, 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*/2223/**24* @test25* @bug 428799226* @summary ClassesByName verifies that all the classes in the27* loaded class list can be found with classesByName..28* @author Robert Field29*30* @run build TestScaffold VMConnection31* @run compile -g HelloWorld.java32* @run build ClassesByName33*34* @run driver ClassesByName HelloWorld35*/36import com.sun.jdi.*;37import com.sun.jdi.event.*;38import com.sun.jdi.request.*;3940import java.util.List;41import java.util.Iterator;4243public class ClassesByName extends TestScaffold {4445public static void main(String args[]) throws Exception {46new ClassesByName(args).startTests();47}4849ClassesByName(String args[]) throws Exception {50super(args);51}5253protected void runTests() throws Exception {54startUp("ClassesByName");5556List all = vm().allClasses();57for (Iterator it = all.iterator(); it.hasNext(); ) {58ReferenceType cls = (ReferenceType)it.next();59String name = cls.name();60List found = vm().classesByName(name);61if (found.contains(cls)) {62System.out.println("Found class: " + name);63} else {64System.out.println("CLASS NOT FOUND: " + name);65throw new Exception("CLASS NOT FOUND (by classesByName): " + name);66}67}6869// Allow application to complete70resumeToVMDisconnect();71}72}737475