JDI Type Signatures

@@ -74,6 +73,5 @@ has the following type signature:
    (ILjava/lang/String;[I)J
 
- diff -r 539748673056 -r a327727090c7 src/jdk.zipfs/share/classes/module-info.java --- a/src/jdk.zipfs/share/classes/module-info.java Mon Jun 24 15:18:05 2019 +0530 +++ b/src/jdk.zipfs/share/classes/module-info.java Tue Jun 25 15:24:41 2019 +0530 @@ -60,7 +60,7 @@ * * * - * + * * * * * * - * + * * * *
JDI Type Signatures
createcreatejava.lang.Stringfalse @@ -69,7 +69,7 @@ *
encodingencodingjava.lang.StringUTF-8 diff -r 539748673056 -r a327727090c7 test/hotspot/gtest/utilities/test_concurrentHashtable.cpp --- a/test/hotspot/gtest/utilities/test_concurrentHashtable.cpp Mon Jun 24 15:18:05 2019 +0530 +++ b/test/hotspot/gtest/utilities/test_concurrentHashtable.cpp Tue Jun 25 15:24:41 2019 +0530 @@ -36,24 +36,22 @@ // Amusingly as long as they do not assert they are mt-safe. #define SIZE_32 5 -struct Pointer; - -typedef ConcurrentHashTable SimpleTestTable; -typedef ConcurrentHashTable::MultiGetHandle SimpleTestGetHandle; - -// Simplest working CRPT implementation for the hash-table. -struct Pointer : public SimpleTestTable::BaseConfig { - static uintx get_hash(const uintptr_t& value, bool* dead_hash) { +struct Pointer : public AllStatic { + typedef uintptr_t Value; + static uintx get_hash(const Value& value, bool* dead_hash) { return (uintx)value; } - static void* allocate_node(size_t size, const uintptr_t& value) { + static void* allocate_node(size_t size, const Value& value) { return ::malloc(size); } - static void free_node(void* memory, const uintptr_t& value) { + static void free_node(void* memory, const Value& value) { ::free(memory); } }; +typedef ConcurrentHashTable SimpleTestTable; +typedef ConcurrentHashTable::MultiGetHandle SimpleTestGetHandle; + struct SimpleTestLookup { uintptr_t _val; SimpleTestLookup(uintptr_t val) : _val(val) {} @@ -414,18 +412,23 @@ //############################################################################################# -class TestInterface; - -typedef ConcurrentHashTable TestTable; -typedef ConcurrentHashTable::MultiGetHandle TestGetHandle; - -class TestInterface : public TestTable::BaseConfig { +class TestInterface : public AllStatic { public: - static uintx get_hash(const uintptr_t& value, bool* dead_hash) { + typedef uintptr_t Value; + static uintx get_hash(const Value& value, bool* dead_hash) { return (uintx)(value + 18446744073709551557ul) * 18446744073709551557ul; } + static void* allocate_node(size_t size, const Value& value) { + return AllocateHeap(size, mtInternal); + } + static void free_node(void* memory, const Value& value) { + FreeHeap(memory); + } }; +typedef ConcurrentHashTable TestTable; +typedef ConcurrentHashTable::MultiGetHandle TestGetHandle; + struct TestLookup { uintptr_t _val; TestLookup(uintptr_t val) : _val(val) {} diff -r 539748673056 -r a327727090c7 test/hotspot/jtreg/compiler/codecache/stress/UnexpectedDeoptimizationAllTest.java --- a/test/hotspot/jtreg/compiler/codecache/stress/UnexpectedDeoptimizationAllTest.java Mon Jun 24 15:18:05 2019 +0530 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,64 +0,0 @@ -/* - * 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 UnexpectedDeoptimizationAllTest - * @key stress - * @summary stressing code cache by forcing unexpected deoptimizations of all methods - * @library /test/lib / - * @modules java.base/jdk.internal.misc - * java.management - * - * @build sun.hotspot.WhiteBox compiler.codecache.stress.Helper compiler.codecache.stress.TestCaseImpl - * @run driver ClassFileInstaller sun.hotspot.WhiteBox - * sun.hotspot.WhiteBox$WhiteBoxPermission - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions - * -XX:+WhiteBoxAPI -XX:-DeoptimizeRandom - * -XX:CompileCommand=dontinline,compiler.codecache.stress.Helper$TestCase::method - * -XX:-SegmentedCodeCache - * compiler.codecache.stress.UnexpectedDeoptimizationAllTest - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions - * -XX:+WhiteBoxAPI -XX:-DeoptimizeRandom - * -XX:CompileCommand=dontinline,compiler.codecache.stress.Helper$TestCase::method - * -XX:+SegmentedCodeCache - * compiler.codecache.stress.UnexpectedDeoptimizationAllTest - */ - -package compiler.codecache.stress; - -public class UnexpectedDeoptimizationAllTest implements Runnable { - - public static void main(String[] args) { - new CodeCacheStressRunner(new UnexpectedDeoptimizationAllTest()).runTest(); - } - - @Override - public void run() { - Helper.WHITE_BOX.deoptimizeAll(); - try { - Thread.sleep(10); - } catch (Exception e) { - } - } - -} diff -r 539748673056 -r a327727090c7 test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestMetaAccessProvider.java --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestMetaAccessProvider.java Mon Jun 24 15:18:05 2019 +0530 +++ b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestMetaAccessProvider.java Tue Jun 25 15:24:41 2019 +0530 @@ -68,16 +68,22 @@ metaAccess.encodeDeoptActionAndReason(DEOPT_ACTION, DEOPT_REASON, DEBUG_IDS[3]).asInt() }; + private static boolean isUnsafeAnoymous(ResolvedJavaType type) { + return type.getHostClass() != null; + } + @Test public void lookupJavaTypeTest() { for (Class c : classes) { ResolvedJavaType type = metaAccess.lookupJavaType(c); assertNotNull(c.toString(), type); - assertEquals(c.toString(), type.getName(), toInternalName(c.getName())); - assertEquals(c.toString(), type.getName(), toInternalName(type.toJavaName())); - assertEquals(c.toString(), c.getName(), type.toClassName()); - if (!type.isArray()) { - assertEquals(c.toString(), c.getName(), type.toJavaName()); + if (!isUnsafeAnoymous(type)) { + assertEquals(c.toString(), type.getName(), toInternalName(c.getName())); + assertEquals(c.toString(), type.getName(), toInternalName(type.toJavaName())); + assertEquals(c.toString(), c.getName(), type.toClassName()); + if (!type.isArray()) { + assertEquals(c.toString(), c.getName(), type.toJavaName()); + } } } } @@ -92,7 +98,9 @@ ResolvedJavaType[] result = metaAccess.lookupJavaTypes(classes.toArray(new Class[classes.size()])); int counter = 0; for (Class aClass : classes) { - assertEquals("Unexpected javaType: " + result[counter] + " while expecting of class: " + aClass, result[counter].toClassName(), aClass.getName()); + if (!isUnsafeAnoymous(result[counter])) { + assertEquals("Unexpected javaType: " + result[counter] + " while expecting of class: " + aClass, result[counter].toClassName(), aClass.getName()); + } counter++; } } diff -r 539748673056 -r a327727090c7 test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaType.java --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaType.java Mon Jun 24 15:18:05 2019 +0530 +++ b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaType.java Tue Jun 25 15:24:41 2019 +0530 @@ -161,7 +161,11 @@ for (Class c : classes) { ResolvedJavaType type = metaAccess.lookupJavaType(c); ResolvedJavaType host = type.getHostClass(); - assertNull(host); + if (!type.equals(predicateType)) { + assertNull(host); + } else { + assertNotNull(host); + } } class LocalClass {} diff -r 539748673056 -r a327727090c7 test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TypeUniverse.java --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TypeUniverse.java Mon Jun 24 15:18:05 2019 +0530 +++ b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TypeUniverse.java Tue Jun 25 15:24:41 2019 +0530 @@ -51,6 +51,7 @@ import java.util.Queue; import java.util.Set; import java.util.TreeMap; +import java.util.function.Predicate; import java.util.stream.Collectors; import static java.lang.reflect.Modifier.isFinal; @@ -68,6 +69,7 @@ public static final ConstantReflectionProvider constantReflection = JVMCI.getRuntime().getHostJVMCIBackend().getConstantReflection(); public static final Collection> classes = new HashSet<>(); public static final Set javaTypes; + public static final ResolvedJavaType predicateType; public static final Map, Class> arrayClasses = new HashMap<>(); private static List constants; @@ -116,6 +118,9 @@ for (Class c : initialClasses) { addClass(c); } + Predicate predicate = s -> s.length() == 1; + addClass(predicate.getClass()); + predicateType = metaAccess.lookupJavaType(predicate.getClass()); javaTypes = Collections.unmodifiableSet(classes.stream().map(c -> metaAccess.lookupJavaType(c)).collect(Collectors.toSet())); } diff -r 539748673056 -r a327727090c7 test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC04/tc04t001.java --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC04/tc04t001.java Mon Jun 24 15:18:05 2019 +0530 +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC04/tc04t001.java Tue Jun 25 15:24:41 2019 +0530 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 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,6 +24,7 @@ package nsk.jvmti.scenarios.contention.TC04; import java.io.PrintStream; +import java.util.concurrent.*; import nsk.share.*; import nsk.share.jvmti.*; @@ -31,6 +32,7 @@ public class tc04t001 extends DebugeeClass { final static int THREADS_LIMIT = 2; + final static CountDownLatch threadsDoneSignal = new CountDownLatch(THREADS_LIMIT); // run test from command line public static void main(String argv[]) { @@ -68,8 +70,8 @@ } try { - for (int i = 0; i < THREADS_LIMIT; i++) { - threads[i].join(timeout/THREADS_LIMIT); + if (!threadsDoneSignal.await(timeout, TimeUnit.MILLISECONDS)) { + throw new RuntimeException("Threads timeout"); } } catch (InterruptedException e) { throw new Failure(e); @@ -122,6 +124,8 @@ */ private int id; + private static volatile int lastEnterEventsCount; + private static native int enterEventsCount(); public tc04t001Thread(int i) { super("Debuggee Thread " + i); @@ -131,11 +135,13 @@ public synchronized void run() { for (int i = 0; i < INCREMENT_LIMIT; i++) { flicker.waitFor(id); + lastEnterEventsCount = enterEventsCount(); increment(id); try { wait(1); } catch (InterruptedException e) {} } + tc04t001.threadsDoneSignal.countDown(); } static synchronized void increment(int i) { @@ -144,10 +150,24 @@ */ flicker.unlock(i); int temp = value; - for (int j = 0; j < DELAY; j++) ; - try { - sleep(500); - } catch (InterruptedException e) {} + + // Wait in a loop for a MonitorContendedEnter event. + // Timeout is: 20ms * DELAY. + for (int j = 0; j < DELAY; j++) { + try { + sleep(20); + } catch (InterruptedException e) {} + + if (enterEventsCount() > lastEnterEventsCount) { + break; // Got an expected MonitorContendedEnter event + } + } + System.out.println("Thread-" + i + ": increment event: " + enterEventsCount()); + + if (enterEventsCount() == lastEnterEventsCount) { + String msg = "Timeout in waiting for a MonitorContendedEnter event"; + throw new RuntimeException(msg); + } value = temp + 1; } } diff -r 539748673056 -r a327727090c7 test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC04/tc04t001/tc04t001.cpp --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC04/tc04t001/tc04t001.cpp Mon Jun 24 15:18:05 2019 +0530 +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC04/tc04t001/tc04t001.cpp Tue Jun 25 15:24:41 2019 +0530 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 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 @@ -344,6 +344,11 @@ return JNI_OK; } +JNIEXPORT jint JNICALL +Java_nsk_jvmti_scenarios_contention_TC04_tc04t001Thread_enterEventsCount(JNIEnv* jni, jclass klass) { + return enterEventsCount; +} + /* ========================================================================== */ } diff -r 539748673056 -r a327727090c7 test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/GarbageUtils.java --- a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/GarbageUtils.java Mon Jun 24 15:18:05 2019 +0530 +++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/GarbageUtils.java Tue Jun 25 15:24:41 2019 +0530 @@ -57,10 +57,10 @@ } /** - * Returns true if the given error message matches - * one of expected strings. - */ - public boolean accept(String errorMessage) { + * Returns true if the given error message matches + * one of expected strings. + */ + public boolean accept(String errorMessage) { if (expectedStrings == null || expectedStrings.length == 0 || errorMessage == null) { return true; } @@ -81,7 +81,6 @@ public static final StringWriter preloadStringWriter = new StringWriter(1); public static final PrintWriter preloadPrintWriter = new PrintWriter(preloadStringWriter); public static final Throwable preloadThrowable = new Throwable("preload"); - public static final StackTraceElement[] preloadStackTraceElement = preloadThrowable.getStackTrace(); private GarbageUtils() { } @@ -215,8 +214,6 @@ public static int eatMemory(ExecutionController stresser, GarbageProducer gp, long initialFactor, long minMemoryChunk, long factor, OOM_TYPE type) { int numberOfOOMEs = 0; try { - StringWriter sw = new StringWriter(10000); - PrintWriter pw = new PrintWriter(sw); byte[] someMemory = new byte[200000]; //200 Kb try { Runtime runtime = Runtime.getRuntime(); @@ -243,13 +240,11 @@ } catch (OutOfMemoryError e) { someMemory = null; if (type != OOM_TYPE.ANY) { - e.printStackTrace(pw); - pw.close(); - if (type.accept(sw.toString())) { + if (type.accept(e.toString())) { numberOfOOMEs++; } else { // Trying to catch situation when Java generates OOM different type that test trying to catch - throw new TestBug("Test throw OOM of unexpected type." + sw.toString()); + throw new TestBug("Test throw OOM of unexpected type." + e.toString()); } } else { numberOfOOMEs++; @@ -265,13 +260,11 @@ } catch (OutOfMemoryError e) { someMemory = null; if (type != OOM_TYPE.ANY) { - e.printStackTrace(pw); - pw.close(); - if (type.accept(sw.toString())) { + if (type.accept(e.toString())) { numberOfOOMEs++; } else { // Trying to catch situation when Java generates OOM different type that test trying to catch - throw new TestBug("Test throw OOM of unexpected type." + sw.toString()); + throw new TestBug("Test throw OOM of unexpected type." + e.toString()); } } else { numberOfOOMEs++; diff -r 539748673056 -r a327727090c7 test/jdk/ProblemList-graal.txt --- a/test/jdk/ProblemList-graal.txt Mon Jun 24 15:18:05 2019 +0530 +++ b/test/jdk/ProblemList-graal.txt Tue Jun 25 15:24:41 2019 +0530 @@ -27,48 +27,8 @@ # ############################################################################# -java/lang/Class/getDeclaredField/ClassDeclaredFieldsTest.java 8185139 generic-all -java/lang/Class/getDeclaredField/FieldSetAccessibleTest.java 8185139 generic-all -java/lang/invoke/InvokeDynamicPrintArgs.java 8185139 generic-all -java/lang/invoke/MethodHandleConstants.java 8185139 generic-all -java/lang/ProcessBuilder/Basic.java#id0 8185139 generic-all -java/lang/ProcessBuilder/Basic.java#id1 8185139 generic-all -java/lang/ProcessBuilder/SecurityManagerClinit.java 8185139 generic-all -java/lang/ProcessHandle/PermissionTest.java 8185139 generic-all -java/lang/reflect/Proxy/nonPublicProxy/NonPublicProxyClass.java 8185139 generic-all -java/lang/StackWalker/CallerSensitiveMethod/Main.java 8185139 generic-all -java/lang/StackWalker/GetCallerClassTest.java 8185139 generic-all -java/lang/String/concat/WithSecurityManager.java 8185139 generic-all -java/lang/System/Logger/custom/CustomLoggerTest.java 8185139 generic-all -java/lang/System/Logger/default/DefaultLoggerTest.java 8185139 generic-all -java/lang/System/LoggerFinder/BaseLoggerFinderTest/BaseLoggerFinderTest.java 8185139 generic-all -java/lang/System/LoggerFinder/DefaultLoggerFinderTest/DefaultLoggerFinderTest.java 8185139 generic-all -java/lang/System/LoggerFinder/internal/BaseDefaultLoggerFinderTest/BaseDefaultLoggerFinderTest.java 8185139 generic-all -java/lang/System/LoggerFinder/internal/BaseLoggerBridgeTest/BaseLoggerBridgeTest.java 8185139 generic-all -java/lang/System/LoggerFinder/internal/BasePlatformLoggerTest/BasePlatformLoggerTest.java 8185139 generic-all -java/lang/System/LoggerFinder/internal/BootstrapLogger/BootstrapLoggerTest.java 8185139 generic-all -java/lang/System/LoggerFinder/internal/LoggerBridgeTest/LoggerBridgeTest.java 8185139 generic-all -java/lang/System/LoggerFinder/internal/LoggerFinderLoaderTest/LoggerFinderLoaderTest.java 8185139 generic-all -java/lang/System/LoggerFinder/internal/PlatformLoggerBridgeTest/PlatformLoggerBridgeTest.java 8185139 generic-all -java/lang/System/LoggerFinder/jdk/DefaultLoggerBridgeTest/DefaultLoggerBridgeTest.java 8185139 generic-all -java/lang/System/LoggerFinder/jdk/DefaultPlatformLoggerTest/DefaultPlatformLoggerTest.java 8185139 generic-all -java/lang/System/LoggerFinder/LoggerFinderAPI/LoggerFinderAPI.java 8185139 generic-all -java/util/concurrent/atomic/AtomicUpdaters.java 8185139 generic-all -java/util/concurrent/Executors/PrivilegedCallables.java 8185139 generic-all -java/util/logging/FileHandlerPath.java 8185139 generic-all -java/util/logging/FileHandlerPatternExceptions.java 8185139 generic-all -java/util/logging/Logger/setResourceBundle/TestSetResourceBundle.java 8185139 generic-all -java/util/logging/LogManagerAppContextDeadlock.java 8185139 generic-all -java/util/logging/LogManager/Configuration/updateConfiguration/HandlersOnComplexResetUpdate.java 8185139 generic-all -java/util/logging/LogManager/Configuration/updateConfiguration/HandlersOnComplexUpdate.java 8185139 generic-all -java/util/logging/LogManager/Configuration/updateConfiguration/SimpleUpdateConfigurationTest.java 8185139 generic-all -java/util/logging/LogManager/Configuration/updateConfiguration/SimpleUpdateConfigWithInputStreamTest.java 8185139 generic-all -java/util/logging/LogManager/RootLogger/setLevel/TestRootLoggerLevel.java 8185139 generic-all -java/util/logging/RootLogger/RootLevelInConfigFile.java 8185139 generic-all -java/util/logging/TestAppletLoggerContext.java 8185139 generic-all -java/util/logging/TestConfigurationListeners.java 8185139 generic-all -java/util/logging/LogManager/Configuration/ParentLoggerWithHandlerGC.java 8185139 generic-all -java/util/logging/FileHandlerLongLimit.java 8185139 generic-all +java/lang/String/concat/WithSecurityManager.java 8207267 generic-all +java/lang/System/LoggerFinder/LoggerFinderAPI/LoggerFinderAPI.java 8207267 generic-all java/util/concurrent/tck/JSR166TestCase.java 8187486 generic-all diff -r 539748673056 -r a327727090c7 test/jdk/java/lang/Class/getDeclaredField/ClassDeclaredFieldsTest.java --- a/test/jdk/java/lang/Class/getDeclaredField/ClassDeclaredFieldsTest.java Mon Jun 24 15:18:05 2019 +0530 +++ b/test/jdk/java/lang/Class/getDeclaredField/ClassDeclaredFieldsTest.java Tue Jun 25 15:24:41 2019 +0530 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 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 @@ -166,6 +166,7 @@ // Policy for the test... public static class SimplePolicy extends Policy { + static final Policy DEFAULT_POLICY = Policy.getPolicy(); final Permissions permissions; final Permissions allPermissions; final ThreadLocal allowAll; // actually: this should be in a thread locale @@ -187,7 +188,7 @@ @Override public boolean implies(ProtectionDomain domain, Permission permission) { if (allowAll.get().get()) return allPermissions.implies(permission); - return permissions.implies(permission); + return permissions.implies(permission) || DEFAULT_POLICY.implies(domain, permission); } @Override diff -r 539748673056 -r a327727090c7 test/jdk/java/lang/Class/getDeclaredField/FieldSetAccessibleTest.java --- a/test/jdk/java/lang/Class/getDeclaredField/FieldSetAccessibleTest.java Mon Jun 24 15:18:05 2019 +0530 +++ b/test/jdk/java/lang/Class/getDeclaredField/FieldSetAccessibleTest.java Tue Jun 25 15:24:41 2019 +0530 @@ -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 @@ -385,6 +385,8 @@ // Policy for the test... public static class SimplePolicy extends Policy { + static final Policy DEFAULT_POLICY = Policy.getPolicy(); + final Permissions permissions; final Permissions allPermissions; final ThreadLocal allowAll; @@ -420,6 +422,7 @@ return true; } } + if (DEFAULT_POLICY.implies(domain, permission)) return true; return false; } diff -r 539748673056 -r a327727090c7 test/jdk/java/lang/ProcessBuilder/Basic.java --- a/test/jdk/java/lang/ProcessBuilder/Basic.java Mon Jun 24 15:18:05 2019 +0530 +++ b/test/jdk/java/lang/ProcessBuilder/Basic.java Tue Jun 25 15:24:41 2019 +0530 @@ -2602,6 +2602,8 @@ // A Policy class designed to make permissions fiddling very easy. //---------------------------------------------------------------- private static class Policy extends java.security.Policy { + static final java.security.Policy DEFAULT_POLICY = java.security.Policy.getPolicy(); + private Permissions perms; public void setPermissions(Permission...permissions) { @@ -2621,7 +2623,7 @@ } public boolean implies(ProtectionDomain pd, Permission p) { - return perms.implies(p); + return perms.implies(p) || DEFAULT_POLICY.implies(pd, p); } public void refresh() {} diff -r 539748673056 -r a327727090c7 test/jdk/java/lang/ProcessBuilder/SecurityManagerClinit.java --- a/test/jdk/java/lang/ProcessBuilder/SecurityManagerClinit.java Mon Jun 24 15:18:05 2019 +0530 +++ b/test/jdk/java/lang/ProcessBuilder/SecurityManagerClinit.java Tue Jun 25 15:24:41 2019 +0530 @@ -1,5 +1,6 @@ /* * Copyright 2010 Google Inc. All Rights Reserved. + * 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 @@ -35,17 +36,19 @@ import java.security.*; public class SecurityManagerClinit { - private static class Policy extends java.security.Policy { + private static class SimplePolicy extends Policy { + static final Policy DEFAULT_POLICY = Policy.getPolicy(); + private Permissions perms; - public Policy(Permission... permissions) { + public SimplePolicy(Permission... permissions) { perms = new Permissions(); for (Permission permission : permissions) perms.add(permission); } public boolean implies(ProtectionDomain pd, Permission p) { - return perms.implies(p); + return perms.implies(p) || DEFAULT_POLICY.implies(pd, p); } } @@ -54,8 +57,8 @@ System.getProperty("java.home") + File.separator + "bin" + File.separator + "java"; - final Policy policy = - new Policy + final SimplePolicy policy = + new SimplePolicy (new FilePermission("<>", "execute"), new RuntimePermission("setSecurityManager")); Policy.setPolicy(policy); diff -r 539748673056 -r a327727090c7 test/jdk/java/lang/ProcessHandle/PermissionTest.java --- a/test/jdk/java/lang/ProcessHandle/PermissionTest.java Mon Jun 24 15:18:05 2019 +0530 +++ b/test/jdk/java/lang/ProcessHandle/PermissionTest.java Tue Jun 25 15:24:41 2019 +0530 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 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 @@ -178,6 +178,9 @@ } class TestPolicy extends Policy { + + static final Policy DEFAULT_POLICY = Policy.getPolicy(); + private final PermissionCollection permissions = new Permissions(); public TestPolicy() { @@ -222,6 +225,6 @@ @Override public boolean implies(ProtectionDomain domain, Permission perm) { - return permissions.implies(perm); + return permissions.implies(perm) || DEFAULT_POLICY.implies(domain, perm); } } diff -r 539748673056 -r a327727090c7 test/jdk/java/lang/System/Logger/custom/CustomLoggerTest.java --- a/test/jdk/java/lang/System/Logger/custom/CustomLoggerTest.java Mon Jun 24 15:18:05 2019 +0530 +++ b/test/jdk/java/lang/System/Logger/custom/CustomLoggerTest.java Tue Jun 25 15:24:41 2019 +0530 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 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 @@ -704,6 +704,8 @@ public static class SimplePolicy extends Policy { + static final Policy DEFAULT_POLICY = Policy.getPolicy(); + static final RuntimePermission LOGGERFINDER_PERMISSION = new RuntimePermission("loggerFinder"); final Permissions permissions; @@ -736,7 +738,7 @@ @Override public boolean implies(ProtectionDomain domain, Permission permission) { - return permissions().implies(permission); + return permissions().implies(permission) || DEFAULT_POLICY.implies(domain, permission); } @Override diff -r 539748673056 -r a327727090c7 test/jdk/java/lang/System/Logger/default/DefaultLoggerTest.java --- a/test/jdk/java/lang/System/Logger/default/DefaultLoggerTest.java Mon Jun 24 15:18:05 2019 +0530 +++ b/test/jdk/java/lang/System/Logger/default/DefaultLoggerTest.java Tue Jun 25 15:24:41 2019 +0530 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, 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 @@ -884,6 +884,9 @@ } public static class SimplePolicy extends Policy { + + static final Policy DEFAULT_POLICY = Policy.getPolicy(); + static final RuntimePermission LOGGERFINDER_PERMISSION = new RuntimePermission("loggerFinder"); final Permissions permissions; @@ -908,7 +911,7 @@ public boolean implies(ProtectionDomain domain, Permission permission) { if (allowAll.get().get()) return allPermissions.implies(permission); if (allowControl.get().get()) return controlPermissions.implies(permission); - return permissions.implies(permission); + return permissions.implies(permission) || DEFAULT_POLICY.implies(domain, permission); } @Override diff -r 539748673056 -r a327727090c7 test/jdk/java/lang/System/LoggerFinder/BaseLoggerFinderTest/BaseLoggerFinderTest.java --- a/test/jdk/java/lang/System/LoggerFinder/BaseLoggerFinderTest/BaseLoggerFinderTest.java Mon Jun 24 15:18:05 2019 +0530 +++ b/test/jdk/java/lang/System/LoggerFinder/BaseLoggerFinderTest/BaseLoggerFinderTest.java Tue Jun 25 15:24:41 2019 +0530 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 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 @@ -652,6 +652,8 @@ final static RuntimePermission CONTROL = LOGGERFINDER_PERMISSION; final static RuntimePermission ACCESS = new RuntimePermission("accessClassInPackage.jdk.internal.logger"); + static final Policy DEFAULT_POLICY = Policy.getPolicy(); + final Permissions permissions; final ThreadLocal allowControl; final ThreadLocal allowAccess; @@ -678,7 +680,7 @@ @Override public boolean implies(ProtectionDomain domain, Permission permission) { - return getPermissions().implies(permission); + return getPermissions().implies(permission) || DEFAULT_POLICY.implies(domain, permission); } @Override diff -r 539748673056 -r a327727090c7 test/jdk/java/lang/System/LoggerFinder/DefaultLoggerFinderTest/DefaultLoggerFinderTest.java --- a/test/jdk/java/lang/System/LoggerFinder/DefaultLoggerFinderTest/DefaultLoggerFinderTest.java Mon Jun 24 15:18:05 2019 +0530 +++ b/test/jdk/java/lang/System/LoggerFinder/DefaultLoggerFinderTest/DefaultLoggerFinderTest.java Tue Jun 25 15:24:41 2019 +0530 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, 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 @@ -842,6 +842,8 @@ public static class SimplePolicy extends Policy { + static final Policy DEFAULT_POLICY = Policy.getPolicy(); + final Permissions permissions; final Permissions withControlPermissions; final Permissions allPermissions; @@ -865,7 +867,7 @@ public boolean implies(ProtectionDomain domain, Permission permission) { if (allowAll.get().get()) return allPermissions.implies(permission); if (allowControl.get().get()) return withControlPermissions.implies(permission); - return permissions.implies(permission); + return permissions.implies(permission) || DEFAULT_POLICY.implies(domain, permission); } @Override diff -r 539748673056 -r a327727090c7 test/jdk/java/lang/System/LoggerFinder/internal/BaseLoggerBridgeTest/BaseLoggerBridgeTest.java --- a/test/jdk/java/lang/System/LoggerFinder/internal/BaseLoggerBridgeTest/BaseLoggerBridgeTest.java Mon Jun 24 15:18:05 2019 +0530 +++ b/test/jdk/java/lang/System/LoggerFinder/internal/BaseLoggerBridgeTest/BaseLoggerBridgeTest.java Tue Jun 25 15:24:41 2019 +0530 @@ -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 @@ -981,6 +981,8 @@ final static RuntimePermission ACCESS_LOGGER = new RuntimePermission("accessClassInPackage.jdk.internal.logger"); final static RuntimePermission ACCESS_LOGGING = new RuntimePermission("accessClassInPackage.sun.util.logging"); + static final Policy DEFAULT_POLICY = Policy.getPolicy(); + final Permissions permissions; final Permissions allPermissions; final ThreadLocal allowControl; @@ -1019,7 +1021,7 @@ @Override public boolean implies(ProtectionDomain domain, Permission permission) { - return getPermissions().implies(permission); + return getPermissions().implies(permission) || DEFAULT_POLICY.implies(domain, permission); } @Override diff -r 539748673056 -r a327727090c7 test/jdk/java/lang/System/LoggerFinder/internal/BasePlatformLoggerTest/BasePlatformLoggerTest.java --- a/test/jdk/java/lang/System/LoggerFinder/internal/BasePlatformLoggerTest/BasePlatformLoggerTest.java Mon Jun 24 15:18:05 2019 +0530 +++ b/test/jdk/java/lang/System/LoggerFinder/internal/BasePlatformLoggerTest/BasePlatformLoggerTest.java Tue Jun 25 15:24:41 2019 +0530 @@ -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 @@ -663,6 +663,8 @@ final static RuntimePermission CONTROL = LOGGERFINDER_PERMISSION; final static RuntimePermission ACCESS_LOGGING = new RuntimePermission("accessClassInPackage.sun.util.logging"); + static final Policy DEFAULT_POLICY = Policy.getPolicy(); + final Permissions permissions; final Permissions allPermissions; final ThreadLocal allowControl; @@ -700,7 +702,7 @@ @Override public boolean implies(ProtectionDomain domain, Permission permission) { - return getPermissions().implies(permission); + return getPermissions().implies(permission) || DEFAULT_POLICY.implies(domain, permission); } @Override diff -r 539748673056 -r a327727090c7 test/jdk/java/lang/System/LoggerFinder/internal/LoggerBridgeTest/LoggerBridgeTest.java --- a/test/jdk/java/lang/System/LoggerFinder/internal/LoggerBridgeTest/LoggerBridgeTest.java Mon Jun 24 15:18:05 2019 +0530 +++ b/test/jdk/java/lang/System/LoggerFinder/internal/LoggerBridgeTest/LoggerBridgeTest.java Tue Jun 25 15:24:41 2019 +0530 @@ -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 @@ -1026,6 +1026,8 @@ final static RuntimePermission ACCESS_LOGGER = new RuntimePermission("accessClassInPackage.jdk.internal.logger"); final static RuntimePermission ACCESS_LOGGING = new RuntimePermission("accessClassInPackage.sun.util.logging"); + static final Policy DEFAULT_POLICY = Policy.getPolicy(); + final Permissions permissions; final Permissions allPermissions; final ThreadLocal allowControl; @@ -1064,7 +1066,7 @@ @Override public boolean implies(ProtectionDomain domain, Permission permission) { - return getPermissions().implies(permission); + return getPermissions().implies(permission) || DEFAULT_POLICY.implies(domain, permission); } @Override diff -r 539748673056 -r a327727090c7 test/jdk/java/lang/System/LoggerFinder/internal/PlatformLoggerBridgeTest/PlatformLoggerBridgeTest.java --- a/test/jdk/java/lang/System/LoggerFinder/internal/PlatformLoggerBridgeTest/PlatformLoggerBridgeTest.java Mon Jun 24 15:18:05 2019 +0530 +++ b/test/jdk/java/lang/System/LoggerFinder/internal/PlatformLoggerBridgeTest/PlatformLoggerBridgeTest.java Tue Jun 25 15:24:41 2019 +0530 @@ -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 @@ -805,6 +805,8 @@ final static RuntimePermission ACCESS_LOGGER = new RuntimePermission("accessClassInPackage.jdk.internal.logger"); final static RuntimePermission ACCESS_LOGGING = new RuntimePermission("accessClassInPackage.sun.util.logging"); + static final Policy DEFAULT_POLICY = Policy.getPolicy(); + final Permissions permissions; final Permissions allPermissions; final ThreadLocal allowControl; @@ -843,7 +845,7 @@ @Override public boolean implies(ProtectionDomain domain, Permission permission) { - return getPermissions().implies(permission); + return getPermissions().implies(permission) || DEFAULT_POLICY.implies(domain, permission); } @Override diff -r 539748673056 -r a327727090c7 test/jdk/java/lang/System/LoggerFinder/jdk/DefaultLoggerBridgeTest/DefaultLoggerBridgeTest.java --- a/test/jdk/java/lang/System/LoggerFinder/jdk/DefaultLoggerBridgeTest/DefaultLoggerBridgeTest.java Mon Jun 24 15:18:05 2019 +0530 +++ b/test/jdk/java/lang/System/LoggerFinder/jdk/DefaultLoggerBridgeTest/DefaultLoggerBridgeTest.java Tue Jun 25 15:24:41 2019 +0530 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, 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 @@ -801,6 +801,8 @@ final static RuntimePermission ACCESS_LOGGER = new RuntimePermission("accessClassInPackage.jdk.internal.logger"); final static RuntimePermission ACCESS_LOGGING = new RuntimePermission("accessClassInPackage.sun.util.logging"); + static final Policy DEFAULT_POLICY = Policy.getPolicy(); + final Permissions permissions; final Permissions allPermissions; final ThreadLocal allowControl; @@ -839,7 +841,7 @@ @Override public boolean implies(ProtectionDomain domain, Permission permission) { - return getPermissions().implies(permission); + return getPermissions().implies(permission) || DEFAULT_POLICY.implies(domain, permission); } @Override diff -r 539748673056 -r a327727090c7 test/jdk/java/lang/System/LoggerFinder/jdk/DefaultPlatformLoggerTest/DefaultPlatformLoggerTest.java --- a/test/jdk/java/lang/System/LoggerFinder/jdk/DefaultPlatformLoggerTest/DefaultPlatformLoggerTest.java Mon Jun 24 15:18:05 2019 +0530 +++ b/test/jdk/java/lang/System/LoggerFinder/jdk/DefaultPlatformLoggerTest/DefaultPlatformLoggerTest.java Tue Jun 25 15:24:41 2019 +0530 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, 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 @@ -499,6 +499,8 @@ public static final RuntimePermission LOGGERFINDER_PERMISSION = new RuntimePermission("loggerFinder"); + static final Policy DEFAULT_POLICY = Policy.getPolicy(); + final Permissions permissions; final Permissions withControlPermissions; final Permissions allPermissions; @@ -522,7 +524,7 @@ public boolean implies(ProtectionDomain domain, Permission permission) { if (allowAll.get().get()) return allPermissions.implies(permission); if (allowControl.get().get()) return withControlPermissions.implies(permission); - return permissions.implies(permission); + return permissions.implies(permission) || DEFAULT_POLICY.implies(domain, permission); } @Override diff -r 539748673056 -r a327727090c7 test/jdk/java/lang/invoke/InvokeDynamicPrintArgs.java --- a/test/jdk/java/lang/invoke/InvokeDynamicPrintArgs.java Mon Jun 24 15:18:05 2019 +0530 +++ b/test/jdk/java/lang/invoke/InvokeDynamicPrintArgs.java Tue Jun 25 15:24:41 2019 +0530 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2013, 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 @@ -234,6 +234,8 @@ } static class TestPolicy extends Policy { + static final Policy DEFAULT_POLICY = Policy.getPolicy(); + final PermissionCollection permissions = new Permissions(); TestPolicy() { permissions.add(new java.io.FilePermission("<>", "read")); @@ -247,7 +249,7 @@ } public boolean implies(ProtectionDomain domain, Permission perm) { - return permissions.implies(perm); + return permissions.implies(perm) || DEFAULT_POLICY.implies(domain, perm); } } } diff -r 539748673056 -r a327727090c7 test/jdk/java/lang/invoke/MethodHandleConstants.java --- a/test/jdk/java/lang/invoke/MethodHandleConstants.java Mon Jun 24 15:18:05 2019 +0530 +++ b/test/jdk/java/lang/invoke/MethodHandleConstants.java Tue Jun 25 15:24:41 2019 +0530 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2013, 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 @@ -169,6 +169,8 @@ } static class TestPolicy extends Policy { + static final Policy DEFAULT_POLICY = Policy.getPolicy(); + final PermissionCollection permissions = new Permissions(); TestPolicy() { permissions.add(new java.io.FilePermission("<>", "read")); @@ -182,7 +184,7 @@ } public boolean implies(ProtectionDomain domain, Permission perm) { - return permissions.implies(perm); + return permissions.implies(perm) || DEFAULT_POLICY.implies(domain, perm); } } } diff -r 539748673056 -r a327727090c7 test/jdk/java/net/MulticastSocket/Promiscuous.java --- a/test/jdk/java/net/MulticastSocket/Promiscuous.java Mon Jun 24 15:18:05 2019 +0530 +++ b/test/jdk/java/net/MulticastSocket/Promiscuous.java Tue Jun 25 15:24:41 2019 +0530 @@ -22,7 +22,7 @@ * /* @test - * @bug 8014499 + * @bug 8014499 8219804 * @library /test/lib * @summary Test for interference when two sockets are bound to the same * port but joined to different multicast groups @@ -44,11 +44,20 @@ throws IOException { byte[] ba = new byte[100]; - DatagramPacket p = new DatagramPacket(ba, ba.length); + DatagramPacket p; try { - mc.receive(p); - int recvId = Integer.parseInt( - new String(p.getData(), 0, p.getLength(), "UTF-8")); + String data = null; + while (true) { + p = new DatagramPacket(ba, ba.length); + mc.receive(p); + data = new String(p.getData(), 0, p.getLength(), "UTF-8"); + if (data.length() > UUID.length() && data.startsWith(UUID)) { + data = data.substring(UUID.length()); + break; + } + logUnexpected(p); + } + int recvId = Integer.parseInt(data); if (datagramExpected) { if (recvId != id) throw new RuntimeException("Unexpected id, got " + recvId @@ -67,6 +76,20 @@ } } + static void logUnexpected(DatagramPacket p) { + byte[] ba = p.getData(); + System.out.printf("Unexpected packet: length: %d. First three bytes: %d, %d, %d\n", + p.getLength(), ba[0], ba[1], ba[2]); + } + + static final String UUID; // process-id : currentTimeMillis + + static { + String s1 = Long.toString(ProcessHandle.current().pid()); + String s2 = Long.toString(System.currentTimeMillis()); + UUID = "<" + s1 + s2 + ">"; + } + static void test(InetAddress group1, InetAddress group2) throws IOException { @@ -79,7 +102,7 @@ mc1.setSoTimeout(TIMEOUT); mc2.setSoTimeout(TIMEOUT); int nextId = id; - byte[] msg = Integer.toString(nextId).getBytes("UTF-8"); + byte[] msg = (UUID + Integer.toString(nextId)).getBytes("UTF-8"); DatagramPacket p = new DatagramPacket(msg, msg.length); p.setAddress(group1); p.setPort(port); @@ -97,7 +120,7 @@ receive(mc2, false, 0); nextId = ++id; - msg = Integer.toString(nextId).getBytes("UTF-8"); + msg = (UUID + Integer.toString(nextId)).getBytes("UTF-8"); p = new DatagramPacket(msg, msg.length); p.setAddress(group2); p.setPort(port); @@ -116,7 +139,6 @@ public static void main(String args[]) throws IOException { IPSupport.throwSkippedExceptionIfNonOperational(); - String os = System.getProperty("os.name"); // Requires IP_MULTICAST_ALL on Linux (new since 2.6.31) so skip @@ -133,8 +155,8 @@ } // multicast groups used for the test - InetAddress ip4Group1 = InetAddress.getByName("224.7.8.9"); - InetAddress ip4Group2 = InetAddress.getByName("225.4.5.6"); + InetAddress ip4Group1 = InetAddress.getByName("224.0.0.120"); + InetAddress ip4Group2 = InetAddress.getByName("224.0.0.121"); test(ip4Group1, ip4Group2); } diff -r 539748673056 -r a327727090c7 test/jdk/java/security/KeyAgreement/KeyAgreementTest.java --- a/test/jdk/java/security/KeyAgreement/KeyAgreementTest.java Mon Jun 24 15:18:05 2019 +0530 +++ b/test/jdk/java/security/KeyAgreement/KeyAgreementTest.java Tue Jun 25 15:24:41 2019 +0530 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 4936763 8184359 8205476 + * @bug 4936763 8184359 8205476 8226307 * @summary KeyAgreement Test with all supported algorithms from JCE. * Arguments order * It removes com/sun/crypto/provider/KeyAgreement/DHGenSecretKey.java @@ -73,7 +73,7 @@ // SEC2 prime curves "secp112r1", "secp112r2", "secp128r1", "secp128r2", "secp160k1", "secp160r1", "secp192k1", "secp192r1", "secp224k1", "secp224r1", - "secp256k1", "secp256r1", "secp384r1", "secp521r1", + "secp256k1", "secp256r1", "secp384r1", "secp521r1", "SECP521R1", // ANSI X9.62 prime curves "X9.62 prime192v2", "X9.62 prime192v3", "X9.62 prime239v1", "X9.62 prime239v2", "X9.62 prime239v3", @@ -87,7 +87,7 @@ "X9.62 c2tnb239v1", "X9.62 c2tnb239v2", "X9.62 c2tnb239v3", "X9.62 c2tnb359v1", "X9.62 c2tnb431r1" ), - XDH("X25519", "X448"), + XDH("X25519", "X448", "x25519"), // There is no curve for DiffieHellman DiffieHellman(new String[]{}); diff -r 539748673056 -r a327727090c7 test/jdk/java/security/Policy/Dynamic/DynamicPolicy.java --- a/test/jdk/java/security/Policy/Dynamic/DynamicPolicy.java Mon Jun 24 15:18:05 2019 +0530 +++ b/test/jdk/java/security/Policy/Dynamic/DynamicPolicy.java Tue Jun 25 15:24:41 2019 +0530 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -28,6 +28,7 @@ public class DynamicPolicy extends Policy{ + static final Policy DEFAULT_POLICY = Policy.getPolicy(); // do this early before setPolicy is called static int refresher = 0; @@ -48,7 +49,7 @@ } public boolean implies(ProtectionDomain pd, Permission p) { - return getPermissions(pd).implies(p); + return getPermissions(pd).implies(p) || DEFAULT_POLICY.implies(pd, p); } public PermissionCollection getPermissions(ProtectionDomain pd) { diff -r 539748673056 -r a327727090c7 test/jdk/java/util/concurrent/Executors/PrivilegedCallables.java --- a/test/jdk/java/util/concurrent/Executors/PrivilegedCallables.java Mon Jun 24 15:18:05 2019 +0530 +++ b/test/jdk/java/util/concurrent/Executors/PrivilegedCallables.java Tue Jun 25 15:24:41 2019 +0530 @@ -70,6 +70,8 @@ // A Policy class designed to make permissions fiddling very easy. //---------------------------------------------------------------- static class Policy extends java.security.Policy { + static final java.security.Policy DEFAULT_POLICY = java.security.Policy.getPolicy(); + private Permissions perms; public void setPermissions(Permission...permissions) { @@ -89,7 +91,7 @@ } public boolean implies(ProtectionDomain pd, Permission p) { - return perms.implies(p); + return perms.implies(p) || DEFAULT_POLICY.implies(pd, p); } public void refresh() {} diff -r 539748673056 -r a327727090c7 test/jdk/java/util/logging/FileHandlerLongLimit.java --- a/test/jdk/java/util/logging/FileHandlerLongLimit.java Mon Jun 24 15:18:05 2019 +0530 +++ b/test/jdk/java/util/logging/FileHandlerLongLimit.java Tue Jun 25 15:24:41 2019 +0530 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2015, 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 @@ -471,6 +471,8 @@ public static class SimplePolicy extends Policy { + static final Policy DEFAULT_POLICY = Policy.getPolicy(); + final Permissions permissions; final Permissions allPermissions; final AtomicBoolean allowAll; @@ -490,7 +492,7 @@ @Override public boolean implies(ProtectionDomain domain, Permission permission) { if (allowAll.get()) return allPermissions.implies(permission); - return permissions.implies(permission); + return permissions.implies(permission) || DEFAULT_POLICY.implies(domain, permission); } @Override diff -r 539748673056 -r a327727090c7 test/jdk/java/util/logging/FileHandlerPath.java --- a/test/jdk/java/util/logging/FileHandlerPath.java Mon Jun 24 15:18:05 2019 +0530 +++ b/test/jdk/java/util/logging/FileHandlerPath.java Tue Jun 25 15:24:41 2019 +0530 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 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 @@ -270,6 +270,8 @@ public static class SimplePolicy extends Policy { + static final Policy DEFAULT_POLICY = Policy.getPolicy(); + final Permissions permissions; final Permissions allPermissions; final AtomicBoolean allowAll; @@ -297,7 +299,7 @@ @Override public boolean implies(ProtectionDomain domain, Permission permission) { if (allowAll.get()) return allPermissions.implies(permission); - return permissions.implies(permission); + return permissions.implies(permission) || DEFAULT_POLICY.implies(domain, permission); } @Override diff -r 539748673056 -r a327727090c7 test/jdk/java/util/logging/FileHandlerPatternExceptions.java --- a/test/jdk/java/util/logging/FileHandlerPatternExceptions.java Mon Jun 24 15:18:05 2019 +0530 +++ b/test/jdk/java/util/logging/FileHandlerPatternExceptions.java Tue Jun 25 15:24:41 2019 +0530 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 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 @@ -294,6 +294,8 @@ public static class SimplePolicy extends Policy { + static final Policy DEFAULT_POLICY = Policy.getPolicy(); + final Permissions permissions; final Permissions allPermissions; final AtomicBoolean allowAll; @@ -313,7 +315,7 @@ @Override public boolean implies(ProtectionDomain domain, Permission permission) { if (allowAll.get()) return allPermissions.implies(permission); - return permissions.implies(permission); + return permissions.implies(permission) || DEFAULT_POLICY.implies(domain, permission); } @Override diff -r 539748673056 -r a327727090c7 test/jdk/java/util/logging/LogManager/Configuration/ParentLoggerWithHandlerGC.java --- a/test/jdk/java/util/logging/LogManager/Configuration/ParentLoggerWithHandlerGC.java Mon Jun 24 15:18:05 2019 +0530 +++ b/test/jdk/java/util/logging/LogManager/Configuration/ParentLoggerWithHandlerGC.java Tue Jun 25 15:24:41 2019 +0530 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 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 @@ -480,6 +480,8 @@ public static class SimplePolicy extends Policy { + static final Policy DEFAULT_POLICY = Policy.getPolicy(); + final Permissions permissions; final Permissions allPermissions; final AtomicBoolean allowAll; @@ -499,7 +501,7 @@ @Override public boolean implies(ProtectionDomain domain, Permission permission) { if (allowAll.get()) return allPermissions.implies(permission); - return permissions.implies(permission); + return permissions.implies(permission) || DEFAULT_POLICY.implies(domain, permission); } @Override diff -r 539748673056 -r a327727090c7 test/jdk/java/util/logging/LogManager/Configuration/updateConfiguration/HandlersOnComplexResetUpdate.java --- a/test/jdk/java/util/logging/LogManager/Configuration/updateConfiguration/HandlersOnComplexResetUpdate.java Mon Jun 24 15:18:05 2019 +0530 +++ b/test/jdk/java/util/logging/LogManager/Configuration/updateConfiguration/HandlersOnComplexResetUpdate.java Tue Jun 25 15:24:41 2019 +0530 @@ -522,6 +522,8 @@ public static class SimplePolicy extends Policy { + static final Policy DEFAULT_POLICY = Policy.getPolicy(); + final Permissions permissions; final Permissions allPermissions; final ThreadLocal allowAll; // actually: this should be in a thread locale @@ -541,7 +543,7 @@ @Override public boolean implies(ProtectionDomain domain, Permission permission) { if (allowAll.get().get()) return allPermissions.implies(permission); - return permissions.implies(permission); + return permissions.implies(permission) || DEFAULT_POLICY.implies(domain, permission); } @Override diff -r 539748673056 -r a327727090c7 test/jdk/java/util/logging/LogManager/Configuration/updateConfiguration/HandlersOnComplexUpdate.java --- a/test/jdk/java/util/logging/LogManager/Configuration/updateConfiguration/HandlersOnComplexUpdate.java Mon Jun 24 15:18:05 2019 +0530 +++ b/test/jdk/java/util/logging/LogManager/Configuration/updateConfiguration/HandlersOnComplexUpdate.java Tue Jun 25 15:24:41 2019 +0530 @@ -521,6 +521,8 @@ public static class SimplePolicy extends Policy { + static final Policy DEFAULT_POLICY = Policy.getPolicy(); + final Permissions permissions; final Permissions allPermissions; final ThreadLocal allowAll; // actually: this should be in a thread locale @@ -540,7 +542,7 @@ @Override public boolean implies(ProtectionDomain domain, Permission permission) { if (allowAll.get().get()) return allPermissions.implies(permission); - return permissions.implies(permission); + return permissions.implies(permission) || DEFAULT_POLICY.implies(domain, permission); } @Override diff -r 539748673056 -r a327727090c7 test/jdk/java/util/logging/LogManager/Configuration/updateConfiguration/SimpleUpdateConfigurationTest.java --- a/test/jdk/java/util/logging/LogManager/Configuration/updateConfiguration/SimpleUpdateConfigurationTest.java Mon Jun 24 15:18:05 2019 +0530 +++ b/test/jdk/java/util/logging/LogManager/Configuration/updateConfiguration/SimpleUpdateConfigurationTest.java Tue Jun 25 15:24:41 2019 +0530 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 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 @@ -652,6 +652,8 @@ public static class SimplePolicy extends Policy { + static final Policy DEFAULT_POLICY = Policy.getPolicy(); + final Permissions basic; final Permissions control; final Permissions all; @@ -690,7 +692,7 @@ @Override public boolean implies(ProtectionDomain domain, Permission permission) { - return getPermissions(domain).implies(permission); + return getPermissions(domain).implies(permission) || DEFAULT_POLICY.implies(domain, permission); } public PermissionCollection permissions() { diff -r 539748673056 -r a327727090c7 test/jdk/java/util/logging/LogManager/RootLogger/setLevel/TestRootLoggerLevel.java --- a/test/jdk/java/util/logging/LogManager/RootLogger/setLevel/TestRootLoggerLevel.java Mon Jun 24 15:18:05 2019 +0530 +++ b/test/jdk/java/util/logging/LogManager/RootLogger/setLevel/TestRootLoggerLevel.java Tue Jun 25 15:24:41 2019 +0530 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -119,6 +119,9 @@ } private static final class SimplePolicy extends Policy { + + static final Policy DEFAULT_POLICY = Policy.getPolicy(); + private final Permissions perms; private static final Permissions permissions(Permission... perms) { @@ -141,7 +144,7 @@ @Override public boolean implies(ProtectionDomain domain, Permission permission) { - return perms.implies(permission); + return perms.implies(permission) || DEFAULT_POLICY.implies(domain, permission); } } diff -r 539748673056 -r a327727090c7 test/jdk/java/util/logging/LogManagerAppContextDeadlock.java --- a/test/jdk/java/util/logging/LogManagerAppContextDeadlock.java Mon Jun 24 15:18:05 2019 +0530 +++ b/test/jdk/java/util/logging/LogManagerAppContextDeadlock.java Tue Jun 25 15:24:41 2019 +0530 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -340,6 +340,8 @@ // Policy for the test... public static class SimplePolicy extends Policy { + static final Policy DEFAULT_POLICY = Policy.getPolicy(); + final Permissions permissions; final Permissions allPermissions; final ThreadLocal allowAll; // actually: this should be in a thread locale @@ -360,7 +362,7 @@ @Override public boolean implies(ProtectionDomain domain, Permission permission) { if (allowAll.get().get()) return allPermissions.implies(permission); - return permissions.implies(permission); + return permissions.implies(permission) || DEFAULT_POLICY.implies(domain, permission); } @Override diff -r 539748673056 -r a327727090c7 test/jdk/java/util/logging/RootLogger/RootLevelInConfigFile.java --- a/test/jdk/java/util/logging/RootLogger/RootLevelInConfigFile.java Mon Jun 24 15:18:05 2019 +0530 +++ b/test/jdk/java/util/logging/RootLogger/RootLevelInConfigFile.java Tue Jun 25 15:24:41 2019 +0530 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -176,6 +176,8 @@ static final class SimplePolicy extends Policy { + static final Policy DEFAULT_POLICY = Policy.getPolicy(); + final PermissionCollection perms = new Permissions(); public SimplePolicy(String configFile) { perms.add(new LoggingPermission("control", null)); @@ -187,7 +189,7 @@ @Override public boolean implies(ProtectionDomain domain, Permission permission) { - return perms.implies(permission); + return perms.implies(permission) || DEFAULT_POLICY.implies(domain, permission); } } diff -r 539748673056 -r a327727090c7 test/jdk/java/util/logging/TestAppletLoggerContext.java --- a/test/jdk/java/util/logging/TestAppletLoggerContext.java Mon Jun 24 15:18:05 2019 +0530 +++ b/test/jdk/java/util/logging/TestAppletLoggerContext.java Tue Jun 25 15:24:41 2019 +0530 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -72,6 +72,9 @@ // Avoids the hassle of dealing with files and system props... static class SimplePolicy extends Policy { + + static final Policy DEFAULT_POLICY = Policy.getPolicy(); + private final Permissions perms; public SimplePolicy(Permission... permissions) { perms = new Permissions(); @@ -89,7 +92,7 @@ } @Override public boolean implies(ProtectionDomain pd, Permission p) { - return perms.implies(p); + return perms.implies(p) || DEFAULT_POLICY.implies(pd, p); } } diff -r 539748673056 -r a327727090c7 test/jdk/java/util/logging/TestConfigurationListeners.java --- a/test/jdk/java/util/logging/TestConfigurationListeners.java Mon Jun 24 15:18:05 2019 +0530 +++ b/test/jdk/java/util/logging/TestConfigurationListeners.java Tue Jun 25 15:24:41 2019 +0530 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 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 @@ -458,6 +458,8 @@ public static class SimplePolicy extends Policy { + static final Policy DEFAULT_POLICY = Policy.getPolicy(); + final Permissions permissions; public SimplePolicy(TestCase test) { permissions = new Permissions(); @@ -472,7 +474,7 @@ @Override public boolean implies(ProtectionDomain domain, Permission permission) { - return permissions.implies(permission); + return permissions.implies(permission) || DEFAULT_POLICY.implies(domain, permission); } @Override diff -r 539748673056 -r a327727090c7 test/jdk/sun/security/tools/keytool/PSS.java --- a/test/jdk/sun/security/tools/keytool/PSS.java Mon Jun 24 15:18:05 2019 +0530 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,112 +0,0 @@ -/* - * 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 8215694 8222987 - * @summary keytool cannot generate RSASSA-PSS certificates - * @library /test/lib - * @modules java.base/sun.security.util - * java.base/sun.security.x509 - * @requires os.family != "solaris" - * @run main PSS - */ - -// This test is excluded from Solaris because the 8192-bit RSA key pair -// generator is extremely slow there. - -import jdk.test.lib.Asserts; -import jdk.test.lib.SecurityTools; -import jdk.test.lib.process.OutputAnalyzer; -import jdk.test.lib.security.DerUtils; -import sun.security.util.ObjectIdentifier; -import sun.security.x509.AlgorithmId; - -import java.io.File; -import java.security.KeyStore; -import java.security.cert.X509Certificate; - -public class PSS { - - public static void main(String[] args) throws Exception { - - genkeypair("p", "-keyalg RSASSA-PSS -sigalg RSASSA-PSS") - .shouldHaveExitValue(0); - - genkeypair("a", "-keyalg RSA -sigalg RSASSA-PSS -keysize 2048") - .shouldHaveExitValue(0); - - genkeypair("b", "-keyalg RSA -sigalg RSASSA-PSS -keysize 4096") - .shouldHaveExitValue(0); - - genkeypair("c", "-keyalg RSA -sigalg RSASSA-PSS -keysize 8192") - .shouldHaveExitValue(0); - - KeyStore ks = KeyStore.getInstance( - new File("ks"), "changeit".toCharArray()); - - check((X509Certificate)ks.getCertificate("p"), "RSASSA-PSS", - AlgorithmId.SHA256_oid); - - check((X509Certificate)ks.getCertificate("a"), "RSA", - AlgorithmId.SHA256_oid); - - check((X509Certificate)ks.getCertificate("b"), "RSA", - AlgorithmId.SHA384_oid); - - check((X509Certificate)ks.getCertificate("c"), "RSA", - AlgorithmId.SHA512_oid); - - // More commands - kt("-certreq -alias p -sigalg RSASSA-PSS -file p.req") - .shouldHaveExitValue(0); - - kt("-gencert -alias a -sigalg RSASSA-PSS -infile p.req -outfile p.cert") - .shouldHaveExitValue(0); - - kt("-importcert -alias p -file p.cert") - .shouldHaveExitValue(0); - - kt("-selfcert -alias p -sigalg RSASSA-PSS") - .shouldHaveExitValue(0); - } - - static OutputAnalyzer genkeypair(String alias, String options) - throws Exception { - return kt("-genkeypair -alias " + alias - + " -dname CN=" + alias + " " + options); - } - - static OutputAnalyzer kt(String cmd) - throws Exception { - return SecurityTools.keytool("-storepass changeit -keypass changeit " - + "-keystore ks " + cmd); - } - - static void check(X509Certificate cert, String expectedKeyAlg, - ObjectIdentifier expectedMdAlg) throws Exception { - Asserts.assertEQ(cert.getPublicKey().getAlgorithm(), expectedKeyAlg); - Asserts.assertEQ(cert.getSigAlgName(), "RSASSA-PSS"); - DerUtils.checkAlg(cert.getSigAlgParams(), "000", expectedMdAlg); - } -} diff -r 539748673056 -r a327727090c7 test/jdk/sun/security/tools/keytool/pss/PSS.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/jdk/sun/security/tools/keytool/pss/PSS.java Tue Jun 25 15:24:41 2019 +0530 @@ -0,0 +1,115 @@ +/* + * 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 8215694 8222987 8225257 + * @summary keytool cannot generate RSASSA-PSS certificates + * @library /test/lib + * @build java.base/sun.security.rsa.RSAKeyPairGenerator + * @modules java.base/sun.security.util + * java.base/sun.security.x509 + * @requires os.family != "solaris" + * @run main PSS + */ + +// This test is excluded from Solaris because the 8192-bit RSA key pair +// generator is extremely slow there. + +import jdk.test.lib.Asserts; +import jdk.test.lib.SecurityTools; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.security.DerUtils; +import sun.security.util.ObjectIdentifier; +import sun.security.x509.AlgorithmId; + +import java.io.File; +import java.security.KeyStore; +import java.security.cert.X509Certificate; + +public class PSS { + + public static void main(String[] args) throws Exception { + + genkeypair("p", "-keyalg RSASSA-PSS -sigalg RSASSA-PSS") + .shouldHaveExitValue(0); + + genkeypair("a", "-keyalg RSA -sigalg RSASSA-PSS -keysize 2048") + .shouldHaveExitValue(0); + + genkeypair("b", "-keyalg RSA -sigalg RSASSA-PSS -keysize 4096") + .shouldHaveExitValue(0); + + genkeypair("c", "-keyalg RSA -sigalg RSASSA-PSS -keysize 8192") + .shouldHaveExitValue(0); + + KeyStore ks = KeyStore.getInstance( + new File("ks"), "changeit".toCharArray()); + + check((X509Certificate)ks.getCertificate("p"), "RSASSA-PSS", + AlgorithmId.SHA256_oid); + + check((X509Certificate)ks.getCertificate("a"), "RSA", + AlgorithmId.SHA256_oid); + + check((X509Certificate)ks.getCertificate("b"), "RSA", + AlgorithmId.SHA384_oid); + + check((X509Certificate)ks.getCertificate("c"), "RSA", + AlgorithmId.SHA512_oid); + + // More commands + kt("-certreq -alias p -sigalg RSASSA-PSS -file p.req") + .shouldHaveExitValue(0); + + kt("-gencert -alias a -sigalg RSASSA-PSS -infile p.req -outfile p.cert") + .shouldHaveExitValue(0); + + kt("-importcert -alias p -file p.cert") + .shouldHaveExitValue(0); + + kt("-selfcert -alias p -sigalg RSASSA-PSS") + .shouldHaveExitValue(0); + } + + static OutputAnalyzer genkeypair(String alias, String options) + throws Exception { + String patchArg = "-J--patch-module=java.base=" + System.getProperty("test.classes") + + File.separator + "patches" + File.separator + "java.base"; + return kt(patchArg + " -genkeypair -alias " + alias + + " -dname CN=" + alias + " " + options); + } + + static OutputAnalyzer kt(String cmd) + throws Exception { + return SecurityTools.keytool("-storepass changeit -keypass changeit " + + "-keystore ks " + cmd); + } + + static void check(X509Certificate cert, String expectedKeyAlg, + ObjectIdentifier expectedMdAlg) throws Exception { + Asserts.assertEQ(cert.getPublicKey().getAlgorithm(), expectedKeyAlg); + Asserts.assertEQ(cert.getSigAlgName(), "RSASSA-PSS"); + DerUtils.checkAlg(cert.getSigAlgParams(), "000", expectedMdAlg); + } +} diff -r 539748673056 -r a327727090c7 test/jdk/sun/security/tools/keytool/pss/java.base/sun/security/rsa/RSAKeyPairGenerator.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/jdk/sun/security/tools/keytool/pss/java.base/sun/security/rsa/RSAKeyPairGenerator.java Tue Jun 25 15:24:41 2019 +0530 @@ -0,0 +1,273 @@ +/* + * 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. + */ + +package sun.security.rsa; + +import java.math.BigInteger; + +import java.security.*; +import java.security.spec.AlgorithmParameterSpec; +import java.security.spec.RSAKeyGenParameterSpec; + +import sun.security.jca.JCAUtil; +import sun.security.x509.AlgorithmId; +import static sun.security.rsa.RSAUtil.KeyType; + +/** + * Fake RSA keypair generation. + */ +public abstract class RSAKeyPairGenerator extends KeyPairGeneratorSpi { + + // public exponent to use + private BigInteger publicExponent; + + // size of the key to generate, >= RSAKeyFactory.MIN_MODLEN + private int keySize; + + private final KeyType type; + private AlgorithmId rsaId; + + RSAKeyPairGenerator(KeyType type, int defKeySize) { + this.type = type; + // initialize to default in case the app does not call initialize() + initialize(defKeySize, null); + } + + // initialize the generator. See JCA doc + public void initialize(int keySize, SecureRandom random) { + try { + initialize(new RSAKeyGenParameterSpec(keySize, + RSAKeyGenParameterSpec.F4), random); + } catch (InvalidAlgorithmParameterException iape) { + throw new InvalidParameterException(iape.getMessage()); + } + } + + // second initialize method. See JCA doc. + public void initialize(AlgorithmParameterSpec params, SecureRandom random) + throws InvalidAlgorithmParameterException { + if (params instanceof RSAKeyGenParameterSpec == false) { + throw new InvalidAlgorithmParameterException + ("Params must be instance of RSAKeyGenParameterSpec"); + } + + RSAKeyGenParameterSpec rsaSpec = (RSAKeyGenParameterSpec)params; + int tmpKeySize = rsaSpec.getKeysize(); + BigInteger tmpPublicExponent = rsaSpec.getPublicExponent(); + AlgorithmParameterSpec tmpParams = rsaSpec.getKeyParams(); + + if (tmpPublicExponent == null) { + tmpPublicExponent = RSAKeyGenParameterSpec.F4; + } else { + if (tmpPublicExponent.compareTo(RSAKeyGenParameterSpec.F0) < 0) { + throw new InvalidAlgorithmParameterException + ("Public exponent must be 3 or larger"); + } + if (tmpPublicExponent.bitLength() > tmpKeySize) { + throw new InvalidAlgorithmParameterException + ("Public exponent must be smaller than key size"); + } + } + + // do not allow unreasonably large key sizes, probably user error + try { + RSAKeyFactory.checkKeyLengths(tmpKeySize, tmpPublicExponent, + 512, 64 * 1024); + } catch (InvalidKeyException e) { + throw new InvalidAlgorithmParameterException( + "Invalid key sizes", e); + } + + try { + this.rsaId = RSAUtil.createAlgorithmId(type, tmpParams); + } catch (ProviderException e) { + throw new InvalidAlgorithmParameterException( + "Invalid key parameters", e); + } + + this.keySize = tmpKeySize; + this.publicExponent = tmpPublicExponent; + } + + // generate the keypair. See JCA doc + public KeyPair generateKeyPair() { + + // accommodate odd key sizes in case anybody wants to use them + BigInteger e = publicExponent; + if (!e.equals(RSAKeyGenParameterSpec.F4)) { + throw new AssertionError("Only support F4 now"); + } + BigInteger p, q, n; + + // Pre-calculated p and q for e == RSAKeyGenParameterSpec.F4 + switch (keySize) { + case 2048: + p = new BigInteger("1600840041787354447543653385760927" + + "2642568308955833364523274045522752644800599" + + "8669541532595690224703734511692014533312515" + + "1867029838883431415692353449578487671384896" + + "6611685764860941767986520897595108597563035" + + "4023785639802607792535812062420427283857665" + + "9883578590844700707106157871508280052743363" + + "65749456332400771"); + q = new BigInteger("1303880717101677622201474394769850" + + "7257196073324816341282215626935164930077468" + + "5999131251387556761167658937349436378464220" + + "4831804147777472146628148336776639855791417" + + "3849903041999943901924899580268176393595653" + + "7357080543898614581363167420619163047562600" + + "6155574020606891195960345238780709194499010" + + "43652862954645301"); + break; + case 4096: + p = new BigInteger("2985635754414679487171962796211911" + + "1563710734938215274736352092606404045130913" + + "2477365484439939846705721840432140066578525" + + "0762327458086280430118434094733412377416194" + + "8736124795243564050755767519346747209606612" + + "5835460937739428885308798309679495432910469" + + "0294757621321446003970767164933974474924664" + + "1513767092845098947552598109657871041666676" + + "2945573325433283821164032766425479703026349" + + "9433641551427112483593214628620450175257586" + + "4350119143877183562692754400346175237007314" + + "7121580349193179272551363894896336921717843" + + "3734726842184251708799134654802475890197293" + + "9094908310578403843742664173424031260840446" + + "591633359364559754200663"); + q = new BigInteger("2279248439141087793789384816271625" + + "1304008816573950275844533962181244003563987" + + "6638461665174020058827698592331066726709304" + + "9231319346136709972639455506783245161859951" + + "6191872757335765533547033659834427437142631" + + "3801232751161907082392011429712327250253948" + + "6012497852063361866175243227579880020724881" + + "9393797645220239009219998518884396282407710" + + "7199202450846395844337846503427790307364624" + + "5124871273035872938616425951596065309519651" + + "1519189356431513094684173807318945903212527" + + "7712469749366620048658571121822171067675915" + + "5479178304648399924549334007222294762969503" + + "5341584429803583589276956979963609078497238" + + "760757619468018224491053"); + break; + case 8192: + p = new BigInteger("9821669838446774374944535804569858" + + "0553278885576950130485823829973470553571905" + + "3014418421996241500307589880457361653957913" + + "9176499436767288125182942994089196450118944" + + "8701794862752733776161684616570463744619126" + + "4981622564763630694110472008409561205704867" + + "0221819623405201369630462487520858670679048" + + "5854008441429858453634949980424333056803703" + + "1205609490778445762604050796894221725977551" + + "1428887194691696420765173256600200430067305" + + "4364524177041858044598166859757042904625691" + + "4292728453597609683799189454690202563236931" + + "8171122071288244573793276051041975005528757" + + "0228306442708182141334279133965507583927772" + + "9244311696220253059281524393613278272067808" + + "7017494446447670799055720358621918361716353" + + "5018317015764698318012095108914870478138809" + + "8204738169777192718869484177321870413838036" + + "8149216482968887382371881239714335470844573" + + "1862934371951394070111726593305334971041399" + + "5517260339034138718517336990212463882142363" + + "9154412320743552301967162100734381046548816" + + "3883737645359595416600487444018399886391071" + + "3777667222706059170707223589163679915863781" + + "4662302526078720977228426750718207481384357" + + "7918717041190413457052439016978578217755022" + + "7370720979516554707297685239584071755267452" + + "6021894842754355160100506065457679069228273" + + "95209345267367982516553449135291473361"); + q = new BigInteger("7902448465953646210110784092684896" + + "0265474424590294110174550047938700740921014" + + "1981650823416127449143596912363210790070524" + + "2903784112701128957948996730263815210531364" + + "0489145287401377007608600217628773627723381" + + "1194123533939872283952535576847014977682278" + + "9332064706645169741712060131540562788886577" + + "3762235020990267901959745687867018811088495" + + "3716021011509120447248882358515954471433808" + + "2782236662758287959413069553620728137831579" + + "2321174813204514354999978428741310035945405" + + "0226661395731921098764192439072425262100813" + + "9732949866553839713092238096261034339815187" + + "2832617055364163276140160068136296115910569" + + "9466440903693740716929166334256441926903849" + + "1082968246155177124035336609654226388424434" + + "5775783323612758615407928446164631651292743" + + "8428509642959278732826297890909454571009075" + + "7836191622138731918099379467912681177757761" + + "6141378131042432093843778753846726589215845" + + "7402160146427434508515156204064224022904659" + + "8645441448874409852211668374267341177082462" + + "7341410218867175406105046487057429530801973" + + "0931082058719258230993681115780999537424968" + + "2385515792331573549935317407789344892257264" + + "7464569110078675090194686816764429827739815" + + "0566036514181547634372488184242167294602000" + + "8232780963578241583529875079397308150506597" + + "37190564909892937290776929541076192569"); + break; + default: + throw new AssertionError("Unknown keySize " + keySize); + } + + n = p.multiply(q); + + // phi = (p - 1) * (q - 1) must be relative prime to e + // otherwise RSA just won't work ;-) + BigInteger p1 = p.subtract(BigInteger.ONE); + BigInteger q1 = q.subtract(BigInteger.ONE); + BigInteger phi = p1.multiply(q1); + // generate new p and q until they work. typically + // the first try will succeed when using F4 + if (e.gcd(phi).equals(BigInteger.ONE) == false) { + throw new AssertionError("Should not happen"); + } + + // private exponent d is the inverse of e mod phi + BigInteger d = e.modInverse(phi); + + // 1st prime exponent pe = d mod (p - 1) + BigInteger pe = d.mod(p1); + // 2nd prime exponent qe = d mod (q - 1) + BigInteger qe = d.mod(q1); + + // crt coefficient coeff is the inverse of q mod p + BigInteger coeff = q.modInverse(p); + + try { + PublicKey publicKey = new RSAPublicKeyImpl(rsaId, n, e); + PrivateKey privateKey = new RSAPrivateCrtKeyImpl( + rsaId, n, e, d, p, q, pe, qe, coeff); + return new KeyPair(publicKey, privateKey); + } catch (InvalidKeyException exc) { + // invalid key exception only thrown for keys < 512 bit, + // will not happen here + throw new RuntimeException(exc); + } + } +} diff -r 539748673056 -r a327727090c7 test/make/TestMake.gmk --- a/test/make/TestMake.gmk Mon Jun 24 15:18:05 2019 +0530 +++ b/test/make/TestMake.gmk Tue Jun 25 15:24:41 2019 +0530 @@ -46,7 +46,8 @@ all: $(TARGETS) +# Prints targets to TARGETS_FILE which must be set when calling this target. print-targets: - $(ECHO) "$(TARGETS)" + $(ECHO) "$(TARGETS)" >> $(TARGETS_FILE) .PHONY: default all $(TARGETS)