8076471: Remove hprof agent tests in JDK

Reviewed-by: alanb
This commit is contained in:
Katja Kantserova 2015-07-10 14:48:13 +02:00
parent 867e029083
commit d8e8d8f1fa
29 changed files with 1 additions and 2089 deletions

View File

@ -154,17 +154,6 @@ javax/management/remote/mandatory/notif/NotifReconnectDeadlockTest.java generi
############################################################################
# jdk_math
############################################################################
# jdk_other
# 6988950
demo/jvmti/compiledMethodLoad/CompiledMethodLoadTest.java generic-all
############################################################################
# jdk_net
# 7148829
@ -387,10 +376,4 @@ sun/jvmstat/monitor/MonitoredVm/MonitorVmStartTerminate.java generic-all
# 8064572 8060736 8062938
sun/jvmstat/monitor/MonitoredVm/CR6672135.java generic-all
# 8079273
demo/jvmti/hprof/CpuOldTest.java generic-all
demo/jvmti/hprof/CpuTimesTest.java generic-all
demo/jvmti/hprof/OptionsTest.java generic-all
demo/jvmti/hprof/StackMapTableTest.java generic-all
############################################################################

View File

@ -223,8 +223,7 @@ svc_tools = \
sun/tools \
-sun/tools/java \
-sun/tools/jrunscript \
sun/jvmstat \
demo/jvmti
sun/jvmstat
jdk_tools = \
:core_tools \
@ -435,7 +434,6 @@ jdk = \
needs_jdk = \
:jdk_jdi \
com/sun/tools \
demo \
sun/security/tools/jarsigner \
sun/security/tools/policytool \
sun/rmi/rmic \

View File

@ -1,188 +0,0 @@
/*
* Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
*
* Sample target application for jvmti demos
*
* java Context [threadCount [iterationCount [sleepContention]]]
* Default: java Context 5 10 0
*
* threadCount Number of threads
* iterationCount Total turns taken for all threads
* sleepContention Time for main thread to sleep while holding lock
* (creates monitor contention on all other threads)
*
*/
/* Used to sync up turns and keep track of who's turn it is */
final class TurnChecker {
int thread_index;
TurnChecker(int thread_index) {
this.thread_index = thread_index;
}
}
/* Creates a bunch of threads that sequentially take turns */
public final class Context extends Thread {
/* Used to track threads */
private static long startTime;
private static TurnChecker turn = new TurnChecker(-1);
private static int total_turns_taken;
/* Used for each Context thread */
private final int thread_count;
private final int thread_index;
private final int thread_turns;
/* Main program */
public static void main(String[] argv) throws InterruptedException {
int default_thread_count = 5;
int default_thread_turns = 10;
int default_contention_sleep = 0;
int expected_turns_taken;
long sleepTime = 10L;
/* Override defaults */
if ( argv.length >= 1 ) {
default_thread_count = Integer.parseInt(argv[0]);
}
if ( argv.length >= 2 ) {
expected_turns_taken = Integer.parseInt(argv[1]);
default_thread_turns = expected_turns_taken/default_thread_count;
}
expected_turns_taken = default_thread_count*default_thread_turns;
if ( argv.length >= 3 ) {
default_contention_sleep = Integer.parseInt(argv[2]);
}
System.out.println("Context started with "
+ default_thread_count + " threads and "
+ default_thread_turns + " turns per thread");
/* Get all threads running (they will block until we set turn) */
for (int i = 0; i < default_thread_count; i++) {
new Context(default_thread_count, i, default_thread_turns).start();
}
/* Sleep to make sure thread_index 0 make it to the wait call */
System.out.println("Context sleeping, so threads will start wait");
Thread.yield();
Thread.sleep(sleepTime);
/* Save start time */
startTime = System.currentTimeMillis();
/* This triggers the starting of taking turns */
synchronized (turn) {
turn.thread_index = 0;
turn.notifyAll();
}
System.out.println("Context sleeping, so threads can run");
Thread.yield();
Thread.sleep(sleepTime);
/* Wait for threads to finish (after everyone has had their turns) */
while ( true ) {
boolean done;
done = false;
synchronized (turn) {
if ( total_turns_taken == expected_turns_taken ) {
done = true;
}
/* Create some monitor contention by sleeping with lock */
if ( default_contention_sleep > 0 ) {
System.out.println("Context sleeping, to create contention");
Thread.yield();
Thread.sleep((long)default_contention_sleep);
}
}
if ( done )
break;
System.out.println("Context sleeping, so threads will complete");
Thread.sleep(sleepTime);
}
long endTime = System.currentTimeMillis();
long totalTime = endTime - startTime;
System.out.println("Total time (milliseconds): " + totalTime);
System.out.println("Milliseconds per thread: " +
((double)totalTime / (default_thread_count)));
System.out.println("Context completed");
System.exit(0);
}
/* Thread object to run */
Context(int thread_count, int thread_index, int thread_turns) {
this.thread_count = thread_count;
this.thread_index = thread_index;
this.thread_turns = thread_turns;
}
/* Main for thread */
public void run() {
int next_thread_index = (thread_index + 1) % thread_count;
int turns_taken = 0;
try {
/* Loop until we make sure we get all our turns */
for (int i = 0; i < thread_turns * thread_count; i++) {
synchronized (turn) {
/* Keep waiting for our turn */
while (turn.thread_index != thread_index)
turn.wait();
/* MY TURN! Each thread gets thread_turns */
total_turns_taken++;
turns_taken++;
System.out.println("Turn #" + total_turns_taken
+ " taken by thread " + thread_index
+ ", " + turns_taken
+ " turns taken by this thread");
/* Give next thread a turn */
turn.thread_index = next_thread_index;
turn.notifyAll();
}
/* If we've had all our turns, break out of this loop */
if (thread_turns == turns_taken) {
System.out.println("Loop end: thread got " + turns_taken
+ " turns, expected " + thread_turns);
break;
}
}
} catch (InterruptedException intEx) {
System.out.println("Got an InterruptedException:" + intEx);
/* skip */
}
/* Make sure we got all our turns */
if ( thread_turns != turns_taken ) {
System.out.println("ERROR: thread got " + turns_taken
+ " turns, expected " + thread_turns);
System.exit(1);
}
}
}

