This commit is contained in:
Jesper Wilhelmsson 2020-06-16 04:20:30 +02:00
commit e33ebc7f0a
21 changed files with 501 additions and 89 deletions
src
hotspot/share
gc/shenandoah
jfr/recorder/checkpoint
memory
java.base/share/classes
com/sun/crypto/provider
java/security
sun/security/provider
jdk.compiler/share/classes/com/sun/tools/javac
jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot
jdk.javadoc/share/classes/jdk/javadoc/doclet
test
hotspot/jtreg
jdk
com/sun/crypto/provider/Mac
java
nio/channels/etc
security
javax/management/MBeanServer
lib-test/jdk/test/lib/hexdump

@ -1297,11 +1297,16 @@ void ShenandoahHeap::object_iterate(ObjectClosure* cl) {
Stack<oop,mtGC> oop_stack;
// First, we process GC roots according to current GC cycle. This populates the work stack with initial objects.
ShenandoahHeapIterationRootScanner rp;
ObjectIterateScanRootClosure oops(&_aux_bit_map, &oop_stack);
rp.roots_do(&oops);
{
// First, we process GC roots according to current GC cycle.
// This populates the work stack with initial objects.
// It is important to relinquish the associated locks before diving
// into heap dumper.
ShenandoahHeapIterationRootScanner rp;
rp.roots_do(&oops);
}
// Work through the oop stack to traverse heap.
while (! oop_stack.is_empty()) {

@ -385,7 +385,6 @@ void JfrCheckpointManager::on_rotation() {
}
void JfrCheckpointManager::clear_type_set() {
assert(!SafepointSynchronize::is_at_safepoint(), "invariant");
assert(!JfrRecorder::is_recording(), "invariant");
Thread* t = Thread::current();
DEBUG_ONLY(JfrJavaSupport::check_java_thread_in_native(t));
@ -398,7 +397,6 @@ void JfrCheckpointManager::clear_type_set() {
}
void JfrCheckpointManager::write_type_set() {
assert(!SafepointSynchronize::is_at_safepoint(), "invariant");
{
Thread* const thread = Thread::current();
DEBUG_ONLY(JfrJavaSupport::check_java_thread_in_native(thread));

@ -2498,8 +2498,8 @@ char* MetaspaceShared::reserve_address_space_for_archives(FileMapInfo* static_ma
"CompressedClassSpaceSize malformed: "
SIZE_FORMAT, CompressedClassSpaceSize);
const size_t ccs_begin_offset = align_up(archive_space_size,
class_space_alignment);
const size_t ccs_begin_offset = align_up(base_address + archive_space_size,
class_space_alignment) - base_address;
const size_t gap_size = ccs_begin_offset - archive_space_size;
const size_t total_range_size =

@ -75,6 +75,7 @@ abstract class HmacCore extends MacSpi implements Cloneable {
} else {
String noCloneProv = md.getProvider().getName();
// if no Sun provider, use provider list
md = null;
Provider[] provs = Security.getProviders();
for (Provider p : provs) {
try {
@ -90,6 +91,10 @@ abstract class HmacCore extends MacSpi implements Cloneable {
continue;
}
}
if (md == null) {
throw new NoSuchAlgorithmException
("No Cloneable digest found for " + digestAlgo);
}
}
}
this.md = md;

@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2020, 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
@ -131,6 +131,12 @@ public abstract class MessageDigest extends MessageDigestSpi {
this.algorithm = algorithm;
}
// private constructor used only by Delegate class
private MessageDigest(String algorithm, Provider p) {
this.algorithm = algorithm;
this.provider = p;
}
/**
* Returns a MessageDigest object that implements the specified digest
* algorithm.
@ -178,10 +184,11 @@ public abstract class MessageDigest extends MessageDigestSpi {
(String)null);
if (objs[0] instanceof MessageDigest) {
md = (MessageDigest)objs[0];
md.provider = (Provider)objs[1];
} else {
md = new Delegate((MessageDigestSpi)objs[0], algorithm);
md = Delegate.of((MessageDigestSpi)objs[0], algorithm,
(Provider) objs[1]);
}
md.provider = (Provider)objs[1];
if (!skipDebug && pdebug != null) {
pdebug.println("MessageDigest." + algorithm +
@ -245,8 +252,8 @@ public abstract class MessageDigest extends MessageDigestSpi {
return md;
} else {
MessageDigest delegate =
new Delegate((MessageDigestSpi)objs[0], algorithm);
delegate.provider = (Provider)objs[1];
Delegate.of((MessageDigestSpi)objs[0], algorithm,
(Provider)objs[1]);
return delegate;
}
}
@ -298,8 +305,8 @@ public abstract class MessageDigest extends MessageDigestSpi {
return md;
} else {
MessageDigest delegate =
new Delegate((MessageDigestSpi)objs[0], algorithm);
delegate.provider = (Provider)objs[1];
Delegate.of((MessageDigestSpi)objs[0], algorithm,
(Provider)objs[1]);
return delegate;
}
}
@ -547,8 +554,6 @@ public abstract class MessageDigest extends MessageDigestSpi {
}
/*
* The following class allows providers to extend from MessageDigestSpi
* rather than from MessageDigest. It represents a MessageDigest with an
@ -563,14 +568,45 @@ public abstract class MessageDigest extends MessageDigestSpi {
* and its original parent (Object).
*/
static class Delegate extends MessageDigest implements MessageDigestSpi2 {
private static class Delegate extends MessageDigest
implements MessageDigestSpi2 {
// use this class for spi objects which implements Cloneable
private static final class CloneableDelegate extends Delegate
implements Cloneable {
private CloneableDelegate(MessageDigestSpi digestSpi,
String algorithm, Provider p) {
super(digestSpi, algorithm, p);
}
}
// The provider implementation (delegate)
private MessageDigestSpi digestSpi;
private final MessageDigestSpi digestSpi;
// constructor
public Delegate(MessageDigestSpi digestSpi, String algorithm) {
super(algorithm);
// factory method used by MessageDigest class to create Delegate objs
static Delegate of(MessageDigestSpi digestSpi, String algo,
Provider p) {
Objects.requireNonNull(digestSpi);
boolean isCloneable = (digestSpi instanceof Cloneable);
// Spi impls from SunPKCS11 provider implement Cloneable but their
// clone() may throw CloneNotSupportException
if (isCloneable && p.getName().startsWith("SunPKCS11") &&
p.getClass().getModule().getName().equals
("jdk.crypto.cryptoki")) {
try {
digestSpi.clone();
} catch (CloneNotSupportedException cnse) {
isCloneable = false;
}
}
return (isCloneable? new CloneableDelegate(digestSpi, algo, p) :
new Delegate(digestSpi, algo, p));
}
// private constructor
private Delegate(MessageDigestSpi digestSpi, String algorithm,
Provider p) {
super(algorithm, p);
this.digestSpi = digestSpi;
}
@ -582,17 +618,16 @@ public abstract class MessageDigest extends MessageDigestSpi {
* @throws CloneNotSupportedException if this is called on a
* delegate that does not support {@code Cloneable}.
*/
@Override
public Object clone() throws CloneNotSupportedException {
if (digestSpi instanceof Cloneable) {
MessageDigestSpi digestSpiClone =
(MessageDigestSpi)digestSpi.clone();
if (this instanceof Cloneable) {
// Because 'algorithm', 'provider', and 'state' are private
// members of our supertype, we must perform a cast to
// access them.
MessageDigest that =
new Delegate(digestSpiClone,
((MessageDigest)this).algorithm);
that.provider = ((MessageDigest)this).provider;
MessageDigest that = new CloneableDelegate(
(MessageDigestSpi)digestSpi.clone(),
((MessageDigest)this).algorithm,
((MessageDigest)this).provider);
that.state = ((MessageDigest)this).state;
return that;
} else {
@ -600,22 +635,27 @@ public abstract class MessageDigest extends MessageDigestSpi {
}
}
@Override
protected int engineGetDigestLength() {
return digestSpi.engineGetDigestLength();
}
@Override
protected void engineUpdate(byte input) {
digestSpi.engineUpdate(input);
}
@Override
protected void engineUpdate(byte[] input, int offset, int len) {
digestSpi.engineUpdate(input, offset, len);
}
@Override
protected void engineUpdate(ByteBuffer input) {
digestSpi.engineUpdate(input);
}
@Override
public void engineUpdate(SecretKey key) throws InvalidKeyException {
if (digestSpi instanceof MessageDigestSpi2) {
((MessageDigestSpi2)digestSpi).engineUpdate(key);
@ -624,15 +664,19 @@ public abstract class MessageDigest extends MessageDigestSpi {
("Digest does not support update of SecretKey object");
}
}
@Override
protected byte[] engineDigest() {
return digestSpi.engineDigest();
}
@Override
protected int engineDigest(byte[] buf, int offset, int len)
throws DigestException {
return digestSpi.engineDigest(buf, offset, len);
}
@Override
protected void engineReset() {
digestSpi.engineReset();
}

@ -272,7 +272,7 @@ public abstract class Signature extends SignatureSpi {
NoSuchAlgorithmException failure;
do {
Service s = t.next();
if (isSpi(s)) {
if (isSpi(s)) { // delayed provider selection
return new Delegate(s, t, algorithm);
} else {
// must be a subclass of Signature, disable dynamic selection
@ -295,7 +295,7 @@ public abstract class Signature extends SignatureSpi {
sig.algorithm = algorithm;
} else {
SignatureSpi spi = (SignatureSpi)instance.impl;
sig = new Delegate(spi, algorithm);
sig = Delegate.of(spi, algorithm);
}
sig.provider = instance.provider;
return sig;
@ -464,7 +464,7 @@ public abstract class Signature extends SignatureSpi {
// check Cipher
try {
Cipher c = Cipher.getInstance(RSA_CIPHER, p);
return new Delegate(new CipherAdapter(c), RSA_SIGNATURE);
return Delegate.of(new CipherAdapter(c), RSA_SIGNATURE);
} catch (GeneralSecurityException e) {
// throw Signature style exception message to avoid confusion,
// but append Cipher exception as cause
@ -1092,6 +1092,14 @@ public abstract class Signature extends SignatureSpi {
@SuppressWarnings("deprecation")
private static class Delegate extends Signature {
// use this class for spi objects which implements Cloneable
private static final class CloneableDelegate extends Delegate
implements Cloneable {
private CloneableDelegate(SignatureSpi digestSpi,
String algorithm) {
super(digestSpi, algorithm);
}
}
// The provider implementation (delegate)
// filled in once the provider is selected
@ -1108,15 +1116,24 @@ public abstract class Signature extends SignatureSpi {
// null once provider is selected
private Iterator<Service> serviceIterator;
// constructor
Delegate(SignatureSpi sigSpi, String algorithm) {
// factory method used by Signature class to create Delegate objs
static Delegate of(SignatureSpi sigSpi, String algorithm) {
if (sigSpi instanceof Cloneable) {
return new CloneableDelegate(sigSpi, algorithm);
} else {
return new Delegate(sigSpi, algorithm);
}
}
// private constructor
private Delegate(SignatureSpi sigSpi, String algorithm) {
super(algorithm);
this.sigSpi = sigSpi;
this.lock = null; // no lock needed
}
// used with delayed provider selection
Delegate(Service service,
// constructor used with delayed provider selection
private Delegate(Service service,
Iterator<Service> iterator, String algorithm) {
super(algorithm);
this.firstService = service;
@ -1132,15 +1149,16 @@ public abstract class Signature extends SignatureSpi {
* @throws CloneNotSupportedException if this is called on a
* delegate that does not support {@code Cloneable}.
*/
@Override
public Object clone() throws CloneNotSupportedException {
chooseFirstProvider();
if (sigSpi instanceof Cloneable) {
SignatureSpi sigSpiClone = (SignatureSpi)sigSpi.clone();
// Because 'algorithm' and 'provider' are private
// members of our supertype, we must perform a cast to
// access them.
Signature that =
new Delegate(sigSpiClone, ((Signature)this).algorithm);
Signature that = new CloneableDelegate(
(SignatureSpi)sigSpi.clone(),
((Signature)this).algorithm);
that.provider = ((Signature)this).provider;
return that;
} else {

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2020, 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
@ -233,6 +233,7 @@ abstract class DigestBase extends MessageDigestSpi implements Cloneable {
public Object clone() throws CloneNotSupportedException {
DigestBase copy = (DigestBase) super.clone();
copy.buffer = copy.buffer.clone();
copy.oneByte = null;
return copy;
}

@ -38,6 +38,8 @@ public class Main {
/** Main entry point for the launcher.
* Note: This method calls System.exit.
* @param args command line arguments
* @throws Exception only if an uncaught internal exception occurs;
* just retained for historical compatibility
*/
public static void main(String[] args) throws Exception {
System.exit(compile(args));

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2020, 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
@ -54,6 +54,7 @@ public class HotSpotMethodHandleAccessProvider implements MethodHandleAccessProv
final ResolvedJavaField methodHandleFormField;
final ResolvedJavaField lambdaFormVmentryField;
final HotSpotResolvedJavaField callSiteTargetField;
final HotSpotResolvedJavaField constantCallSiteFrozenField;
final ResolvedJavaField methodField;
final HotSpotResolvedJavaField vmtargetField;
@ -94,6 +95,9 @@ public class HotSpotMethodHandleAccessProvider implements MethodHandleAccessProv
ResolvedJavaType callSiteType = resolveType("Ljava/lang/invoke/CallSite;");
callSiteTargetField = (HotSpotResolvedJavaField) findFieldInClass(callSiteType, "target", methodHandleType);
ResolvedJavaType constantCallSiteType = resolveType("Ljava/lang/invoke/ConstantCallSite;");
ResolvedJavaType booleanType = resolveType("Z");
constantCallSiteFrozenField = (HotSpotResolvedJavaField) findFieldInClass(constantCallSiteType, "isFrozen", booleanType);
} catch (Throwable ex) {
throw new JVMCIError(ex);
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2009, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2009, 2020, 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
@ -65,18 +65,39 @@ abstract class HotSpotObjectConstantImpl implements HotSpotObjectConstant {
@Override
public abstract int getIdentityHashCode();
static class Fields {
// Initializing these too early causes a hang, so do it here in a subclass
static final HotSpotResolvedJavaField callSiteTargetField = HotSpotMethodHandleAccessProvider.Internals.instance().callSiteTargetField;
static final HotSpotResolvedJavaField constantCallSiteFrozenField = HotSpotMethodHandleAccessProvider.Internals.instance().constantCallSiteFrozenField;
}
private boolean isFullyInitializedConstantCallSite() {
if (!runtime().getConstantCallSite().isInstance(this)) {
return false;
}
// read ConstantCallSite.isFrozen as a volatile field
boolean isFrozen = readFieldValue(Fields.constantCallSiteFrozenField, true /* volatile */).asBoolean();
// isFrozen true implies fully-initialized
return isFrozen;
}
private HotSpotObjectConstantImpl readTarget() {
// read CallSite.target as a volatile field
return (HotSpotObjectConstantImpl) readFieldValue(Fields.callSiteTargetField, true /* volatile */);
}
@Override
public JavaConstant getCallSiteTarget(Assumptions assumptions) {
if (runtime().getCallSite().isInstance(this)) {
HotSpotObjectConstantImpl target = (HotSpotObjectConstantImpl) runtime().getHostJVMCIBackend().getConstantReflection().readFieldValue(
HotSpotMethodHandleAccessProvider.Internals.instance().callSiteTargetField, this);
if (!runtime().getConstantCallSite().isInstance(this)) {
// For ConstantCallSites, we need to read "isFrozen" before reading "target"
// isFullyInitializedConstantCallSite() reads "isFrozen"
if (!isFullyInitializedConstantCallSite()) {
if (assumptions == null) {
return null;
}
assumptions.record(new Assumptions.CallSiteTargetValue(this, target));
assumptions.record(new Assumptions.CallSiteTargetValue(this, readTarget()));
}
return target;
return readTarget();
}
return null;
}

@ -138,6 +138,9 @@ public interface DocletEnvironment {
*/
Kind getFileKind(TypeElement type);
/**
* The mode specifying the level of detail of module documentation.
*/
enum ModuleMode {
/** Indicate API level documentation is required */
API,

@ -70,6 +70,10 @@ public class StandardDoclet implements Doclet {
private final HtmlDoclet htmlDoclet;
/**
* Creates an instance of the standard doclet, used to generate HTML-formatted
* documentation.
*/
public StandardDoclet() {
htmlDoclet = new HtmlDoclet(this);
}

@ -41,6 +41,7 @@ public class SharedBaseAddress {
"1g", "8g", "64g","512g", "4t",
"32t", "128t", "0",
"1", "64k", "64M",
"0x800001000", // Default base address + 1 page - probably valid but unaligned to metaspace alignment, see JDK 8247522
"0xfffffffffff00000", // archive top wraps around 64-bit address space
"0xfff80000", // archive top wraps around 32-bit address space
"0xffffffffffffffff", // archive bottom wraps around 64-bit address space -- due to align_up()

@ -41,7 +41,8 @@ public class SharedBaseAddress {
private static final String[] testTable = {
"1g", "8g", "64g","512g", "4t",
"32t", "128t", "0",
"1", "64k", "64M", "320g"
"1", "64k", "64M", "320g",
"0x800001000" // Default base address + 1 page - probably valid but unaligned to metaspace alignment, see JDK 8247522
};
public static void main(String[] args) throws Exception {

@ -79,7 +79,7 @@ import jdk.test.lib.process.OutputAnalyzer;
* java.compiler
* java.management
* jdk.internal.jvmstat/sun.jvmstat.monitor
* @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+UseZGC HeapDumpCompressedTest
* @run main/othervm -XX:+UseZGC HeapDumpCompressedTest
*/
/*
@ -91,7 +91,7 @@ import jdk.test.lib.process.OutputAnalyzer;
* java.compiler
* java.management
* jdk.internal.jvmstat/sun.jvmstat.monitor
* @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC HeapDumpCompressedTest
* @run main/othervm -XX:+UseShenandoahGC HeapDumpCompressedTest
*/
/*

@ -0,0 +1,106 @@
/*
* Copyright (c) 2020, 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 8246077
* @summary Ensure a cloneable digest can be accepted/used by HmacCore
*/
import java.security.*;
import java.security.spec.AlgorithmParameterSpec;
import javax.crypto.*;
import javax.crypto.spec.*;
public class DigestCloneabilityTest {
private static String ALGO = "HmacSHA512";
public static void main(String[] args) throws Exception {
Provider p = new SampleProvider();
// make SampleProvider the most preferred, so its digest impl is picked
int status = Security.insertProviderAt(p, 1);
try {
Mac mac = Mac.getInstance(ALGO, "SunJCE");
// do a complete mac generation and check if the supplied
// digest is used
mac.init(new SecretKeySpec(new byte[512>>3], ALGO));
mac.update((byte)0x12);
byte[] macBytes = mac.doFinal();
if (!SampleProvider.CloneableDigest.isUsed) {
throw new RuntimeException("Expected Digest impl not used");
}
} finally {
if (status != -1) {
Security.removeProvider(p.getName());
}
}
System.out.println("Test Passed");
}
public static class SampleProvider extends Provider {
public SampleProvider() {
super("Sample", "1.0", "test provider");
putService(new Provider.Service(this, "MessageDigest", "SHA-512",
"DigestCloneabilityTest$SampleProvider$CloneableDigest",
null, null));
}
public static class CloneableDigest extends MessageDigestSpi
implements Cloneable {
private MessageDigest md;
static boolean isUsed = false;
public CloneableDigest() throws NoSuchAlgorithmException {
try {
md = MessageDigest.getInstance("SHA-512", "SUN");
} catch (NoSuchProviderException nspe) {
// should never happen
}
}
public byte[] engineDigest() {
isUsed = true;
return md.digest();
}
public void engineReset() {
isUsed = true;
md.reset();
}
public void engineUpdate(byte input) {
isUsed = true;
md.update(input);
}
public void engineUpdate(byte[] b, int ofs, int len) {
isUsed = true;
md.update(b, ofs, len);
}
public Object clone() throws CloneNotSupportedException {
return this;
}
}
}
}

@ -94,12 +94,23 @@ public class OpenAndConnect {
@DataProvider(name = "openConnect")
public Object[][] openConnect() {
LinkedList<Object[]> l = new LinkedList<>();
l.addAll(openConnectGenTests);
if (IA4LOCAL != null) {
l.addAll(openConnectV4LocalTests);
if (IPSupport.hasIPv4()) {
l.addAll(openConnectV4Tests);
if (IA4LOCAL != null) {
l.addAll(openConnectV4LocalTests);
}
}
if (IA6LOCAL != null) {
l.addAll(openConnectV6LocalTests);
if (IPSupport.hasIPv6()) {
l.addAll(openConnectV6Tests);
if (IA6LOCAL != null) {
l.addAll(openConnectV6LocalTests);
}
}
if (IPSupport.hasIPv4() && IPSupport.hasIPv6()) {
l.addAll(openConnectV4AndV6Tests);
if (IA4LOCAL != null) {
l.addAll(openConnectV4LocalAndV6Tests);
}
}
return l.toArray(new Object[][]{});
}
@ -122,40 +133,20 @@ public class OpenAndConnect {
// + + + +
// { sfam, saddr, cfam, caddr, }
public static List<Object[]> openConnectGenTests =
// Basic tests for when an IPv4 is available
public static List<Object[]> openConnectV4Tests =
Arrays.asList(new Object[][] {
{ INET, IA4LOOPBACK, INET, IA4LOOPBACK },
{ INET, IA4LOOPBACK, null, IA4LOOPBACK },
{ INET, IA4ANYLOCAL, null, IA4LOOPBACK },
{ INET, IA4ANYLOCAL, INET, IA4LOOPBACK },
{ INET6, IA6ANYLOCAL, null, IA6LOOPBACK },
{ INET6, IA6ANYLOCAL, INET6, IA6LOOPBACK },
{ INET6, IA6LOOPBACK, INET6, IA6LOOPBACK },
{ null, IA4LOOPBACK, INET, IA4ANYLOCAL },
{ null, IA4LOOPBACK, INET, IA4LOOPBACK },
{ null, IA4LOOPBACK, INET, null },
{ null, IA4LOOPBACK, INET6, IA6ANYLOCAL },
{ null, IA6LOOPBACK, INET6, IA6ANYLOCAL },
{ null, IA6LOOPBACK, INET6, IA6LOOPBACK },
{ null, IA6LOOPBACK, INET6, DONT_BIND },
{ null, IA4LOOPBACK, INET6, DONT_BIND },
{ null, IA4LOOPBACK, INET6, null },
{ null, IA6LOOPBACK, INET6, null },
{ null, IA4LOOPBACK, null, IA6ANYLOCAL },
{ null, IA6LOOPBACK, null, IA6ANYLOCAL },
{ null, IA6LOOPBACK, null, IA6LOOPBACK },
{ null, IA4LOOPBACK, null, null },
{ null, IA6LOOPBACK, null, null },
{ null, IA6ANYLOCAL, null, IA6LOCAL },
{ null, IA6ANYLOCAL, null, IA6LOOPBACK },
{ null, IA6ANYLOCAL, INET6, IA6LOCAL },
{ null, IA6ANYLOCAL, INET6, IA6LOOPBACK },
{ INET6, IA6LOOPBACK, INET6, IA6LOOPBACK }
{ null, IA4LOOPBACK, null, null }
});
// Additional tests for when an IPv4 local address or V6
// local address is available
// Additional tests for when an IPv4 local address is available
public List<Object[]> openConnectV4LocalTests =
Arrays.asList(new Object[][] {
{ INET, IA4LOCAL, INET, IA4LOCAL },
@ -166,11 +157,28 @@ public class OpenAndConnect {
{ null, IA4LOCAL, INET, IA4ANYLOCAL },
{ null, IA4LOCAL, INET, IA4LOCAL },
{ null, IA4LOCAL, INET, null },
{ null, IA4LOCAL, INET6, IA6ANYLOCAL },
{ null, IA4LOCAL, INET6, null },
{ null, IA4LOCAL, null, IA6ANYLOCAL }
{ null, IA4LOCAL, null, null }
});
// Basic tests for when an IPv6 is available
public List<Object[]> openConnectV6Tests =
Arrays.asList(new Object[][] {
{ INET6, IA6ANYLOCAL, null, IA6LOOPBACK },
{ INET6, IA6ANYLOCAL, INET6, IA6LOOPBACK },
{ INET6, IA6LOOPBACK, INET6, IA6LOOPBACK },
{ INET6, IA6LOOPBACK, INET6, IA6LOOPBACK },
{ null, IA6ANYLOCAL, null, IA6LOOPBACK },
{ null, IA6ANYLOCAL, INET6, IA6LOOPBACK },
{ null, IA6LOOPBACK, INET6, IA6LOOPBACK },
{ null, IA6LOOPBACK, INET6, DONT_BIND },
{ null, IA6LOOPBACK, INET6, null },
{ null, IA6LOOPBACK, null, IA6LOOPBACK },
{ null, IA6LOOPBACK, null, null },
{ null, IA6LOOPBACK, INET6, IA6ANYLOCAL },
{ null, IA6LOOPBACK, null, IA6ANYLOCAL }
});
// Additional tests for when an IPv6 local address is available
public List<Object[]> openConnectV6LocalTests =
Arrays.asList(new Object[][] {
{ INET6, IA6ANYLOCAL, null, IA6LOCAL },
@ -178,16 +186,33 @@ public class OpenAndConnect {
{ INET6, IA6LOCAL, INET6, IA6LOCAL },
{ INET6, IA6LOCAL, null, IA6LOCAL },
{ INET6, IA6LOCAL, null, DONT_BIND },
{ INET6, IA6LOCAL, INET6, IA6LOCAL },
{ null, IA6ANYLOCAL, null, IA6LOCAL },
{ null, IA6ANYLOCAL, INET6, IA6LOCAL },
{ null, IA6LOCAL, INET6, IA6LOCAL },
{ null, IA6LOCAL, INET6, IA6ANYLOCAL },
{ null, IA6LOCAL, null, IA6ANYLOCAL },
{ null, IA6LOCAL, null, IA6LOCAL },
{ null, IA6LOCAL, INET6, null },
{ null, IA6LOCAL, null, null },
{ null, IA4LOCAL, null, null },
{ INET6, IA6LOCAL, INET6, IA6LOCAL }
{ null, IA6LOCAL, null, null }
});
// Additional tests for when IPv4 and IPv6 are available
public List<Object[]> openConnectV4AndV6Tests =
Arrays.asList(new Object[][] {
{ null, IA4LOOPBACK, INET6, IA6ANYLOCAL },
{ null, IA4LOOPBACK, null, IA6ANYLOCAL },
{ null, IA4LOOPBACK, INET6, DONT_BIND },
{ null, IA4LOOPBACK, INET6, null }
});
// Additional tests for when IPv4 local address and IPv6 are available
public List<Object[]> openConnectV4LocalAndV6Tests =
Arrays.asList(new Object[][] {
{ null, IA4LOCAL, INET6, IA6ANYLOCAL },
{ null, IA4LOCAL, INET6, null },
{ null, IA4LOCAL, null, IA6ANYLOCAL }
});
/**
* If the destination address is the wildcard, it is replaced by the alternate

@ -0,0 +1,76 @@
/*
* Copyright (c) 2020, 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 8246077
* @summary Make sure that digest spi and the resulting digest impl are
* consistent in the impl of Cloneable interface
* @run testng TestCloneable
*/
import java.security.*;
import java.util.Objects;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import org.testng.Assert;
public class TestCloneable {
private static final Class<CloneNotSupportedException> CNSE =
CloneNotSupportedException.class;
@DataProvider
public Object[][] testData() {
return new Object[][] {
{ "MD2", "SUN" }, { "MD5", "SUN" }, { "SHA-1", "SUN" },
{ "SHA-224", "SUN" }, { "SHA-256", "SUN" },
{ "SHA-384", "SUN" }, { "SHA-512", "SUN" },
{ "SHA3-224", "SUN" }, { "SHA3-256", "SUN" },
{ "SHA3-384", "SUN" }, { "SHA3-512", "SUN" }
};
}
@Test(dataProvider = "testData")
public void test(String algo, String provName)
throws NoSuchProviderException, NoSuchAlgorithmException,
CloneNotSupportedException {
System.out.print("Testing " + algo + " impl from " + provName);
Provider p = Security.getProvider(provName);
Provider.Service s = p.getService("MessageDigest", algo);
Objects.requireNonNull(s);
MessageDigestSpi spi = (MessageDigestSpi) s.newInstance(null);
MessageDigest md = MessageDigest.getInstance(algo, provName);
if (spi instanceof Cloneable) {
System.out.println(": Cloneable");
Assert.assertTrue(md instanceof Cloneable);
MessageDigest md2 = (MessageDigest) md.clone();
Assert.assertEquals(md2.getAlgorithm(), algo);
Assert.assertEquals(md2.getProvider().getName(), provName);
Assert.assertTrue(md2 instanceof Cloneable);
} else {
System.out.println(": NOT Cloneable");
Assert.assertThrows(CNSE, ()->md.clone());
}
System.out.println("Test Passed");
}
}

@ -0,0 +1,95 @@
/*
* Copyright (c) 2020, 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 8246077
* @summary Make sure that signature objects which are cloneable
* implement the Cloneable interface
* @run testng TestCloneable
*/
import java.security.NoSuchProviderException;
import java.security.NoSuchAlgorithmException;
import java.security.Signature;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import org.testng.Assert;
public class TestCloneable {
private static final Class<CloneNotSupportedException> CNSE =
CloneNotSupportedException.class;
@DataProvider
public Object[][] testData() {
return new Object[][] {
{ "SHA1withDSA", "SUN" }, { "NONEwithDSA", "SUN" },
{ "SHA224withDSA", "SUN" }, { "SHA256withDSA", "SUN" },
{ "EdDSA", "SunEC" }, { "Ed25519", "SunEC" }, { "Ed448", "SunEC" },
{ "SHA1withECDSA", "SunEC" }, { "SHA224withECDSA", "SunEC" },
{ "SHA256withECDSA", "SunEC" }, { "SHA384withECDSA", "SunEC" },
{ "SHA512withECDSA", "SunEC" }, { "NONEwithECDSA", "SunEC" },
{ "MD2withRSA", "SunRsaSign" }, { "MD5withRSA", "SunRsaSign" },
{ "SHA1withRSA", "SunRsaSign" }, { "SHA224withRSA", "SunRsaSign" },
{ "SHA256withRSA", "SunRsaSign" },
{ "SHA384withRSA", "SunRsaSign" },
{ "SHA512withRSA", "SunRsaSign" },
{ "SHA512/224withRSA", "SunRsaSign" },
{ "SHA512/256withRSA", "SunRsaSign" },
{ "RSASSA-PSS", "SunRsaSign" },
{ "NONEwithRSA", "SunMSCAPI" },
{ "SHA1withRSA", "SunMSCAPI" }, { "SHA256withRSA", "SunMSCAPI" },
{ "SHA384withRSA", "SunMSCAPI" }, { "SHA512withRSA", "SunMSCAPI" },
{ "RSASSA-PSS", "SunMSCAPI" },
{ "MD5withRSA", "SunMSCAPI" }, { "MD2withRSA", "SunMSCAPI" },
{ "SHA1withECDSA", "SunMSCAPI" },
{ "SHA224withECDSA", "SunMSCAPI" },
{ "SHA256withECDSA", "SunMSCAPI" },
{ "SHA384withECDSA", "SunMSCAPI" },
{ "SHA512withECDSA", "SunMSCAPI" }
};
}
@Test(dataProvider = "testData")
public void test(String algo, String provName)
throws NoSuchAlgorithmException, CloneNotSupportedException {
System.out.print("Testing " + algo + " impl from " + provName);
try {
Signature sig = Signature.getInstance(algo, provName);
if (sig instanceof Cloneable) {
System.out.println(": Cloneable");
Signature sig2 = (Signature) sig.clone();
Assert.assertEquals(sig2.getAlgorithm(), algo);
Assert.assertEquals(sig2.getProvider().getName(), provName);
Assert.assertTrue(sig2 instanceof Cloneable);
} else {
System.out.println(": NOT Cloneable");
Assert.assertThrows(CNSE, ()->sig.clone());
}
System.out.println("Test Passed");
} catch (NoSuchProviderException nspe) {
// skip testing
System.out.println("Skip " + provName + " - not available");
}
}
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2020, 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
@ -92,11 +92,14 @@ import javax.management.remote.JMXConnectorServer;
import javax.management.remote.JMXConnectorServerFactory;
import javax.management.remote.JMXServiceURL;
import jdk.test.lib.Utils;
/*
* @test OldMBeanServerTest.java
* @bug 5072268
* @summary Test that nothing assumes a post-1.2 MBeanServer
* @author Eamonn McManus
* @library /test/lib
* @modules java.management.rmi
* @run main/othervm -ea OldMBeanServerTest
*/
@ -278,7 +281,7 @@ public class OldMBeanServerTest {
count += (Integer) h;
}
void waitForCount(int expect) throws InterruptedException {
long deadline = System.currentTimeMillis() + 2000L;
long deadline = System.currentTimeMillis() + Utils.adjustTimeout(2000);
while (count < expect && System.currentTimeMillis() < deadline)
Thread.sleep(1);
assert count == expect;

@ -77,9 +77,9 @@ public class HexPrinterTest {
Object[][] builtinParams() {
return new Object[][]{
{"minimal", "", "%02x", 16, "", 64, HexPrinter.Formatters.NONE, ""},
{"canonical", "%08x ", "%02x ", 16, "|", 31, HexPrinter.Formatters.PRINTABLE, "|\n"},
{"simple", "%5d: ", "%02x ", 16, " // ", 64, HexPrinter.Formatters.ASCII, "\n"},
{"source", " ", "(byte)%3d, ", 8, " // ", 64, HexPrinter.Formatters.PRINTABLE, "\n"},
{"canonical", "%08x ", "%02x ", 16, "|", 31, HexPrinter.Formatters.PRINTABLE, "|" + System.lineSeparator()},
{"simple", "%5d: ", "%02x ", 16, " // ", 64, HexPrinter.Formatters.ASCII, System.lineSeparator()},
{"source", " ", "(byte)%3d, ", 8, " // ", 64, HexPrinter.Formatters.PRINTABLE, System.lineSeparator()},
};
}