From 545e81413e51d3f02259210cd45cea3930682b6c Mon Sep 17 00:00:00 2001 From: Igor Ignatyev Date: Thu, 13 Jun 2019 13:42:41 -0700 Subject: [PATCH 01/15] 8225746: hotspot problem lists list unexciting tests Reviewed-by: kvn --- test/hotspot/jtreg/ProblemList-graal.txt | 3 +-- test/hotspot/jtreg/ProblemList.txt | 3 --- test/jdk/ProblemList-graal.txt | 1 - 3 files changed, 1 insertion(+), 6 deletions(-) diff --git a/test/hotspot/jtreg/ProblemList-graal.txt b/test/hotspot/jtreg/ProblemList-graal.txt index 95775764fa3..d564f75a578 100644 --- a/test/hotspot/jtreg/ProblemList-graal.txt +++ b/test/hotspot/jtreg/ProblemList-graal.txt @@ -62,7 +62,7 @@ gc/g1/TestConcurrentSystemGC.java 8196611 generi gc/g1/TestPeriodicCollection.java 8196611 generic-all gc/g1/TestFromCardCacheIndex.java 8196611 generic-all gc/parallel/TestPrintGCDetailsVerbose.java 8196611 generic-all -vm/gc/InfiniteList.java 8196611 generic-all +gc/InfiniteList.java 8196611 generic-all vmTestbase/gc/lock/jni/jnilock001/TestDescription.java 8196611 generic-all vmTestbase/gc/lock/jniref/jnireflock04/TestDescription.java 8196611 generic-all @@ -176,7 +176,6 @@ vmTestbase/nsk/jdi/BScenarios/hotswap/tc06x001/TestDescription.java vmTestbase/nsk/jdi/BScenarios/hotswap/tc08x001/TestDescription.java 8195635 generic-all vmTestbase/nsk/jdi/BScenarios/hotswap/tc10x002/TestDescription.java 8195635 generic-all vmTestbase/nsk/jdi/MethodExitEvent/returnValue/returnValue003/returnValue003.java 8195635 generic-all -vmTestbase/nsk/jdi/Scenarios/invokeMethod/popframes001/TestDescription.jav 8195635 generic-all vmTestbase/nsk/jdi/Scenarios/invokeMethod/popframes001/TestDescription.java 8195635 generic-all vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes001/TestDescription.java 8195635 generic-all vmTestbase/nsk/jdi/VirtualMachine/redefineClasses/redefineclasses002/TestDescription.java 8195635 generic-all diff --git a/test/hotspot/jtreg/ProblemList.txt b/test/hotspot/jtreg/ProblemList.txt index 09bda8e1f82..136f6de6a5e 100644 --- a/test/hotspot/jtreg/ProblemList.txt +++ b/test/hotspot/jtreg/ProblemList.txt @@ -80,7 +80,6 @@ gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java 8193639 solaris-all # :hotspot_runtime -runtime/SharedArchiveFile/SASymbolTableTest.java 8193639 solaris-all runtime/jni/terminatedThread/TestTerminatedThread.java 8219652 aix-ppc64 ############################################################################# @@ -107,8 +106,6 @@ serviceability/sa/ClhsdbPstack.java 8193639,8211767 solaris-all,linux-ppc64le,li serviceability/sa/ClhsdbRegionDetailsScanOopsForG1.java 8193639 solaris-all serviceability/sa/ClhsdbScanOops.java 8193639,8211767 solaris-all,linux-ppc64le,linux-ppc64 serviceability/sa/ClhsdbSource.java 8193639,8211767 solaris-all,linux-ppc64le,linux-ppc64 -serviceability/sa/ClhsdbSymbol.java 8193639 solaris-all -serviceability/sa/ClhsdbSymbolTable.java 8193639 solaris-all serviceability/sa/ClhsdbThread.java 8193639,8211767 solaris-all,linux-ppc64le,linux-ppc64 serviceability/sa/ClhsdbVmStructsDump.java 8193639 solaris-all serviceability/sa/ClhsdbWhere.java 8193639,8211767 solaris-all,linux-ppc64le,linux-ppc64 diff --git a/test/jdk/ProblemList-graal.txt b/test/jdk/ProblemList-graal.txt index 87ab7ebcb31..f9b82c786aa 100644 --- a/test/jdk/ProblemList-graal.txt +++ b/test/jdk/ProblemList-graal.txt @@ -76,7 +76,6 @@ java/lang/ref/OOMEInReferenceHandler.java 8196611 java/lang/ref/SoftReference/Pin.java 8196611 generic-all java/lang/Runtime/exec/LotsOfOutput.java 8196611 generic-all java/util/concurrent/ScheduledThreadPoolExecutor/BasicCancelTest.java 8196611 generic-all -vm/gc/InfiniteList.java 8196611 generic-all # tests require pop_frame and force_early_return capabilities com/sun/jdi/RedefineTTYLineNumber.java 8195635 generic-all From b2893466aa8a773ffb8d53d36b50ead030347235 Mon Sep 17 00:00:00 2001 From: Sean Mullan Date: Thu, 13 Jun 2019 17:49:49 -0400 Subject: [PATCH 02/15] 8225730: Add sun/security/pkcs11/tls/tls12/FipsModeTLS12.java to ProblemList for linux Reviewed-by: xuelei --- test/jdk/ProblemList.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index 98e7f3ab307..937c133368c 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -656,7 +656,7 @@ com/sun/nio/sctp/SctpChannel/SocketOptionTests.java 8141694 linux-al sun/security/pkcs11/ec/TestKeyFactory.java 8026976 generic-all sun/security/pkcs11/Secmod/AddTrustedCert.java 8180837 generic-all sun/security/pkcs11/tls/TestKeyMaterial.java 8180837 generic-all -sun/security/pkcs11/tls/tls12/FipsModeTLS12.java 8224954 windows-all +sun/security/pkcs11/tls/tls12/FipsModeTLS12.java 8224954,8225678 windows-all,linux-all sun/security/pkcs11/sslecc/ClientJSSEServerJSSE.java 8161536 generic-all sun/security/tools/keytool/ListKeychainStore.sh 8156889 macosx-all From 2527f768bc4ba19142f1f8df501c15d8ae9a6f0f Mon Sep 17 00:00:00 2001 From: Vladimir Kozlov Date: Thu, 13 Jun 2019 17:18:06 -0700 Subject: [PATCH 03/15] 8209590: compiler/compilercontrol/DontInlineCommandTest.java test fails with "Inline message differs" error Increase InlineSmallCode to 4000 for tests which check inlining decisions. Reviewed-by: iignatyev --- .../compiler/compilercontrol/share/scenario/Command.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/hotspot/jtreg/compiler/compilercontrol/share/scenario/Command.java b/test/hotspot/jtreg/compiler/compilercontrol/share/scenario/Command.java index 49fdf74f406..b30afd6265e 100644 --- a/test/hotspot/jtreg/compiler/compilercontrol/share/scenario/Command.java +++ b/test/hotspot/jtreg/compiler/compilercontrol/share/scenario/Command.java @@ -33,8 +33,8 @@ import java.util.Arrays; public enum Command { COMPILEONLY("compileonly", ".*", "-Xbatch"), EXCLUDE("exclude", "", "-Xbatch"), - INLINE("inline", ".*", "-Xbatch"), - DONTINLINE("dontinline", "", "-Xbatch"), + INLINE("inline", ".*", "-Xbatch", "-XX:InlineSmallCode=4000"), + DONTINLINE("dontinline", "", "-Xbatch", "-XX:InlineSmallCode=4000"), LOG("log", "", "-XX:+UnlockDiagnosticVMOptions", "-XX:+LogCompilation", "-XX:LogFile=" + LogProcessor.LOG_FILE), PRINT("print", ""), From 97b0d4562228209b77a6eabbf52aff426843e6a0 Mon Sep 17 00:00:00 2001 From: Jesper Wilhelmsson Date: Fri, 14 Jun 2019 03:50:25 +0200 Subject: [PATCH 04/15] Added tag jdk-13+25 for changeset 22b3b7983ada --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index bdfaf6ad0f4..caabc0b90e0 100644 --- a/.hgtags +++ b/.hgtags @@ -562,3 +562,4 @@ f2f11d7f7f4e7128f8aba6ffa576cfa76fbf7d1a jdk-13+21 181986c5476468bc2dd4532af49599003ee8af37 jdk-13+22 b034d2dee5fc93d42a81b65e58ce3f91e42586ff jdk-13+23 7e2238451585029680f126ccbb46d01f2ff5607f jdk-13+24 +22b3b7983adab54e318f75aeb94471f7a4429c1e jdk-13+25 From 8125b0c2bafaced87521c8ab24942e9a2ab78891 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Fri, 14 Jun 2019 10:02:57 +0200 Subject: [PATCH 05/15] 8225695: 32-bit build failures after JDK-8080462 (Update SunPKCS11 provider with PKCS11 v2.40 support) Reviewed-by: alanb --- .../share/native/libj2pkcs11/p11_general.c | 5 +++-- .../share/native/libj2pkcs11/p11_sign.c | 16 ++++++++-------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/jdk.crypto.cryptoki/share/native/libj2pkcs11/p11_general.c b/src/jdk.crypto.cryptoki/share/native/libj2pkcs11/p11_general.c index ad4857d8d59..a6d3e089ebb 100644 --- a/src/jdk.crypto.cryptoki/share/native/libj2pkcs11/p11_general.c +++ b/src/jdk.crypto.cryptoki/share/native/libj2pkcs11/p11_general.c @@ -51,6 +51,7 @@ #include #include #include +#include "jlong.h" #include "sun_security_pkcs11_wrapper_PKCS11.h" @@ -96,8 +97,8 @@ JNIEXPORT jlong JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_freeMechanism (JNIEnv *env, jclass thisClass, jlong ckpMechanism) { if (ckpMechanism != 0L) { - freeCKMechanismPtr((CK_MECHANISM_PTR) ckpMechanism); - TRACE1("DEBUG PKCS11_freeMechanism: free pMech = %x\n", (jlong)ckpMechanism); + freeCKMechanismPtr(jlong_to_ptr(ckpMechanism)); + TRACE1("DEBUG PKCS11_freeMechanism: free pMech = %x\n", ckpMechanism); } return 0L; } diff --git a/src/jdk.crypto.cryptoki/share/native/libj2pkcs11/p11_sign.c b/src/jdk.crypto.cryptoki/share/native/libj2pkcs11/p11_sign.c index 83bf3936dc8..a2b852788e1 100644 --- a/src/jdk.crypto.cryptoki/share/native/libj2pkcs11/p11_sign.c +++ b/src/jdk.crypto.cryptoki/share/native/libj2pkcs11/p11_sign.c @@ -91,8 +91,8 @@ JNIEXPORT void JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1SignInit (ckpMechanism->pParameter == NULL)) { freeCKMechanismPtr(ckpMechanism); } else { - (*env)->SetLongField(env, jMechanism, mech_pHandleID, (jlong)ckpMechanism); - TRACE1("DEBUG C_SignInit: stored pMech = 0x%lX\n", (jlong)ckpMechanism); + (*env)->SetLongField(env, jMechanism, mech_pHandleID, ptr_to_jlong(ckpMechanism)); + TRACE1("DEBUG C_SignInit: stored pMech = 0x%lX\n", ptr_to_jlong(ckpMechanism)); } TRACE0("FINISHED\n"); } @@ -303,8 +303,8 @@ JNIEXPORT void JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1SignRecoverIni (ckpMechanism->pParameter == NULL)) { freeCKMechanismPtr(ckpMechanism); } else { - (*env)->SetLongField(env, jMechanism, mech_pHandleID, (jlong)ckpMechanism); - TRACE1("DEBUG C_SignRecoverInit, stored pMech = 0x%lX\n", (jlong)ckpMechanism); + (*env)->SetLongField(env, jMechanism, mech_pHandleID, ptr_to_jlong(ckpMechanism)); + TRACE1("DEBUG C_SignRecoverInit, stored pMech = 0x%lX\n", ptr_to_jlong(ckpMechanism)); } TRACE0("FINISHED\n"); } @@ -413,8 +413,8 @@ JNIEXPORT void JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1VerifyInit (ckpMechanism->pParameter == NULL)) { freeCKMechanismPtr(ckpMechanism); } else { - (*env)->SetLongField(env, jMechanism, mech_pHandleID, (jlong)ckpMechanism); - TRACE1("DEBUG C_VerifyInit: stored pMech = 0x%lX\n", (jlong)ckpMechanism); + (*env)->SetLongField(env, jMechanism, mech_pHandleID, ptr_to_jlong(ckpMechanism)); + TRACE1("DEBUG C_VerifyInit: stored pMech = 0x%lX\n", ptr_to_jlong(ckpMechanism)); } TRACE0("FINISHED\n"); } @@ -601,8 +601,8 @@ JNIEXPORT void JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1VerifyRecoverI (ckpMechanism->pParameter == NULL)) { freeCKMechanismPtr(ckpMechanism); } else { - (*env)->SetLongField(env, jMechanism, mech_pHandleID, (jlong)ckpMechanism); - TRACE1("DEBUG C_VerifyRecoverInit: stored pMech = 0x%lX\n", (jlong)ckpMechanism); + (*env)->SetLongField(env, jMechanism, mech_pHandleID, ptr_to_jlong(ckpMechanism)); + TRACE1("DEBUG C_VerifyRecoverInit: stored pMech = 0x%lX\n", ptr_to_jlong(ckpMechanism)); } TRACE0("FINISHED\n"); } From a4277e56c8e4cbf801d1e00daec79b37ad4fdb84 Mon Sep 17 00:00:00 2001 From: Xue-Lei Andrew Fan Date: Fri, 14 Jun 2019 12:19:14 -0700 Subject: [PATCH 06/15] 8224829: AsyncSSLSocketClose.java has timing issue Reviewed-by: jnimeh, dfuchs --- .../sun/security/ssl/SSLSocketImpl.java | 106 +++++++++++-- .../net/ssl/SSLSocket/Tls13PacketSize.java | 6 + .../ssl/SSLSocketImpl/BlockedAsyncClose.java | 147 ++++++++++++++++++ 3 files changed, 242 insertions(+), 17 deletions(-) create mode 100644 test/jdk/sun/security/ssl/SSLSocketImpl/BlockedAsyncClose.java diff --git a/src/java.base/share/classes/sun/security/ssl/SSLSocketImpl.java b/src/java.base/share/classes/sun/security/ssl/SSLSocketImpl.java index bcb9b1b5876..d65b754b105 100644 --- a/src/java.base/share/classes/sun/security/ssl/SSLSocketImpl.java +++ b/src/java.base/share/classes/sun/security/ssl/SSLSocketImpl.java @@ -38,6 +38,7 @@ import java.net.SocketException; import java.net.UnknownHostException; import java.nio.ByteBuffer; import java.util.List; +import java.util.concurrent.TimeUnit; import java.util.concurrent.locks.ReentrantLock; import java.util.function.BiFunction; import javax.net.ssl.HandshakeCompletedListener; @@ -618,27 +619,76 @@ public final class SSLSocketImpl // Need a lock here so that the user_canceled alert and the // close_notify alert can be delivered together. - conContext.outputRecord.recordLock.lock(); - try { + int linger = getSoLinger(); + if (linger >= 0) { + // don't wait more than SO_LINGER for obtaining the + // the lock. + // + // keep and clear the current thread interruption status. + boolean interrupted = Thread.interrupted(); try { - // send a user_canceled alert if needed. - if (useUserCanceled) { - conContext.warning(Alert.USER_CANCELED); - } + if (conContext.outputRecord.recordLock.tryLock() || + conContext.outputRecord.recordLock.tryLock( + linger, TimeUnit.SECONDS)) { + try { + handleClosedNotifyAlert(useUserCanceled); + } finally { + conContext.outputRecord.recordLock.unlock(); + } + } else { + // For layered, non-autoclose sockets, we are not + // able to bring them into a usable state, so we + // treat it as fatal error. + if (!super.isOutputShutdown()) { + if (isLayered() && !autoClose) { + throw new SSLException( + "SO_LINGER timeout, " + + "close_notify message cannot be sent."); + } else { + super.shutdownOutput(); + if (SSLLogger.isOn && SSLLogger.isOn("ssl")) { + SSLLogger.warning( + "SSLSocket output duplex close failed: " + + "SO_LINGER timeout, " + + "close_notify message cannot be sent."); + } + } + } - // send a close_notify alert - conContext.warning(Alert.CLOSE_NOTIFY); - } finally { - if (!conContext.isOutboundClosed()) { - conContext.outputRecord.close(); - } - - if ((autoClose || !isLayered()) && !super.isOutputShutdown()) { - super.shutdownOutput(); + // RFC2246 requires that the session becomes + // unresumable if any connection is terminated + // without proper close_notify messages with + // level equal to warning. + // + // RFC4346 no longer requires that a session not be + // resumed if failure to properly close a connection. + // + // We choose to make the session unresumable if + // failed to send the close_notify message. + // + conContext.conSession.invalidate(); + if (SSLLogger.isOn && SSLLogger.isOn("ssl")) { + SSLLogger.warning( + "Invalidate the session: SO_LINGER timeout, " + + "close_notify message cannot be sent."); + } } + } catch (InterruptedException ex) { + // keep interrupted status + interrupted = true; + } + + // restore the interrupted status + if (interrupted) { + Thread.currentThread().interrupt(); + } + } else { + conContext.outputRecord.recordLock.lock(); + try { + handleClosedNotifyAlert(useUserCanceled); + } finally { + conContext.outputRecord.recordLock.unlock(); } - } finally { - conContext.outputRecord.recordLock.unlock(); } if (!isInputShutdown()) { @@ -646,6 +696,28 @@ public final class SSLSocketImpl } } + private void handleClosedNotifyAlert( + boolean useUserCanceled) throws IOException { + try { + // send a user_canceled alert if needed. + if (useUserCanceled) { + conContext.warning(Alert.USER_CANCELED); + } + + // send a close_notify alert + conContext.warning(Alert.CLOSE_NOTIFY); + } finally { + if (!conContext.isOutboundClosed()) { + conContext.outputRecord.close(); + } + + if (!super.isOutputShutdown() && + (autoClose || !isLayered())) { + super.shutdownOutput(); + } + } + } + /** * Duplex close, start from closing inbound. * diff --git a/test/jdk/javax/net/ssl/SSLSocket/Tls13PacketSize.java b/test/jdk/javax/net/ssl/SSLSocket/Tls13PacketSize.java index 1d6317f4bc6..b8e2410643b 100644 --- a/test/jdk/javax/net/ssl/SSLSocket/Tls13PacketSize.java +++ b/test/jdk/javax/net/ssl/SSLSocket/Tls13PacketSize.java @@ -53,6 +53,9 @@ public class Tls13PacketSize extends SSLSocketTemplate { @Override protected void runServerApplication(SSLSocket socket) throws Exception { + // Set SO_LINGER in case of slow socket + socket.setSoLinger(true, 10); + // here comes the test logic InputStream sslIS = socket.getInputStream(); OutputStream sslOS = socket.getOutputStream(); @@ -81,6 +84,9 @@ public class Tls13PacketSize extends SSLSocketTemplate { * @see #isCustomizedClientConnection() */ protected void runClientApplication(SSLSocket socket) throws Exception { + // Set SO_LINGER in case of slow socket + socket.setSoLinger(true, 10); + socket.setEnabledProtocols(new String[] {"TLSv1.3"}); InputStream sslIS = socket.getInputStream(); OutputStream sslOS = socket.getOutputStream(); diff --git a/test/jdk/sun/security/ssl/SSLSocketImpl/BlockedAsyncClose.java b/test/jdk/sun/security/ssl/SSLSocketImpl/BlockedAsyncClose.java new file mode 100644 index 00000000000..c350b5cfda8 --- /dev/null +++ b/test/jdk/sun/security/ssl/SSLSocketImpl/BlockedAsyncClose.java @@ -0,0 +1,147 @@ +/* + * Copyright (c) 2019, 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. + */ + +// +// SunJSSE does not support dynamic system properties, no way to re-use +// system properties in samevm/agentvm mode. +// + +/* + * @test + * @bug 8224829 + * @summary AsyncSSLSocketClose.java has timing issue + * @run main/othervm BlockedAsyncClose + */ + +import javax.net.ssl.*; +import java.io.*; +import java.net.SocketException; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + +public class BlockedAsyncClose implements Runnable { + SSLSocket socket; + SSLServerSocket ss; + + // Is the socket ready to close? + private final CountDownLatch closeCondition = new CountDownLatch(1); + + // Where do we find the keystores? + static String pathToStores = "../../../../javax/net/ssl/etc"; + static String keyStoreFile = "keystore"; + static String trustStoreFile = "truststore"; + static String passwd = "passphrase"; + + public static void main(String[] args) throws Exception { + String keyFilename = + System.getProperty("test.src", "./") + "/" + pathToStores + + "/" + keyStoreFile; + String trustFilename = + System.getProperty("test.src", "./") + "/" + pathToStores + + "/" + trustStoreFile; + + System.setProperty("javax.net.ssl.keyStore", keyFilename); + System.setProperty("javax.net.ssl.keyStorePassword", passwd); + System.setProperty("javax.net.ssl.trustStore", trustFilename); + System.setProperty("javax.net.ssl.trustStorePassword", passwd); + + new BlockedAsyncClose(); + } + + public BlockedAsyncClose() throws Exception { + SSLServerSocketFactory sslssf = + (SSLServerSocketFactory)SSLServerSocketFactory.getDefault(); + InetAddress loopback = InetAddress.getLoopbackAddress(); + ss = (SSLServerSocket)sslssf.createServerSocket(); + ss.bind(new InetSocketAddress(loopback, 0)); + + SSLSocketFactory sslsf = + (SSLSocketFactory)SSLSocketFactory.getDefault(); + socket = (SSLSocket)sslsf.createSocket(loopback, ss.getLocalPort()); + SSLSocket serverSoc = (SSLSocket)ss.accept(); + ss.close(); + + (new Thread(this)).start(); + serverSoc.startHandshake(); + + boolean closeIsReady = closeCondition.await(90L, TimeUnit.SECONDS); + if (!closeIsReady) { + System.out.println( + "Ignore, the closure is not ready yet in 90 seconds."); + return; + } + + socket.setSoLinger(true, 10); + System.out.println("Calling Socket.close"); + + // Sleep for a while so that the write thread blocks by hitting the + // output stream buffer limit. + Thread.sleep(1000); + + socket.close(); + System.out.println("ssl socket get closed"); + System.out.flush(); + } + + // block in write + public void run() { + byte[] ba = new byte[1024]; + for (int i = 0; i < ba.length; i++) { + ba[i] = 0x7A; + } + + try { + OutputStream os = socket.getOutputStream(); + int count = 0; + + // 1st round write + count += ba.length; + System.out.println(count + " bytes to be written"); + os.write(ba); + System.out.println(count + " bytes written"); + + // Signal, ready to close. + closeCondition.countDown(); + + // write more + while (true) { + count += ba.length; + System.out.println(count + " bytes to be written"); + os.write(ba); + System.out.println(count + " bytes written"); + } + } catch (SocketException se) { + // the closing may be in progress + System.out.println("interrupted? " + se); + } catch (Exception e) { + if (socket.isClosed() || socket.isOutputShutdown()) { + System.out.println("interrupted, the socket is closed"); + } else { + throw new RuntimeException("interrupted?", e); + } + } + } +} + From c12cf04011619c211a5619ca1f16e69226918acc Mon Sep 17 00:00:00 2001 From: Weijun Wang Date: Sat, 15 Jun 2019 14:39:04 +0800 Subject: [PATCH 07/15] 8225392: Comparison builds are failing due to cacerts file Reviewed-by: erikj, martin, mullan --- .../generatecacerts/GenerateCacerts.java | 121 +++++++++++++++--- .../sun/security/tools/keytool/Main.java | 6 +- .../security/lib/cacerts/VerifyCACerts.java | 21 ++- .../sun/security/tools/keytool/ListOrder.java | 64 +++++++++ 4 files changed, 189 insertions(+), 23 deletions(-) create mode 100644 test/jdk/sun/security/tools/keytool/ListOrder.java diff --git a/make/jdk/src/classes/build/tools/generatecacerts/GenerateCacerts.java b/make/jdk/src/classes/build/tools/generatecacerts/GenerateCacerts.java index 953e33d7f9c..aa769b47b78 100644 --- a/make/jdk/src/classes/build/tools/generatecacerts/GenerateCacerts.java +++ b/make/jdk/src/classes/build/tools/generatecacerts/GenerateCacerts.java @@ -25,12 +25,23 @@ package build.tools.generatecacerts; +import java.io.DataOutputStream; import java.io.FileOutputStream; +import java.io.IOException; import java.io.InputStream; +import java.io.OutputStream; +import java.io.UnsupportedEncodingException; import java.nio.file.Files; import java.nio.file.Path; -import java.security.KeyStore; +import java.security.DigestOutputStream; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.security.cert.CertificateException; import java.security.cert.CertificateFactory; +import java.security.cert.X509Certificate; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; /** * Generate cacerts @@ -39,23 +50,99 @@ import java.security.cert.CertificateFactory; */ public class GenerateCacerts { public static void main(String[] args) throws Exception { - KeyStore ks = KeyStore.getInstance("JKS"); - ks.load(null, null); - CertificateFactory cf = CertificateFactory.getInstance("X509"); - Files.list(Path.of(args[0])) - .filter(p -> !p.getFileName().toString().equals("README")) - .forEach(p -> { - try { - String alias = p.getFileName().toString() + " [jdk]"; - try (InputStream fis = Files.newInputStream(p)) { - ks.setCertificateEntry(alias, cf.generateCertificate(fis)); - } - } catch (Exception e) { - throw new RuntimeException(e); - } - }); try (FileOutputStream fos = new FileOutputStream(args[1])) { - ks.store(fos, "changeit".toCharArray()); + store(args[0], fos, "changeit".toCharArray()); } } + + // The following code are copied from JavaKeyStore.java. + + private static final int MAGIC = 0xfeedfeed; + private static final int VERSION_2 = 0x02; + + // This method is a simplified version of JavaKeyStore::engineStore. + // A new "dir" argument is added. All cert names in "dir" is collected into + // a sorted array. Each cert is stored with a creation date set to its + // notBefore value. Thus the output is determined as long as the certs + // are the same. + public static void store(String dir, OutputStream stream, char[] password) + throws IOException, NoSuchAlgorithmException, CertificateException + { + byte[] encoded; // the certificate encoding + CertificateFactory cf = CertificateFactory.getInstance("X509"); + + MessageDigest md = getPreKeyedHash(password); + DataOutputStream dos + = new DataOutputStream(new DigestOutputStream(stream, md)); + + dos.writeInt(MAGIC); + // always write the latest version + dos.writeInt(VERSION_2); + + // All file names in dir sorted. + // README is excluded. Name starting with "." excluded. + List entries = Files.list(Path.of(dir)) + .map(p -> p.getFileName().toString()) + .filter(s -> !s.equals("README") && !s.startsWith(".")) + .collect(Collectors.toList()); + + entries.sort(String::compareTo); + + dos.writeInt(entries.size()); + + for (String entry : entries) { + + String alias = entry + " [jdk]"; + X509Certificate cert; + try (InputStream fis = Files.newInputStream(Path.of(dir, entry))) { + cert = (X509Certificate) cf.generateCertificate(fis); + } + + dos.writeInt(2); + + // Write the alias + dos.writeUTF(alias); + + // Write the (entry creation) date, which is notBefore of the cert + dos.writeLong(cert.getNotBefore().getTime()); + + // Write the trusted certificate + encoded = cert.getEncoded(); + dos.writeUTF(cert.getType()); + dos.writeInt(encoded.length); + dos.write(encoded); + } + + /* + * Write the keyed hash which is used to detect tampering with + * the keystore (such as deleting or modifying key or + * certificate entries). + */ + byte[] digest = md.digest(); + + dos.write(digest); + dos.flush(); + } + + private static MessageDigest getPreKeyedHash(char[] password) + throws NoSuchAlgorithmException, UnsupportedEncodingException + { + + MessageDigest md = MessageDigest.getInstance("SHA"); + byte[] passwdBytes = convertToBytes(password); + md.update(passwdBytes); + Arrays.fill(passwdBytes, (byte) 0x00); + md.update("Mighty Aphrodite".getBytes("UTF8")); + return md; + } + + private static byte[] convertToBytes(char[] password) { + int i, j; + byte[] passwdBytes = new byte[password.length * 2]; + for (i=0, j=0; i> 8); + passwdBytes[j++] = (byte)password[i]; + } + return passwdBytes; + } } diff --git a/src/java.base/share/classes/sun/security/tools/keytool/Main.java b/src/java.base/share/classes/sun/security/tools/keytool/Main.java index b2325b99bf6..3416801ee5e 100644 --- a/src/java.base/share/classes/sun/security/tools/keytool/Main.java +++ b/src/java.base/share/classes/sun/security/tools/keytool/Main.java @@ -2418,9 +2418,9 @@ public final class Main { out.println(form.format(source)); out.println(); - for (Enumeration e = keyStore.aliases(); - e.hasMoreElements(); ) { - String alias = e.nextElement(); + List aliases = Collections.list(keyStore.aliases()); + aliases.sort(String::compareTo); + for (String alias : aliases) { doPrintEntry("<" + alias + ">", alias, out); if (verbose || rfc) { out.println(rb.getString("NEWLINE")); diff --git a/test/jdk/sun/security/lib/cacerts/VerifyCACerts.java b/test/jdk/sun/security/lib/cacerts/VerifyCACerts.java index 1cafc024465..8be056ebdee 100644 --- a/test/jdk/sun/security/lib/cacerts/VerifyCACerts.java +++ b/test/jdk/sun/security/lib/cacerts/VerifyCACerts.java @@ -26,11 +26,13 @@ * @test * @bug 8189131 8198240 8191844 8189949 8191031 8196141 8204923 8195774 8199779 * 8209452 8209506 8210432 8195793 8216577 8222089 8222133 8222137 8222136 - * 8223499 + * 8223499 8225392 * @summary Check root CA entries in cacerts file */ +import java.io.ByteArrayInputStream; import java.io.File; -import java.io.FileInputStream; +import java.nio.file.Files; +import java.nio.file.Path; import java.security.KeyStore; import java.security.MessageDigest; import java.security.cert.Certificate; @@ -52,6 +54,11 @@ public class VerifyCACerts { // The numbers of certs now. private static final int COUNT = 88; + // SHA-256 of cacerts, can be generated with + // shasum -a 256 cacerts | sed -e 's/../&:/g' | tr '[:lower:]' '[:upper:]' | cut -c1-95 + private static final String CHECKSUM + = "4E:21:94:7C:1D:49:28:BB:34:B0:40:DF:AE:19:B4:41:C6:B5:8A:EE:EB:D5:DE:B4:EF:07:AF:63:18:73:A6:FE"; + // map of cert alias to SHA-256 fingerprint @SuppressWarnings("serial") private static final Map FINGERPRINT_MAP = new HashMap<>() { @@ -255,8 +262,16 @@ public class VerifyCACerts { public static void main(String[] args) throws Exception { System.out.println("cacerts file: " + CACERTS); md = MessageDigest.getInstance("SHA-256"); + + byte[] data = Files.readAllBytes(Path.of(CACERTS)); + String checksum = toHexString(md.digest(data)); + if (!checksum.equals(CHECKSUM)) { + atLeastOneFailed = true; + System.err.println("ERROR: wrong checksum\n" + checksum); + } + KeyStore ks = KeyStore.getInstance("JKS"); - ks.load(new FileInputStream(CACERTS), "changeit".toCharArray()); + ks.load(new ByteArrayInputStream(data), "changeit".toCharArray()); // check the count of certs inside if (ks.size() != COUNT) { diff --git a/test/jdk/sun/security/tools/keytool/ListOrder.java b/test/jdk/sun/security/tools/keytool/ListOrder.java new file mode 100644 index 00000000000..13ba2dbe8cb --- /dev/null +++ b/test/jdk/sun/security/tools/keytool/ListOrder.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2019, 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 8225392 + * @summary Comparison builds are failing due to cacerts file + * @library /test/lib + */ + +import jdk.test.lib.SecurityTools; + +import java.util.Random; + +public class ListOrder { + + public static void main(String[] args) throws Throwable { + + Random rand = new Random(); + for (int i = 0; i < 10; i++) { + gen(String.format("a%02d", rand.nextInt(100))); + } + + String last = ""; + for (String line : SecurityTools.keytool( + "-keystore ks -storepass changeit -list").asLines()) { + if (line.contains("PrivateKeyEntry")) { + // This is the line starting with the alias + System.out.println(line); + if (line.compareTo(last) <= 0) { + throw new RuntimeException("Not ordered"); + } else { + last = line; + } + } + } + } + + static void gen(String a) throws Exception { + // Do not check result, there might be duplicated alias(es). + SecurityTools.keytool("-keystore ks -storepass changeit " + + "-keyalg ec -genkeypair -alias " + a + " -dname CN=" + a); + } +} From 356c9f1db8e41c3665b524fc6de2b18ca4ae429f Mon Sep 17 00:00:00 2001 From: Zhengyu Gu Date: Fri, 14 Jun 2019 12:08:55 -0400 Subject: [PATCH 08/15] 8225801: Shenandoah: Adjust SA to reflect recent forwarding pointer changes Reviewed-by: shade --- .../jvm/hotspot/gc/shenandoah/ShenandoahHeap.java | 7 ------- .../hotspot/gc/shenandoah/ShenandoahHeapRegion.java | 12 +++++------- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/shenandoah/ShenandoahHeap.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/shenandoah/ShenandoahHeap.java index 0c4589be25e..917e5b35046 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/shenandoah/ShenandoahHeap.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/shenandoah/ShenandoahHeap.java @@ -48,7 +48,6 @@ public class ShenandoahHeap extends CollectedHeap { static private CIntegerField logMinObjAlignmentInBytes; static private long regionPtrFieldSize; - static private long brookPtrSize; static { VM.registerVMInitializedObserver(new Observer() { public void update(Observable o, Object data) { @@ -65,7 +64,6 @@ public class ShenandoahHeap extends CollectedHeap { regions = type.getAddressField("_regions"); logMinObjAlignmentInBytes = type.getCIntegerField("_log_min_obj_alignment_in_bytes"); - brookPtrSize = db.lookupIntConstant("HeapWordSize").longValue(); Type regionPtrType = db.lookupType("ShenandoahHeapRegion*"); regionPtrFieldSize = regionPtrType.getSize(); } @@ -74,11 +72,6 @@ public class ShenandoahHeap extends CollectedHeap { super(addr); } - @Override - public long oopOffset() { - return brookPtrSize; - } - @Override public CollectedHeapName kind() { return CollectedHeapName.SHENANDOAH; diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/shenandoah/ShenandoahHeapRegion.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/shenandoah/ShenandoahHeapRegion.java index a3a0756b93d..f1678571dcd 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/shenandoah/ShenandoahHeapRegion.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/shenandoah/ShenandoahHeapRegion.java @@ -184,10 +184,10 @@ public class ShenandoahHeapRegion extends ContiguousSpace implements LiveRegions if (regionStart == null) { regionStart = start; } else { - regionEnd = start.addOffsetTo(heap.oopOffset() + size); + regionEnd = start.addOffsetTo(size); } } - start = start.addOffsetTo(heap.oopOffset() + size); + start = start.addOffsetTo(size); } if (regionStart != null) { @@ -201,15 +201,13 @@ public class ShenandoahHeapRegion extends ContiguousSpace implements LiveRegions } private boolean hasForwardee(Address rawPtr) { - // Use Mark as a helper to read forward pointer value. + // Forwarding pointer is stored in mark word when it is flagged "marked" Mark mark = new Mark(rawPtr); - Address forwardee = mark.valueAsAddress(); - return (forwardee != rawPtr.addOffsetTo(heap.oopOffset())); + return mark.isMarked(); } private long getObjectSize(Address rawPtr) { - // Dealing with a raw pointer, offsets forward pointer to find real Oop. - OopHandle handle = rawPtr.addOffsetToAsOopHandle(heap.oopOffset()); + OopHandle handle = rawPtr.addOffsetToAsOopHandle(0); Oop obj = null; try { From 6fc80b4eed794f37d0dfe75c6390ea1a8dbdbd63 Mon Sep 17 00:00:00 2001 From: Vladimir Kozlov Date: Mon, 17 Jun 2019 09:11:27 -0700 Subject: [PATCH 09/15] 8181837: [Graal] compiler/jvmci/SecurityRestrictionsTest.java fails with AccessControlException Remove test from Problem list because it does not fail anymore. Reviewed-by: iignatyev --- test/hotspot/jtreg/ProblemList-graal.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/hotspot/jtreg/ProblemList-graal.txt b/test/hotspot/jtreg/ProblemList-graal.txt index d564f75a578..e37be5a52ce 100644 --- a/test/hotspot/jtreg/ProblemList-graal.txt +++ b/test/hotspot/jtreg/ProblemList-graal.txt @@ -43,8 +43,6 @@ compiler/jsr292/InvokerSignatureMismatch.java 8223807 generi compiler/graalunit/JttThreadsTest.java 8207757 generic-all -compiler/jvmci/SecurityRestrictionsTest.java 8181837 generic-all - compiler/unsafe/UnsafeGetConstantField.java 8181833 generic-all compiler/unsafe/UnsafeGetStableArrayElement.java 8181833 generic-all compiler/unsafe/UnsafeOffHeapBooleanTest.java 8181833 generic-all From c7df05efea1d9d03f6d5055a63a1e5ff5151c060 Mon Sep 17 00:00:00 2001 From: Daniil Titov Date: Thu, 13 Jun 2019 11:21:50 -0700 Subject: [PATCH 10/15] 8225543: Jcmd fails to attach to the Java process on Linux using the main class name if whitespace options were used to launch the process Reviewed-by: sspitsyn, dholmes --- .../classes/sun/tools/ProcessHelper.java | 36 +++++++-- .../jdk/sun/tools/jcmd/TestProcessHelper.java | 74 ++++++++++++------- 2 files changed, 79 insertions(+), 31 deletions(-) diff --git a/src/jdk.jcmd/linux/classes/sun/tools/ProcessHelper.java b/src/jdk.jcmd/linux/classes/sun/tools/ProcessHelper.java index b77a20cd023..4e9abb45678 100644 --- a/src/jdk.jcmd/linux/classes/sun/tools/ProcessHelper.java +++ b/src/jdk.jcmd/linux/classes/sun/tools/ProcessHelper.java @@ -66,7 +66,7 @@ public class ProcessHelper implements sun.tools.common.ProcessHelper { if (cmdLine.startsWith(CMD_PREFIX)) { cmdLine = cmdLine.substring(CMD_PREFIX.length()); } - String[] parts = cmdLine.split(" "); + String[] parts = cmdLine.split("\0"); String mainClass = null; if(parts.length == 0) { @@ -87,7 +87,7 @@ public class ProcessHelper implements sun.tools.common.ProcessHelper { // options are used then just return the value (the path to the jar file or module // name with a main class). Otherwise, the main class name is the first part that // is not a Java option (doesn't start with '-' and is not a classpath or a module - // path). + // whitespace option). for (int i = 1; i < parts.length && mainClass == null; i++) { if (i < parts.length - 1) { @@ -95,10 +95,15 @@ public class ProcessHelper implements sun.tools.common.ProcessHelper { return parts[i + 1]; } } - // If this is a classpath or a module path option then skip the next part - // (the classpath or the module path itself) + + if (parts[i].startsWith("--module=")) { + return parts[i].substring("--module=".length()); + } + + // If this is a classpath or a module whitespace option then skip the next part + // (the classpath or the option value itself) if (parts[i].equals("-cp") || parts[i].equals("-classpath") || parts[i].equals("--class-path") || - parts[i].equals("-p") || parts[i].equals("--module-path")) { + isModuleWhiteSpaceOption(parts[i])) { i++; continue; } @@ -106,6 +111,12 @@ public class ProcessHelper implements sun.tools.common.ProcessHelper { if (parts[i].startsWith("-")) { continue; } + + // If it is a source-file mode then return null + if (parts[i].endsWith(".java")) { + return null; + } + mainClass = parts[i]; } return mainClass; @@ -115,11 +126,24 @@ public class ProcessHelper implements sun.tools.common.ProcessHelper { private static String getCommandLine(String pid) { try (Stream lines = Files.lines(Paths.get("/proc/" + pid + "/cmdline"))) { - return lines.map(x -> x.replaceAll("\0", " ")).findFirst().orElse(null); + return lines.findFirst().orElse(null); } catch (IOException | UncheckedIOException e) { return null; } } + + private static boolean isModuleWhiteSpaceOption(String option) { + return option.equals("-p") || + option.equals("--module-path") || + option.equals("--upgrade-module-path") || + option.equals("--add-modules") || + option.equals("--limit-modules") || + option.equals("--add-exports") || + option.equals("--add-opens") || + option.equals("--add-reads") || + option.equals("--patch-module"); + } + } diff --git a/test/jdk/sun/tools/jcmd/TestProcessHelper.java b/test/jdk/sun/tools/jcmd/TestProcessHelper.java index f4e02383d6e..87b5ecbd5b5 100644 --- a/test/jdk/sun/tools/jcmd/TestProcessHelper.java +++ b/test/jdk/sun/tools/jcmd/TestProcessHelper.java @@ -73,13 +73,21 @@ public class TestProcessHelper { .resolve(TEST_PROCESS_MAIN_CLASS_NAME + ".class"); private static final String[] CP_OPTIONS = {"-cp", "-classpath", "--class-path"}; - private static final String[][] VM_ARGS = {{}, {"-Dtest1=aaa"}, {"-Dtest1=aaa", "-Dtest2=bbb"}}; + private static final String[][] VM_ARGS = {{}, {"-Dtest1=aaa"}, {"-Dtest1=aaa", "-Dtest2=bbb ccc"}}; private static final String[][] ARGS = {{}, {"param1"}, {"param1", "param2"}}; private static final String[] MP_OPTIONS = {"-p", "--module-path"}; - private static final String[] MODULE_OPTIONS = {"-m", "--module"}; + private static final String[] MODULE_OPTIONS = {"-m", "--module", "--module="}; private static final String JAR_OPTION = "-jar"; private static final String MODULE_NAME = "module1"; + private static final String[][] EXTRA_MODULAR_OPTIONS = {null, + {"--add-opens", "java.base/java.net=ALL-UNNAMED"}, + {"--add-exports", "java.base/java.net=ALL-UNNAMED"}, + {"--add-reads", "java.base/java.net=ALL-UNNAMED"}, + {"--add-modules", "java.management"}, + {"--limit-modules", "java.management"}, + {"--upgrade-module-path", "test"}}; + private static final String[] PATCH_MODULE_OPTIONS = {"--patch-module", null}; public static void main(String[] args) throws Exception { new TestProcessHelper().runTests(); @@ -97,18 +105,24 @@ public class TestProcessHelper { for (String cp : CP_OPTIONS) { for (String[] vma : VM_ARGS) { for (String[] arg : ARGS) { - List cmd = new LinkedList<>(); - cmd.add(JAVA_PATH); - cmd.add(cp); - cmd.add(TEST_CLASSES.toAbsolutePath().toString()); - for (String v : vma) { - cmd.add(v); + for (String[] modularOptions : EXTRA_MODULAR_OPTIONS) { + List cmd = new LinkedList<>(); + cmd.add(JAVA_PATH); + cmd.add(cp); + cmd.add(TEST_CLASSES.toAbsolutePath().toString()); + for (String v : vma) { + cmd.add(v); + } + if (modularOptions != null) { + cmd.add(modularOptions[0]); + cmd.add(modularOptions[1]); + } + cmd.add(TEST_PROCESS_MAIN_CLASS); + for (String a : arg) { + cmd.add(a); + } + testProcessHelper(cmd, TEST_PROCESS_MAIN_CLASS); } - cmd.add(TEST_PROCESS_MAIN_CLASS); - for (String a : arg) { - cmd.add(a); - } - testProcessHelper(cmd, TEST_PROCESS_MAIN_CLASS); } } } @@ -144,19 +158,29 @@ public class TestProcessHelper { for (String m : MODULE_OPTIONS) { for (String[] vma : VM_ARGS) { for (String[] arg : ARGS) { - List cmd = new LinkedList<>(); - cmd.add(JAVA_PATH); - cmd.add(mp); - cmd.add(TEST_MODULES.toAbsolutePath().toString()); - for (String v : vma) { - cmd.add(v); + for(String patchModuleOption : PATCH_MODULE_OPTIONS) { + List cmd = new LinkedList<>(); + cmd.add(JAVA_PATH); + cmd.add(mp); + cmd.add(TEST_MODULES.toAbsolutePath().toString()); + if (patchModuleOption != null) { + cmd.add(patchModuleOption); + cmd.add(MODULE_NAME + "=" + TEST_MODULES.toAbsolutePath().toString()); + } + for (String v : vma) { + cmd.add(v); + } + if (m.endsWith("=")) { + cmd.add(m + MODULE_NAME + "/" + TEST_PROCESS_MAIN_CLASS); + } else { + cmd.add(m); + cmd.add(MODULE_NAME + "/" + TEST_PROCESS_MAIN_CLASS); + } + for (String a : arg) { + cmd.add(a); + } + testProcessHelper(cmd, MODULE_NAME + "/" + TEST_PROCESS_MAIN_CLASS); } - cmd.add(m); - cmd.add(MODULE_NAME + "/" + TEST_PROCESS_MAIN_CLASS); - for (String a : arg) { - cmd.add(a); - } - testProcessHelper(cmd, MODULE_NAME + "/" + TEST_PROCESS_MAIN_CLASS); } } } From 6ad0d8a6c7699c94d42e773ddc68ff5ac3c8cf40 Mon Sep 17 00:00:00 2001 From: Daniil Titov Date: Mon, 17 Jun 2019 14:31:49 -0700 Subject: [PATCH 11/15] 8217348: assert(thread->is_Java_thread()) failed: just checking Reviewed-by: sspitsyn, dholmes, amenkov, jcbeyler --- src/hotspot/share/prims/jvmtiEnvBase.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hotspot/share/prims/jvmtiEnvBase.cpp b/src/hotspot/share/prims/jvmtiEnvBase.cpp index 39b8238862f..b5a617960c7 100644 --- a/src/hotspot/share/prims/jvmtiEnvBase.cpp +++ b/src/hotspot/share/prims/jvmtiEnvBase.cpp @@ -1083,7 +1083,7 @@ JvmtiEnvBase::get_object_monitor_usage(JavaThread* calling_thread, jobject objec // If the monitor has no owner, then a non-suspended contending // thread could potentially change the state of the monitor by // entering it. The JVM/TI spec doesn't allow this. - if (owning_thread == NULL && !at_safepoint & + if (owning_thread == NULL && !at_safepoint && !pending_thread->is_thread_fully_suspended(true, &debug_bits)) { if (ret.owner != NULL) { destroy_jni_reference(calling_thread, ret.owner); From a38e980eb53646297a8c072b964f1324787738d0 Mon Sep 17 00:00:00 2001 From: Robert Field Date: Mon, 17 Jun 2019 17:14:05 -0700 Subject: [PATCH 12/15] 8200701: jdk/jshell/ExceptionsTest.java fails on Windows, after JDK-8198801 8159740: JShell: corralled declarations do not have correct source to wrapper mapping 8212167: JShell : Stack trace of exception has wrong line number Build corralled (recoverable undeclared definitions) declarations from position translating wraps.... Reviewed-by: jlahoda --- .../share/classes/jdk/jshell/Corraller.java | 274 ++++++++++++------ .../share/classes/jdk/jshell/Eval.java | 13 +- .../share/classes/jdk/jshell/GeneralWrap.java | 5 +- .../jdk/jshell/SourceCodeAnalysisImpl.java | 15 +- .../share/classes/jdk/jshell/Wrap.java | 72 +++-- test/langtools/ProblemList.txt | 1 - test/langtools/jdk/jshell/ClassesTest.java | 2 +- test/langtools/jdk/jshell/ExceptionsTest.java | 50 +++- test/langtools/jdk/jshell/KullaTesting.java | 5 +- test/langtools/jdk/jshell/WrapperTest.java | 146 +++++++++- 10 files changed, 440 insertions(+), 143 deletions(-) diff --git a/src/jdk.jshell/share/classes/jdk/jshell/Corraller.java b/src/jdk.jshell/share/classes/jdk/jshell/Corraller.java index dcb9596c64b..01d7898feea 100644 --- a/src/jdk.jshell/share/classes/jdk/jshell/Corraller.java +++ b/src/jdk.jshell/share/classes/jdk/jshell/Corraller.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2019, 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,132 +25,226 @@ package jdk.jshell; -import java.io.IOException; -import java.io.StringWriter; import com.sun.source.tree.ClassTree; import com.sun.source.tree.MethodTree; import com.sun.source.tree.Tree; -import com.sun.tools.javac.code.Flags; +import com.sun.source.tree.Tree.Kind; import com.sun.tools.javac.tree.JCTree; import com.sun.tools.javac.tree.JCTree.JCBlock; import com.sun.tools.javac.tree.JCTree.JCClassDecl; -import com.sun.tools.javac.tree.JCTree.JCExpression; import com.sun.tools.javac.tree.JCTree.JCMethodDecl; -import com.sun.tools.javac.tree.JCTree.JCNewClass; -import com.sun.tools.javac.tree.JCTree.JCStatement; import com.sun.tools.javac.tree.JCTree.JCVariableDecl; -import com.sun.tools.javac.tree.Pretty; -import com.sun.tools.javac.tree.TreeMaker; -import com.sun.tools.javac.util.Context; +import com.sun.tools.javac.tree.JCTree.Visitor; import com.sun.tools.javac.util.List; import com.sun.tools.javac.util.ListBuffer; -import com.sun.tools.javac.util.Names; +import static com.sun.tools.javac.code.Flags.FINAL; +import static com.sun.tools.javac.code.Flags.PUBLIC; import static com.sun.tools.javac.code.Flags.STATIC; import static com.sun.tools.javac.code.Flags.INTERFACE; import static com.sun.tools.javac.code.Flags.ENUM; -import static com.sun.tools.javac.code.Flags.PUBLIC; -import com.sun.tools.javac.util.Name; -import jdk.jshell.spi.SPIResolutionException; +import jdk.jshell.Wrap.CompoundWrap; +import jdk.jshell.Wrap.Range; +import jdk.jshell.Wrap.RangeWrap; /** * Produce a corralled version of the Wrap for a snippet. - * Incoming tree is mutated. - * - * @author Robert Field */ -class Corraller extends Pretty { +class Corraller extends Visitor { - private final StringWriter out; - private final int keyIndex; - private final TreeMaker make; - private final Names names; - private JCBlock resolutionExceptionBlock; + /** Visitor result field: a Wrap + */ + protected Wrap result; - public Corraller(int keyIndex, Context context) { - this(new StringWriter(), keyIndex, context); + private final TreeDissector dis; + private final String resolutionExceptionBlock; + private final String source; + + public Corraller(TreeDissector dis, int keyIndex, String source) { + this.dis = dis; + this.resolutionExceptionBlock = "\n { throw new jdk.jshell.spi.SPIResolutionException(" + keyIndex + "); }"; + this.source = source; } - private Corraller(StringWriter out, int keyIndex, Context context) { - super(out, false); - this.out = out; - this.keyIndex = keyIndex; - this.make = TreeMaker.instance(context); - this.names = Names.instance(context); + public Wrap corralType(ClassTree tree) { + return corralToWrap(tree); } - public Wrap corralType(ClassTree ct) { - ((JCClassDecl) ct).mods.flags |= Flags.STATIC | Flags.PUBLIC; - return corral(ct); + public Wrap corralMethod(MethodTree tree) { + return corralToWrap(tree); } - public Wrap corralMethod(MethodTree mt) { - ((JCMethodDecl) mt).mods.flags |= Flags.STATIC | Flags.PUBLIC; - return corral(mt); - } - - private Wrap corral(Tree tree) { + private Wrap corralToWrap(Tree tree) { try { - printStat((JCTree) tree); - } catch (IOException e) { - throw new AssertionError(e); + JCTree jct = (JCTree) tree; + Wrap w = new CompoundWrap( + " public static\n ", + corral(jct)); + debugWrap("corralToWrap SUCCESS source: %s -- wrap:\n %s\n", tree, w.wrapped()); + return w; + } catch (Exception ex) { + debugWrap("corralToWrap FAIL: %s - %s\n", tree, ex); + //ex.printStackTrace(System.err); + return null; } - return Wrap.simpleWrap(out.toString()); } - @Override - public void visitBlock(JCBlock tree) { - // Top-level executable blocks (usually method bodies) are corralled - super.visitBlock((tree.flags & STATIC) != 0 - ? tree - : resolutionExceptionBlock()); + // Corral a single node. +// @SuppressWarnings("unchecked") + private Wrap corral(T tree) { + if (tree == null) { + return null; + } else { + tree.accept(this); + Wrap tmpResult = this.result; + this.result = null; + return tmpResult; + } } - @Override - public void visitVarDef(JCVariableDecl tree) { - // No field inits in corralled classes - tree.init = null; - super.visitVarDef(tree); + private String defaultConstructor(JCClassDecl tree) { + return " public " + tree.name.toString() + "() " + + resolutionExceptionBlock; } + /* *************************************************************************** + * Visitor methods + ****************************************************************************/ + @Override public void visitClassDef(JCClassDecl tree) { - if ((tree.mods.flags & (INTERFACE | ENUM)) == 0 && - !tree.getMembers().stream() - .anyMatch(t -> t.getKind() == Tree.Kind.METHOD && - ((MethodTree) t).getName() == tree.name.table.names.init)) { - // Generate a default constructor, since - // this is a regular class and there are no constructors - ListBuffer ndefs = new ListBuffer<>(); - ndefs.addAll(tree.defs); - ndefs.add(make.MethodDef(make.Modifiers(PUBLIC), - tree.name.table.names.init, - null, List.nil(), List.nil(), List.nil(), - resolutionExceptionBlock(), null)); - tree.defs = ndefs.toList(); - } - super.visitClassDef(tree); - } - - // Build a compiler tree for an exception throwing block, e.g.: - // { - // throw new jdk.jshell.spi.SPIResolutionException(9); - // } - private JCBlock resolutionExceptionBlock() { - if (resolutionExceptionBlock == null) { - JCExpression expClass = null; - // Split the exception class name at dots - for (String id : SPIResolutionException.class.getName().split("\\.")) { - Name nm = names.fromString(id); - if (expClass == null) { - expClass = make.Ident(nm); - } else { - expClass = make.Select(expClass, nm); + boolean isEnum = (tree.mods.flags & ENUM) != 0; + boolean isInterface = (tree.mods.flags & INTERFACE ) != 0; + int classBegin = dis.getStartPosition(tree); + int classEnd = dis.getEndPosition(tree); + //debugWrap("visitClassDef: %d-%d = %s\n", classBegin, classEnd, source.substring(classBegin, classEnd)); + ListBuffer wrappedDefs = new ListBuffer<>(); + int bodyBegin = -1; + if (tree.defs != null && !tree.defs.isEmpty()) { + if (isEnum) { + // copy the enum constants verbatim + int enumBegin = dis.getStartPosition(tree.defs.head); + JCTree t = null; // null to shut-up compiler, always set because non-empty + List l = tree.defs; + for (; l.nonEmpty(); l = l.tail) { + t = l.head; + if (t.getKind() == Kind.VARIABLE) { + if ((((JCVariableDecl)t).mods.flags & (PUBLIC | STATIC | FINAL)) != (PUBLIC | STATIC | FINAL)) { + // non-enum constant, process normally + break; + } + } else { + // non-variable, process normally + break; + } + } + int constEnd = l.nonEmpty() // end of constants + ? dis.getStartPosition(l.head) - 1 // is one before next defs, if there is one + : dis.getEndPosition(t); // and otherwise end of the last constant + wrappedDefs.append(new RangeWrap(source, new Range(enumBegin, constEnd))); + // handle any other defs + for (; l.nonEmpty(); l = l.tail) { + wrappedDefs.append("\n"); + t = l.head; + wrappedDefs.append(corral(t)); + } + } else { + // non-enum + boolean constructorSeen = false; + for (List l = tree.defs; l.nonEmpty(); l = l.tail) { + wrappedDefs.append("\n "); + JCTree t = l.head; + switch (t.getKind()) { + case METHOD: + constructorSeen = constructorSeen || ((MethodTree)t).getName() == tree.name.table.names.init; + break; + case BLOCK: + // throw exception in instance initializer too -- inline because String not Wrap + wrappedDefs.append((((JCBlock)t).flags & STATIC) != 0 + ? new RangeWrap(source, dis.treeToRange(t)) + : resolutionExceptionBlock); + continue; // already appended, skip append below + } + wrappedDefs.append(corral(t)); + } + if (!constructorSeen && !isInterface && !isEnum) { + // Generate a default constructor, since + // this is a regular class and there are no constructors + if (wrappedDefs.length() > 0) { + wrappedDefs.append("\n "); + } + wrappedDefs.append(defaultConstructor(tree)); } } - JCNewClass exp = make.NewClass(null, - null, expClass, List.of(make.Literal(keyIndex)), null); - resolutionExceptionBlock = make.Block(0L, List.of(make.Throw(exp))); + bodyBegin = dis.getStartPosition(tree.defs.head); } - return resolutionExceptionBlock; + Object defs = wrappedDefs.length() == 1 + ? wrappedDefs.first() + : new CompoundWrap(wrappedDefs.toArray()); + if (bodyBegin < 0) { + int brace = source.indexOf('{', classBegin); + if (brace < 0 || brace >= classEnd) { + throw new IllegalArgumentException("No brace found: " + source.substring(classBegin, classEnd)); + } + bodyBegin = brace + 1; + } + // body includes openning brace + result = new CompoundWrap( + new RangeWrap(source, new Range(classBegin, bodyBegin)), + defs, + "\n}" + ); + } + + // Corral the body + @Override + public void visitMethodDef(JCMethodDecl tree) { + int methodBegin = dis.getStartPosition(tree); + int methodEnd = dis.getEndPosition(tree); + //debugWrap("+visitMethodDef: %d-%d = %s\n", methodBegin, methodEnd, + // source.substring(methodBegin, methodEnd)); + int bodyBegin = dis.getStartPosition(tree.getBody()); + if (bodyBegin < 0) { + bodyBegin = source.indexOf('{', methodBegin); + if (bodyBegin > methodEnd) { + bodyBegin = -1; + } + } + if (bodyBegin > 0) { + //debugWrap("-visitMethodDef BEGIN: %d = '%s'\n", bodyBegin, + // source.substring(methodBegin, bodyBegin)); + Range noBodyRange = new Range(methodBegin, bodyBegin); + result = new CompoundWrap( + new RangeWrap(source, noBodyRange), + resolutionExceptionBlock); + } else { + Range range = new Range(methodBegin, methodEnd); + result = new RangeWrap(source, range); + } + } + + // Remove initializer, if present + @Override + public void visitVarDef(JCVariableDecl tree) { + int begin = dis.getStartPosition(tree); + int end = dis.getEndPosition(tree); + if (tree.init == null) { + result = new RangeWrap(source, new Range(begin, end)); + } else { + int sinit = dis.getStartPosition(tree.init); + int eq = source.lastIndexOf('=', sinit); + if (eq < begin) { + throw new IllegalArgumentException("Equals not found before init: " + source + " @" + sinit); + } + result = new CompoundWrap(new RangeWrap(source, new Range(begin, eq - 1)), ";"); + } + } + + @Override + public void visitTree(JCTree tree) { + throw new IllegalArgumentException("Unexpected tree: " + tree); + } + + void debugWrap(String format, Object... args) { + //state.debug(this, InternalDebugControl.DBG_WRAP, format, args); } } diff --git a/src/jdk.jshell/share/classes/jdk/jshell/Eval.java b/src/jdk.jshell/share/classes/jdk/jshell/Eval.java index 83d4c440f26..2053a05d13f 100644 --- a/src/jdk.jshell/share/classes/jdk/jshell/Eval.java +++ b/src/jdk.jshell/share/classes/jdk/jshell/Eval.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2019, 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 @@ -44,7 +44,6 @@ import com.sun.source.tree.ModifiersTree; import com.sun.source.tree.NewClassTree; import com.sun.source.tree.Tree; import com.sun.source.tree.VariableTree; -import com.sun.source.util.TreeScanner; import com.sun.tools.javac.tree.JCTree; import com.sun.tools.javac.tree.Pretty; import java.io.IOException; @@ -622,7 +621,6 @@ class Eval { name = "$" + ++varNumber; } } - TreeDissector dis = TreeDissector.createByFirstClass(pt); ExpressionInfo varEI = ExpressionToTypeInfo.localVariableTypeForInitializer(compileSource, state, true); String declareTypeName; @@ -634,6 +632,7 @@ class Eval { fullTypeName = varEI.fullTypeName; displayTypeName = varEI.displayTypeName; + TreeDissector dis = TreeDissector.createByFirstClass(pt); Pair anonymous2Member = anonymous2Member(varEI, compileSource, new Range(0, compileSource.length()), dis, expr.getExpression()); guts = Wrap.tempVarWrap(anonymous2Member.second.wrapped(), declareTypeName, name, anonymous2Member.first); @@ -680,8 +679,8 @@ class Eval { String name = klassTree.getSimpleName().toString(); DiagList modDiag = modifierDiagnostics(klassTree.getModifiers(), dis, false); TypeDeclKey key = state.keyMap.keyForClass(name); - // Corralling mutates. Must be last use of pt, unitTree, klassTree - Wrap corralled = new Corraller(key.index(), pt.getContext()).corralType(klassTree); + // Corralling + Wrap corralled = new Corraller(dis, key.index(), compileSource).corralType(klassTree); Wrap guts = Wrap.classMemberWrap(compileSource); Snippet snip = new TypeDeclSnippet(key, userSource, guts, @@ -752,8 +751,8 @@ class Eval { Tree returnType = mt.getReturnType(); DiagList modDiag = modifierDiagnostics(mt.getModifiers(), dis, true); MethodKey key = state.keyMap.keyForMethod(name, parameterTypes); - // Corralling mutates. Must be last use of pt, unitTree, mt - Wrap corralled = new Corraller(key.index(), pt.getContext()).corralMethod(mt); + // Corralling + Wrap corralled = new Corraller(dis, key.index(), compileSource).corralMethod(mt); if (modDiag.hasErrors()) { return compileFailResult(modDiag, userSource, Kind.METHOD); diff --git a/src/jdk.jshell/share/classes/jdk/jshell/GeneralWrap.java b/src/jdk.jshell/share/classes/jdk/jshell/GeneralWrap.java index 217fcd7c260..89c1a9b256b 100644 --- a/src/jdk.jshell/share/classes/jdk/jshell/GeneralWrap.java +++ b/src/jdk.jshell/share/classes/jdk/jshell/GeneralWrap.java @@ -28,7 +28,10 @@ package jdk.jshell; /** * Common interface for all wrappings of snippet source to Java source. * - * @author Robert Field + * Snippet index is index into the source of the snippet. Note: If the snippet is a sub-range of + * the source, the index is not the index in the snippet. + * + * Wrap index is index into the wrapped snippet. */ interface GeneralWrap { diff --git a/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysisImpl.java b/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysisImpl.java index a86f27c4290..ad935e9d38b 100644 --- a/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysisImpl.java +++ b/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysisImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2019, 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 @@ -301,7 +301,7 @@ class SourceCodeAnalysisImpl extends SourceCodeAnalysis { SourcePositions sp = at.trees().getSourcePositions(); CompilationUnitTree topLevel = at.firstCuTree(); List result = new ArrayList<>(); - TreePath tp = pathFor(topLevel, sp, code.snippetIndexToWrapIndex(cursor)); + TreePath tp = pathFor(topLevel, sp, code, cursor); if (tp != null) { Scope scope = at.trees().getScope(tp); Predicate accessibility = createAccessibilityFilter(at, tp); @@ -563,7 +563,10 @@ class SourceCodeAnalysisImpl extends SourceCodeAnalysis { } } - private TreePath pathFor(CompilationUnitTree topLevel, SourcePositions sp, int pos) { + private TreePath pathFor(CompilationUnitTree topLevel, SourcePositions sp, GeneralWrap wrap, int snippetEndPos) { + int wrapEndPos = snippetEndPos == 0 + ? wrap.snippetIndexToWrapIndex(snippetEndPos) + : wrap.snippetIndexToWrapIndex(snippetEndPos - 1) + 1; TreePath[] deepest = new TreePath[1]; new TreePathScanner() { @@ -576,7 +579,7 @@ class SourceCodeAnalysisImpl extends SourceCodeAnalysis { long end = sp.getEndPosition(topLevel, tree); long prevEnd = deepest[0] != null ? sp.getEndPosition(topLevel, deepest[0].getLeaf()) : -1; - if (start <= pos && pos <= end && + if (start <= wrapEndPos && wrapEndPos <= end && (start != end || prevEnd != end || deepest[0] == null || deepest[0].getParentPath().getLeaf() != getCurrentPath().getLeaf())) { deepest[0] = new TreePath(getCurrentPath(), tree); @@ -1176,7 +1179,7 @@ class SourceCodeAnalysisImpl extends SourceCodeAnalysis { return proc.taskFactory.analyze(codeWrap, List.of(keepParameterNames), at -> { SourcePositions sp = at.trees().getSourcePositions(); CompilationUnitTree topLevel = at.firstCuTree(); - TreePath tp = pathFor(topLevel, sp, codeWrap.snippetIndexToWrapIndex(cursor)); + TreePath tp = pathFor(topLevel, sp, codeWrap, cursor); if (tp == null) return Collections.emptyList(); @@ -1526,7 +1529,7 @@ class SourceCodeAnalysisImpl extends SourceCodeAnalysis { return proc.taskFactory.analyze(codeWrap, at -> { SourcePositions sp = at.trees().getSourcePositions(); CompilationUnitTree topLevel = at.firstCuTree(); - TreePath tp = pathFor(topLevel, sp, codeWrap.snippetIndexToWrapIndex(codeFin.length())); + TreePath tp = pathFor(topLevel, sp, codeWrap, codeFin.length()); if (tp.getLeaf().getKind() != Kind.IDENTIFIER) { return new QualifiedNames(Collections.emptyList(), -1, true, false); } diff --git a/src/jdk.jshell/share/classes/jdk/jshell/Wrap.java b/src/jdk.jshell/share/classes/jdk/jshell/Wrap.java index 05ae629aa17..1486b631f28 100644 --- a/src/jdk.jshell/share/classes/jdk/jshell/Wrap.java +++ b/src/jdk.jshell/share/classes/jdk/jshell/Wrap.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2019, 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 @@ -34,8 +34,6 @@ import static jdk.jshell.Util.DOIT_METHOD_NAME; /** * Wrapping of source into Java methods, fields, etc. All but outer layer * wrapping with imports and class. - * - * @author Robert Field */ abstract class Wrap implements GeneralWrap { @@ -184,7 +182,7 @@ abstract class Wrap implements GeneralWrap { public static final class Range { final int begin; - final int end; + final int end; // exclusive Range(int begin, int end) { this.begin = begin; @@ -216,7 +214,7 @@ abstract class Wrap implements GeneralWrap { @Override public String toString() { - return "Range[" + begin + "," + end + "]"; + return "Range[" + begin + "," + end + ")"; } } @@ -280,8 +278,12 @@ abstract class Wrap implements GeneralWrap { before += s.length(); } else if (o instanceof Wrap) { Wrap w = (Wrap) o; - if (sni >= w.firstSnippetIndex() && sni <= w.lastSnippetIndex()) { - return w.snippetIndexToWrapIndex(sni) + before; + if (sni >= w.firstSnippetIndex() && sni < w.lastSnippetIndex()) { + int wwi = w.snippetIndexToWrapIndex(sni); + debugWrap("\nCommoundWrap.snippetIndexToWrapIndex: SnippetIndex(%d) -> WrapIndex(%d + %d = %d)" + + "\n === %s", + sni, wwi, before, wwi + before, wrapped()); + return wwi + before; } before += w.wrapped().length(); } @@ -300,8 +302,8 @@ abstract class Wrap implements GeneralWrap { w = (Wrap) o; int len = w.wrapped().length(); if ((wi - before) <= len) { - //System.err.printf("Defer to wrap %s - wi: %d. before; %d -- %s >>> %s\n", - // w, wi, before, w.debugPos(wi - before), w.wrapped()); + debugWrap("CommoundWrap.wrapIndexToWrap: Defer to wrap %s - wi: %d. before; %d >>> %s\n", + w, wi, before, w.wrapped()); return w; } before += len; @@ -321,9 +323,10 @@ abstract class Wrap implements GeneralWrap { Wrap w = (Wrap) o; int len = w.wrapped().length(); if ((wi - before) <= len) { - //System.err.printf("Defer to wrap %s - wi: %d. before; %d -- %s >>> %s\n", - // w, wi, before, w.debugPos(wi - before), w.wrapped()); - return w.wrapIndexToSnippetIndex(wi - before); + int si = w.wrapIndexToSnippetIndex(wi - before); + debugWrap("\nCommoundWrap.wrapIndexToSnippetIndex: WrapIndex(%d) -> SnippetIndex(%d)\n", + wi, si); + return si; } before += len; } @@ -369,7 +372,7 @@ abstract class Wrap implements GeneralWrap { } else if (o instanceof Wrap) { w = (Wrap) o; int lns = countLines(w.wrapped()); - if ((wline - before) < lns) { + if ((wline - before) <= lns) { return w; } before += lns; @@ -388,7 +391,7 @@ abstract class Wrap implements GeneralWrap { } else if (o instanceof Wrap) { Wrap w = (Wrap) o; int lns = countLines(w.wrapped()); - if ((wline - before) < lns) { + if ((wline - before) <= lns) { return w.wrapLineToSnippetLine(wline - before); } before += lns; @@ -409,16 +412,21 @@ abstract class Wrap implements GeneralWrap { @Override public String toString() { - return "CompoundWrap(" + Arrays.stream(os).map(Object::toString).collect(joining(",")) + ")"; + return "CompoundWrap(" + Arrays.stream(os) + .map(o -> (o instanceof String) + ? "\"" + o + "\"" + : o.toString()) + .collect(joining(",")) + + ")"; } } - private static class RangeWrap extends Wrap { + static class RangeWrap extends Wrap { final Range range; - final String wrapped; - final int firstSnline; - final int lastSnline; + final String wrapped; // The snippet portion of the source + final int firstSnline; // Line count to start of snippet portion + final int lastSnline; // Line count to end of snippet portion RangeWrap(String snippetSource, Range usedWithinSnippet) { this.range = usedWithinSnippet; @@ -436,24 +444,39 @@ abstract class Wrap implements GeneralWrap { @Override public int snippetIndexToWrapIndex(int sni) { if (sni < range.begin) { + debugWrap("\nRangeWrap.snippetIndexToWrapIndex: ERR before SnippetIndex(%d) -> WrapIndex(%d + %d = %d)\n", + sni, 0); return 0; } if (sni > range.end) { + debugWrap("\nRangeWrap.snippetIndexToWrapIndex: ERR after SnippetIndex(%d) -> WrapIndex(%d + %d = %d)\n", + sni, range.length()); return range.length(); } - return sni - range.begin; + int wi = sni - range.begin; + debugWrap("\nRangeWrap.snippetIndexToWrapIndex: SnippetIndex(%d) -> WrapIndex(%d + %d = %d)" + + "\n === %s", + sni, sni, range.begin, sni - range.begin, wrapped()); + return wi; } @Override public int wrapIndexToSnippetIndex(int wi) { if (wi < 0) { + debugWrap("\nRangeWrap.wrapIndexToSnippetIndex: ERR before WrapIndex(%d) -> SnippetIndex(%d)\n", + wi, 0); return 0; // bad index } int max = range.length(); if (wi > max) { - wi = max; + debugWrap("\nRangeWrap.wrapIndexToSnippetIndex: ERR after WrapIndex(%d) -> SnippetIndex(%d)\n", + wi, max + range.begin); + return max + range.begin; } - return wi + range.begin; + int sni = wi + range.begin; + debugWrap("\nRangeWrap.wrapIndexToSnippetIndex: WrapIndex(%d) -> SnippetIndex(%d)\n", + wi, sni); + return sni; } @Override @@ -535,4 +558,9 @@ abstract class Wrap implements GeneralWrap { super(" public static ", wtype, brackets + " ", wname, semi(wname)); } } + + void debugWrap(String format, Object... args) { + //System.err.printf(format, args); + //state.debug(this, InternalDebugControl.DBG_WRAP, format, args); + } } diff --git a/test/langtools/ProblemList.txt b/test/langtools/ProblemList.txt index d8e9fad98ce..4b6d8b4f4b7 100644 --- a/test/langtools/ProblemList.txt +++ b/test/langtools/ProblemList.txt @@ -37,7 +37,6 @@ jdk/javadoc/doclet/testIOException/TestIOException.java jdk/jshell/UserJdiUserRemoteTest.java 8173079 linux-all jdk/jshell/UserInputTest.java 8169536 generic-all -jdk/jshell/ExceptionsTest.java 8200701 windows-all ########################################################################### # diff --git a/test/langtools/jdk/jshell/ClassesTest.java b/test/langtools/jdk/jshell/ClassesTest.java index c4bbebcd845..2e2855f47e7 100644 --- a/test/langtools/jdk/jshell/ClassesTest.java +++ b/test/langtools/jdk/jshell/ClassesTest.java @@ -344,7 +344,7 @@ public class ClassesTest extends KullaTesting { " public T get() {return null;}\n" + "}", added(VALID), - ste(aClass, Status.RECOVERABLE_DEFINED, Status.VALID, true, null)); + ste(aClass, Status.RECOVERABLE_DEFINED, Status.VALID, false, null)); assertEval("new A()"); } diff --git a/test/langtools/jdk/jshell/ExceptionsTest.java b/test/langtools/jdk/jshell/ExceptionsTest.java index 48443347fc9..fd15120f002 100644 --- a/test/langtools/jdk/jshell/ExceptionsTest.java +++ b/test/langtools/jdk/jshell/ExceptionsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2019, 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 @@ -24,7 +24,7 @@ /* * @test * @summary Tests for exceptions - * @bug 8198801 + * @bug 8198801 8212167 * @build KullaTesting TestingInputStream * @run testng ExceptionsTest */ @@ -207,6 +207,49 @@ public class ExceptionsTest extends KullaTesting { newStackTraceElement("", "", cr2.snippet(), 1))); } + // test 8212167 + public void throwLineFormat1() { + SnippetEvent se = assertEvalException( + "if (true) { \n" + + " int x = 10; \n" + + " int y = 10 / 0;}" + ); + assertExceptionMatch(se, + new ExceptionInfo(ArithmeticException.class, "/ by zero", + newStackTraceElement("", "", se.snippet(), 3))); + } + + public void throwLineFormat3() { + Snippet sp = methodKey(assertEval( + "int p() \n" + + " { return 4/0; }")); + Snippet sm = methodKey(assertEval( + "int m(int x)\n" + + " \n" + + " {\n" + + " return p() + x; \n" + + " }")); + Snippet sn = methodKey(assertEval( + "int n(int x) {\n" + + " try {\n" + + " return m(x);\n" + + " }\n" + + " catch (Throwable ex) {\n" + + " throw new IllegalArgumentException( \"GOT:\", ex);\n" + + " }\n" + + " }")); + SnippetEvent se = assertEvalException("n(33);"); + assertExceptionMatch(se, + new ExceptionInfo(IllegalArgumentException.class, null, + new ExceptionInfo(ArithmeticException.class, "/ by zero", + newStackTraceElement("", "p", sp, 2), + newStackTraceElement("", "m", sm, 4), + newStackTraceElement("", "n", sn, 3), + newStackTraceElement("", "", se.snippet(), 1)), + newStackTraceElement("", "n", sn, 6), + newStackTraceElement("", "", se.snippet(), 1))); + } + @Test(enabled = false) // TODO 8129427 public void outOfMemory() { assertEval("import java.util.*;"); @@ -333,7 +376,8 @@ public class ExceptionsTest extends KullaTesting { } assertEquals(actualElement.getFileName(), expectedElement.getFileName(), message + " : file names"); assertEquals(actualElement.getLineNumber(), expectedElement.getLineNumber(), message + " : line numbers" - + " -- actual: " + actual + ", expected: " + expected); + + " -- actual: " + actualElement.getLineNumber() + ", expected: " + expectedElement.getLineNumber() + + " -- in: " + actualElement.getClassName()); } } } diff --git a/test/langtools/jdk/jshell/KullaTesting.java b/test/langtools/jdk/jshell/KullaTesting.java index 802ed3f6773..369b2ed1f44 100644 --- a/test/langtools/jdk/jshell/KullaTesting.java +++ b/test/langtools/jdk/jshell/KullaTesting.java @@ -911,7 +911,10 @@ public class KullaTesting { public void assertCompletionIncludesExcludes(String code, Boolean isSmart, Set expected, Set notExpected) { List completions = computeCompletions(code, isSmart); - assertTrue(completions.containsAll(expected), String.valueOf(completions)); + assertTrue(completions.containsAll(expected), "Expected completions: " + + String.valueOf(expected) + + ", got: " + + String.valueOf(completions)); assertTrue(Collections.disjoint(completions, notExpected), String.valueOf(completions)); } diff --git a/test/langtools/jdk/jshell/WrapperTest.java b/test/langtools/jdk/jshell/WrapperTest.java index 8debd466403..8986c99b4b3 100644 --- a/test/langtools/jdk/jshell/WrapperTest.java +++ b/test/langtools/jdk/jshell/WrapperTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2019, 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 @@ -23,7 +23,7 @@ /* * @test - * @bug 8159111 + * @bug 8159111 8159740 * @summary test wrappers and dependencies * @modules jdk.jshell/jdk.jshell * @build KullaTesting @@ -62,15 +62,126 @@ public class WrapperTest extends KullaTesting { assertPosition(swg, src, 15, 6); } - @Test(enabled = false) // TODO 8159740 + // test 8159740 public void testMethodCorralled() { String src = "void glib() { f(); }"; + // _123456789_123456789 Snippet g = methodKey(assertEval(src, added(RECOVERABLE_DEFINED))); SnippetWrapper swg = getState().sourceCodeAnalysis().wrapper(g); - assertWrapperHas(swg, src, Kind.METHOD, "void", "glib"); + assertWrapperHas(swg, src, Kind.METHOD, "SPIResolutionException", + "void", "glib"); + assertPosition(swg, src, 0, 4); assertPosition(swg, src, 5, 4); } + // test 8159740 + public void testClassCorralled0() { + String src = "class AAA { float mmm(double d1234) { return (float) (f0 * d1234); } }"; + // _123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789 + Snippet a = classKey(assertEval(src, added(RECOVERABLE_DEFINED))); + SnippetWrapper swa = getState().sourceCodeAnalysis().wrapper(a); + assertWrapperHas(swa, src, Kind.TYPE_DECL, "SPIResolutionException", + "class", "AAA", "float", "mmm", "double", "d1234"); + assertPosition(swa, src, 0, 5); + assertPosition(swa, src, 6, 3); + assertPosition(swa, src, 12, 5); + assertPosition(swa, src, 18, 3); + assertPosition(swa, src, 22, 6); + assertPosition(swa, src, 29, 5); + } + + // test 8159740 + public void testClassCorralled() { + String src = "class AAA { int xxx = x0 + 4; float mmm(float ffff) { return f0 * ffff; } }"; + // _123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789 + Snippet a = classKey(assertEval(src, added(RECOVERABLE_DEFINED))); + SnippetWrapper swa = getState().sourceCodeAnalysis().wrapper(a); + assertWrapperHas(swa, src, Kind.TYPE_DECL, "SPIResolutionException", + "class", "AAA", "int", "xxx", "float", "mmm", "ffff"); + assertPosition(swa, src, 0, 5); + assertPosition(swa, src, 6, 3); + assertPosition(swa, src, 12, 3); + assertPosition(swa, src, 16, 3); + assertPosition(swa, src, 30, 5); + assertPosition(swa, src, 36, 3); + assertPosition(swa, src, 40, 5); + assertPosition(swa, src, 46, 4); + } + + // test 8159740 + public void testClassWithConstructorCorralled() { + String src = "public class AAA { AAA(String b) {} int xxx = x0 + 4; float mmm(float ffff) { return f0 * ffff; } }"; + // _123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789 + Snippet a = classKey(assertEval(src, added(RECOVERABLE_DEFINED))); + SnippetWrapper swa = getState().sourceCodeAnalysis().wrapper(a); + assertWrapperHas(swa, src, Kind.TYPE_DECL, "SPIResolutionException", + "class", "AAA", "String", "int", "xxx", "float", "mmm", "ffff"); + assertPosition(swa, src, 7, 5); + assertPosition(swa, src, 13, 3); + assertPosition(swa, src, 19, 3); + assertPosition(swa, src, 23, 5); + assertPosition(swa, src, 30, 1); + assertPosition(swa, src, 36, 3); + assertPosition(swa, src, 40, 3); + assertPosition(swa, src, 54, 5); + assertPosition(swa, src, 60, 3); + assertPosition(swa, src, 64, 5); + assertPosition(swa, src, 70, 4); + } + + // test 8159740 + public void testInterfaceCorralled() { + String src = "interface AAA { default float mmm(double d1234) { return (float) (f0 * d1234); } }"; + // _123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789 + Snippet a = classKey(assertEval(src, added(RECOVERABLE_DEFINED))); + SnippetWrapper swa = getState().sourceCodeAnalysis().wrapper(a); + assertWrapperHas(swa, src, Kind.TYPE_DECL, "SPIResolutionException", + "interface", "AAA", "float", "mmm", "double", "d1234"); + assertPosition(swa, src, 0, 9); + assertPosition(swa, src, 10, 3); + assertPosition(swa, src, 16, 7); + assertPosition(swa, src, 24, 5); + assertPosition(swa, src, 30, 3); + assertPosition(swa, src, 34, 6); + assertPosition(swa, src, 41, 5); + } + + // test 8159740 + public void testEnumCorralled() { + String src = + "public enum Planet {\n" + + " MERCURY (3.303e+23, 2.4397e6),\n" + + " VENUS (4.869e+24, 6.0518e6),\n" + + " EARTH (5.976e+24, 6.37814e6),\n" + + " MARS (6.421e+23, 3.3972e6),\n" + + " JUPITER (1.9e+27, 7.1492e7),\n" + + " SATURN (5.688e+26, 6.0268e7),\n" + + " URANUS (8.686e+25, 2.5559e7),\n" + + " NEPTUNE (1.024e+26, 2.4746e7);\n" + + "\n" + + " private final double mass; // in kilograms\n" + + " private final double radius; // in meters\n" + + " Planet(double mass, double radius) {\n" + + " this.mass = mass;\n" + + " this.radius = radius;\n" + + " }\n" + + " private double mass() { return mass; }\n" + + " private double radius() { return radius; }\n" + + "\n" + + " double surfaceGravity() {\n" + + " return GRAVITATIONAL_CONSTANT * mass / (radius * radius);\n" + + " }\n" + + " double surfaceWeight(double otherMass) {\n" + + " return otherMass * surfaceGravity();\n" + + " }\n" + + "}\n"; + Snippet a = classKey(assertEval(src, added(RECOVERABLE_DEFINED))); + SnippetWrapper swa = getState().sourceCodeAnalysis().wrapper(a); + assertWrapperHas(swa, src, Kind.TYPE_DECL, "SPIResolutionException", + "enum", "Planet", "double", "mass", "EARTH", "NEPTUNE", "MERCURY", + "radius", "surfaceGravity", "surfaceWeight"); + } + public void testMethodBad() { String src = "void flob() { ?????; }"; List swl = getState().sourceCodeAnalysis().wrappers(src); @@ -182,23 +293,36 @@ public class WrapperTest extends KullaTesting { private void assertWrapperHas(SnippetWrapper sw, String source, Kind kind, String... has) { assertEquals(sw.source(), source); assertEquals(sw.kind(), kind); + String s = sw.wrapped(); if (kind == Kind.IMPORT) { - assertTrue(sw.wrapped().contains("import")); + assertHas(s, "import"); } else { String cn = sw.fullClassName(); int idx = cn.lastIndexOf("."); - assertTrue(sw.wrapped().contains(cn.substring(idx+1))); - assertTrue(sw.wrapped().contains("class")); + assertHas(s, cn.substring(idx+1)); + assertHas(s, "class"); } - for (String s : has) { - assertTrue(sw.wrapped().contains(s)); + for (String hx : has) { + assertHas(s, hx); } } + private void assertHas(String s, String has) { + assertTrue(s.contains(has), "Expected to find '" + has + "' in: '" + s + "'"); + } + private void assertPosition(SnippetWrapper sw, String source, int start, int length) { + //System.err.printf("\n#assertPosition:\n# debug-source: %s\n# SnippetWrapper --\n# source: %s\n# wrapped: %s\n", + // source, sw.source(), sw.wrapped()); + //System.err.printf("# start: %d length: %d\n", start, length); int wpg = sw.sourceToWrappedPosition(start); - assertEquals(sw.wrapped().substring(wpg, wpg+length), - source.substring(start, start+length), + //System.err.printf("# wrappedPos: %d\n", wpg); + String wrappedPart = sw.wrapped().substring(wpg, wpg+length); + String sourcePart = source.substring(start, start+length); + //System.err.printf("# wrapped @ wrappedPos: %s\n", wrappedPart); + //System.err.printf("# source @ start: %s\n", sourcePart); + + assertEquals(wrappedPart, sourcePart, "position " + wpg + " in " + sw.wrapped()); assertEquals(sw.wrappedToSourcePosition(wpg), start); } From 28f3ab859637a902445c18be13f09426934fc453 Mon Sep 17 00:00:00 2001 From: Rahul Raghavan Date: Tue, 18 Jun 2019 10:00:35 +0530 Subject: [PATCH 13/15] 8226198: use of & instead of && in LibraryCallKit::arraycopy_restore_alloc_state Used logical operator correctly Reviewed-by: kvn, thartmann --- src/hotspot/share/opto/library_call.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hotspot/share/opto/library_call.cpp b/src/hotspot/share/opto/library_call.cpp index f8556ad2d9c..07a938ba3ac 100644 --- a/src/hotspot/share/opto/library_call.cpp +++ b/src/hotspot/share/opto/library_call.cpp @@ -4501,8 +4501,8 @@ JVMState* LibraryCallKit::arraycopy_restore_alloc_state(AllocateArrayNode* alloc ciMethod* trap_method = alloc->jvms()->method(); int trap_bci = alloc->jvms()->bci(); - if (!C->too_many_traps(trap_method, trap_bci, Deoptimization::Reason_intrinsic) & - !C->too_many_traps(trap_method, trap_bci, Deoptimization::Reason_null_check)) { + if (!C->too_many_traps(trap_method, trap_bci, Deoptimization::Reason_intrinsic) && + !C->too_many_traps(trap_method, trap_bci, Deoptimization::Reason_null_check)) { // Make sure there's no store between the allocation and the // arraycopy otherwise visible side effects could be rexecuted // in case of deoptimization and cause incorrect execution. From 2cf9999ae20128681f38cb5f6f37373296d75b00 Mon Sep 17 00:00:00 2001 From: Gerard Ziemski Date: Tue, 18 Jun 2019 12:39:29 -0500 Subject: [PATCH 14/15] 8225310: JFR crashed in JfrPeriodicEventSet::requestProtectionDomainCacheTableStatistics() Added lock around table usage Reviewed-by: coleenp, hseigel --- src/hotspot/share/classfile/systemDictionary.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/hotspot/share/classfile/systemDictionary.cpp b/src/hotspot/share/classfile/systemDictionary.cpp index 59e39b2ba14..fdf15ebe420 100644 --- a/src/hotspot/share/classfile/systemDictionary.cpp +++ b/src/hotspot/share/classfile/systemDictionary.cpp @@ -2861,14 +2861,17 @@ void SystemDictionary::dump(outputStream *st, bool verbose) { } TableStatistics SystemDictionary::placeholders_statistics() { + MutexLocker ml(SystemDictionary_lock); return placeholders()->statistics_calculate(); } TableStatistics SystemDictionary::loader_constraints_statistics() { + MutexLocker ml(SystemDictionary_lock); return constraints()->statistics_calculate(); } TableStatistics SystemDictionary::protection_domain_cache_statistics() { + MutexLocker ml(SystemDictionary_lock); return pd_cache_table()->statistics_calculate(); } From 454f9f9fd0a9d7ffda4fbead51ea009359265835 Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Tue, 18 Jun 2019 11:52:57 -0700 Subject: [PATCH 15/15] 8225748: Use SHA-256 for javap classfile checksum Reviewed-by: mchung --- .../share/classes/com/sun/tools/javac/main/Main.java | 2 +- .../share/classes/com/sun/tools/javap/JavapTask.java | 6 +++--- .../classes/com/sun/tools/javap/resources/javap.properties | 2 +- test/langtools/tools/javac/T6942649.java | 6 +++--- test/langtools/tools/javap/T4884240.java | 6 +++--- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Main.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Main.java index 697b62321bd..a6a01570350 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Main.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Main.java @@ -477,7 +477,7 @@ public class Main { } try (InputStream in = getClass().getResourceAsStream('/' + className.replace('.', '/') + ".class")) { - final String algorithm = "MD5"; + final String algorithm = "SHA-256"; byte[] digest; MessageDigest md = MessageDigest.getInstance(algorithm); try (DigestInputStream din = new DigestInputStream(in, md)) { diff --git a/src/jdk.jdeps/share/classes/com/sun/tools/javap/JavapTask.java b/src/jdk.jdeps/share/classes/com/sun/tools/javap/JavapTask.java index e674a156019..adcecbedbe0 100644 --- a/src/jdk.jdeps/share/classes/com/sun/tools/javap/JavapTask.java +++ b/src/jdk.jdeps/share/classes/com/sun/tools/javap/JavapTask.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2019, 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 @@ -808,7 +808,7 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages { MessageDigest md = null; if (options.sysInfo || options.verbose) { try { - md = MessageDigest.getInstance("MD5"); + md = MessageDigest.getInstance("SHA-256"); } catch (NoSuchAlgorithmException ignore) { } in = new DigestInputStream(in, md); @@ -829,7 +829,7 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages { if (options.sysInfo || options.verbose) { classWriter.setFile(info.fo.toUri()); classWriter.setLastModified(info.fo.getLastModified()); - classWriter.setDigest("MD5", info.digest); + classWriter.setDigest("SHA-256", info.digest); classWriter.setFileSize(info.size); } diff --git a/src/jdk.jdeps/share/classes/com/sun/tools/javap/resources/javap.properties b/src/jdk.jdeps/share/classes/com/sun/tools/javap/resources/javap.properties index 3af66f7c5ea..71b107371d6 100644 --- a/src/jdk.jdeps/share/classes/com/sun/tools/javap/resources/javap.properties +++ b/src/jdk.jdeps/share/classes/com/sun/tools/javap/resources/javap.properties @@ -99,7 +99,7 @@ main.opt.constants=\ \ -constants Show final constants main.opt.sysinfo=\ -\ -sysinfo Show system info (path, size, date, MD5 hash)\n\ +\ -sysinfo Show system info (path, size, date, SHA-256 hash)\n\ \ of class being processed main.opt.module=\ diff --git a/test/langtools/tools/javac/T6942649.java b/test/langtools/tools/javac/T6942649.java index 8cdea11fa28..c715eff24f9 100644 --- a/test/langtools/tools/javac/T6942649.java +++ b/test/langtools/tools/javac/T6942649.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2019, 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 @@ -23,7 +23,7 @@ /* * @test - * @bug 6942649 + * @bug 6942649 8225748 * @summary add hidden option to identify location and version of javac classes * @modules jdk.compiler */ @@ -60,7 +60,7 @@ public class T6942649 { throw new Exception("location of class not found in output"); } - if (!out.contains("MD5 checksum: ")) + if (!out.contains("SHA-256 checksum: ")) throw new Exception("checksum not found in output"); } } diff --git a/test/langtools/tools/javap/T4884240.java b/test/langtools/tools/javap/T4884240.java index bd3f04f317c..52e58fbffaa 100644 --- a/test/langtools/tools/javap/T4884240.java +++ b/test/langtools/tools/javap/T4884240.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2019, 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 @@ -23,7 +23,7 @@ /* * @test - * @bug 4884240 + * @bug 4884240 8225748 * @summary additional option required for javap * @modules jdk.jdeps/com.sun.tools.javap */ @@ -47,7 +47,7 @@ public class T4884240 { if (lines.length < 3 || !lines[0].trim().startsWith("Classfile") || !lines[1].trim().startsWith("Last modified") - || !lines[2].trim().startsWith("MD5")) { + || !lines[2].trim().startsWith("SHA-256")) { System.out.println(sw); throw new Exception("unexpected output"); }