View File

@ -1,219 +0,0 @@
/*
* Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* DemoRun:
*
* Support classes for java jvmti demo tests
*
*/
import java.io.InputStream;
import java.io.IOException;
import java.io.File;
import java.io.BufferedInputStream;
import java.io.PrintStream;
/*
* Helper class to direct process output to a StringBuffer
*/
class MyInputStream implements Runnable {
private String name;
private BufferedInputStream in;
private StringBuffer buffer;
/* Create MyInputStream that saves all output to a StringBuffer */
MyInputStream(String name, InputStream in) {
this.name = name;
this.in = new BufferedInputStream(in);
buffer = new StringBuffer(4096);
Thread thr = new Thread(this);
thr.setDaemon(true);
thr.start();
}
/* Dump the buffer */
void dump(PrintStream x) {
String str = buffer.toString();
x.println("<beginning of " + name + " buffer>");
x.println(str);
x.println("<end of buffer>");
}
/* Check to see if a pattern is inside the output. */
boolean contains(String pattern) {
String str = buffer.toString();
return str.contains(pattern);
}
/* Runs as a separate thread capturing all output in a StringBuffer */
public void run() {
try {
byte b[] = new byte[100];
for (;;) {
int n = in.read(b);
String str;
if (n < 0) {
break;
}
str = new String(b, 0, n);
buffer.append(str);
System.out.print(str);
}
} catch (IOException ioe) { /* skip */ }
}
}
/*
* Main JVMTI Demo Run class.
*/
public class DemoRun {
private String demo_name;
private String demo_options;
private MyInputStream output;
private MyInputStream error;
/* Create a Demo run process */
public DemoRun(String name, String options)
{
demo_name = name;
demo_options = options;
}
/*
* Execute a process with an -agentpath or -agentlib command option
*/
public void runit(String class_name)
{
runit(class_name, null);
}
/*
* Execute a process with an -agentpath or -agentlib command option
* plus any set of other java options.
*/
public void runit(String class_name, String vm_options[])
{
String sdk_home = System.getProperty("java.home");
String cdir = System.getProperty("test.classes", ".");
String os_arch = System.getProperty("os.arch");
String os_name = System.getProperty("os.name");
String libprefix = os_name.contains("Windows")?"":"lib";
String libsuffix = os_name.contains("Windows")?".dll":
os_name.contains("OS X")?".dylib":".so";
boolean hprof = demo_name.equals("hprof");
String java = sdk_home
+ File.separator + "bin"
+ File.separator + "java";
/* Array of strings to be passed in for exec:
* 1. java
* 2. -Dtest.classes=.
* 3. -Xcheck:jni (Just because it finds bugs)
* 4. -Xverify:all (Make sure verification is on full blast)
* 5. -agent
* vm_options
* 6+i. classname
*/
int nvm_options = 0;
if ( vm_options != null ) nvm_options = vm_options.length;
String cmd[] = new String[1 + 7 + nvm_options];
String cmdLine;
int exitStatus;
int i,j;
i = 0;
cmdLine = "";
cmdLine += (cmd[i++] = java);
cmdLine += " ";
cmdLine += (cmd[i++] = "-cp");
cmdLine += " ";
cmdLine += (cmd[i++] = cdir);
cmdLine += " ";
cmdLine += (cmd[i++] = "-Dtest.classes=" + cdir);
cmdLine += " ";
cmdLine += (cmd[i++] = "-Xcheck:jni");
cmdLine += " ";
cmdLine += (cmd[i++] = "-Xverify:all");
if ( hprof ) {
/* Load hprof with -agentlib since it's part of jre */
cmdLine += " ";
cmdLine += (cmd[i++] = "-agentlib:" + demo_name
+ (demo_options.equals("")?"":("="+demo_options)));
} else {
String libname = sdk_home
+ File.separator + "demo"
+ File.separator + "jvmti"
+ File.separator + demo_name
+ File.separator + "lib"
+ File.separator + libprefix + demo_name + libsuffix;
cmdLine += " ";
cmdLine += (cmd[i++] = "-agentpath:" + libname
+ (demo_options.equals("")?"":("="+demo_options)));
}
/* Add any special VM options */
for ( j = 0; j < nvm_options; j++ ) {
cmdLine += " ";
cmdLine += (cmd[i++] = vm_options[j]);
}
/* Add classname */
cmdLine += " ";
cmdLine += (cmd[i++] = class_name);
/* Begin process */
Process p;
System.out.println("Starting: " + cmdLine);
try {
p = Runtime.getRuntime().exec(cmd);
} catch ( IOException e ) {
throw new RuntimeException("Test failed - exec got IO exception");
}
/* Save process output in StringBuffers */
output = new MyInputStream("Input Stream", p.getInputStream());
error = new MyInputStream("Error Stream", p.getErrorStream());
/* Wait for process to complete, and if exit code is non-zero we fail */
try {
exitStatus = p.waitFor();
if ( exitStatus != 0) {
System.out.println("Exit code is " + exitStatus);
error.dump(System.out);
output.dump(System.out);
throw new RuntimeException("Test failed - " +
"exit return code non-zero " +
"(exitStatus==" + exitStatus + ")");
}
} catch ( InterruptedException e ) {
throw new RuntimeException("Test failed - process interrupted");
}
System.out.println("Completed: " + cmdLine);
}
/* Does the pattern appear in the output of this process */
public boolean output_contains(String pattern)
{
return output.contains(pattern) || error.contains(pattern);
}
}

