From 083d9a2b6145a422bad64423675660c94bb32958 Mon Sep 17 00:00:00 2001 From: Paul Sandoz Date: Thu, 15 Jan 2015 11:18:14 +0100 Subject: [PATCH 1/3] 8054494: Remove sun.misc.Unsafe.monitorEnter, monitorExit and tryMonitorEnter Co-authored-by: Peter Levart Reviewed-by: dholmes, coleenp --- .../share/classes/sun/misc/Unsafe.java | 18 +--------- jdk/test/java/lang/ProcessBuilder/Basic.java | 33 ++++++++++++++----- 2 files changed, 25 insertions(+), 26 deletions(-) diff --git a/jdk/src/java.base/share/classes/sun/misc/Unsafe.java b/jdk/src/java.base/share/classes/sun/misc/Unsafe.java index 08d04fde377..46080c3bd22 100644 --- a/jdk/src/java.base/share/classes/sun/misc/Unsafe.java +++ b/jdk/src/java.base/share/classes/sun/misc/Unsafe.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -845,22 +845,6 @@ public final class Unsafe { public native Object allocateInstance(Class cls) throws InstantiationException; - /** Lock the object. It must get unlocked via {@link #monitorExit}. */ - public native void monitorEnter(Object o); - - /** - * Unlock the object. It must have been locked via {@link - * #monitorEnter}. - */ - public native void monitorExit(Object o); - - /** - * Tries to lock the object. Returns true or false to indicate - * whether the lock succeeded. If it did, the object must be - * unlocked via {@link #monitorExit}. - */ - public native boolean tryMonitorEnter(Object o); - /** Throw the exception without telling the verifier. */ public native void throwException(Throwable ee); diff --git a/jdk/test/java/lang/ProcessBuilder/Basic.java b/jdk/test/java/lang/ProcessBuilder/Basic.java index b81853bd9ee..5f9f14de933 100644 --- a/jdk/test/java/lang/ProcessBuilder/Basic.java +++ b/jdk/test/java/lang/ProcessBuilder/Basic.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -26,7 +26,7 @@ * @bug 4199068 4738465 4937983 4930681 4926230 4931433 4932663 4986689 * 5026830 5023243 5070673 4052517 4811767 6192449 6397034 6413313 * 6464154 6523983 6206031 4960438 6631352 6631966 6850957 6850958 - * 4947220 7018606 7034570 4244896 5049299 8003488 + * 4947220 7018606 7034570 4244896 5049299 8003488 8054494 * @summary Basic tests for Process and Environment Variable code * @run main/othervm/timeout=300 Basic * @run main/othervm/timeout=300 -Djdk.lang.Process.launchMechanism=fork Basic @@ -2059,13 +2059,11 @@ public class Basic { Thread.yield(); } } else if (s instanceof BufferedInputStream) { - Field f = Unsafe.class.getDeclaredField("theUnsafe"); - f.setAccessible(true); - Unsafe unsafe = (Unsafe)f.get(null); - - while (unsafe.tryMonitorEnter(s)) { - unsafe.monitorExit(s); - Thread.sleep(1); + // Wait until after the s.read occurs in "thread" by + // checking when the input stream monitor is acquired + // (BufferedInputStream.read is synchronized) + while (!isLocked(s, 10)) { + Thread.sleep(100); } } p.destroy(); @@ -2565,4 +2563,21 @@ public class Basic { catch (Throwable t) { if (k.isAssignableFrom(t.getClass())) pass(); else unexpected(t);}} + + static boolean isLocked(final Object monitor, final long millis) throws InterruptedException { + return new Thread() { + volatile boolean unlocked; + + @Override + public void run() { + synchronized (monitor) { unlocked = true; } + } + + boolean isLocked() throws InterruptedException { + start(); + join(millis); + return !unlocked; + } + }.isLocked(); + } } From 580e7ed3ed09ccb40a5c844239f42745d5f1ece4 Mon Sep 17 00:00:00 2001 From: Pavel Chistyakov Date: Fri, 16 Jan 2015 15:09:01 +0300 Subject: [PATCH 2/3] 8068234: java/lang/instrument/NativeMethodPrefixAgent.java is still in exclude list Reviewed-by: kvn, iignatyev --- jdk/test/ProblemList.txt | 3 --- 1 file changed, 3 deletions(-) diff --git a/jdk/test/ProblemList.txt b/jdk/test/ProblemList.txt index c6c35f2e4d6..8b88b86b585 100644 --- a/jdk/test/ProblemList.txt +++ b/jdk/test/ProblemList.txt @@ -128,9 +128,6 @@ java/lang/ClassLoader/deadlock/GetResource.java generic-all # jdk_instrument -# 8058536 -java/lang/instrument/NativeMethodPrefixAgent.java generic-all - # 8061177 java/lang/instrument/RedefineBigClass.sh generic-all java/lang/instrument/RetransformBigClass.sh generic-all From c15946fb1aef0a95be9db8d4ecbf2cd553d56c71 Mon Sep 17 00:00:00 2001 From: Michail Chernov Date: Tue, 20 Jan 2015 13:29:26 -0800 Subject: [PATCH 3/3] 8067751: OOMEInReferenceHandler.java fails: Cleaner terminated abnormally OOME with message "GC overhead limit exceeded". -XX:-UseGCOverheadLimit was added to avoid OOME in resource handler. Reviewed-by: jmasa, jwilhelm --- jdk/test/java/lang/ref/OOMEInReferenceHandler.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jdk/test/java/lang/ref/OOMEInReferenceHandler.java b/jdk/test/java/lang/ref/OOMEInReferenceHandler.java index 39848fa4aab..cd09b070aa8 100644 --- a/jdk/test/java/lang/ref/OOMEInReferenceHandler.java +++ b/jdk/test/java/lang/ref/OOMEInReferenceHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -25,7 +25,7 @@ * @test * @bug 7038914 8016341 * @summary Verify that the reference handler does not die after an OOME allocating the InterruptedException object - * @run main/othervm -Xmx24M -XX:-UseTLAB OOMEInReferenceHandler + * @run main/othervm -XX:-UseGCOverheadLimit -Xmx24M -XX:-UseTLAB OOMEInReferenceHandler * @author peter.levart@gmail.com */