2362N/A * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 0N/A * published by the Free Software Foundation. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * @summary Add support for backtracking reference graph. 0N/A * @run build TestScaffold VMConnection TargetListener TargetAdapter 0N/A * @run main ReferrersTest 0N/A * To run this test do this: 0N/A * runregress -no ReferrersTest <cmd line options> 0N/A * where <cmd line options> are the options to be used to 0N/A * launch the debuggee, with the classname prefixed with @@. 0N/A * For example, this would run java2d demo as the debuggee: 0N/A * runregress -no ReferrersTest -classpath 0N/A * In this mode, the specified debuggee is launched in debug mode, 0N/A * and the debugger waits for a keystroke before connecting to the debuggee. 0N/A * If <cmd line options> is not specified, then the ReferrersTarg class below 0N/A * is run as the debuggee. 0N/A // This many instances of this are created. 0N/A // This many instances + 1 of this class are created. 0N/A // Each instance will point to the theReferrersTarg 0N/A/********** test program **********/ 0N/A * If args contains @@xxxx, then that is the 0N/A * name of the class we are to run. 0N/A * Used to sort a list of ReferenceTypes by 0N/A * Get to the top of main() 0N/A * to determine targetClass and mainThread 0N/A // Let debuggee run for awhile to get classes loaded 0N/A " classes from vm.allClasses() took " +
0N/A failure(
"failure: NullPointerException not thrown on instanceCounts(null)");
0N/A // Test for 0 length array 0N/A failure(
"failure: instanceCounts with a zero length array fails: " +
0N/A // Test various values of maxInstances 0N/A failure(
"failure: instances(-1) did not get an exception");
0N/A // Instance counts for all classes 0N/A // Create a list of ReferenceTypes sorted by instance count 0N/A " classes got " +
size +
" instances and took " +
0N/A " instances of ReferrersFiller");
0N/A " instances of ReferrersTarg");
0N/A // Instances, one class at a time, in sorted order, printing each line 0N/A "at a time (limited) in sorted order");
0N/A " instances of ReferrersFiller");
0N/A " instances of ReferrersTarg");
0N/A // Test various values of maxReferrers 0N/A failure(
"failure: referringObjects(-1) did not get an exception");
0N/A // Create someInstances to find the referrers of. 0N/A // Remember one instance per class to get referrers 0N/A //System.out.println( "Getting referrers for " + objRef); 0N/A * deal with results of test 0N/A * if anything has called failure("foo") testFailed will be true 0N/A //System.out.println(which + "/" + total + ": " + objRef + " took " + time + " ms"); 0N/A //System.out.println( "Getting referrers for " + objRef); 0N/A // We have to stop going up a referrer chain in some cases 0N/A // oh oh, should really check for a subclass of ClassLoader :-) 0N/A // No doubt there are other reasons to stop ...