View File

@ -1,72 +0,0 @@
/*
* Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
*
* Sample target application
*
*/
class Animal {
int category;
int age;
}
class Pet extends Animal {
String owner;
String name;
String vet;
String records;
String address;
Pet(String name) { this.name = name; }
}
class Dog extends Pet {
int breed;
int barks;
Dog(String name) { super(name); }
}
class Cat extends Pet {
int breed;
int claws;
Cat(String name) { super(name); }
}
public class HeapUser {
private static Dog dogs[];
private static Cat cats[];
public static void main(String args[]) {
System.out.println("HeapUser start, 101 dogs, 1000 cats");
dogs = new Dog[101];
for(int i=0; i<101; i++) {
dogs[i] = new Dog("fido " + i);
}
cats = new Cat[1000];
for(int i=0; i<1000; i++) {
cats[i] = new Cat("feefee " + i);
}
System.out.println("HeapUser end");
}
}

View File

@ -1,35 +0,0 @@
/*
* Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
*
* Sample target application for jvmti demos
*
*/
public class Hello {
public static void main(String args[]) {
System.out.println("Hello");
}
}

View File

@ -1,51 +0,0 @@
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
* @bug 6580131
* @summary Test jvmti demo compiledMethodLoad
*
* @compile ../DemoRun.java ../Hello.java
* @build CompiledMethodLoadTest
* @run main CompiledMethodLoadTest Hello
*/
public class CompiledMethodLoadTest {
public static void main(String args[]) throws Exception {
DemoRun demo;
/* Run demo that uses JVMTI compiledMethodLoad agent (no options) */
demo = new DemoRun("compiledMethodLoad", "" /* options to compiledMethodLoad */ );
demo.runit(args[0]);
/* Make sure patterns in output look ok */
if (demo.output_contains("ERROR")) {
throw new RuntimeException("Test failed - ERROR seen in output");
}
/* Must be a pass. */
System.out.println("Test passed - cleanly terminated");
}
}

View File

@ -1,47 +0,0 @@
/*
* Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
*
* Sample target application for gctest demo
*
*/
public class BigHello {
private final static int NLOOPS = 20000;
private static Object garbage[];
public static void main(String args[]) {
long count = 0;
System.out.println("Big Hello start");
for(int i=1; i<=NLOOPS; i++) {
count += i;
garbage = new Object[i];
garbage[0] = new Object();
}
System.out.println("Allocated " + count +
" array elements, and " + NLOOPS +
" arrays and Objects.");
System.out.println("Big Hello end");
}
}

View File

