--- a/jdk/test/TEST.groups Mon Jul 13 15:35:57 2015 +0200
+++ b/jdk/test/TEST.groups Wed Jul 15 13:21:25 2015 +0200
@@ -223,7 +223,8 @@
sun/tools \
-sun/tools/java \
-sun/tools/jrunscript \
- sun/jvmstat
+ sun/jvmstat \
+ demo/jvmti
jdk_tools = \
:core_tools \
@@ -434,6 +435,7 @@
needs_jdk = \
:jdk_jdi \
com/sun/tools \
+ demo \
sun/security/tools/jarsigner \
sun/security/tools/policytool \
sun/rmi/rmic \
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/demo/jvmti/Context.java Wed Jul 15 13:21:25 2015 +0200
@@ -0,0 +1,188 @@
+/*
+ * 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);
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/demo/jvmti/DemoRun.java Wed Jul 15 13:21:25 2015 +0200
@@ -0,0 +1,211 @@
+/*
+ * 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";
+ 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");
+ 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);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/demo/jvmti/HeapUser.java Wed Jul 15 13:21:25 2015 +0200
@@ -0,0 +1,72 @@
+/*
+ * 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");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/demo/jvmti/Hello.java Wed Jul 15 13:21:25 2015 +0200
@@ -0,0 +1,35 @@
+/*
+ * 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");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/demo/jvmti/compiledMethodLoad/CompiledMethodLoadTest.java Wed Jul 15 13:21:25 2015 +0200
@@ -0,0 +1,51 @@
+/*
+ * 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");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/demo/jvmti/gctest/BigHello.java Wed Jul 15 13:21:25 2015 +0200
@@ -0,0 +1,47 @@
+/*
+ * 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");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/demo/jvmti/gctest/Gctest.java Wed Jul 15 13:21:25 2015 +0200
@@ -0,0 +1,51 @@
+/*
+ * 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");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/demo/jvmti/heapTracker/HeapTrackerTest.java Wed Jul 15 13:21:25 2015 +0200
@@ -0,0 +1,52 @@
+/*
+ * 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");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/demo/jvmti/heapViewer/HeapViewerTest.java Wed Jul 15 13:21:25 2015 +0200
@@ -0,0 +1,52 @@
+/*
+ * 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");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/demo/jvmti/minst/MinstExample.java Wed Jul 15 13:21:25 2015 +0200
@@ -0,0 +1,39 @@
+/*
+ * 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");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/demo/jvmti/minst/MinstTest.java Wed Jul 15 13:21:25 2015 +0200
@@ -0,0 +1,52 @@
+/*
+ * 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");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/demo/jvmti/versionCheck/FailsWhenJvmtiVersionDiffers.java Wed Jul 15 13:21:25 2015 +0200
@@ -0,0 +1,57 @@
+/*
+ * 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");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/demo/jvmti/waiters/WaitersTest.java Wed Jul 15 13:21:25 2015 +0200
@@ -0,0 +1,52 @@
+/*
+ * 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");
+ }
+}