From 72f951e112562a5dcc0c06fd745e93e9d48a80b6 Mon Sep 17 00:00:00 2001 From: Alex Henrie Date: Tue, 17 Nov 2015 23:10:30 -0700 Subject: [PATCH 1/8] 8145278: Fix memory leak in splitPathList Reviewed-by: sspitsyn, dsamersoff, dcubed --- .../share/native/libinstrument/InvocationAdapter.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/jdk/src/java.instrument/share/native/libinstrument/InvocationAdapter.c b/jdk/src/java.instrument/share/native/libinstrument/InvocationAdapter.c index 0c57f8b289d..a74b2b725ba 100644 --- a/jdk/src/java.instrument/share/native/libinstrument/InvocationAdapter.c +++ b/jdk/src/java.instrument/share/native/libinstrument/InvocationAdapter.c @@ -518,18 +518,22 @@ static void splitPathList(const char* str, int* pathCount, char*** paths) { int count = 0; char** segments = NULL; + char** new_segments; char* c = (char*) str; while (*c != '\0') { while (*c == ' ') c++; /* skip leading spaces */ if (*c == '\0') { break; } - if (segments == NULL) { - segments = (char**)malloc( sizeof(char**) ); - } else { - segments = (char**)realloc( segments, (count+1)*sizeof(char**) ); + new_segments = (char**)realloc(segments, (count+1)*sizeof(char*)); + if (new_segments == NULL) { + jplis_assert(0); + free(segments); + count = 0; + segments = NULL; + break; } - jplis_assert(segments != (char**)NULL); + segments = new_segments; segments[count++] = c; c = strchr(c, ' '); if (c == NULL) { From 34abb0688722c725998916cf5b61d7660c24e0c4 Mon Sep 17 00:00:00 2001 From: Gil Tene Date: Wed, 30 Mar 2016 17:04:09 +0200 Subject: [PATCH 2/8] 8147844: new method j.l.Thread.onSpinWait() and the corresponding x86 hotspot instrinsic See JEP-285 for details Co-authored-by: Ivan Krylov Reviewed-by: psandoz, alanb, dholmes --- .../share/classes/java/lang/Thread.java | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/jdk/src/java.base/share/classes/java/lang/Thread.java b/jdk/src/java.base/share/classes/java/lang/Thread.java index eb47a05427d..972815e16c7 100644 --- a/jdk/src/java.base/share/classes/java/lang/Thread.java +++ b/jdk/src/java.base/share/classes/java/lang/Thread.java @@ -340,6 +340,45 @@ class Thread implements Runnable { sleep(millis); } + /** + * Indicates that the caller is momentarily unable to progress, until the + * occurrence of one or more actions on the part of other activities. By + * invoking this method within each iteration of a spin-wait loop construct, + * the calling thread indicates to the runtime that it is busy-waiting. + * The runtime may take action to improve the performance of invoking + * spin-wait loop constructions. + *

+ * @apiNote + * As an example consider a method in a class that spins in a loop until + * some flag is set outside of that method. A call to the {@code onSpinWait} + * method should be placed inside the spin loop. + *

{@code
+     *     class EventHandler {
+     *         volatile boolean eventNotificationNotReceived;
+     *         void waitForEventAndHandleIt() {
+     *             while ( eventNotificationNotReceived ) {
+     *                 java.lang.Thread.onSpinWait();
+     *             }
+     *             readAndProcessEvent();
+     *         }
+     *
+     *         void readAndProcessEvent() {
+     *             // Read event from some source and process it
+     *              . . .
+     *         }
+     *     }
+     * }
+ *

+ * The code above would remain correct even if the {@code onSpinWait} + * method was not called at all. However on some architectures the Java + * Virtual Machine may issue the processor instructions to address such + * code patterns in a more beneficial way. + *

+ * @since 9 + */ + @HotSpotIntrinsicCandidate + public static void onSpinWait() {} + /** * Initializes a Thread with the current AccessControlContext. * @see #init(ThreadGroup,Runnable,String,long,AccessControlContext,boolean) From fd6507d3538a451cdeb8b31ea2ea8633d66c466e Mon Sep 17 00:00:00 2001 From: Stefan Karlsson Date: Wed, 20 Apr 2016 09:57:01 +0200 Subject: [PATCH 3/8] 8072921: -Xincgc should be removed from output Reviewed-by: alanb --- .../share/classes/sun/launcher/resources/launcher.properties | 1 - 1 file changed, 1 deletion(-) diff --git a/jdk/src/java.base/share/classes/sun/launcher/resources/launcher.properties b/jdk/src/java.base/share/classes/sun/launcher/resources/launcher.properties index 52d621b414d..f678ba37057 100644 --- a/jdk/src/java.base/share/classes/sun/launcher/resources/launcher.properties +++ b/jdk/src/java.base/share/classes/sun/launcher/resources/launcher.properties @@ -99,7 +99,6 @@ java.launcher.X.usage=\ \ -Xdiag show additional diagnostic messages\n\ \ -Xdiag:resolver show resolver diagnostic messages\n\ \ -Xnoclassgc disable class garbage collection\n\ -\ -Xincgc enable incremental garbage collection\n\ \ -Xloggc: log GC status to a file with time stamps\n\ \ -Xbatch disable background compilation\n\ \ -Xms set initial Java heap size\n\ From 3f6fc8998db487dbf80789d6ae78b07d3aed2933 Mon Sep 17 00:00:00 2001 From: Dmitry Samersoff Date: Wed, 20 Apr 2016 18:01:02 +0300 Subject: [PATCH 4/8] 8152847: JDI use of sun.boot.class.path needs to be updated for Jigsaw Remove references to bootclasspath Reviewed-by: alanb, sspitsyn --- .../share/classes/com/sun/tools/example/debug/tty/Commands.java | 1 - .../classes/com/sun/tools/example/debug/tty/TTYResources.java | 1 - .../com/sun/tools/example/debug/tty/TTYResources_ja.java | 1 - .../com/sun/tools/example/debug/tty/TTYResources_zh_CN.java | 1 - .../share/classes/com/sun/tools/jdi/VirtualMachineImpl.java | 2 +- 5 files changed, 1 insertion(+), 5 deletions(-) diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/Commands.java b/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/Commands.java index 61823822d0e..11a376e0f22 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/Commands.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/Commands.java @@ -1534,7 +1534,6 @@ class Commands { PathSearchingVirtualMachine vm = (PathSearchingVirtualMachine)Env.vm(); MessageOutput.println("base directory:", vm.baseDirectory()); MessageOutput.println("classpath:", vm.classPath().toString()); - MessageOutput.println("bootclasspath:", vm.bootClassPath().toString()); } else { MessageOutput.println("The VM does not use paths"); } diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTYResources.java b/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTYResources.java index c412743c4b6..39e703d88b8 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTYResources.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTYResources.java @@ -74,7 +74,6 @@ public class TTYResources extends java.util.ListResourceBundle { {"Array element is not a method", "Array element is not a method"}, {"Array index must be a integer type", "Array index must be a integer type"}, {"base directory:", "base directory: {0}"}, - {"bootclasspath:", "bootclasspath: {0}"}, {"Breakpoint hit:", "Breakpoint hit: "}, {"breakpoint", "breakpoint {0}"}, {"Breakpoints set:", "Breakpoints set:"}, diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTYResources_ja.java b/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTYResources_ja.java index 1cb6d231d50..b3562226398 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTYResources_ja.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTYResources_ja.java @@ -74,7 +74,6 @@ public class TTYResources_ja extends java.util.ListResourceBundle { {"Array element is not a method", "\u914D\u5217\u8981\u7D20\u306F\u30E1\u30BD\u30C3\u30C9\u3067\u306F\u3042\u308A\u307E\u305B\u3093"}, {"Array index must be a integer type", "\u914D\u5217\u306E\u6DFB\u3048\u5B57\u306F\u6574\u6570\u578B\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059"}, {"base directory:", "\u30D9\u30FC\u30B9\u30FB\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA: {0}"}, - {"bootclasspath:", "\u30D6\u30FC\u30C8\u30FB\u30AF\u30E9\u30B9\u30D1\u30B9: {0}"}, {"Breakpoint hit:", "\u30D2\u30C3\u30C8\u3057\u305F\u30D6\u30EC\u30FC\u30AF\u30DD\u30A4\u30F3\u30C8: "}, {"breakpoint", "\u30D6\u30EC\u30FC\u30AF\u30DD\u30A4\u30F3\u30C8{0}"}, {"Breakpoints set:", "\u8A2D\u5B9A\u3055\u308C\u3066\u3044\u308B\u30D6\u30EC\u30FC\u30AF\u30DD\u30A4\u30F3\u30C8:"}, diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTYResources_zh_CN.java b/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTYResources_zh_CN.java index 50790cb9d72..79dc9268da0 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTYResources_zh_CN.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTYResources_zh_CN.java @@ -74,7 +74,6 @@ public class TTYResources_zh_CN extends java.util.ListResourceBundle { {"Array element is not a method", "\u6570\u7EC4\u5143\u7D20\u4E0D\u662F\u65B9\u6CD5"}, {"Array index must be a integer type", "\u6570\u7EC4\u7D22\u5F15\u5FC5\u987B\u4E3A\u6574\u6570\u7C7B\u578B"}, {"base directory:", "\u57FA\u76EE\u5F55: {0}"}, - {"bootclasspath:", "\u5F15\u5BFC\u7C7B\u8DEF\u5F84: {0}"}, {"Breakpoint hit:", "\u65AD\u70B9\u547D\u4E2D: "}, {"breakpoint", "\u65AD\u70B9{0}"}, {"Breakpoints set:", "\u65AD\u70B9\u96C6:"}, diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/tools/jdi/VirtualMachineImpl.java b/jdk/src/jdk.jdi/share/classes/com/sun/tools/jdi/VirtualMachineImpl.java index 47e743483e3..28c3dfbfa3c 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/tools/jdi/VirtualMachineImpl.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/tools/jdi/VirtualMachineImpl.java @@ -1439,7 +1439,7 @@ class VirtualMachineImpl extends MirrorImpl } public List bootClassPath() { - return Arrays.asList(getClasspath().bootclasspaths); + return Collections.emptyList(); } public String baseDirectory() { From ebbecb1b63493e47e7ad3a4d49698564ae1ac99a Mon Sep 17 00:00:00 2001 From: Dmitry Samersoff Date: Thu, 21 Apr 2016 13:18:46 +0300 Subject: [PATCH 5/8] 8143921: nsk/jdi/ObjectReference/waitingThreads/waitingthreads003 fails with JVMTI_ERROR_INVALID_CLASS Skip invalid classes Reviewed-by: sspitsyn --- .../share/native/libjdwp/VirtualMachineImpl.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/jdk/src/jdk.jdwp.agent/share/native/libjdwp/VirtualMachineImpl.c b/jdk/src/jdk.jdwp.agent/share/native/libjdwp/VirtualMachineImpl.c index 2718ad1e3a4..8e1639c5e2e 100644 --- a/jdk/src/jdk.jdwp.agent/share/native/libjdwp/VirtualMachineImpl.c +++ b/jdk/src/jdk.jdwp.agent/share/native/libjdwp/VirtualMachineImpl.c @@ -126,7 +126,7 @@ classesForSignature(PacketInputStream *in, PacketOutputStream *out) int writtenCount = 0; int i; - for (i=0; i Date: Thu, 28 Apr 2016 00:38:21 -0700 Subject: [PATCH 6/8] 8153749: New capability can_generate_early_class_hook_events Add new capability Reviewed-by: alanb, dsamersoff --- jdk/src/java.base/share/native/include/jvmti.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jdk/src/java.base/share/native/include/jvmti.h b/jdk/src/java.base/share/native/include/jvmti.h index 684fd2d7046..5f8835c0baa 100644 --- a/jdk/src/java.base/share/native/include/jvmti.h +++ b/jdk/src/java.base/share/native/include/jvmti.h @@ -704,7 +704,8 @@ typedef struct { unsigned int can_generate_resource_exhaustion_heap_events : 1; unsigned int can_generate_resource_exhaustion_threads_events : 1; unsigned int can_generate_early_vmstart : 1; - unsigned int : 6; + unsigned int can_generate_early_class_hook_events : 1; + unsigned int : 5; unsigned int : 16; unsigned int : 16; unsigned int : 16; From 528b2cc81a583705fd00075aa465256cd306be09 Mon Sep 17 00:00:00 2001 From: Harold Seigel Date: Fri, 29 Apr 2016 15:17:46 -0400 Subject: [PATCH 7/8] 8155727: java/util/concurrent/locks/Lock/TimedAcquireLeak.java timeouts Fix regex pattern to handle possible (module@version) text Reviewed-by: ctornqvi, martin --- .../java/util/concurrent/locks/Lock/TimedAcquireLeak.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jdk/test/java/util/concurrent/locks/Lock/TimedAcquireLeak.java b/jdk/test/java/util/concurrent/locks/Lock/TimedAcquireLeak.java index 7d6da0b255e..630f3796b8c 100644 --- a/jdk/test/java/util/concurrent/locks/Lock/TimedAcquireLeak.java +++ b/jdk/test/java/util/concurrent/locks/Lock/TimedAcquireLeak.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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 @@ -167,7 +167,7 @@ public class TimedAcquireLeak { final String childPid, final String className) { final String regex = - "(?m)^ *[0-9]+: +([0-9]+) +[0-9]+ +\\Q"+className+"\\E$"; + "(?m)^ *[0-9]+: +([0-9]+) +[0-9]+ +\\Q"+className+"\\E(?:$| )"; final Callable objectsInUse = new Callable() { public Integer call() { Integer i = Integer.parseInt( From 3dfed24a479db9972f0ba9324ca27a9586fe2a45 Mon Sep 17 00:00:00 2001 From: Max Ockner Date: Fri, 29 Apr 2016 22:39:44 -0400 Subject: [PATCH 8/8] 8154110: Update class* and safepoint* logging subsystems Refactored logging tags in class and safepoint subsystems. Reviewed-by: coleenp, rehn, hseigel --- jdk/test/java/lang/ClassLoader/deadlock/TestCrossDelegate.sh | 2 +- jdk/test/java/lang/ClassLoader/deadlock/TestOneWayDelegate.sh | 2 +- .../instrument/appendToClassLoaderSearch/ClassUnloadTest.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/jdk/test/java/lang/ClassLoader/deadlock/TestCrossDelegate.sh b/jdk/test/java/lang/ClassLoader/deadlock/TestCrossDelegate.sh index 3872f813ffd..a00c14077d6 100644 --- a/jdk/test/java/lang/ClassLoader/deadlock/TestCrossDelegate.sh +++ b/jdk/test/java/lang/ClassLoader/deadlock/TestCrossDelegate.sh @@ -106,7 +106,7 @@ done # run test ${TESTJAVA}${FS}bin${FS}java \ ${TESTVMOPTS} \ - -verbose:class -Xlog:classload -cp . \ + -verbose:class -Xlog:class+load -cp . \ -Dtest.classes=${TESTCLASSES} \ Starter cross # -XX:+UnlockDiagnosticVMOptions -XX:+UnsyncloadClass \ diff --git a/jdk/test/java/lang/ClassLoader/deadlock/TestOneWayDelegate.sh b/jdk/test/java/lang/ClassLoader/deadlock/TestOneWayDelegate.sh index 198cd70827a..1289b4c861e 100644 --- a/jdk/test/java/lang/ClassLoader/deadlock/TestOneWayDelegate.sh +++ b/jdk/test/java/lang/ClassLoader/deadlock/TestOneWayDelegate.sh @@ -102,7 +102,7 @@ done # run test ${TESTJAVA}${FS}bin${FS}java \ ${TESTVMOPTS} \ - -verbose:class -Xlog:classload -cp . \ + -verbose:class -Xlog:class+load -cp . \ -Dtest.classes=${TESTCLASSES} \ Starter one-way # -XX:+UnlockDiagnosticVMOptions -XX:+UnsyncloadClass \ diff --git a/jdk/test/java/lang/instrument/appendToClassLoaderSearch/ClassUnloadTest.sh b/jdk/test/java/lang/instrument/appendToClassLoaderSearch/ClassUnloadTest.sh index f5bb3b83179..b428a59bb28 100644 --- a/jdk/test/java/lang/instrument/appendToClassLoaderSearch/ClassUnloadTest.sh +++ b/jdk/test/java/lang/instrument/appendToClassLoaderSearch/ClassUnloadTest.sh @@ -80,5 +80,5 @@ $JAR ${TESTTOOLVMOPTS} -cfm "${TESTCLASSES}"/ClassUnloadTest.jar "${MANIFEST}" \ # Finally we run the test (cd "${TESTCLASSES}"; \ - $JAVA ${TESTVMOPTS} -Xverify:none -Xlog:classunload \ + $JAVA ${TESTVMOPTS} -Xverify:none -Xlog:class+unload \ -javaagent:ClassUnloadTest.jar ClassUnloadTest "${OTHERDIR}" Bar.jar)