@ -1,51 +0,0 @@
/*
* Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
* @bug 5027764
* @summary Test jvmti demo gctest
*
* @compile ../DemoRun.java
* @build BigHello Gctest
* @run main Gctest BigHello
*/
public class Gctest {
public static void main(String args[]) throws Exception {
DemoRun demo;
/* Run demo that uses JVMTI gctest agent (no options) */
demo = new DemoRun("gctest", "" /* options to gctest */ );
demo.runit(args[0]);
/* Make sure patterns in output look ok */
if (demo.output_contains("ERROR")) {
throw new RuntimeException("Test failed - ERROR seen in output");
}
/* Must be a pass. */
System.out.println("Test passed - cleanly terminated");
}
}

View File

@ -1,52 +0,0 @@
/*
* Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
* @bug 5050116 6299047
* @summary Test jvmti demo heapTracker
*
* @compile ../DemoRun.java
* @compile ../HeapUser.java
* @build HeapTrackerTest
* @run main HeapTrackerTest HeapUser
*/
public class HeapTrackerTest {
public static void main(String args[]) throws Exception {
DemoRun demo;
/* Run demo that uses JVMTI heapTracker agent (no options) */
demo = new DemoRun("heapTracker", "" /* options to heapTracker */ );
demo.runit(args[0]);
/* Make sure patterns in output look ok */
if (demo.output_contains("ERROR")) {
throw new RuntimeException("Test failed - ERROR seen in output");
}
/* Must be a pass. */
System.out.println("Test passed - cleanly terminated");
}
}

View File

@ -1,52 +0,0 @@
/*
* Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
* @bug 5033539
* @summary Test jvmti demo heapViewer
*
* @compile ../DemoRun.java
* @compile ../HeapUser.java
* @build HeapViewerTest
* @run main HeapViewerTest HeapUser
*/
public class HeapViewerTest {
public static void main(String args[]) throws Exception {
DemoRun demo;
/* Run demo that uses JVMTI heapViewer agent (no options) */
demo = new DemoRun("heapViewer", "" /* options to heapViewer */ );
demo.runit(args[0]);
/* Make sure patterns in output look ok */
if (demo.output_contains("ERROR")) {
throw new RuntimeException("Test failed - ERROR seen in output");
}
/* Must be a pass. */
System.out.println("Test passed - cleanly terminated");
}
}

View File

@ -1,51 +0,0 @@
/*
* Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
* @bug 5012882 6299047
* @summary Test jvmti hprof
*
* @compile -g HelloWorld.java ../DemoRun.java
* @build CpuOldTest
* @run main CpuOldTest HelloWorld
*/
public class CpuOldTest {
public static void main(String args[]) throws Exception {
DemoRun hprof;
/* Run JVMTI hprof agent with cpu=old */
hprof = new DemoRun("hprof", "cpu=old,file=cpuold.txt");
hprof.runit(args[0]);
/* Make sure patterns in output look ok */
if (hprof.output_contains("ERROR")) {
throw new RuntimeException("Test failed - ERROR seen in output");
}
/* Must be a pass. */
System.out.println("Test passed - cleanly terminated");
}
}

View File

@ -1,51 +0,0 @@
/*
* Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
* @bug 5012882
* @summary Test jvmti hprof
*
* @compile -g:lines HelloWorld.java ../DemoRun.java
* @build CpuSamplesTest
* @run main CpuSamplesTest HelloWorld
*/
public class CpuSamplesTest {
public static void main(String args[]) throws Exception {
DemoRun hprof;
/* Run JVMTI hprof agent with cpu=samples */
hprof = new DemoRun("hprof", "cpu=samples,file=cpusamples.txt");
hprof.runit(args[0]);
/* Make sure patterns in output look ok */
if (hprof.output_contains("ERROR")) {
throw new RuntimeException("Test failed - ERROR seen in output");
}
/* Must be a pass. */
System.out.println("Test passed - cleanly terminated");
}
}

View File

@ -1,53 +0,0 @@
/*
* Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
* @bug 5097131 6299047
* @summary Test jvmti hprof
*
* @compile -g HelloWorld.java DefineClass.java ../DemoRun.java
* @build CpuTimesDefineClassTest
* @run main CpuTimesDefineClassTest DefineClass
*
*
*/
public class CpuTimesDefineClassTest {
public static void main(String args[]) throws Exception {
DemoRun hprof;
/* Run JVMTI hprof agent with cpu=times */
hprof = new DemoRun("hprof", "cpu=times,file=cputimedefineclass.txt");
hprof.runit(args[0]);
/* Make sure patterns in output look ok */
if (hprof.output_contains("ERROR")) {
throw new RuntimeException("Test failed - ERROR seen in output");
}
/* Must be a pass. */
System.out.println("Test passed - cleanly terminated");
}
}

View File

@ -1,51 +0,0 @@
/*
* Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
* @bug 5012882 6299047
* @summary Test jvmti hprof
*
* @compile -g HelloWorld.java ../DemoRun.java
* @build CpuTimesTest
* @run main CpuTimesTest HelloWorld
*/
public class CpuTimesTest {
public static void main(String args[]) throws Exception {
DemoRun hprof;
/* Run JVMTI hprof agent with cpu=times */
hprof = new DemoRun("hprof", "cpu=times,file=cputimes.txt");
hprof.runit(args[0]);
/* Make sure patterns in output look ok */
if (hprof.output_contains("ERROR")) {
throw new RuntimeException("Test failed - ERROR seen in output");
}
/* Must be a pass. */
System.out.println("Test passed - cleanly terminated");
}
}

View File

@ -1,70 +0,0 @@
/*
* Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* Testcase that does a defineClass with a NULL name on HelloWorld.class */
import java.io.*;
public class DefineClass extends ClassLoader {
public static void main(String args[]) {
DefineClass t = new DefineClass();
t.run(args);
}
public void run(String args[]) {
Class n;
byte b[] = new byte[10000];
int len = 0;
String cdir;
String cfile;
/* Class is found here: */
cdir = System.getProperty("test.classes", ".");
cfile = cdir + java.io.File.separator + "HelloWorld.class";
try {
/* Construct byte array with complete class image in it. */
FileInputStream fis = new FileInputStream(cfile);
int nbytes;
do {
nbytes = fis.read(b, len, b.length-len);
if ( nbytes > 0 ) {
len += nbytes;
}
} while ( nbytes > 0 );
} catch ( Throwable x ) {
System.err.println("Cannot find " + cfile);
x.printStackTrace();
}
/* Define the class with null for the name */
n = defineClass(null, b, 0, len);
/* Try to create an instance of it */
try {
n.newInstance();
} catch ( Throwable x ) {
x.printStackTrace();
}
}
}

View File

@ -1,51 +0,0 @@
/*
* Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
* @bug 5012882 6299047
* @summary Test jvmti hprof
*
* @compile -g HelloWorld.java ../DemoRun.java
* @build HeapAllTest
* @run main HeapAllTest HelloWorld
*/
public class HeapAllTest {
public static void main(String args[]) throws Exception {
DemoRun hprof;
/* Run JVMTI hprof agent with heap=all */
hprof = new DemoRun("hprof", "heap=all,file=heapall.txt");
hprof.runit(args[0]);
/* Make sure patterns in output look ok */
if (hprof.output_contains("ERROR")) {
throw new RuntimeException("Test failed - ERROR seen in output");
}
/* Must be a pass. */
System.out.println("Test passed - cleanly terminated");
}
}

View File

@ -1,64 +0,0 @@
/*
* Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
* @bug 4965057 6313381
* @summary Test jvmti hprof format=b
*
* @compile -g:source HelloWorld.java ../DemoRun.java
* @build HeapBinaryFormatTest
* @run main HeapBinaryFormatTest HelloWorld
*/
public class HeapBinaryFormatTest {
public static void main(String args[]) throws Exception {
DemoRun hprof;
/* Run JVMTI hprof agent to get binary format dump */
hprof = new DemoRun("hprof", "heap=dump,format=b,logflags=4,file=heapbinaryformat.txt");
hprof.runit(args[0]);
/* Make sure patterns in output look ok */
if (hprof.output_contains("ERROR")) {
throw new RuntimeException("Test failed - ERROR seen in output");
}
/* Try a variation */
String vm_opts[] = new String[1];
vm_opts[0] = "-Xmx2100m";
/* Crashes on small Linux machines: (like fyi)
How can I tell how much real memory is on a machine?
hprof.runit(args[0], vm_opts);
*/
/* Make sure patterns in output look ok */
if (hprof.output_contains("ERROR")) {
throw new RuntimeException("Test failed - ERROR seen in output");
}
/* Must be a pass. */
System.out.println("Test passed - cleanly terminated");
}
}

View File

@ -1,51 +0,0 @@
/*
* Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
* @bug 5012882 6299047
* @summary Test jvmti hprof
*
* @compile -g:source HelloWorld.java ../DemoRun.java
* @build HeapDumpTest
* @run main HeapDumpTest HelloWorld
*/
public class HeapDumpTest {
public static void main(String args[]) throws Exception {
DemoRun hprof;
/* Run JVMTI hprof agent with heap=dump */
hprof = new DemoRun("hprof", "heap=dump,file=heapdump.txt");
hprof.runit(args[0]);
/* Make sure patterns in output look ok */
if (hprof.output_contains("ERROR")) {
throw new RuntimeException("Test failed - ERROR seen in output");
}
/* Must be a pass. */
System.out.println("Test passed - cleanly terminated");
}
}

View File

@ -1,51 +0,0 @@
/*
* Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
* @bug 5012882 6299047
* @summary Test jvmti hprof
*
* @compile -g:vars HelloWorld.java ../DemoRun.java
* @build HeapSitesTest
* @run main HeapSitesTest HelloWorld
*/
public class HeapSitesTest {
public static void main(String args[]) throws Exception {
DemoRun hprof;
/* Run JVMTI hprof agent with heap=sites */
hprof = new DemoRun("hprof", "heap=sites,file=heapsites.txt");
hprof.runit(args[0]);
/* Make sure patterns in output look ok */
if (hprof.output_contains("ERROR")) {
throw new RuntimeException("Test failed - ERROR seen in output");
}
/* Must be a pass. */
System.out.println("Test passed - cleanly terminated");
}
}

View File

@ -1,119 +0,0 @@
/*
* Copyright (c) 2004, 2009, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* HelloWorld:
*
* Sample target application for HPROF tests
*
*/
/* Just some classes that create a variety of references */
class AAAA {
public int AAAA_i;
public static int AAAA_si;
public Object AAAA_j;
public static Object AAAA_sj;
public long AAAA_k;
public static long AAAA_sk;
}
interface IIII {
Object o = new Object();
}
class BBBB extends AAAA implements IIII {
public byte BBBB_ii;
public static byte BBBB_sii;
public Object BBBB_jj;
public static Object BBBB_sjj;
public short BBBB_kk;
public static short BBBB_skk;
}
class REFS {
private static String s1 = new String("REFS_string1");
private String is2 = new String("REFS_string2");
private static String s3 = new String("REFS_string3");
private static String s4 = new String("REFS_string4");
private String is5 = new String("REFS_string5");
private AAAA aaaa;
private BBBB bbbb;
public void test() {
aaaa = new AAAA();
bbbb = new BBBB();
aaaa.AAAA_i = 1;
AAAA.AAAA_si = 2;
aaaa.AAAA_j = s1;
AAAA.AAAA_sj = is2;
aaaa.AAAA_k = 5;
AAAA.AAAA_sk = 6;
bbbb.BBBB_ii = 11;
BBBB.BBBB_sii = 22;
bbbb.BBBB_jj = s3;
BBBB.BBBB_sjj = s4;
bbbb.BBBB_kk = 55;
BBBB.BBBB_skk = 66;
bbbb.AAAA_i = 111;
bbbb.AAAA_j = is5;
bbbb.AAAA_k = 555;
}
}
/* Fairly simple hello world program that does some exercises first. */
public class HelloWorld {
public static void main(String args[]) {
/* References exercise. */
REFS r = new REFS();
r.test();
/* Use a generic type exercise. */
java.util.List<String> l = new java.util.ArrayList<String>();
String.format("%s", "");
/* Create a class that has lots of different bytecodes exercise. */
/* (Don't run it!) */
UseAllBytecodes x = new UseAllBytecodes(1,2);
/* Just some code with branches exercise. */
try {
if ( args.length == 0 ) {
System.out.println("No arguments passed in (doesn't matter)");
} else {
System.out.println("Arguments passed in (doesn't matter)");
}
} catch ( Throwable e ) {
System.out.println("ERROR: System.out.println() did a throw");
} finally {
System.out.println("Hello, world!");
}
}
}

View File

@ -1,56 +0,0 @@
/*
* Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
* @bug 5012882
* @summary Test jvmti hprof
*
* @compile -g ../Context.java ../DemoRun.java
* @build MonitorTest
* @run main MonitorTest Context 25 200 1000
*/
/* To create monitor contention, increase the default configuration.
* Hprof seems to have historically not output anything unless certain
* limits have been reached on the total contention time.
*/
public class MonitorTest {
public static void main(String args[]) throws Exception {
DemoRun hprof;
/* Run JVMTI hprof agent with monitor=y */
hprof = new DemoRun("hprof", "monitor=y,file=monitor.txt");
hprof.runit(args[0]);
/* Make sure patterns in output look ok */
if (hprof.output_contains("ERROR")) {
throw new RuntimeException("Test failed - ERROR seen in output");
}
/* Must be a pass. */
System.out.println("Test passed - cleanly terminated");
}
}

View File

@ -1,62 +0,0 @@
/*
* Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
* @bug 5083441 6299047
* @summary Test jvmti hprof
*
* @compile -g:lines HelloWorld.java ../DemoRun.java
* @build OptionsTest
* @run main OptionsTest HelloWorld
*/
import java.util.*;
public class OptionsTest {
public static void main(String args[]) throws Exception {
DemoRun hprof;
List<String> options = new LinkedList<String>();
options.add("cpu=samples,depth=0,file=options0.txt");
options.add("cpu=times,depth=0,file=options1.txt");
options.add("cpu=old,depth=0,file=options2.txt");
options.add("depth=0,file=options3.txt");
for(String option: options) {
/* Run JVMTI hprof agent with various options */
hprof = new DemoRun("hprof", option);
hprof.runit(args[0]);
/* Make sure patterns in output look ok */
if (hprof.output_contains("ERROR")) {
throw new RuntimeException("Test failed with " + option
+ " - ERROR seen in output");
}
}
/* Must be a pass. */
System.out.println("Test passed - cleanly terminated");
}
}

View File

@ -1,63 +0,0 @@
/*
* Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
* @bug 6266289 6299047 6855180 6855551
* @summary Test jvmti hprof and java_crw_demo with StackMapTable attributes
*
* @compile ../DemoRun.java
* @compile -g:lines HelloWorld.java
* @build StackMapTableTest
* @run main StackMapTableTest HelloWorld
*/
import java.util.*;
public class StackMapTableTest {
public static void main(String args[]) throws Exception {
DemoRun hprof;
List<String> options = new LinkedList<String>();
options.add("cpu=samples,file=stackmaptable0.txt");
options.add("cpu=times,file=stackmaptable1.txt");
options.add("heap=sites,file=stackmaptable2.txt");
options.add("file=stackmaptable3.txt");
for(String option: options) {
/* Run JVMTI hprof agent with various options */
hprof = new DemoRun("hprof", option);
hprof.runit(args[0]);
/* Make sure patterns in output look ok */
if (hprof.output_contains("ERROR")) {
throw new RuntimeException("Test failed with " + option
+ " - ERROR seen in output");
}
}
/* Must be a pass. */
System.out.println("Test passed - cleanly terminated");
}
}

View File

@ -1,309 +0,0 @@
/*
* Copyright (c) 1996, 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
A simple Java class definition that helps self-test the runtime
interpreter. Used for getfield/putfield, invoke* opcodes and
their _quick variants.
See src/share/java/runtime/selftest.c for details of the test
environment.
*/
/* Used to be sun/misc/SelfTest.java */
interface UseAllBytecodesInterface
{
public void test_an_interface(int p1);
}
public class UseAllBytecodes implements UseAllBytecodesInterface
{
public int i1, i2;
public float f1, f2;
public double d1, d2;
public long l1, l2;
public static int si1, si2;
public static float sf1, sf2;
public static double sd1, sd2;
public static long sl1, sl2;
public UseAllBytecodesInterface interfaceObject;
public int multi[][][];
public UseAllBytecodes()
{
/* This constructor is not intended to ever be run. It is here
to force CONSTANT_Methodref constants into the CP */
set_i1(11);
set_i2(22);
set_f1(1.1f);
set_f2(2.2f);
set_d1(1.0);
set_d2(2.0);
set_l1(3);
set_l2(4);
set_si1(33);
set_si2(44);
set_sf1(3.3f);
set_sf2(4.4f);
set_sd1(3.0);
set_sd2(4.0);
set_sl1(5);
set_sl2(6);
test_areturn();
test_athrow1();
test_athrow2();
test_athrow3();
test_athrow4();
/* This puts a CONSTANT_InterfaceMethodref into the CP */
interfaceObject.test_an_interface(1234);
/* This creates an array and puts it into the CP */
multi = new int[2][3][4];
}
public UseAllBytecodes(int p1)
{
i1 = p1;
i2 = 12345678; /* This puts a CONSTANT_Integer into the CP */
d1 = (double) p1;
d2 = 1.2e234; /* This puts a CONSTANT_Double into the CP */
}
public UseAllBytecodes(int p1, int p2)
{
i1 = p1;
i2 = p2;
}
/* These methods should return something other than their
arguments, so the self test can easily determine that
the correct value was returned. */
public int set_i1(int p1)
{
i1 = p1;
return i1 + 1;
}
public int set_i2(int p2)
{
i2 = p2;
return i2 + 1;
}
public float set_f1(float p1)
{
f1 = p1;
return f1 + 1.0e34f;
}
public float set_f2(float p2)
{
f2 = p2;
return f2 + 1.0e34f;
}
public double set_d1(double p1)
{
d1 = p1;
return d1 + 1.0e234;
}
public double set_d2(double p2)
{
d2 = p2;
return d2 + 1.0e234;
}
public long set_l1(long p1)
{
l1 = p1;
return l1 + 1;
}
public long set_l2(long p2)
{
l2 = p2;
return l2 + 1;
}
public static void set_si1(int p1)
{
si1 = p1;
}
public static void set_si2(int p2)
{
si2 = p2;
}
public static void set_sf1(float p1)
{
sf1 = p1;
}
public static void set_sf2(float p2)
{
sf2 = p2;
}
public static void set_sd1(double p1)
{
sd1 = p1;
}
public static void set_sd2(double p2)
{
sd2 = p2;
}
public static void set_sl1(long p1)
{
sl1 = p1;
}
public static void set_sl2(long p2)
{
sl2 = p2;
}
public UseAllBytecodes test_areturn()
{
return this;
}
/* This method does the same thing as set_i1.
It is here to test the invokeinterface opcode. */
public void test_an_interface(int p1)
{
i1 = p1;
}
/* The following 10 methods test various permutations of
try-and-catch. */
public static void test_athrow1() throws NullPointerException
{
try
{
si1 = -1;
throw new NullPointerException();
}
catch (Exception e)
{
si1 = 1;
}
}
public static void test_athrow2()
{
int i = 1;
try
{
si1 = -1;
test_athrow1();
}
catch (Exception e)
{
// This should *not* catch the exception;
// should be caught in test_athrow1.
si1 = i + 1;
}
}
public static void test_athrow3()
{
int i = 1;
try
{
// Ultimately throws NullPointerException
si1 = -1;
si2 = -1;
test_athrow5();
}
catch (NullPointerException np)
{
si1 = i + 1;
}
catch (NoSuchMethodException e)
{
si2 = i + 1;
}
si1++; // total is 3
}
public static void test_athrow4()
{
int i = 2;
try
{
// Ultimately throws NoSuchMethodException
si1 = -1;
si2 = -1;
test_athrow7();
}
catch (NullPointerException e)
{
si1 = i + 1;
}
catch (NoSuchMethodException nsm)
{
si2 = i + 1;
}
si2++; // total is 4
}
public static void test_throw_nosuchmethod() throws NoSuchMethodException
{
throw new NoSuchMethodException();
}
public static void test_throw_nullpointer() throws NullPointerException
{
throw new NullPointerException();
}
public static void test_athrow5() throws NullPointerException, NoSuchMethodException
{
test_athrow6();
}
public static void test_athrow6() throws NullPointerException, NoSuchMethodException
{
test_throw_nullpointer();
}
public static void test_athrow7() throws NullPointerException, NoSuchMethodException
{
test_athrow8();
}
public static void test_athrow8() throws NullPointerException, NoSuchMethodException
{
test_throw_nosuchmethod();
}
}

View File

@ -1,39 +0,0 @@
/*
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* MinstExample:
*
*/
public class MinstExample {
private static int called = 0;
private static void foobar() {
called++;
}
public static void main(String[] args) {
System.out.println("MinstExample started");
for(int i=0; i<200; i++) foobar();
System.out.println("MinstExample ended");
}
}

View File

@ -1,52 +0,0 @@
/*
* Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
* @bug 6377205
* @summary Test jvmti demo minst
*
* @compile ../DemoRun.java
* @compile MinstExample.java
* @build MinstTest
* @run main MinstTest MinstExample
*/
public class MinstTest {
public static void main(String args[]) throws Exception {
DemoRun demo;
/* Run demo that uses JVMTI minst agent (no options) */
demo = new DemoRun("minst", "exclude=java/*,exclude=javax/*,exclude=com/*,exclude=jdk/*,exclude=sun/*" /* options to minst */ );
demo.runit(args[0]);
/* Make sure patterns in output look ok */
if (demo.output_contains("ERROR")) {
throw new RuntimeException("Test failed - ERROR seen in output");
}
/* Must be a pass. */
System.out.println("Test passed - cleanly terminated");
}
}

View File

@ -1,57 +0,0 @@
/*
* Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
* @bug 5039613
* @summary Test jvmti demo versionCheck
*
* @compile ../DemoRun.java ../Hello.java
* @build FailsWhenJvmtiVersionDiffers
* @run main FailsWhenJvmtiVersionDiffers Hello
*/
public class FailsWhenJvmtiVersionDiffers {
public static void main(String args[]) throws Exception {
DemoRun demo;
/* Run demo that uses JVMTI versionCheck agent (no options) */
demo = new DemoRun("versionCheck", "" /* options to versionCheck */ );
demo.runit(args[0]);
/* Make sure patterns in output look ok */
if (demo.output_contains("ERROR")) {
System.out.println(
"NOTE: The jmvti.h file doesn't match the JVMTI in the VM.\n"
+" This may or may not be a serious issue.\n"
+" Check the jtr file for details.\n"
+" Call your local serviceability representative for help."
);
throw new RuntimeException("Test failed - ERROR seen in output");
}
/* Must be a pass. */
System.out.println("Test passed - cleanly terminated");
}
}

View File

@ -1,52 +0,0 @@
/*
* Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
* @bug 5027764
* @summary Test jvmti demo waiters
*
* @compile ../DemoRun.java
* @compile ../Context.java
* @build WaitersTest
* @run main WaitersTest Context
*/
public class WaitersTest {
public static void main(String args[]) throws Exception {
DemoRun demo;
/* Run demo that uses JVMTI waiters agent (no options) */
demo = new DemoRun("waiters", "" /* options to waiters */ );
demo.runit(args[0]);
/* Make sure patterns in output look ok */
if (demo.output_contains("ERROR")) {
throw new RuntimeException("Test failed - ERROR seen in output");
}
/* Must be a pass. */
System.out.println("Test passed - cleanly terminated");
}
}