mirror of
https://github.com/openjdk/jdk.git
synced 2026-03-03 20:50:19 +00:00
Merge
This commit is contained in:
commit
05f6d3edc7
1
.hgtags
1
.hgtags
@ -386,3 +386,4 @@ d273dfe9a126d3bffe92072547fef2cd1361b0eb jdk-9+138
|
||||
9aadd2163b568d76f8969ad2fb404a63733da359 jdk-9+141
|
||||
df0e03e3ca0ed1307793017dfc1a054c8726131c jdk-9+142
|
||||
d62173b931bf5b6bffc6e80a9060bb2e8b8efc75 jdk-9+143
|
||||
31f5023200d42185b70c4c00ba5672391e4642d0 jdk-9+144
|
||||
|
||||
@ -386,3 +386,4 @@ a5815c6098a241d3a1df64d22b84b3524e4a77df jdk-9+140
|
||||
f64afae7f1a5608e438585bbf0bc23785e69cba0 jdk-9+141
|
||||
2b3e5caafe3594ea507c37675c4d3086f415dc64 jdk-9+142
|
||||
1fc62b1c629fb80fdaa639d3b59452a184f0d705 jdk-9+143
|
||||
8d337fd6333e28c48aa87880144b840aad82baaf jdk-9+144
|
||||
|
||||
@ -942,7 +942,7 @@ AC_DEFUN([FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK_HELPER],
|
||||
# Little endian machine uses ELFv2 ABI.
|
||||
$2JVM_CFLAGS="[$]$2JVM_CFLAGS -DABI_ELFv2"
|
||||
# Use Power8, this is the first CPU to support PPC64 LE with ELFv2 ABI.
|
||||
$2JVM_CFLAGS="[$]$2JVM_CFLAGS -mcpu=power7 -mtune=power8"
|
||||
$2JVM_CFLAGS="[$]$2JVM_CFLAGS -mcpu=power8 -mtune=power8"
|
||||
fi
|
||||
elif test "x$OPENJDK_$1_CPU" = xs390x; then
|
||||
if test "x$OPENJDK_$1_OS" = xlinux; then
|
||||
|
||||
@ -5093,7 +5093,7 @@ VS_SDK_PLATFORM_NAME_2013=
|
||||
#CUSTOM_AUTOCONF_INCLUDE
|
||||
|
||||
# Do not change or remove the following line, it is needed for consistency checks:
|
||||
DATE_WHEN_GENERATED=1478524503
|
||||
DATE_WHEN_GENERATED=1479120453
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
@ -50124,7 +50124,7 @@ $as_echo "$as_me: GCC >= 6 detected; adding ${NO_DELETE_NULL_POINTER_CHECKS_CFLA
|
||||
# Little endian machine uses ELFv2 ABI.
|
||||
JVM_CFLAGS="$JVM_CFLAGS -DABI_ELFv2"
|
||||
# Use Power8, this is the first CPU to support PPC64 LE with ELFv2 ABI.
|
||||
JVM_CFLAGS="$JVM_CFLAGS -mcpu=power7 -mtune=power8"
|
||||
JVM_CFLAGS="$JVM_CFLAGS -mcpu=power8 -mtune=power8"
|
||||
fi
|
||||
elif test "x$OPENJDK_TARGET_CPU" = xs390x; then
|
||||
if test "x$OPENJDK_TARGET_OS" = xlinux; then
|
||||
@ -50948,7 +50948,7 @@ $as_echo "$as_me: GCC >= 6 detected; adding ${NO_DELETE_NULL_POINTER_CHECKS_CFLA
|
||||
# Little endian machine uses ELFv2 ABI.
|
||||
OPENJDK_BUILD_JVM_CFLAGS="$OPENJDK_BUILD_JVM_CFLAGS -DABI_ELFv2"
|
||||
# Use Power8, this is the first CPU to support PPC64 LE with ELFv2 ABI.
|
||||
OPENJDK_BUILD_JVM_CFLAGS="$OPENJDK_BUILD_JVM_CFLAGS -mcpu=power7 -mtune=power8"
|
||||
OPENJDK_BUILD_JVM_CFLAGS="$OPENJDK_BUILD_JVM_CFLAGS -mcpu=power8 -mtune=power8"
|
||||
fi
|
||||
elif test "x$OPENJDK_BUILD_CPU" = xs390x; then
|
||||
if test "x$OPENJDK_BUILD_OS" = xlinux; then
|
||||
|
||||
@ -372,7 +372,7 @@ compare_general_files() {
|
||||
$CAT $OTHER_DIR/$f | eval "$HTML_FILTER" > $OTHER_FILE &
|
||||
$CAT $THIS_DIR/$f | eval "$HTML_FILTER" > $THIS_FILE &
|
||||
wait
|
||||
elif [ "$f" = "./lib/classlist" ]; then
|
||||
elif [[ "$f" = *"/lib/classlist" ]]; then
|
||||
# The classlist files may have some lines in random order
|
||||
OTHER_FILE=$WORK_DIR/$f.other
|
||||
THIS_FILE=$WORK_DIR/$f.this
|
||||
@ -642,69 +642,18 @@ compare_bin_file() {
|
||||
|
||||
if [ "$OPENJDK_TARGET_OS" = "windows" ]; then
|
||||
unset _NT_SYMBOL_PATH
|
||||
# On windows we need to unzip the debug symbols, if present
|
||||
OTHER_FILE_BASE=${OTHER_FILE/.dll/}
|
||||
OTHER_FILE_BASE=${OTHER_FILE_BASE/.exe/}
|
||||
OTHER_FILE_BASE=${OTHER_FILE_BASE/.cpl/}
|
||||
DIZ_NAME=$(basename $OTHER_FILE_BASE).diz
|
||||
# Some .exe files have the same name as a .dll file. Make sure the exe
|
||||
# files get the right debug symbols.
|
||||
if [ "$NAME" = "java.exe" ] \
|
||||
&& [ -f "$OTHER/support/native/java.base/java_objs/java.diz" ]; then
|
||||
OTHER_DIZ_FILE="$OTHER/support/native/java.base/java_objs/java.diz"
|
||||
elif [ "$NAME" = "jimage.exe" ] \
|
||||
&& [ -f "$OTHER/support/native/jdk.jlink/jimage_objs/jimage.diz" ]; then
|
||||
OTHER_DIZ_FILE="$OTHER/support/modules_cmds/jdk.jlink/jimage.diz"
|
||||
elif [ "$NAME" = "javacpl.exe" ] \
|
||||
&& [ -f "$OTHER/support/native/jdk.plugin/javacpl/javacpl.diz" ]; then
|
||||
OTHER_DIZ_FILE="$OTHER/support/modules_cmds/jdk.deploy.controlpanel/javacpl.diz"
|
||||
elif [ -f "${OTHER_FILE_BASE}.diz" ]; then
|
||||
OTHER_DIZ_FILE=${OTHER_FILE_BASE}.diz
|
||||
else
|
||||
# Some files, jli.dll, appears twice in the image but only one of
|
||||
# them has a diz file next to it.
|
||||
OTHER_DIZ_FILE="$($FIND $OTHER_DIR -name $DIZ_NAME | $SED 1q)"
|
||||
if [ ! -f "$OTHER_DIZ_FILE" ]; then
|
||||
# As a last resort, look for diz file in the whole build output
|
||||
# dir.
|
||||
OTHER_DIZ_FILE="$($FIND $OTHER -name $DIZ_NAME | $SED 1q)"
|
||||
fi
|
||||
fi
|
||||
if [ -n "$OTHER_DIZ_FILE" ]; then
|
||||
$MKDIR -p $FILE_WORK_DIR/other
|
||||
(cd $FILE_WORK_DIR/other ; $UNARCHIVE -o $OTHER_DIZ_FILE)
|
||||
export _NT_SYMBOL_PATH="$FILE_WORK_DIR/other"
|
||||
fi
|
||||
|
||||
THIS_FILE_BASE=${THIS_FILE/.dll/}
|
||||
THIS_FILE_BASE=${THIS_FILE_BASE/.exe/}
|
||||
THIS_FILE_BASE=${THIS_FILE_BASE/.cpl/}
|
||||
# Some .exe files have the same name as a .dll file. Make sure the exe
|
||||
# files get the right debug symbols.
|
||||
if [ "$NAME" = "java.exe" ] \
|
||||
&& [ -f "$THIS/support/native/java.base/java_objs/java.diz" ]; then
|
||||
THIS_DIZ_FILE="$THIS/support/native/java.base/java_objs/java.diz"
|
||||
elif [ "$NAME" = "jimage.exe" ] \
|
||||
&& [ -f "$THIS/support/native/jdk.jlink/jimage_objs/jimage.diz" ]; then
|
||||
THIS_DIZ_FILE="$THIS/support/modules_cmds/jdk.jlink/jimage.diz"
|
||||
elif [ "$NAME" = "javacpl.exe" ] \
|
||||
&& [ -f "$THIS/support/native/jdk.plugin/javacpl/javacpl.diz" ]; then
|
||||
THIS_DIZ_FILE="$THIS/support/modules_cmds/jdk.deploy.controlpanel/javacpl.diz"
|
||||
elif [ -f "${THIS_FILE_BASE}.diz" ]; then
|
||||
THIS_DIZ_FILE=${THIS_FILE/.dll/}.diz
|
||||
else
|
||||
THIS_DIZ_FILE="$($FIND $THIS_DIR -name $DIZ_NAME | $SED 1q)"
|
||||
if [ ! -f "$THIS_DIZ_FILE" ]; then
|
||||
# As a last resort, look for diz file in the whole build output
|
||||
# dir.
|
||||
THIS_DIZ_FILE="$($FIND $THIS -name $DIZ_NAME | $SED 1q)"
|
||||
fi
|
||||
fi
|
||||
if [ -n "$THIS_DIZ_FILE" ]; then
|
||||
$MKDIR -p $FILE_WORK_DIR/this
|
||||
(cd $FILE_WORK_DIR/this ; $UNARCHIVE -o $THIS_DIZ_FILE)
|
||||
export _NT_SYMBOL_PATH="$_NT_SYMBOL_PATH;$FILE_WORK_DIR/this"
|
||||
if [ "$(uname -o)" = "Cygwin" ]; then
|
||||
THIS=$(cygpath -msa $THIS)
|
||||
OTHER=$(cygpath -msa $OTHER)
|
||||
fi
|
||||
# Build an _NT_SYMBOL_PATH that contains all known locations for
|
||||
# pdb files.
|
||||
PDB_DIRS="$(ls -d \
|
||||
{$OTHER,$THIS}/support/modules_{cmds,libs}/{*,*/*} \
|
||||
{$OTHER,$THIS}/support/demos/image/jvmti/*/lib \
|
||||
{$OTHER,$THIS}/support/native/java.base/java_objs \
|
||||
)"
|
||||
export _NT_SYMBOL_PATH="$(echo $PDB_DIRS | tr ' ' ';')"
|
||||
fi
|
||||
|
||||
if [ -z "$SKIP_BIN_DIFF" ]; then
|
||||
|
||||
@ -431,6 +431,8 @@ if [ "$OPENJDK_TARGET_OS" = "windows" ]; then
|
||||
|
||||
ACCEPTED_JARZIP_CONTENTS="
|
||||
/modules_libs/java.security.jgss/w2k_lsa_auth.diz
|
||||
/modules_libs/java.security.jgss/w2k_lsa_auth.pdb
|
||||
/modules_libs/java.security.jgss/w2k_lsa_auth.map
|
||||
/modules_libs/java.security.jgss/w2k_lsa_auth.dll
|
||||
"
|
||||
|
||||
|
||||
@ -386,3 +386,4 @@ aa053a3faf266c12b4fd5272da431a3e08e4a3e3 jdk-9+136
|
||||
b32f998da32b488ec7c4e9dbb3c750841b48e74d jdk-9+141
|
||||
408c9c621938ca028e20bced0459f815de47eba8 jdk-9+142
|
||||
6211236ef15ec796806357608b1dd1b70c258ece jdk-9+143
|
||||
d4f1dae174098e799c48948e866054c52e11a186 jdk-9+144
|
||||
|
||||
@ -546,3 +546,4 @@ fec31089c2ef5a12dd64f401b0bf2e00f56ee0d0 jdk-9+140
|
||||
160a00bc6ed0af1fdf8418fc65e6bddbbc0c536d jdk-9+141
|
||||
7b48d63dfd6b8e2657288de3d7b1f153dee02d7e jdk-9+142
|
||||
d87d5d430c42342f0320ca7f5cbe0cbd1f9d62ba jdk-9+143
|
||||
6187b582d02aee38341dc8ce4011906e9b364e9f jdk-9+144
|
||||
|
||||
@ -386,3 +386,4 @@ a8d5fe567ae72b4931040e59dd4478363f9004f5 jdk-9+137
|
||||
037c095ba0c345edbeaaab52fda913a76c3930c0 jdk-9+141
|
||||
bdafa0cc34a97a2f8db4847a4efd34b407943591 jdk-9+142
|
||||
ce81d03ad7320dca3d673374c1a33bc0efd9136a jdk-9+143
|
||||
99be33734ff62b75116b1202d49a4d4e1bda4226 jdk-9+144
|
||||
|
||||
@ -389,3 +389,4 @@ ab1d78d395d4cb8be426ff181211da1a4085cf01 jdk-9+134
|
||||
b2c18f755228d1d19a86cd7d5fa1abb6b1495dfb jdk-9+141
|
||||
59101416d90160cfcb4f45dfbccaec15e2c27a29 jdk-9+142
|
||||
1c988e708a06257119d54d8a57e99e3b0f37ff18 jdk-9+143
|
||||
92523c51d6a48b0a83912ba3cc43bc57b8159c2a jdk-9+144
|
||||
|
||||
@ -387,3 +387,4 @@ e93b7ea559759f036c9f69fd2ddaf47bb4e98385 jdk-9+140
|
||||
6ce43dd8e954b452f330dd7a412df5107f7e1923 jdk-9+142
|
||||
8dbc8594f9d5149bf1c22221272284609408227a jdk-9+143
|
||||
efa71dc820eb8bd5a6c9f2f66f39c383ac3ee99d jdk-9+144
|
||||
99b7853cfbd8227c4441de4b6119c10742556840 jdk-9+145
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -118,7 +118,7 @@ class EPollArrayWrapper {
|
||||
// file descriptors higher than MAX_UPDATE_ARRAY_SIZE (unlimited case at
|
||||
// least) then the update is stored in a map.
|
||||
private final byte[] eventsLow = new byte[MAX_UPDATE_ARRAY_SIZE];
|
||||
private Map<Integer,Byte> eventsHigh;
|
||||
private final Map<Integer,Byte> eventsHigh = new HashMap<>();
|
||||
|
||||
// Used by release and updateRegistrations to track whether a file
|
||||
// descriptor is registered with epoll.
|
||||
@ -133,10 +133,6 @@ class EPollArrayWrapper {
|
||||
int allocationSize = NUM_EPOLLEVENTS * SIZE_EPOLLEVENT;
|
||||
pollArray = new AllocatedNativeObject(allocationSize, true);
|
||||
pollArrayAddress = pollArray.address();
|
||||
|
||||
// eventHigh needed when using file descriptors > 64k
|
||||
if (OPEN_MAX > MAX_UPDATE_ARRAY_SIZE)
|
||||
eventsHigh = new HashMap<>();
|
||||
}
|
||||
|
||||
void initInterrupt(int fd0, int fd1) {
|
||||
|
||||
@ -2704,9 +2704,6 @@ public final class Class<T> implements java.io.Serializable,
|
||||
* Reflection support.
|
||||
*/
|
||||
|
||||
// Caches for certain reflective results
|
||||
private static boolean useCaches = true;
|
||||
|
||||
// reflection data that might get invalidated when JVM TI RedefineClasses() is called
|
||||
private static class ReflectionData<T> {
|
||||
volatile Field[] declaredFields;
|
||||
@ -2739,8 +2736,7 @@ public final class Class<T> implements java.io.Serializable,
|
||||
SoftReference<ReflectionData<T>> reflectionData = this.reflectionData;
|
||||
int classRedefinedCount = this.classRedefinedCount;
|
||||
ReflectionData<T> rd;
|
||||
if (useCaches &&
|
||||
reflectionData != null &&
|
||||
if (reflectionData != null &&
|
||||
(rd = reflectionData.get()) != null &&
|
||||
rd.redefinedCount == classRedefinedCount) {
|
||||
return rd;
|
||||
@ -2752,8 +2748,6 @@ public final class Class<T> implements java.io.Serializable,
|
||||
|
||||
private ReflectionData<T> newReflectionData(SoftReference<ReflectionData<T>> oldReflectionData,
|
||||
int classRedefinedCount) {
|
||||
if (!useCaches) return null;
|
||||
|
||||
while (true) {
|
||||
ReflectionData<T> rd = new ReflectionData<>(classRedefinedCount);
|
||||
// try to CAS it...
|
||||
@ -2819,7 +2813,6 @@ public final class Class<T> implements java.io.Serializable,
|
||||
// be propagated to the outside world, but must instead be copied
|
||||
// via ReflectionFactory.copyField.
|
||||
private Field[] privateGetDeclaredFields(boolean publicOnly) {
|
||||
checkInitted();
|
||||
Field[] res;
|
||||
ReflectionData<T> rd = reflectionData();
|
||||
if (rd != null) {
|
||||
@ -2842,7 +2835,6 @@ public final class Class<T> implements java.io.Serializable,
|
||||
// be propagated to the outside world, but must instead be copied
|
||||
// via ReflectionFactory.copyField.
|
||||
private Field[] privateGetPublicFields(Set<Class<?>> traversedInterfaces) {
|
||||
checkInitted();
|
||||
Field[] res;
|
||||
ReflectionData<T> rd = reflectionData();
|
||||
if (rd != null) {
|
||||
@ -2902,7 +2894,6 @@ public final class Class<T> implements java.io.Serializable,
|
||||
// objects must NOT be propagated to the outside world, but must
|
||||
// instead be copied via ReflectionFactory.copyConstructor.
|
||||
private Constructor<T>[] privateGetDeclaredConstructors(boolean publicOnly) {
|
||||
checkInitted();
|
||||
Constructor<T>[] res;
|
||||
ReflectionData<T> rd = reflectionData();
|
||||
if (rd != null) {
|
||||
@ -2937,7 +2928,6 @@ public final class Class<T> implements java.io.Serializable,
|
||||
// be propagated to the outside world, but must instead be copied
|
||||
// via ReflectionFactory.copyMethod.
|
||||
private Method[] privateGetDeclaredMethods(boolean publicOnly) {
|
||||
checkInitted();
|
||||
Method[] res;
|
||||
ReflectionData<T> rd = reflectionData();
|
||||
if (rd != null) {
|
||||
@ -3134,7 +3124,6 @@ public final class Class<T> implements java.io.Serializable,
|
||||
// be propagated to the outside world, but must instead be copied
|
||||
// via ReflectionFactory.copyMethod.
|
||||
private Method[] privateGetPublicMethods() {
|
||||
checkInitted();
|
||||
Method[] res;
|
||||
ReflectionData<T> rd = reflectionData();
|
||||
if (rd != null) {
|
||||
@ -3445,7 +3434,7 @@ public final class Class<T> implements java.io.Serializable,
|
||||
* @since 1.4
|
||||
*/
|
||||
public boolean desiredAssertionStatus() {
|
||||
ClassLoader loader = getClassLoader();
|
||||
ClassLoader loader = getClassLoader0();
|
||||
// If the loader is null this is a system class, so ask the VM
|
||||
if (loader == null)
|
||||
return desiredAssertionStatus0(this);
|
||||
@ -3490,39 +3479,6 @@ public final class Class<T> implements java.io.Serializable,
|
||||
}
|
||||
private static ReflectionFactory reflectionFactory;
|
||||
|
||||
// To be able to query system properties as soon as they're available
|
||||
private static boolean initted = false;
|
||||
private static void checkInitted() {
|
||||
if (initted) return;
|
||||
AccessController.doPrivileged(new PrivilegedAction<>() {
|
||||
public Void run() {
|
||||
// Tests to ensure the system properties table is fully
|
||||
// initialized. This is needed because reflection code is
|
||||
// called very early in the initialization process (before
|
||||
// command-line arguments have been parsed and therefore
|
||||
// these user-settable properties installed.) We assume that
|
||||
// if System.out is non-null then the System class has been
|
||||
// fully initialized and that the bulk of the startup code
|
||||
// has been run.
|
||||
|
||||
if (System.out == null) {
|
||||
// java.lang.System not yet fully initialized
|
||||
return null;
|
||||
}
|
||||
|
||||
// Doesn't use Boolean.getBoolean to avoid class init.
|
||||
String val =
|
||||
System.getProperty("sun.reflect.noCaches");
|
||||
if (val != null && val.equals("true")) {
|
||||
useCaches = false;
|
||||
}
|
||||
|
||||
initted = true;
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the elements of this enum class or null if this
|
||||
* Class object does not represent an enum type.
|
||||
|
||||
@ -80,7 +80,7 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
|
||||
default : throw newInternalError("unexpected xtype: " + xtype);
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
throw newInternalError(t);
|
||||
throw uncaughtException(t);
|
||||
}
|
||||
}
|
||||
|
||||
@ -188,7 +188,7 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
|
||||
case D_TYPE: return (double) speciesData().getters[i].invokeBasic(this);
|
||||
}
|
||||
} catch (Throwable ex) {
|
||||
throw newInternalError(ex);
|
||||
throw uncaughtException(ex);
|
||||
}
|
||||
throw new InternalError("unexpected type: " + speciesData().typeChars+"."+i);
|
||||
}
|
||||
@ -408,18 +408,14 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
|
||||
*/
|
||||
static boolean speciesDataCachePopulated() {
|
||||
Class<BoundMethodHandle> rootCls = BoundMethodHandle.class;
|
||||
try {
|
||||
for (Class<?> c : rootCls.getDeclaredClasses()) {
|
||||
if (rootCls.isAssignableFrom(c)) {
|
||||
final Class<? extends BoundMethodHandle> cbmh = c.asSubclass(BoundMethodHandle.class);
|
||||
SpeciesData d = Factory.getSpeciesDataFromConcreteBMHClass(cbmh);
|
||||
assert(d != null) : cbmh.getName();
|
||||
assert(d.clazz == cbmh);
|
||||
assert(CACHE.get(d.typeChars) == d);
|
||||
}
|
||||
for (Class<?> c : rootCls.getDeclaredClasses()) {
|
||||
if (rootCls.isAssignableFrom(c)) {
|
||||
final Class<? extends BoundMethodHandle> cbmh = c.asSubclass(BoundMethodHandle.class);
|
||||
SpeciesData d = Factory.getSpeciesDataFromConcreteBMHClass(cbmh);
|
||||
assert(d != null) : cbmh.getName();
|
||||
assert(d.clazz == cbmh);
|
||||
assert(CACHE.get(d.typeChars) == d);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
throw newInternalError(e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -272,7 +272,7 @@ public class CallSite {
|
||||
MethodHandleNatives.setCallSiteTargetVolatile(this, newTarget);
|
||||
}
|
||||
|
||||
// this implements the upcall from the JVM, MethodHandleNatives.makeDynamicCallSite:
|
||||
// this implements the upcall from the JVM, MethodHandleNatives.linkCallSite:
|
||||
static CallSite makeSite(MethodHandle bootstrapMethod,
|
||||
// Callee information:
|
||||
String name, MethodType type,
|
||||
@ -293,59 +293,72 @@ public class CallSite {
|
||||
Object[] argv = (Object[]) info;
|
||||
maybeReBoxElements(argv);
|
||||
switch (argv.length) {
|
||||
case 0:
|
||||
binding = bootstrapMethod.invoke(caller, name, type);
|
||||
break;
|
||||
case 1:
|
||||
binding = bootstrapMethod.invoke(caller, name, type,
|
||||
argv[0]);
|
||||
break;
|
||||
case 2:
|
||||
binding = bootstrapMethod.invoke(caller, name, type,
|
||||
argv[0], argv[1]);
|
||||
break;
|
||||
case 3:
|
||||
binding = bootstrapMethod.invoke(caller, name, type,
|
||||
argv[0], argv[1], argv[2]);
|
||||
break;
|
||||
case 4:
|
||||
binding = bootstrapMethod.invoke(caller, name, type,
|
||||
argv[0], argv[1], argv[2], argv[3]);
|
||||
break;
|
||||
case 5:
|
||||
binding = bootstrapMethod.invoke(caller, name, type,
|
||||
argv[0], argv[1], argv[2], argv[3], argv[4]);
|
||||
break;
|
||||
case 6:
|
||||
binding = bootstrapMethod.invoke(caller, name, type,
|
||||
argv[0], argv[1], argv[2], argv[3], argv[4], argv[5]);
|
||||
break;
|
||||
default:
|
||||
final int NON_SPREAD_ARG_COUNT = 3; // (caller, name, type)
|
||||
if (NON_SPREAD_ARG_COUNT + argv.length > MethodType.MAX_MH_ARITY)
|
||||
throw new BootstrapMethodError("too many bootstrap method arguments");
|
||||
MethodType bsmType = bootstrapMethod.type();
|
||||
MethodType invocationType = MethodType.genericMethodType(NON_SPREAD_ARG_COUNT + argv.length);
|
||||
MethodHandle typedBSM = bootstrapMethod.asType(invocationType);
|
||||
MethodHandle spreader = invocationType.invokers().spreadInvoker(NON_SPREAD_ARG_COUNT);
|
||||
binding = spreader.invokeExact(typedBSM, (Object)caller, (Object)name, (Object)type, argv);
|
||||
case 0:
|
||||
binding = bootstrapMethod.invoke(caller, name, type);
|
||||
break;
|
||||
case 1:
|
||||
binding = bootstrapMethod.invoke(caller, name, type,
|
||||
argv[0]);
|
||||
break;
|
||||
case 2:
|
||||
binding = bootstrapMethod.invoke(caller, name, type,
|
||||
argv[0], argv[1]);
|
||||
break;
|
||||
case 3:
|
||||
binding = bootstrapMethod.invoke(caller, name, type,
|
||||
argv[0], argv[1], argv[2]);
|
||||
break;
|
||||
case 4:
|
||||
binding = bootstrapMethod.invoke(caller, name, type,
|
||||
argv[0], argv[1], argv[2], argv[3]);
|
||||
break;
|
||||
case 5:
|
||||
binding = bootstrapMethod.invoke(caller, name, type,
|
||||
argv[0], argv[1], argv[2], argv[3], argv[4]);
|
||||
break;
|
||||
case 6:
|
||||
binding = bootstrapMethod.invoke(caller, name, type,
|
||||
argv[0], argv[1], argv[2], argv[3], argv[4], argv[5]);
|
||||
break;
|
||||
default:
|
||||
final int NON_SPREAD_ARG_COUNT = 3; // (caller, name, type)
|
||||
if (NON_SPREAD_ARG_COUNT + argv.length > MethodType.MAX_MH_ARITY)
|
||||
throw new BootstrapMethodError("too many bootstrap method arguments");
|
||||
MethodType bsmType = bootstrapMethod.type();
|
||||
MethodType invocationType = MethodType.genericMethodType(NON_SPREAD_ARG_COUNT + argv.length);
|
||||
MethodHandle typedBSM = bootstrapMethod.asType(invocationType);
|
||||
MethodHandle spreader = invocationType.invokers().spreadInvoker(NON_SPREAD_ARG_COUNT);
|
||||
binding = spreader.invokeExact(typedBSM, (Object) caller, (Object) name, (Object) type, argv);
|
||||
}
|
||||
}
|
||||
//System.out.println("BSM for "+name+type+" => "+binding);
|
||||
if (binding instanceof CallSite) {
|
||||
site = (CallSite) binding;
|
||||
} else {
|
||||
} else {
|
||||
// See the "Linking Exceptions" section for the invokedynamic
|
||||
// instruction in JVMS 6.5.
|
||||
// Throws a runtime exception defining the cause that is then
|
||||
// in the "catch (Throwable ex)" a few lines below wrapped in
|
||||
// BootstrapMethodError
|
||||
throw new ClassCastException("bootstrap method failed to produce a CallSite");
|
||||
}
|
||||
if (!site.getTarget().type().equals(type))
|
||||
if (!site.getTarget().type().equals(type)) {
|
||||
// See the "Linking Exceptions" section for the invokedynamic
|
||||
// instruction in JVMS 6.5.
|
||||
// Throws a runtime exception defining the cause that is then
|
||||
// in the "catch (Throwable ex)" a few lines below wrapped in
|
||||
// BootstrapMethodError
|
||||
throw wrongTargetType(site.getTarget(), type);
|
||||
}
|
||||
} catch (Error e) {
|
||||
// Pass through an Error, including BootstrapMethodError, any other
|
||||
// form of linkage error, such as IllegalAccessError if the bootstrap
|
||||
// method is inaccessible, or say ThreadDeath/OutOfMemoryError
|
||||
// See the "Linking Exceptions" section for the invokedynamic
|
||||
// instruction in JVMS 6.5.
|
||||
throw e;
|
||||
} catch (Throwable ex) {
|
||||
BootstrapMethodError bex;
|
||||
if (ex instanceof BootstrapMethodError)
|
||||
bex = (BootstrapMethodError) ex;
|
||||
else
|
||||
bex = new BootstrapMethodError("call site initialization exception", ex);
|
||||
throw bex;
|
||||
// Wrap anything else in BootstrapMethodError
|
||||
throw new BootstrapMethodError("call site initialization exception", ex);
|
||||
}
|
||||
return site;
|
||||
}
|
||||
|
||||
@ -1021,7 +1021,7 @@ class InvokerBytecodeGenerator {
|
||||
try {
|
||||
emptyArray = name.function.resolvedHandle().invoke();
|
||||
} catch (Throwable ex) {
|
||||
throw newInternalError(ex);
|
||||
throw uncaughtException(ex);
|
||||
}
|
||||
assert(java.lang.reflect.Array.getLength(emptyArray) == 0);
|
||||
assert(emptyArray.getClass() == rtype); // exact typing
|
||||
|
||||
@ -855,7 +855,11 @@ class LambdaForm {
|
||||
System.out.println("LambdaForm compilation failed: " + this);
|
||||
bge.printStackTrace(System.out);
|
||||
}
|
||||
} catch (Error | Exception e) {
|
||||
} catch (Error e) {
|
||||
// Pass through any error
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
// Wrap any exception
|
||||
throw newInternalError(this.toString(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -957,7 +957,7 @@ assertEquals("[A, B, C]", (String) caToString2.invokeExact('A', "BC".toCharArray
|
||||
if (!fail) return needType;
|
||||
// elicit an error:
|
||||
this.asType(needType);
|
||||
throw newInternalError("should not return", null);
|
||||
throw newInternalError("should not return");
|
||||
}
|
||||
|
||||
private void spreadArrayChecks(Class<?> arrayType, int arrayLength) {
|
||||
|
||||
@ -379,11 +379,13 @@ class MethodHandleNatives {
|
||||
name, fixMethodType(callerClass, type), appendixResult);
|
||||
}
|
||||
}
|
||||
} catch (Error e) {
|
||||
// Pass through an Error, including say StackOverflowError or
|
||||
// OutOfMemoryError
|
||||
throw e;
|
||||
} catch (Throwable ex) {
|
||||
if (ex instanceof LinkageError)
|
||||
throw (LinkageError) ex;
|
||||
else
|
||||
throw new LinkageError(ex.getMessage(), ex);
|
||||
// Wrap anything else in LinkageError
|
||||
throw new LinkageError(ex.getMessage(), ex);
|
||||
}
|
||||
throw new LinkageError("no such method "+defc.getName()+"."+name+type);
|
||||
}
|
||||
|
||||
@ -107,10 +107,10 @@ import java.util.Properties;
|
||||
/*non-public*/ static InternalError newInternalError(String message) {
|
||||
return new InternalError(message);
|
||||
}
|
||||
/*non-public*/ static InternalError newInternalError(String message, Throwable cause) {
|
||||
/*non-public*/ static InternalError newInternalError(String message, Exception cause) {
|
||||
return new InternalError(message, cause);
|
||||
}
|
||||
/*non-public*/ static InternalError newInternalError(Throwable cause) {
|
||||
/*non-public*/ static InternalError newInternalError(Exception cause) {
|
||||
return new InternalError(cause);
|
||||
}
|
||||
/*non-public*/ static RuntimeException newIllegalStateException(String message) {
|
||||
@ -132,7 +132,7 @@ import java.util.Properties;
|
||||
/*non-public*/ static Error uncaughtException(Throwable ex) {
|
||||
if (ex instanceof Error) throw (Error) ex;
|
||||
if (ex instanceof RuntimeException) throw (RuntimeException) ex;
|
||||
throw newInternalError("uncaught exception", ex);
|
||||
throw new InternalError("uncaught exception", ex);
|
||||
}
|
||||
private static String message(String message, Object obj) {
|
||||
if (obj != null) message = message + ": " + obj;
|
||||
|
||||
@ -723,6 +723,9 @@ public final class StringConcatFactory {
|
||||
default:
|
||||
throw new StringConcatException("Concatenation strategy " + STRATEGY + " is not implemented");
|
||||
}
|
||||
} catch (Error | StringConcatException e) {
|
||||
// Pass through any error or existing StringConcatException
|
||||
throw e;
|
||||
} catch (Throwable t) {
|
||||
throw new StringConcatException("Generator failed", t);
|
||||
}
|
||||
@ -1092,9 +1095,9 @@ public final class StringConcatFactory {
|
||||
UNSAFE.ensureClassInitialized(innerClass);
|
||||
dumpIfEnabled(innerClass.getName(), classBytes);
|
||||
return Lookup.IMPL_LOOKUP.findStatic(innerClass, METHOD_NAME, args);
|
||||
} catch (Throwable e) {
|
||||
} catch (Exception e) {
|
||||
dumpIfEnabled(className + "$$FAILED", classBytes);
|
||||
throw new StringConcatException("Error while spinning the class", e);
|
||||
throw new StringConcatException("Exception while spinning the class", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -84,20 +84,21 @@
|
||||
* </ul>
|
||||
* Invocation is as if by
|
||||
* {@link java.lang.invoke.MethodHandle#invoke MethodHandle.invoke}.
|
||||
* The returned result must be a {@link java.lang.invoke.CallSite CallSite} (or a subclass).
|
||||
* The returned result must be a {@link java.lang.invoke.CallSite CallSite}
|
||||
* (or a subclass), otherwise a
|
||||
* {@link java.lang.BootstrapMethodError BootstrapMethodError} is thrown.
|
||||
* The type of the call site's target must be exactly equal to the type
|
||||
* derived from the dynamic call site's type descriptor and passed to
|
||||
* the bootstrap method.
|
||||
* The call site then becomes permanently linked to the dynamic call site.
|
||||
* the bootstrap method, otherwise a {@code BootstrapMethodError} is thrown.
|
||||
* On success the call site then becomes permanently linked to the dynamic call
|
||||
* site.
|
||||
* <p>
|
||||
* As documented in the JVM specification, all failures arising from
|
||||
* the linkage of a dynamic call site are reported
|
||||
* by a {@link java.lang.BootstrapMethodError BootstrapMethodError},
|
||||
* which is thrown as the abnormal termination of the dynamic call
|
||||
* site execution.
|
||||
* If this happens, the same error will the thrown for all subsequent
|
||||
* attempts to execute the dynamic call site.
|
||||
*
|
||||
* If an exception, {@code E} say, occurs when linking the call site then the
|
||||
* linkage fails and terminates abnormally. {@code E} is rethrown if the type of
|
||||
* {@code E} is {@code Error} or a subclass, otherwise a
|
||||
* {@code BootstrapMethodError} that wraps {@code E} is thrown.
|
||||
* If this happens, the same {@code Error} or subclass will the thrown for all
|
||||
* subsequent attempts to execute the dynamic call site.
|
||||
* <h2>timing of linkage</h2>
|
||||
* A dynamic call site is linked just before its first execution.
|
||||
* The bootstrap method call implementing the linkage occurs within
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -130,6 +130,35 @@ class Authenticator {
|
||||
theAuthenticator = a;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the default authenticator.
|
||||
* First, if there is a security manager, its {@code checkPermission}
|
||||
* method is called with a
|
||||
* {@code NetPermission("requestPasswordAuthentication")} permission.
|
||||
* This may result in a java.lang.SecurityException.
|
||||
* Then the default authenticator, if set, is returned.
|
||||
* Otherwise, {@code null} is returned.
|
||||
*
|
||||
* @return The default authenticator, if set, {@code null} otherwise.
|
||||
*
|
||||
* @throws SecurityException
|
||||
* if a security manager exists and its
|
||||
* {@code checkPermission} method doesn't allow
|
||||
* requesting password authentication.
|
||||
* @since 9
|
||||
* @see SecurityManager#checkPermission
|
||||
* @see java.net.NetPermission
|
||||
*/
|
||||
public static Authenticator getDefault() {
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
if (sm != null) {
|
||||
NetPermission requestPermission
|
||||
= new NetPermission("requestPasswordAuthentication");
|
||||
sm.checkPermission(requestPermission);
|
||||
}
|
||||
return theAuthenticator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ask the authenticator that has been registered with the system
|
||||
* for a password.
|
||||
|
||||
@ -32,6 +32,7 @@ import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import jdk.internal.misc.JavaSecurityAccess;
|
||||
import jdk.internal.misc.JavaSecurityProtectionDomainAccess;
|
||||
@ -524,7 +525,7 @@ public class ProtectionDomain {
|
||||
// have some side effects so this manual
|
||||
// comparison is sufficient.
|
||||
if (pdpName.equals(pp.getName()) &&
|
||||
pdpActions.equals(pp.getActions())) {
|
||||
Objects.equals(pdpActions, pp.getActions())) {
|
||||
plVector.remove(i);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -120,6 +120,24 @@ import sun.security.util.Debug;
|
||||
* gathered, for example, if the entropy source is /dev/random on various
|
||||
* Unix-like operating systems.
|
||||
*
|
||||
* <h2> Thread safety </h2>
|
||||
* {@code SecureRandom} objects are safe for use by multiple concurrent threads.
|
||||
*
|
||||
* @implSpec
|
||||
* A {@code SecureRandom} service provider can advertise that it is thread-safe
|
||||
* by setting the <a href=
|
||||
* "{@docRoot}/../technotes/guides/security/StandardNames.html#Service">service
|
||||
* provider attribute</a> "ThreadSafe" to "true" when registering the provider.
|
||||
* Otherwise, this class will instead synchronize access to the following
|
||||
* methods of the {@code SecureRandomSpi} implementation:
|
||||
* <ul>
|
||||
* <li>{@link SecureRandomSpi#engineSetSeed(byte[])}
|
||||
* <li>{@link SecureRandomSpi#engineNextBytes(byte[])}
|
||||
* <li>{@link SecureRandomSpi#engineNextBytes(byte[], SecureRandomParameters)}
|
||||
* <li>{@link SecureRandomSpi#engineGenerateSeed(int)}
|
||||
* <li>{@link SecureRandomSpi#engineReseed(SecureRandomParameters)}
|
||||
* </ul>
|
||||
*
|
||||
* @see java.security.SecureRandomSpi
|
||||
* @see java.util.Random
|
||||
*
|
||||
@ -150,6 +168,14 @@ public class SecureRandom extends java.util.Random {
|
||||
*/
|
||||
private SecureRandomSpi secureRandomSpi = null;
|
||||
|
||||
/**
|
||||
* Thread safety.
|
||||
*
|
||||
* @serial
|
||||
* @since 9
|
||||
*/
|
||||
private final boolean threadSafe;
|
||||
|
||||
/*
|
||||
* The algorithm name of null if unknown.
|
||||
*
|
||||
@ -189,6 +215,16 @@ public class SecureRandom extends java.util.Random {
|
||||
*/
|
||||
super(0);
|
||||
getDefaultPRNG(false, null);
|
||||
this.threadSafe = getThreadSafe();
|
||||
}
|
||||
|
||||
private boolean getThreadSafe() {
|
||||
if (provider == null || algorithm == null) {
|
||||
return false;
|
||||
} else {
|
||||
return Boolean.parseBoolean(provider.getProperty(
|
||||
"SecureRandom." + algorithm + " ThreadSafe", "false"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -217,6 +253,7 @@ public class SecureRandom extends java.util.Random {
|
||||
public SecureRandom(byte[] seed) {
|
||||
super(0);
|
||||
getDefaultPRNG(true, seed);
|
||||
this.threadSafe = getThreadSafe();
|
||||
}
|
||||
|
||||
private void getDefaultPRNG(boolean setSeed, byte[] seed) {
|
||||
@ -269,6 +306,7 @@ public class SecureRandom extends java.util.Random {
|
||||
this.secureRandomSpi = secureRandomSpi;
|
||||
this.provider = provider;
|
||||
this.algorithm = algorithm;
|
||||
this.threadSafe = getThreadSafe();
|
||||
|
||||
if (!skipDebug && pdebug != null) {
|
||||
pdebug.println("SecureRandom." + algorithm +
|
||||
@ -653,8 +691,14 @@ public class SecureRandom extends java.util.Random {
|
||||
*
|
||||
* @see #getSeed
|
||||
*/
|
||||
public synchronized void setSeed(byte[] seed) {
|
||||
secureRandomSpi.engineSetSeed(seed);
|
||||
public void setSeed(byte[] seed) {
|
||||
if (threadSafe) {
|
||||
secureRandomSpi.engineSetSeed(seed);
|
||||
} else {
|
||||
synchronized (this) {
|
||||
secureRandomSpi.engineSetSeed(seed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -679,7 +723,7 @@ public class SecureRandom extends java.util.Random {
|
||||
* yet been initialized at that point.
|
||||
*/
|
||||
if (seed != 0) {
|
||||
this.secureRandomSpi.engineSetSeed(longToByteArray(seed));
|
||||
setSeed(longToByteArray(seed));
|
||||
}
|
||||
}
|
||||
|
||||
@ -690,7 +734,13 @@ public class SecureRandom extends java.util.Random {
|
||||
*/
|
||||
@Override
|
||||
public void nextBytes(byte[] bytes) {
|
||||
secureRandomSpi.engineNextBytes(bytes);
|
||||
if (threadSafe) {
|
||||
secureRandomSpi.engineNextBytes(bytes);
|
||||
} else {
|
||||
synchronized (this) {
|
||||
secureRandomSpi.engineNextBytes(bytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -707,12 +757,19 @@ public class SecureRandom extends java.util.Random {
|
||||
*
|
||||
* @since 9
|
||||
*/
|
||||
public synchronized void nextBytes(
|
||||
byte[] bytes, SecureRandomParameters params) {
|
||||
public void nextBytes(byte[] bytes, SecureRandomParameters params) {
|
||||
if (params == null) {
|
||||
throw new IllegalArgumentException("params cannot be null");
|
||||
}
|
||||
secureRandomSpi.engineNextBytes(Objects.requireNonNull(bytes), params);
|
||||
if (threadSafe) {
|
||||
secureRandomSpi.engineNextBytes(
|
||||
Objects.requireNonNull(bytes), params);
|
||||
} else {
|
||||
synchronized (this) {
|
||||
secureRandomSpi.engineNextBytes(
|
||||
Objects.requireNonNull(bytes), params);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -756,6 +813,7 @@ public class SecureRandom extends java.util.Random {
|
||||
*
|
||||
* @param numBytes the number of seed bytes to generate.
|
||||
*
|
||||
* @throws IllegalArgumentException if {@code numBytes} is negative
|
||||
* @return the seed bytes.
|
||||
*
|
||||
* @see #setSeed
|
||||
@ -782,7 +840,13 @@ public class SecureRandom extends java.util.Random {
|
||||
if (numBytes < 0) {
|
||||
throw new IllegalArgumentException("numBytes cannot be negative");
|
||||
}
|
||||
return secureRandomSpi.engineGenerateSeed(numBytes);
|
||||
if (threadSafe) {
|
||||
return secureRandomSpi.engineGenerateSeed(numBytes);
|
||||
} else {
|
||||
synchronized (this) {
|
||||
return secureRandomSpi.engineGenerateSeed(numBytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -917,8 +981,14 @@ public class SecureRandom extends java.util.Random {
|
||||
*
|
||||
* @since 9
|
||||
*/
|
||||
public synchronized void reseed() {
|
||||
secureRandomSpi.engineReseed(null);
|
||||
public void reseed() {
|
||||
if (threadSafe) {
|
||||
secureRandomSpi.engineReseed(null);
|
||||
} else {
|
||||
synchronized (this) {
|
||||
secureRandomSpi.engineReseed(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -937,11 +1007,17 @@ public class SecureRandom extends java.util.Random {
|
||||
*
|
||||
* @since 9
|
||||
*/
|
||||
public synchronized void reseed(SecureRandomParameters params) {
|
||||
public void reseed(SecureRandomParameters params) {
|
||||
if (params == null) {
|
||||
throw new IllegalArgumentException("params cannot be null");
|
||||
}
|
||||
secureRandomSpi.engineReseed(params);
|
||||
if (threadSafe) {
|
||||
secureRandomSpi.engineReseed(params);
|
||||
} else {
|
||||
synchronized (this) {
|
||||
secureRandomSpi.engineReseed(params);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Declare serialVersionUID to be compatible with JDK1.1
|
||||
|
||||
@ -58,6 +58,26 @@ package java.security;
|
||||
* a {@code SecureRandomParameters} argument will never
|
||||
* return an instance of this implementation. The
|
||||
* {@link #engineGetParameters()} method must return {@code null}.
|
||||
* <p>
|
||||
* See {@link SecureRandom} for additional details on thread safety. By
|
||||
* default, a {@code SecureRandomSpi} implementation is considered to be
|
||||
* not safe for use by multiple concurrent threads and {@code SecureRandom}
|
||||
* will synchronize access to each of the applicable engine methods
|
||||
* (see {@link SecureRandom} for the list of methods). However, if a
|
||||
* {@code SecureRandomSpi} implementation is thread-safe, the <a href=
|
||||
* "{@docRoot}/../technotes/guides/security/StandardNames.html#Service">
|
||||
* service provider attribute</a> "ThreadSafe" should be set to "true" during
|
||||
* its registration, as follows:
|
||||
* <blockquote><pre>
|
||||
* put("SecureRandom.AlgName ThreadSafe", "true");</pre>
|
||||
* </blockquote>
|
||||
* or
|
||||
* <blockquote><pre>
|
||||
* putService(new Service(this, "SecureRandom", "AlgName", className,
|
||||
* null, Map.of("ThreadSafe", "true")));</pre>
|
||||
* </blockquote>
|
||||
* {@code SecureRandom} will call the applicable engine methods
|
||||
* without any synchronization.
|
||||
*
|
||||
* @since 1.2
|
||||
*/
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -76,6 +76,7 @@ import java.time.temporal.UnsupportedTemporalTypeException;
|
||||
import java.time.zone.ZoneRules;
|
||||
import java.time.zone.ZoneRulesException;
|
||||
import java.time.zone.ZoneRulesProvider;
|
||||
import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
@ -284,7 +285,7 @@ public abstract class ZoneId implements Serializable {
|
||||
* @return a modifiable copy of the set of zone IDs, not null
|
||||
*/
|
||||
public static Set<String> getAvailableZoneIds() {
|
||||
return ZoneRulesProvider.getAvailableZoneIds();
|
||||
return new HashSet<String>(ZoneRulesProvider.getAvailableZoneIds());
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -302,14 +302,10 @@ final class DateTimePrintContext {
|
||||
* @throws DateTimeException if the field is not available and the section is not optional
|
||||
*/
|
||||
Long getValue(TemporalField field) {
|
||||
try {
|
||||
return temporal.getLong(field);
|
||||
} catch (DateTimeException ex) {
|
||||
if (optional > 0) {
|
||||
return null;
|
||||
}
|
||||
throw ex;
|
||||
if (optional > 0 && !temporal.isSupported(field)) {
|
||||
return null;
|
||||
}
|
||||
return temporal.getLong(field);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -77,6 +77,7 @@ import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
* Provider of time-zone rules to the system.
|
||||
@ -137,6 +138,11 @@ public abstract class ZoneRulesProvider {
|
||||
*/
|
||||
private static final ConcurrentMap<String, ZoneRulesProvider> ZONES = new ConcurrentHashMap<>(512, 0.75f, 2);
|
||||
|
||||
/**
|
||||
* The zone ID data
|
||||
*/
|
||||
private static volatile Set<String> ZONE_IDS;
|
||||
|
||||
static {
|
||||
// if the property java.time.zone.DefaultZoneRulesProvider is
|
||||
// set then its value is the class name of the default provider
|
||||
@ -194,10 +200,10 @@ public abstract class ZoneRulesProvider {
|
||||
* <p>
|
||||
* These IDs are the string form of a {@link ZoneId}.
|
||||
*
|
||||
* @return a modifiable copy of the set of zone IDs, not null
|
||||
* @return the unmodifiable set of zone IDs, not null
|
||||
*/
|
||||
public static Set<String> getAvailableZoneIds() {
|
||||
return new HashSet<>(ZONES.keySet());
|
||||
return ZONE_IDS;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -303,7 +309,7 @@ public abstract class ZoneRulesProvider {
|
||||
* @param provider the provider to register, not null
|
||||
* @throws ZoneRulesException if unable to complete the registration
|
||||
*/
|
||||
private static void registerProvider0(ZoneRulesProvider provider) {
|
||||
private static synchronized void registerProvider0(ZoneRulesProvider provider) {
|
||||
for (String zoneId : provider.provideZoneIds()) {
|
||||
Objects.requireNonNull(zoneId, "zoneId");
|
||||
ZoneRulesProvider old = ZONES.putIfAbsent(zoneId, provider);
|
||||
@ -313,6 +319,8 @@ public abstract class ZoneRulesProvider {
|
||||
", currently loading from provider: " + provider);
|
||||
}
|
||||
}
|
||||
Set<String> combinedSet = new HashSet<String>(ZONES.keySet());
|
||||
ZONE_IDS = Collections.unmodifiableSet(combinedSet);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1995, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -29,6 +29,7 @@ import java.io.*;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.LongBuffer;
|
||||
import java.util.function.IntConsumer;
|
||||
import java.util.stream.IntStream;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
@ -1217,32 +1218,156 @@ public class BitSet implements Cloneable, java.io.Serializable {
|
||||
* @since 1.8
|
||||
*/
|
||||
public IntStream stream() {
|
||||
class BitSetIterator implements PrimitiveIterator.OfInt {
|
||||
int next = nextSetBit(0);
|
||||
class BitSetSpliterator implements Spliterator.OfInt {
|
||||
private int index; // current bit index for a set bit
|
||||
private int fence; // -1 until used; then one past last bit index
|
||||
private int est; // size estimate
|
||||
private boolean root; // true if root and not split
|
||||
// root == true then size estimate is accurate
|
||||
// index == -1 or index >= fence if fully traversed
|
||||
// Special case when the max bit set is Integer.MAX_VALUE
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return next != -1;
|
||||
BitSetSpliterator(int origin, int fence, int est, boolean root) {
|
||||
this.index = origin;
|
||||
this.fence = fence;
|
||||
this.est = est;
|
||||
this.root = root;
|
||||
}
|
||||
|
||||
private int getFence() {
|
||||
int hi;
|
||||
if ((hi = fence) < 0) {
|
||||
// Round up fence to maximum cardinality for allocated words
|
||||
// This is sufficient and cheap for sequential access
|
||||
// When splitting this value is lowered
|
||||
hi = fence = (wordsInUse >= wordIndex(Integer.MAX_VALUE))
|
||||
? Integer.MAX_VALUE
|
||||
: wordsInUse << ADDRESS_BITS_PER_WORD;
|
||||
est = cardinality();
|
||||
index = nextSetBit(0);
|
||||
}
|
||||
return hi;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int nextInt() {
|
||||
if (next != -1) {
|
||||
int ret = next;
|
||||
next = (next == Integer.MAX_VALUE) ? -1 : nextSetBit(next+1);
|
||||
return ret;
|
||||
} else {
|
||||
throw new NoSuchElementException();
|
||||
public boolean tryAdvance(IntConsumer action) {
|
||||
Objects.requireNonNull(action);
|
||||
|
||||
int hi = getFence();
|
||||
int i = index;
|
||||
if (i < 0 || i >= hi) {
|
||||
// Check if there is a final bit set for Integer.MAX_VALUE
|
||||
if (i == Integer.MAX_VALUE && hi == Integer.MAX_VALUE) {
|
||||
index = -1;
|
||||
action.accept(Integer.MAX_VALUE);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
index = nextSetBit(i + 1, wordIndex(hi - 1));
|
||||
action.accept(i);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forEachRemaining(IntConsumer action) {
|
||||
Objects.requireNonNull(action);
|
||||
|
||||
int hi = getFence();
|
||||
int i = index;
|
||||
int v = wordIndex(hi - 1);
|
||||
index = -1;
|
||||
while (i >= 0 && i < hi) {
|
||||
action.accept(i);
|
||||
i = nextSetBit(i + 1, v);
|
||||
}
|
||||
// Check if there is a final bit set for Integer.MAX_VALUE
|
||||
if (i == Integer.MAX_VALUE && hi == Integer.MAX_VALUE) {
|
||||
action.accept(Integer.MAX_VALUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return StreamSupport.intStream(
|
||||
() -> Spliterators.spliterator(
|
||||
new BitSetIterator(), cardinality(),
|
||||
Spliterator.ORDERED | Spliterator.DISTINCT | Spliterator.SORTED),
|
||||
Spliterator.SIZED | Spliterator.SUBSIZED |
|
||||
Spliterator.ORDERED | Spliterator.DISTINCT | Spliterator.SORTED,
|
||||
false);
|
||||
@Override
|
||||
public OfInt trySplit() {
|
||||
int hi = getFence();
|
||||
int lo = index;
|
||||
if (lo < 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Lower the fence to be the upper bound of last bit set
|
||||
// The index is the first bit set, thus this spliterator
|
||||
// covers one bit and cannot be split, or two or more
|
||||
// bits
|
||||
hi = fence = (hi < Integer.MAX_VALUE || !get(Integer.MAX_VALUE))
|
||||
? previousSetBit(hi - 1) + 1
|
||||
: Integer.MAX_VALUE;
|
||||
|
||||
// Find the mid point
|
||||
int mid = (lo + hi) >>> 1;
|
||||
if (lo >= mid) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Raise the index of this spliterator to be the next set bit
|
||||
// from the mid point
|
||||
index = nextSetBit(mid, wordIndex(hi - 1));
|
||||
root = false;
|
||||
|
||||
// Don't lower the fence (mid point) of the returned spliterator,
|
||||
// traversal or further splitting will do that work
|
||||
return new BitSetSpliterator(lo, mid, est >>>= 1, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long estimateSize() {
|
||||
getFence(); // force init
|
||||
return est;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int characteristics() {
|
||||
// Only sized when root and not split
|
||||
return (root ? Spliterator.SIZED : 0) |
|
||||
Spliterator.ORDERED | Spliterator.DISTINCT | Spliterator.SORTED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Comparator<? super Integer> getComparator() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return StreamSupport.intStream(new BitSetSpliterator(0, -1, 0, true), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the index of the first bit that is set to {@code true}
|
||||
* that occurs on or after the specified starting index and up to and
|
||||
* including the specified word index
|
||||
* If no such bit exists then {@code -1} is returned.
|
||||
*
|
||||
* @param fromIndex the index to start checking from (inclusive)
|
||||
* @param toWordIndex the last word index to check (inclusive)
|
||||
* @return the index of the next set bit, or {@code -1} if there
|
||||
* is no such bit
|
||||
*/
|
||||
private int nextSetBit(int fromIndex, int toWordIndex) {
|
||||
int u = wordIndex(fromIndex);
|
||||
// Check if out of bounds
|
||||
if (u > toWordIndex)
|
||||
return -1;
|
||||
|
||||
long word = words[u] & (WORD_MASK << fromIndex);
|
||||
|
||||
while (true) {
|
||||
if (word != 0)
|
||||
return (u * BITS_PER_WORD) + Long.numberOfTrailingZeros(word);
|
||||
// Check if out of bounds
|
||||
if (++u > toWordIndex)
|
||||
return -1;
|
||||
word = words[u];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1327,7 +1327,7 @@ public interface Stream<T> extends BaseStream<T, Stream<T>> {
|
||||
* @param s the {@code Supplier} of generated elements
|
||||
* @return a new infinite sequential unordered {@code Stream}
|
||||
*/
|
||||
public static<T> Stream<T> generate(Supplier<T> s) {
|
||||
public static<T> Stream<T> generate(Supplier<? extends T> s) {
|
||||
Objects.requireNonNull(s);
|
||||
return StreamSupport.stream(
|
||||
new StreamSpliterators.InfiniteSupplyingSpliterator.OfRef<>(Long.MAX_VALUE, s), false);
|
||||
|
||||
@ -1346,9 +1346,9 @@ class StreamSpliterators {
|
||||
}
|
||||
|
||||
static final class OfRef<T> extends InfiniteSupplyingSpliterator<T> {
|
||||
final Supplier<T> s;
|
||||
final Supplier<? extends T> s;
|
||||
|
||||
OfRef(long size, Supplier<T> s) {
|
||||
OfRef(long size, Supplier<? extends T> s) {
|
||||
super(size);
|
||||
this.s = s;
|
||||
}
|
||||
|
||||
@ -72,13 +72,13 @@ public class ClassLoaders {
|
||||
// If neither is specified then default to -cp <working directory>
|
||||
// If -cp is not specified and -m is specified, the value of
|
||||
// java.class.path is an empty string, then no class path.
|
||||
URLClassPath ucp = null;
|
||||
URLClassPath ucp = new URLClassPath(new URL[0]);
|
||||
String mainMid = System.getProperty("jdk.module.main");
|
||||
String cp = System.getProperty("java.class.path");
|
||||
if (cp == null)
|
||||
cp = "";
|
||||
if (mainMid == null || cp.length() > 0)
|
||||
ucp = toURLClassPath(cp);
|
||||
addClassPathToUCP(cp, ucp);
|
||||
|
||||
// create the class loaders
|
||||
BOOT_LOADER = new BootClassLoader(bcp);
|
||||
|
||||
@ -462,6 +462,8 @@ public final class LauncherHelper {
|
||||
* This method:
|
||||
* 1. Loads the main class from the module or class path
|
||||
* 2. Checks the public static void main method.
|
||||
* 3. If the main class extends FX Application then call on FXHelper to
|
||||
* perform the launch.
|
||||
*
|
||||
* @param printToStderr if set, all output will be routed to stderr
|
||||
* @param mode LaunchMode as determined by the arguments passed on the
|
||||
@ -479,11 +481,23 @@ public final class LauncherHelper {
|
||||
Class<?> mainClass = (mode == LM_MODULE) ? loadModuleMainClass(what)
|
||||
: loadMainClass(mode, what);
|
||||
|
||||
validateMainClass(mainClass);
|
||||
// record the real main class for UI purposes
|
||||
// neither method above can return null, they will abort()
|
||||
appClass = mainClass;
|
||||
|
||||
// record main class if not already set
|
||||
if (appClass == null)
|
||||
appClass = mainClass;
|
||||
/*
|
||||
* Check if FXHelper can launch it using the FX launcher. In an FX app,
|
||||
* the main class may or may not have a main method, so do this before
|
||||
* validating the main class.
|
||||
*/
|
||||
if (JAVAFX_FXHELPER_CLASS_NAME_SUFFIX.equals(mainClass.getName()) ||
|
||||
doesExtendFXApplication(mainClass)) {
|
||||
// Will abort() if there are problems with FX runtime
|
||||
FXHelper.setFXLaunchParameters(what, mode);
|
||||
mainClass = FXHelper.class;
|
||||
}
|
||||
|
||||
validateMainClass(mainClass);
|
||||
|
||||
return mainClass;
|
||||
}
|
||||
@ -530,7 +544,6 @@ public final class LauncherHelper {
|
||||
|
||||
String cn = Normalizer.normalize(mainClass, Normalizer.Form.NFC);
|
||||
c = Class.forName(m, cn);
|
||||
|
||||
}
|
||||
if (c == null) {
|
||||
abort(null, "java.launcher.module.error2", mainClass, mainModule);
|
||||
@ -542,8 +555,6 @@ public final class LauncherHelper {
|
||||
|
||||
/**
|
||||
* Loads the main class from the class path (LM_CLASS or LM_JAR).
|
||||
* If the main class extends FX Application then call on FXHelper to
|
||||
* determine the main class to launch.
|
||||
*/
|
||||
private static Class<?> loadMainClass(int mode, String what) {
|
||||
// get the class name
|
||||
@ -570,7 +581,7 @@ public final class LauncherHelper {
|
||||
if (System.getProperty("os.name", "").contains("OS X")
|
||||
&& Normalizer.isNormalized(cn, Normalizer.Form.NFD)) {
|
||||
try {
|
||||
// On Mac OS X since all names with diacretic symbols are
|
||||
// On Mac OS X since all names with diacritical marks are
|
||||
// given as decomposed it is possible that main class name
|
||||
// comes incorrectly from the command line and we have
|
||||
// to re-compose it
|
||||
@ -583,21 +594,6 @@ public final class LauncherHelper {
|
||||
abort(cnfe, "java.launcher.cls.error1", cn);
|
||||
}
|
||||
}
|
||||
|
||||
// record the main class
|
||||
appClass = mainClass;
|
||||
|
||||
/*
|
||||
* Check if FXHelper can launch it using the FX launcher. In an FX app,
|
||||
* the main class may or may not have a main method, so do this before
|
||||
* validating the main class.
|
||||
*/
|
||||
if (JAVAFX_FXHELPER_CLASS_NAME_SUFFIX.equals(mainClass.getName()) ||
|
||||
doesExtendFXApplication(mainClass)) {
|
||||
// Will abort() if there are problems with FX runtime
|
||||
FXHelper.setFXLaunchParameters(what, mode);
|
||||
return FXHelper.class;
|
||||
}
|
||||
return mainClass;
|
||||
}
|
||||
|
||||
@ -773,9 +769,15 @@ public final class LauncherHelper {
|
||||
* java -cp somedir FXClass N/A LM_CLASS "LM_CLASS"
|
||||
* java -jar fxapp.jar Present LM_JAR "LM_JAR"
|
||||
* java -jar fxapp.jar Not Present LM_JAR "LM_JAR"
|
||||
* java -m module/class [1] N/A LM_MODULE "LM_MODULE"
|
||||
* java -m module N/A LM_MODULE "LM_MODULE"
|
||||
*
|
||||
* [1] - JavaFX-Application-Class is ignored when modular args are used, even
|
||||
* if present in a modular jar
|
||||
*/
|
||||
private static final String JAVAFX_LAUNCH_MODE_CLASS = "LM_CLASS";
|
||||
private static final String JAVAFX_LAUNCH_MODE_JAR = "LM_JAR";
|
||||
private static final String JAVAFX_LAUNCH_MODE_MODULE = "LM_MODULE";
|
||||
|
||||
/*
|
||||
* FX application launcher and launch method, so we can launch
|
||||
@ -835,6 +837,9 @@ public final class LauncherHelper {
|
||||
case LM_JAR:
|
||||
fxLaunchMode = JAVAFX_LAUNCH_MODE_JAR;
|
||||
break;
|
||||
case LM_MODULE:
|
||||
fxLaunchMode = JAVAFX_LAUNCH_MODE_MODULE;
|
||||
break;
|
||||
default:
|
||||
// should not have gotten this far...
|
||||
throw new InternalError(mode + ": Unknown launch mode");
|
||||
|
||||
@ -96,25 +96,32 @@ final class SunEntries {
|
||||
if (nativeAvailable && useNativePRNG) {
|
||||
map.put("SecureRandom.NativePRNG",
|
||||
"sun.security.provider.NativePRNG");
|
||||
map.put("SecureRandom.NativePRNG ThreadSafe", "true");
|
||||
}
|
||||
|
||||
map.put("SecureRandom.DRBG", "sun.security.provider.DRBG");
|
||||
map.put("SecureRandom.DRBG ThreadSafe", "true");
|
||||
|
||||
map.put("SecureRandom.SHA1PRNG",
|
||||
"sun.security.provider.SecureRandom");
|
||||
|
||||
map.put("SecureRandom.SHA1PRNG ThreadSafe", "true");
|
||||
if (nativeAvailable && !useNativePRNG) {
|
||||
map.put("SecureRandom.NativePRNG",
|
||||
"sun.security.provider.NativePRNG");
|
||||
map.put("SecureRandom.NativePRNG ThreadSafe", "true");
|
||||
}
|
||||
|
||||
if (NativePRNG.Blocking.isAvailable()) {
|
||||
map.put("SecureRandom.NativePRNGBlocking",
|
||||
"sun.security.provider.NativePRNG$Blocking");
|
||||
map.put("SecureRandom.NativePRNGBlocking ThreadSafe", "true");
|
||||
}
|
||||
|
||||
if (NativePRNG.NonBlocking.isAvailable()) {
|
||||
map.put("SecureRandom.NativePRNGNonBlocking",
|
||||
"sun.security.provider.NativePRNG$NonBlocking");
|
||||
map.put("SecureRandom.NativePRNGNonBlocking ThreadSafe", "true");
|
||||
}
|
||||
|
||||
/*
|
||||
@ -329,6 +336,7 @@ final class SunEntries {
|
||||
map.put("AlgorithmParameters.DSA ImplementedIn", "Software");
|
||||
map.put("KeyFactory.DSA ImplementedIn", "Software");
|
||||
map.put("SecureRandom.SHA1PRNG ImplementedIn", "Software");
|
||||
map.put("SecureRandom.DRBG ImplementedIn", "Software");
|
||||
map.put("CertificateFactory.X.509 ImplementedIn", "Software");
|
||||
map.put("KeyStore.JKS ImplementedIn", "Software");
|
||||
map.put("CertPathValidator.PKIX ImplementedIn", "Software");
|
||||
|
||||
@ -740,7 +740,7 @@ class RevocationChecker extends PKIXRevocationChecker {
|
||||
}
|
||||
|
||||
response = OCSP.check(Collections.singletonList(certId),
|
||||
responderURI, issuerInfo, responderCert, params.date(),
|
||||
responderURI, issuerInfo, responderCert, null,
|
||||
ocspExtensions);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
|
||||
@ -58,7 +58,7 @@ public class AnchorCertificates {
|
||||
try {
|
||||
cacerts = KeyStore.getInstance("JKS");
|
||||
try (FileInputStream fis = new FileInputStream(f)) {
|
||||
cacerts.load(fis, "changeit".toCharArray());
|
||||
cacerts.load(fis, null);
|
||||
certs = new HashSet<>();
|
||||
Enumeration<String> list = cacerts.aliases();
|
||||
String alias;
|
||||
|
||||
@ -155,7 +155,6 @@ grant codeBase "jrt:/jdk.jsobject" {
|
||||
grant codeBase "jrt:/jdk.localedata" {
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.text.*";
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.util.*";
|
||||
permission java.util.PropertyPermission "*", "read";
|
||||
};
|
||||
|
||||
grant codeBase "jrt:/jdk.naming.dns" {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -554,7 +554,7 @@ public class ThreadInfo {
|
||||
* @return an array of {@code StackTraceElement} objects of the thread.
|
||||
*/
|
||||
public StackTraceElement[] getStackTrace() {
|
||||
return stackTrace;
|
||||
return stackTrace.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -868,7 +868,7 @@ public class ThreadInfo {
|
||||
* @since 1.6
|
||||
*/
|
||||
public MonitorInfo[] getLockedMonitors() {
|
||||
return lockedMonitors;
|
||||
return lockedMonitors.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -885,7 +885,7 @@ public class ThreadInfo {
|
||||
* @since 1.6
|
||||
*/
|
||||
public LockInfo[] getLockedSynchronizers() {
|
||||
return lockedSynchronizers;
|
||||
return lockedSynchronizers.clone();
|
||||
}
|
||||
|
||||
private static final StackTraceElement[] NO_STACK_TRACE =
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -916,14 +916,14 @@ public interface ModuleMXBean {
|
||||
<li><p>Otherwise, <em>J</em> is not reconstructible.</p></li>
|
||||
</ol>
|
||||
|
||||
<p>When only {@code @java.beans.ConstructorProperties} is present then
|
||||
rule 2 is not applicable to subset Profiles of Java SE that do not include
|
||||
the {@code java.beans} package. When targeting a runtime that does
|
||||
not include the {@code java.beans} package, and where there is a mismatch
|
||||
between the compile-time and runtime environment whereby <em>J</em> is
|
||||
compiled with a public constructor and the {@code ConstructorProperties}
|
||||
annotation, then <em>J</em> is not reconstructible unless another rule
|
||||
applies.</p>
|
||||
<p>Rule 2 is not applicable when {@code java.beans.ConstructorProperties}
|
||||
is not visible (e.g. when the java.desktop module is not readable or when
|
||||
the runtime image does not contain the java.desktop module). When
|
||||
targeting a runtime that does not include the {@code java.beans} package,
|
||||
and where there is a mismatch between the compile-time and runtime
|
||||
environment whereby <em>J</em> is compiled with a public constructor
|
||||
and the {@code ConstructorProperties} annotation, then <em>J</em> is
|
||||
not reconstructible unless another rule applies.</p>
|
||||
|
||||
<p>Here are examples showing different ways to code a type {@code
|
||||
NamedNumber} that consists of an {@code int} and a {@code
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -102,7 +102,13 @@ class VMManagementImpl implements VMManagement {
|
||||
}
|
||||
|
||||
public boolean isGcNotificationSupported() {
|
||||
return gcNotificationSupport;
|
||||
boolean isSupported = true;
|
||||
try {
|
||||
Class.forName("com.sun.management.GarbageCollectorMXBean");
|
||||
} catch (ClassNotFoundException x) {
|
||||
isSupported = false;
|
||||
}
|
||||
return isSupported;
|
||||
}
|
||||
|
||||
public boolean isRemoteDiagnosticCommandsSupported() {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -96,13 +96,6 @@ Java_sun_management_VMManagementImpl_initOptionalSupportFields
|
||||
|
||||
value = mos.isRemoteDiagnosticCommandsSupported;
|
||||
setStaticBooleanField(env, cls, "remoteDiagnosticCommandsSupport", value);
|
||||
|
||||
if ((jmm_version > JMM_VERSION_1_2) ||
|
||||
(jmm_version == JMM_VERSION_1_2 && ((jmm_version&0xFF) >= 1))) {
|
||||
setStaticBooleanField(env, cls, "gcNotificationSupport", JNI_TRUE);
|
||||
} else {
|
||||
setStaticBooleanField(env, cls, "gcNotificationSupport", JNI_FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT jobjectArray JNICALL
|
||||
|
||||
@ -33,6 +33,8 @@ import java.security.InvalidParameterException;
|
||||
import java.security.ProviderException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
import static sun.security.util.SecurityConstants.PROVIDER_VER;
|
||||
|
||||
/**
|
||||
@ -133,8 +135,11 @@ public final class SunMSCAPI extends Provider {
|
||||
/*
|
||||
* Secure random
|
||||
*/
|
||||
HashMap<String, String> srattrs = new HashMap<>(1);
|
||||
srattrs.put("ThreadSafe", "true");
|
||||
putService(new ProviderService(p, "SecureRandom",
|
||||
"Windows-PRNG", "sun.security.mscapi.PRNG"));
|
||||
"Windows-PRNG", "sun.security.mscapi.PRNG",
|
||||
null, srattrs));
|
||||
|
||||
/*
|
||||
* Key store
|
||||
|
||||
@ -987,7 +987,8 @@ public final class SunPKCS11 extends AuthProvider {
|
||||
|
||||
P11Service(Token token, String type, String algorithm,
|
||||
String className, String[] al, long mechanism) {
|
||||
super(token.provider, type, algorithm, className, toList(al), null);
|
||||
super(token.provider, type, algorithm, className, toList(al),
|
||||
type.equals(SR) ? Map.of("ThreadSafe", "true") : null);
|
||||
this.token = token;
|
||||
this.mechanism = mechanism & 0xFFFFFFFFL;
|
||||
}
|
||||
|
||||
@ -174,9 +174,20 @@ byteArrayToPacket(JNIEnv *env, jbyteArray b, jdwpPacket *str)
|
||||
* Get the packet header
|
||||
*/
|
||||
(*env)->GetByteArrayRegion(env, b, 0, sizeof(pktHeader), pktHeader);
|
||||
if ((*env)->ExceptionOccurred(env)) {
|
||||
/* b shorter than sizeof(pktHeader) */
|
||||
return;
|
||||
}
|
||||
|
||||
total_length = (int)pktHeader[3] | ((int)pktHeader[2] << 8) |
|
||||
((int)pktHeader[1] << 16) | ((int)pktHeader[0] << 24);
|
||||
|
||||
if (total_length < sizeof(pktHeader)) {
|
||||
throwException(env, "java/lang/IllegalArgumentException",
|
||||
"JDWP header is incorrect");
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* The id field is in big endian (also errorCode field in the case
|
||||
* of reply packets).
|
||||
@ -195,9 +206,9 @@ byteArrayToPacket(JNIEnv *env, jbyteArray b, jdwpPacket *str)
|
||||
}
|
||||
|
||||
/*
|
||||
* The length of the JDWP packet is 11 + data
|
||||
* The length of the JDWP packet is sizeof(pktHeader) + data
|
||||
*/
|
||||
data_length = total_length - 11;
|
||||
data_length = total_length - sizeof(pktHeader);
|
||||
|
||||
if (data_length == 0) {
|
||||
data = NULL;
|
||||
@ -209,7 +220,7 @@ byteArrayToPacket(JNIEnv *env, jbyteArray b, jdwpPacket *str)
|
||||
return;
|
||||
}
|
||||
|
||||
(*env)->GetByteArrayRegion(env, b, 11, /*sizeof(CmdPacket)+4*/ data_length, data);
|
||||
(*env)->GetByteArrayRegion(env, b, sizeof(pktHeader), /*sizeof(CmdPacket)+4*/ data_length, data);
|
||||
if ((*env)->ExceptionOccurred(env)) {
|
||||
free(data);
|
||||
return;
|
||||
|
||||
@ -32,6 +32,7 @@ import java.nio.file.FileSystem;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.PathMatcher;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.MissingResourceException;
|
||||
@ -190,19 +191,12 @@ class JImageTask {
|
||||
if (options.help) {
|
||||
if (unhandled.isEmpty()) {
|
||||
log.println(TASK_HELPER.getMessage("main.usage", PROGNAME));
|
||||
|
||||
for (Option<?> o : RECOGNIZED_OPTIONS) {
|
||||
String name = o.aliases()[0];
|
||||
|
||||
if (name.startsWith("--")) {
|
||||
name = name.substring(2);
|
||||
} else if (name.startsWith("-")) {
|
||||
name = name.substring(1);
|
||||
}
|
||||
|
||||
log.println(TASK_HELPER.getMessage("main.opt." + name));
|
||||
}
|
||||
|
||||
Arrays.asList(RECOGNIZED_OPTIONS).stream()
|
||||
.filter(option -> !option.isHidden())
|
||||
.sorted()
|
||||
.forEach(option -> {
|
||||
log.println(TASK_HELPER.getMessage(option.resourceName()));
|
||||
});
|
||||
log.println(TASK_HELPER.getMessage("main.opt.footer"));
|
||||
} else {
|
||||
try {
|
||||
|
||||
@ -60,36 +60,36 @@ error.prefix=Error:
|
||||
warn.prefix=Warning:
|
||||
|
||||
main.opt.dir=\
|
||||
\ --dir Target directory for extract directive
|
||||
\ --dir Target directory for extract directive
|
||||
|
||||
main.opt.include=\
|
||||
\ --include <pattern-list> Pattern list for filtering entries.
|
||||
|
||||
main.opt.footer=\
|
||||
\n\
|
||||
\For options requiring a <pattern-list>, the value will be a comma\
|
||||
\ separated list of elements each using one the following forms:\n\
|
||||
\ <glob-pattern>\n\
|
||||
\ glob:<glob-pattern>\n\
|
||||
\ regex:<regex-pattern>\n\
|
||||
\ @<filename> where filename is the name of a file containing patterns to be\
|
||||
\ used, one pattern per line\n\
|
||||
|
||||
\ --include <pattern-list> Pattern list for filtering entries.
|
||||
|
||||
main.opt.full-version=\
|
||||
\ --full-version Print full version information
|
||||
\ --full-version Print full version information
|
||||
|
||||
main.opt.help=\
|
||||
\ -h, --help Print usage message
|
||||
|
||||
main.opt.verbose=\
|
||||
\ --verbose Listing prints entry size and offset attributes
|
||||
\ --verbose Listing prints entry size and offset\n\
|
||||
\ attributes
|
||||
|
||||
main.opt.version=\
|
||||
\ --version Print version information
|
||||
\ --version Print version information
|
||||
|
||||
main.command.files=\
|
||||
\ @<filename> Read options from file
|
||||
\ @<filename> Read options from file
|
||||
|
||||
main.opt.footer=\
|
||||
\n\
|
||||
\For options requiring a <pattern-list>, the value will be a comma separated\n\
|
||||
\list of elements each using one the following forms:\n\
|
||||
\ <glob-pattern>\n\
|
||||
\ glob:<glob-pattern>\n\
|
||||
\ regex:<regex-pattern>
|
||||
|
||||
|
||||
|
||||
err.not.a.task=task must be one of <extract | info | list | verify>: {0}
|
||||
err.missing.arg=no value given for {0}
|
||||
|
||||
@ -27,6 +27,7 @@ package jdk.tools.jlink.internal;
|
||||
import java.lang.reflect.Layer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -278,6 +279,13 @@ public final class Jlink {
|
||||
*/
|
||||
public void build(JlinkConfiguration config, PluginsConfiguration pluginsConfig) {
|
||||
Objects.requireNonNull(config);
|
||||
if (pluginsConfig == null) {
|
||||
pluginsConfig = new PluginsConfiguration();
|
||||
}
|
||||
|
||||
// add all auto-enabled plugins from boot layer
|
||||
pluginsConfig = addAutoEnabledPlugins(pluginsConfig);
|
||||
|
||||
try {
|
||||
JlinkTask.createImage(config, pluginsConfig);
|
||||
} catch (Exception ex) {
|
||||
@ -285,6 +293,19 @@ public final class Jlink {
|
||||
}
|
||||
}
|
||||
|
||||
private PluginsConfiguration addAutoEnabledPlugins(PluginsConfiguration pluginsConfig) {
|
||||
List<Plugin> plugins = new ArrayList<>(pluginsConfig.getPlugins());
|
||||
List<Plugin> bootPlugins = PluginRepository.getPlugins(Layer.boot());
|
||||
for (Plugin bp : bootPlugins) {
|
||||
if (Utils.isAutoEnabled(bp)) {
|
||||
bp.configure(Collections.emptyMap());
|
||||
plugins.add(bp);
|
||||
}
|
||||
}
|
||||
return new PluginsConfiguration(plugins, pluginsConfig.getImageBuilder(),
|
||||
pluginsConfig.getLastSorterPluginName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Post process the image with a plugin configuration.
|
||||
*
|
||||
|
||||
@ -134,7 +134,7 @@ public class JlinkTask {
|
||||
}, true, "--full-version"),
|
||||
new Option<JlinkTask>(false, (task, opt, arg) -> {
|
||||
task.options.ignoreSigning = true;
|
||||
}, true, "--ignore-signing-information"),};
|
||||
}, "--ignore-signing-information"),};
|
||||
|
||||
private static final String PROGNAME = "jlink";
|
||||
private final OptionsValues options = new OptionsValues();
|
||||
|
||||
@ -46,8 +46,8 @@ import java.util.Map.Entry;
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import jdk.tools.jlink.internal.plugins.ExcludeFilesPlugin;
|
||||
import jdk.tools.jlink.internal.plugins.ExcludeJmodSectionPlugin;
|
||||
import jdk.tools.jlink.plugin.Plugin;
|
||||
import jdk.tools.jlink.plugin.Plugin.Category;
|
||||
@ -90,8 +90,7 @@ public final class TaskHelper {
|
||||
public boolean showUsage;
|
||||
}
|
||||
|
||||
public static class Option<T> {
|
||||
|
||||
public static class Option<T> implements Comparable<T> {
|
||||
public interface Processing<T> {
|
||||
|
||||
void process(T task, String opt, String arg) throws BadArgs;
|
||||
@ -100,17 +99,34 @@ public final class TaskHelper {
|
||||
final boolean hasArg;
|
||||
final Processing<T> processing;
|
||||
final boolean hidden;
|
||||
final String[] aliases;
|
||||
final String name;
|
||||
final String shortname;
|
||||
|
||||
public Option(boolean hasArg, Processing<T> processing, boolean hidden, String name, String shortname) {
|
||||
if (!name.startsWith("--")) {
|
||||
throw new RuntimeException("option name missing --, " + name);
|
||||
}
|
||||
if (!shortname.isEmpty() && !shortname.startsWith("-")) {
|
||||
throw new RuntimeException("short name missing -, " + shortname);
|
||||
}
|
||||
|
||||
public Option(boolean hasArg, Processing<T> processing, boolean hidden, String... aliases) {
|
||||
this.hasArg = hasArg;
|
||||
this.processing = processing;
|
||||
this.aliases = aliases;
|
||||
this.hidden = hidden;
|
||||
this.name = name;
|
||||
this.shortname = shortname;
|
||||
}
|
||||
|
||||
public Option(boolean hasArg, Processing<T> processing, String... aliases) {
|
||||
this(hasArg, processing, false, aliases);
|
||||
public Option(boolean hasArg, Processing<T> processing, String name, String shortname) {
|
||||
this(hasArg, processing, false, name, shortname);
|
||||
}
|
||||
|
||||
public Option(boolean hasArg, Processing<T> processing, boolean hidden, String name) {
|
||||
this(hasArg, processing, hidden, name, "");
|
||||
}
|
||||
|
||||
public Option(boolean hasArg, Processing<T> processing, String name) {
|
||||
this(hasArg, processing, false, name, "");
|
||||
}
|
||||
|
||||
public boolean isHidden() {
|
||||
@ -118,16 +134,10 @@ public final class TaskHelper {
|
||||
}
|
||||
|
||||
public boolean matches(String opt) {
|
||||
for (String a : aliases) {
|
||||
if (a.equals(opt)) {
|
||||
return true;
|
||||
} else if (opt.startsWith("--")
|
||||
&& (hasArg && opt.startsWith(a + "="))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return opt.equals(name) ||
|
||||
opt.equals(shortname) ||
|
||||
hasArg && opt.startsWith("--") && opt.startsWith(name + "=");
|
||||
}
|
||||
|
||||
public boolean ignoreRest() {
|
||||
return false;
|
||||
@ -137,28 +147,54 @@ public final class TaskHelper {
|
||||
processing.process(task, opt, arg);
|
||||
}
|
||||
|
||||
public String[] aliases() {
|
||||
return aliases;
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String resourceName() {
|
||||
return resourcePrefix() + name.substring(2);
|
||||
}
|
||||
|
||||
public String getShortname() {
|
||||
return shortname;
|
||||
}
|
||||
|
||||
public String resourcePrefix() {
|
||||
return "main.opt.";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Object object) {
|
||||
if (!(object instanceof Option<?>)) {
|
||||
throw new RuntimeException("comparing non-Option");
|
||||
}
|
||||
|
||||
Option<?> option = (Option<?>)object;
|
||||
|
||||
return name.compareTo(option.name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class PluginOption extends Option<PluginsHelper> {
|
||||
public PluginOption(boolean hasArg,
|
||||
Processing<PluginsHelper> processing, boolean hidden, String name, String shortname) {
|
||||
super(hasArg, processing, hidden, name, shortname);
|
||||
}
|
||||
|
||||
public PluginOption(boolean hasArg,
|
||||
Processing<PluginsHelper> processing, boolean hidden, String name) {
|
||||
super(hasArg, processing, hidden, name, "");
|
||||
}
|
||||
|
||||
public String resourcePrefix() {
|
||||
return "plugin.opt.";
|
||||
}
|
||||
}
|
||||
|
||||
private static class PlugOption extends Option<PluginsOptions> {
|
||||
|
||||
public PlugOption(boolean hasArg,
|
||||
Processing<PluginsOptions> processing, boolean hidden, String... aliases) {
|
||||
super(hasArg, processing, hidden, aliases);
|
||||
}
|
||||
|
||||
public PlugOption(boolean hasArg,
|
||||
Processing<PluginsOptions> processing, String... aliases) {
|
||||
super(hasArg, processing, aliases);
|
||||
}
|
||||
}
|
||||
|
||||
private final class PluginsOptions {
|
||||
private final class PluginsHelper {
|
||||
|
||||
private static final String PLUGINS_PATH = "--plugin-module-path";
|
||||
private static final String POST_PROCESS = "--post-process-path";
|
||||
|
||||
private Layer pluginsLayer = Layer.boot();
|
||||
private final List<Plugin> plugins;
|
||||
@ -170,10 +206,10 @@ public final class TaskHelper {
|
||||
// Each such occurrence results in a Map of arguments. So, there could be multiple
|
||||
// args maps per plugin instance.
|
||||
private final Map<Plugin, List<Map<String, String>>> pluginToMaps = new HashMap<>();
|
||||
private final List<PlugOption> pluginsOptions = new ArrayList<>();
|
||||
private final List<PlugOption> mainOptions = new ArrayList<>();
|
||||
private final List<PluginOption> pluginsOptions = new ArrayList<>();
|
||||
private final List<PluginOption> mainOptions = new ArrayList<>();
|
||||
|
||||
private PluginsOptions(String pp) throws BadArgs {
|
||||
private PluginsHelper(String pp) throws BadArgs {
|
||||
|
||||
if (pp != null) {
|
||||
String[] dirs = pp.split(File.pathSeparator);
|
||||
@ -193,13 +229,13 @@ public final class TaskHelper {
|
||||
addOrderedPluginOptions(plugin, optionsSeen);
|
||||
}
|
||||
}
|
||||
mainOptions.add(new PlugOption(false,
|
||||
mainOptions.add(new PluginOption(false,
|
||||
(task, opt, arg) -> {
|
||||
// This option is handled prior
|
||||
// to have the options parsed.
|
||||
},
|
||||
"--plugin-module-path"));
|
||||
mainOptions.add(new PlugOption(true, (task, opt, arg) -> {
|
||||
false, "--plugin-module-path"));
|
||||
mainOptions.add(new PluginOption(true, (task, opt, arg) -> {
|
||||
for (Plugin plugin : plugins) {
|
||||
if (plugin.getName().equals(arg)) {
|
||||
pluginToMaps.remove(plugin);
|
||||
@ -208,24 +244,24 @@ public final class TaskHelper {
|
||||
}
|
||||
throw newBadArgs("err.no.such.plugin", arg);
|
||||
},
|
||||
"--disable-plugin"));
|
||||
mainOptions.add(new PlugOption(true, (task, opt, arg) -> {
|
||||
false, "--disable-plugin"));
|
||||
mainOptions.add(new PluginOption(true, (task, opt, arg) -> {
|
||||
Path path = Paths.get(arg);
|
||||
if (!Files.exists(path) || !Files.isDirectory(path)) {
|
||||
throw newBadArgs("err.image.must.exist", path);
|
||||
}
|
||||
existingImage = path.toAbsolutePath();
|
||||
}, true, POST_PROCESS));
|
||||
mainOptions.add(new PlugOption(true,
|
||||
}, true, "--post-process-path"));
|
||||
mainOptions.add(new PluginOption(true,
|
||||
(task, opt, arg) -> {
|
||||
lastSorter = arg;
|
||||
},
|
||||
true, "--resources-last-sorter"));
|
||||
mainOptions.add(new PlugOption(false,
|
||||
mainOptions.add(new PluginOption(false,
|
||||
(task, opt, arg) -> {
|
||||
listPlugins = true;
|
||||
},
|
||||
"--list-plugins"));
|
||||
false, "--list-plugins"));
|
||||
}
|
||||
|
||||
private List<Map<String, String>> argListFor(Plugin plugin) {
|
||||
@ -261,8 +297,8 @@ public final class TaskHelper {
|
||||
}
|
||||
optionsSeen.add(option);
|
||||
|
||||
PlugOption plugOption
|
||||
= new PlugOption(plugin.hasArguments(),
|
||||
PluginOption plugOption
|
||||
= new PluginOption(plugin.hasArguments(),
|
||||
(task, opt, arg) -> {
|
||||
if (!Utils.isFunctional(plugin)) {
|
||||
throw newBadArgs("err.provider.not.functional",
|
||||
@ -312,7 +348,7 @@ public final class TaskHelper {
|
||||
}
|
||||
}
|
||||
},
|
||||
"--" + option);
|
||||
false, "--" + option);
|
||||
pluginsOptions.add(plugOption);
|
||||
|
||||
if (Utils.isFunctional(plugin)) {
|
||||
@ -322,44 +358,44 @@ public final class TaskHelper {
|
||||
|
||||
if (plugin instanceof DefaultCompressPlugin) {
|
||||
plugOption
|
||||
= new PlugOption(false,
|
||||
= new PluginOption(false,
|
||||
(task, opt, arg) -> {
|
||||
Map<String, String> m = addArgumentMap(plugin);
|
||||
m.put(DefaultCompressPlugin.NAME, DefaultCompressPlugin.LEVEL_2);
|
||||
}, "-c");
|
||||
}, false, "--compress", "-c");
|
||||
mainOptions.add(plugOption);
|
||||
} else if (plugin instanceof StripDebugPlugin) {
|
||||
plugOption
|
||||
= new PlugOption(false,
|
||||
= new PluginOption(false,
|
||||
(task, opt, arg) -> {
|
||||
addArgumentMap(plugin);
|
||||
}, "-G");
|
||||
}, false, "--strip-debug", "-G");
|
||||
mainOptions.add(plugOption);
|
||||
} else if (plugin instanceof ExcludeJmodSectionPlugin) {
|
||||
plugOption = new PlugOption(false, (task, opt, arg) -> {
|
||||
plugOption = new PluginOption(false, (task, opt, arg) -> {
|
||||
Map<String, String> m = addArgumentMap(plugin);
|
||||
m.put(ExcludeJmodSectionPlugin.NAME,
|
||||
ExcludeJmodSectionPlugin.MAN_PAGES);
|
||||
}, "--no-man-pages");
|
||||
}, false, "--no-man-pages");
|
||||
mainOptions.add(plugOption);
|
||||
|
||||
plugOption = new PlugOption(false, (task, opt, arg) -> {
|
||||
plugOption = new PluginOption(false, (task, opt, arg) -> {
|
||||
Map<String, String> m = addArgumentMap(plugin);
|
||||
m.put(ExcludeJmodSectionPlugin.NAME,
|
||||
ExcludeJmodSectionPlugin.INCLUDE_HEADER_FILES);
|
||||
}, "--no-header-files");
|
||||
}, false, "--no-header-files");
|
||||
mainOptions.add(plugOption);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private PlugOption getOption(String name) throws BadArgs {
|
||||
for (PlugOption o : pluginsOptions) {
|
||||
private PluginOption getOption(String name) throws BadArgs {
|
||||
for (PluginOption o : pluginsOptions) {
|
||||
if (o.matches(name)) {
|
||||
return o;
|
||||
}
|
||||
}
|
||||
for (PlugOption o : mainOptions) {
|
||||
for (PluginOption o : mainOptions) {
|
||||
if (o.matches(name)) {
|
||||
return o;
|
||||
}
|
||||
@ -461,7 +497,7 @@ public final class TaskHelper {
|
||||
private String getPluginsPath(String[] args) throws BadArgs {
|
||||
String pp = null;
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
if (args[i].equals(PluginsOptions.PLUGINS_PATH)) {
|
||||
if (args[i].equals(PluginsHelper.PLUGINS_PATH)) {
|
||||
if (i == args.length - 1) {
|
||||
throw new BadArgs("err.no.plugins.path").showUsage(true);
|
||||
} else {
|
||||
@ -498,13 +534,13 @@ public final class TaskHelper {
|
||||
// Must extract it prior to do any option analysis.
|
||||
// Required to interpret custom plugin options.
|
||||
// Unit tests can call Task multiple time in same JVM.
|
||||
pluginOptions = new PluginsOptions(getPluginsPath(args));
|
||||
pluginOptions = new PluginsHelper(getPluginsPath(args));
|
||||
|
||||
// First extract plugins path if any
|
||||
String pp = null;
|
||||
List<String> filteredArgs = new ArrayList<>();
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
if (args[i].equals(PluginsOptions.PLUGINS_PATH)) {
|
||||
if (args[i].equals(PluginsHelper.PLUGINS_PATH)) {
|
||||
if (i == args.length - 1) {
|
||||
throw new BadArgs("err.no.plugins.path").showUsage(true);
|
||||
} else {
|
||||
@ -529,7 +565,7 @@ public final class TaskHelper {
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
if (args[i].charAt(0) == '-') {
|
||||
String name = args[i];
|
||||
PlugOption pluginOption = null;
|
||||
PluginOption pluginOption = null;
|
||||
Option<T> option = getOption(name);
|
||||
if (option == null) {
|
||||
pluginOption = pluginOptions.getOption(name);
|
||||
@ -585,32 +621,13 @@ public final class TaskHelper {
|
||||
}
|
||||
|
||||
public void showHelp(String progName) {
|
||||
showHelp(progName, true);
|
||||
}
|
||||
|
||||
private void showHelp(String progName, boolean showsImageBuilder) {
|
||||
log.println(bundleHelper.getMessage("main.usage", progName));
|
||||
for (Option<?> o : options) {
|
||||
String name = o.aliases[0].substring(1); // there must always be at least one name
|
||||
name = name.charAt(0) == '-' ? name.substring(1) : name;
|
||||
if (o.isHidden() || name.equals("h")) {
|
||||
continue;
|
||||
}
|
||||
log.println(bundleHelper.getMessage("main.opt." + name));
|
||||
}
|
||||
|
||||
for (Option<?> o : pluginOptions.mainOptions) {
|
||||
if (o.aliases[0].equals(PluginsOptions.POST_PROCESS)
|
||||
&& !showsImageBuilder) {
|
||||
continue;
|
||||
}
|
||||
String name = o.aliases[0].substring(1); // there must always be at least one name
|
||||
name = name.charAt(0) == '-' ? name.substring(1) : name;
|
||||
if (o.isHidden()) {
|
||||
continue;
|
||||
}
|
||||
log.println(bundleHelper.getMessage("plugin.opt." + name));
|
||||
}
|
||||
Stream.concat(options.stream(), pluginOptions.mainOptions.stream())
|
||||
.filter(option -> !option.isHidden())
|
||||
.sorted()
|
||||
.forEach(option -> {
|
||||
log.println(bundleHelper.getMessage(option.resourceName()));
|
||||
});
|
||||
|
||||
log.println(bundleHelper.getMessage("main.command.files"));
|
||||
}
|
||||
@ -619,6 +636,7 @@ public final class TaskHelper {
|
||||
log.println("\n" + bundleHelper.getMessage("main.extended.help"));
|
||||
List<Plugin> pluginList = PluginRepository.
|
||||
getPlugins(pluginOptions.pluginsLayer);
|
||||
|
||||
for (Plugin plugin : Utils.getSortedPlugins(pluginList)) {
|
||||
showPlugin(plugin, log);
|
||||
}
|
||||
@ -671,7 +689,7 @@ public final class TaskHelper {
|
||||
}
|
||||
}
|
||||
|
||||
private PluginsOptions pluginOptions;
|
||||
private PluginsHelper pluginOptions;
|
||||
private PrintWriter log;
|
||||
private final ResourceBundleHelper bundleHelper;
|
||||
|
||||
|
||||
@ -118,8 +118,6 @@ public final class AppRuntimeImageBuilder {
|
||||
null));
|
||||
}
|
||||
|
||||
plugins.add(Jlink.newPlugin("installed-modules", Collections.emptyMap(), null));
|
||||
|
||||
// build the image
|
||||
Jlink.PluginsConfiguration pluginConfig = new Jlink.PluginsConfiguration(
|
||||
plugins, new DefaultImageBuilder(outputDir), null);
|
||||
|
||||
@ -24,46 +24,51 @@
|
||||
#
|
||||
|
||||
main.usage.summary=\
|
||||
Usage: {0} <options> --module-path <modulepath> --add-modules <mods> --output <path>\n\
|
||||
use --help for a list of possible options
|
||||
Usage: {0} <options> --module-path <modulepath> --add-modules <mods> --output\n\
|
||||
\<path> use --help for a list of possible options
|
||||
|
||||
main.usage=\
|
||||
Usage: {0} <options> --module-path <modulepath> --add-modules <mods> --output <path>\n\
|
||||
\Possible options include:
|
||||
Usage: {0} <options> --module-path <modulepath> --add-modules <mods> --output
|
||||
\<path> Possible options include:
|
||||
|
||||
error.prefix=Error:
|
||||
warn.prefix=Warning:
|
||||
|
||||
main.opt.help=\
|
||||
\ -h, --help Print this help message
|
||||
\ -h, --help Print this help message
|
||||
|
||||
main.opt.version=\
|
||||
\ --version Version information
|
||||
\ --version Version information
|
||||
|
||||
main.opt.module-path=\
|
||||
\ -p <modulepath>\n\
|
||||
\ --module-path <modulepath> Module path
|
||||
\ -p, --module-path <path> Module path
|
||||
|
||||
main.opt.add-modules=\
|
||||
\ --add-modules <mod>[,<mod>...] Root modules to resolve
|
||||
\ --add-modules <mod>[,<mod>...] Root modules to resolve
|
||||
|
||||
main.opt.limit-modules=\
|
||||
\ --limit-modules <mod>[,<mod>...] Limit the universe of observable modules
|
||||
\ --limit-modules <mod>[,<mod>...] Limit the universe of observable\n\
|
||||
\ modules
|
||||
|
||||
main.opt.output=\
|
||||
\ --output <path> Location of output path
|
||||
\ --output <path> Location of output path
|
||||
|
||||
main.command.files=\
|
||||
\ @<filename> Read options from file
|
||||
\ @<filename> Read options from file
|
||||
|
||||
main.opt.endian=\
|
||||
\ --endian <little|big> Byte order of generated jimage (default:native)
|
||||
\ --endian <little|big> Byte order of generated jimage\n\
|
||||
\ (default:native)
|
||||
|
||||
main.opt.save-opts=\
|
||||
\ --save-opts <filename> Save jlink options in the given file
|
||||
\ --save-opts <filename> Save jlink options in the given file
|
||||
|
||||
main.opt.ignore-signing-information=\
|
||||
\ --ignore-signing-information Ignore signing information in modular JARs
|
||||
\ --ignore-signing-information Suppress a fatal error when signed\n\
|
||||
\ modular JARs are linked in the image.\n\
|
||||
\ The signature related files of the\n\
|
||||
\ signed modular JARs are not copied to\n\
|
||||
\ the runtime image.
|
||||
|
||||
main.msg.bug=\
|
||||
An exception has occurred in jlink. \
|
||||
@ -75,13 +80,13 @@ main.extended.help=\
|
||||
\List of available plugins:
|
||||
|
||||
main.extended.help.footer=\
|
||||
\For options requiring a <pattern-list>, the value will be a comma\
|
||||
\ separated list of elements each using one the following forms:\n\
|
||||
\For options requiring a <pattern-list>, the value will be a comma separated\n\
|
||||
\list of elements each using one the following forms:\n\
|
||||
\ <glob-pattern>\n\
|
||||
\ glob:<glob-pattern>\n\
|
||||
\ regex:<regex-pattern>\n\
|
||||
\ @<filename> where filename is the name of a file containing patterns to be\
|
||||
\ used, one pattern per line\n\
|
||||
\ @<filename> where filename is the name of a file containing patterns to be\n\
|
||||
\ used, one pattern per line\n\
|
||||
\n\
|
||||
|
||||
|
||||
@ -110,6 +115,6 @@ err.bom.generation=bom file generation failed: {0}
|
||||
err.not.modular.format=selected module {0} ({1}) not in jmod or modular JAR format
|
||||
err.signing=signed modular JAR {0} is currently not supported,\
|
||||
\ use --ignore-signing-information to suppress error
|
||||
warn.signing=signed modular JAR {0} is currently not supported
|
||||
warn.signing=WARNING: signed modular JAR {0} is currently not supported
|
||||
warn.invalid.arg=invalid classname or pathname not exist: {0}
|
||||
warn.split.package=package {0} defined in {1} {2}
|
||||
|
||||
@ -132,32 +132,33 @@ plugin.plugins.header=\
|
||||
List of available plugin options:
|
||||
|
||||
plugin.opt.list-plugins=\
|
||||
\ --list-plugins List available plugins
|
||||
\ --list-plugins List available plugins
|
||||
|
||||
plugin.opt.post-process-path=\
|
||||
\ --post-process-path <imagefile> Post process an existing image
|
||||
\ --post-process-path <imagefile> Post process an existing image
|
||||
|
||||
plugin.opt.resources-last-sorter=\
|
||||
\ --resources-last-sorter <name> The last plugin allowed to sort resources
|
||||
\ --resources-last-sorter <name> The last plugin allowed to sort\n\
|
||||
\ resources
|
||||
|
||||
plugin.opt.plugin-module-path=\
|
||||
\ --plugin-module-path <modulepath> Custom plugin module path
|
||||
\ --plugin-module-path <modulepath> Custom plugin module path
|
||||
|
||||
plugin.opt.disable-plugin=\
|
||||
\ --disable-plugin <pluginname> Disable the plugin mentioned
|
||||
\ --disable-plugin <pluginname> Disable the plugin mentioned
|
||||
|
||||
plugin.opt.c=\
|
||||
\ -c, --compress=<0|1|2> Enable compression of resources\
|
||||
\n More details in --list-plugins option
|
||||
plugin.opt.compress=\
|
||||
\ -c, --compress=<0|1|2> Enable compression of resources\n\
|
||||
\ More details in --list-plugins option
|
||||
|
||||
plugin.opt.G=\
|
||||
\ -G, --strip-debug Strip debug information
|
||||
plugin.opt.strip-debug=\
|
||||
\ -G, --strip-debug Strip debug information
|
||||
|
||||
plugin.opt.no-man-pages=\
|
||||
\ --no-man-pages Exclude man pages
|
||||
\ --no-man-pages Exclude man pages
|
||||
|
||||
plugin.opt.no-header-files=\
|
||||
\ --no-header-files Exclude include header files
|
||||
\ --no-header-files Exclude include header files
|
||||
|
||||
main.plugin.name=\
|
||||
\Plugin Name
|
||||
|
||||
@ -55,7 +55,7 @@ TEE = tee
|
||||
UNAME = uname
|
||||
UNIQ = uniq
|
||||
WC = wc
|
||||
ZIP = zip
|
||||
ZIPEXE = zip
|
||||
|
||||
# Get OS name from uname (Cygwin inexplicably adds _NT-5.1)
|
||||
UNAME_S := $(shell $(UNAME) -s | $(CUT) -f1 -d_)
|
||||
@ -143,7 +143,8 @@ ifneq ($(FAILURE_HANDLER_DIR), )
|
||||
-timeoutHandlerDir:$(FAILURE_HANDLER_DIR_MIXED)/jtregFailureHandler.jar \
|
||||
-observerDir:$(FAILURE_HANDLER_DIR_MIXED)/jtregFailureHandler.jar \
|
||||
-timeoutHandler:jdk.test.failurehandler.jtreg.GatherProcessInfoTimeoutHandler \
|
||||
-observer:jdk.test.failurehandler.jtreg.GatherDiagnosticInfoObserver
|
||||
-observer:jdk.test.failurehandler.jtreg.GatherDiagnosticInfoObserver \
|
||||
-timeoutHandlerTimeout:0
|
||||
ifeq ($(UNAME_S), CYGWIN)
|
||||
JTREG_FAILURE_HANDLER_OPTIONS += -J-Djava.library.path="$(FAILURE_HANDLER_DIR_MIXED)"
|
||||
endif
|
||||
@ -161,7 +162,7 @@ endif
|
||||
ZIP_UP_RESULTS = ( $(MKDIR) -p `$(DIRNAME) $(ARCHIVE_BUNDLE)` \
|
||||
&& $(CD) $(ABS_TEST_OUTPUT_DIR) \
|
||||
&& $(CHMOD) -R a+r . \
|
||||
&& $(ZIP) -q -r $(ARCHIVE_BUNDLE) . )
|
||||
&& $(ZIPEXE) -q -r $(ARCHIVE_BUNDLE) . )
|
||||
|
||||
# important results files
|
||||
SUMMARY_TXT = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/JTreport/text/summary.txt")
|
||||
|
||||
@ -124,6 +124,7 @@ java/beans/Introspector/8132566/OverrideUserDefPropertyInfoTest.java 8132565 gen
|
||||
# jdk_lang
|
||||
|
||||
java/lang/StringCoding/CheckEncodings.sh 7008363 generic-all
|
||||
java/lang/ClassLoader/platformClassLoader/DefinePlatformClass.java 8169639 windows-all
|
||||
|
||||
############################################################################
|
||||
|
||||
@ -135,7 +136,7 @@ java/lang/instrument/RetransformBigClass.sh 8065756 generic-
|
||||
java/lang/instrument/BootClassPath/BootClassPathTest.sh 8072130 macosx-all
|
||||
|
||||
java/lang/management/MemoryMXBean/Pending.java 8158837 generic-all
|
||||
java/lang/management/MemoryMXBean/PendingAllGC.sh 8158760 generic-all
|
||||
java/lang/management/MemoryMXBean/PendingAllGC.sh 8158837 generic-all
|
||||
|
||||
############################################################################
|
||||
|
||||
@ -252,10 +253,14 @@ sanity/client/SwingSet/src/ButtonDemoScreenshotTest.java 8157338 generic-
|
||||
|
||||
# core_tools
|
||||
|
||||
tools/pack200/CommandLineTests.java 7143279,8059906 generic-all
|
||||
tools/pack200/CommandLineTests.java 8059906 generic-all
|
||||
|
||||
tools/launcher/FXLauncherTest.java 8068049 linux-all,macosx-all
|
||||
|
||||
tools/jimage/JImageExtractTest.java 8169713 generic-all
|
||||
tools/jimage/JImageListTest.java 8169713 generic-all
|
||||
tools/jimage/JImageVerifyTest.java 8169713 generic-all
|
||||
|
||||
############################################################################
|
||||
|
||||
# jdk_jdi
|
||||
@ -292,16 +297,6 @@ java/util/BitSet/BitSetStreamTest.java 8079538 generic-
|
||||
|
||||
sun/tools/jcmd/TestJcmdSanity.java 8031482 windows-all
|
||||
|
||||
sun/tools/jhsdb/BasicLauncherTest.java 8160376 macosx-all
|
||||
|
||||
sun/tools/jhsdb/HeapDumpTest.java 8160376 macosx-all
|
||||
|
||||
sun/tools/jhsdb/heapconfig/JMapHeapConfigTest.java 8160376 macosx-all
|
||||
|
||||
sun/tools/jps/TestJpsJar.java 8165500 generic-all
|
||||
|
||||
sun/tools/jps/TestJpsJarRelative.java 6456333 generic-all
|
||||
|
||||
sun/jvmstat/monitor/MonitoredVm/MonitorVmStartTerminate.java 8057732 generic-all
|
||||
|
||||
demo/jvmti/compiledMethodLoad/CompiledMethodLoadTest.java 8151899 generic-all
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -24,11 +24,13 @@
|
||||
/*
|
||||
* @test
|
||||
* @bug 6657619
|
||||
* @modules jdk.naming.dns
|
||||
* @summary DnsContext.debug is public static mutable (findbugs)
|
||||
* @author Vincent Ryan
|
||||
*/
|
||||
|
||||
import java.lang.reflect.*;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
|
||||
/*
|
||||
* Check that the 'debug' class member is no longer publicly accessible.
|
||||
|
||||
@ -30,13 +30,14 @@ import java.awt.TextArea;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
/**
|
||||
/*
|
||||
* @test
|
||||
* @bug 6991580 8080108 8133035
|
||||
* @requires os.family != "windows"
|
||||
* @summary IPv6 Nameservers in resolv.conf throws NumberFormatException
|
||||
* @modules jdk.naming.dns/com.sun.jndi.dns
|
||||
* @build IPv6NameserverPlatformParsingTest
|
||||
* @modules java.desktop
|
||||
* jdk.naming.dns/com.sun.jndi.dns
|
||||
* @compile --add-modules jdk.naming.dns IPv6NameserverPlatformParsingTest.java
|
||||
* @run main/manual Test6991580
|
||||
*/
|
||||
|
||||
|
||||
1
jdk/test/com/sun/jndi/ldap/TEST.properties
Normal file
1
jdk/test/com/sun/jndi/ldap/TEST.properties
Normal file
@ -0,0 +1 @@
|
||||
modules = java.naming
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -28,6 +28,7 @@
|
||||
* successfully.
|
||||
* @modules java.rmi/sun.rmi.registry java.rmi/sun.rmi.server
|
||||
* java.rmi/sun.rmi.transport java.rmi/sun.rmi.transport.tcp
|
||||
* jdk.naming.rmi
|
||||
* @library ../../../../../../java/rmi/testlibrary
|
||||
* @build TestLibrary
|
||||
* @run main UnbindIdempotent
|
||||
@ -49,8 +50,10 @@ public class UnbindIdempotent {
|
||||
|
||||
try {
|
||||
rctx = (Context)ictx.lookup("rmi://localhost:" + Integer.toString(registryPort));
|
||||
System.out.println("Got context: " + rctx.getClass());
|
||||
} catch (NamingException e) {
|
||||
// Unable to set up for test.
|
||||
System.err.println("WARNING: The test skipped due to NamingException: " + e);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -72,22 +72,9 @@ public class GarbageCollectionNotificationContentTest {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
|
||||
final Boolean isNotificationSupported = AccessController.doPrivileged (new PrivilegedAction<Boolean>() {
|
||||
public Boolean run() {
|
||||
try {
|
||||
Class cl = Class.forName("sun.management.VMManagementImpl");
|
||||
Field f = cl.getDeclaredField("gcNotificationSupport");
|
||||
f.setAccessible(true);
|
||||
return f.getBoolean(null);
|
||||
} catch(ClassNotFoundException e) {
|
||||
return false;
|
||||
} catch(NoSuchFieldException e) {
|
||||
return false;
|
||||
} catch(IllegalAccessException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
final boolean isNotificationSupported =
|
||||
sun.management.ManagementFactoryHelper.getVMManagement().isGcNotificationSupported();
|
||||
|
||||
if(!isNotificationSupported) {
|
||||
System.out.println("GC Notification not supported by the JVM, test skipped");
|
||||
return;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -71,22 +71,9 @@ public class GarbageCollectionNotificationTest {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
|
||||
final Boolean isNotificationSupported = AccessController.doPrivileged (new PrivilegedAction<Boolean>() {
|
||||
public Boolean run() {
|
||||
try {
|
||||
Class cl = Class.forName("sun.management.VMManagementImpl");
|
||||
Field f = cl.getDeclaredField("gcNotificationSupport");
|
||||
f.setAccessible(true);
|
||||
return f.getBoolean(null);
|
||||
} catch(ClassNotFoundException e) {
|
||||
return false;
|
||||
} catch(NoSuchFieldException e) {
|
||||
return false;
|
||||
} catch(IllegalAccessException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
final boolean isNotificationSupported =
|
||||
sun.management.ManagementFactoryHelper.getVMManagement().isGcNotificationSupported();
|
||||
|
||||
if(!isNotificationSupported) {
|
||||
System.out.println("GC Notification not supported by the JVM, test skipped");
|
||||
return;
|
||||
|
||||
2
jdk/test/com/sun/nio/sctp/TEST.properties
Normal file
2
jdk/test/com/sun/nio/sctp/TEST.properties
Normal file
@ -0,0 +1,2 @@
|
||||
modules = jdk.sctp
|
||||
|
||||
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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 8169909
|
||||
* @library src /lib/testlibrary
|
||||
* @build test/*
|
||||
* @run shell AppendToClassPathModuleTest.sh
|
||||
* @run main AppendToClassPathModuleTest
|
||||
*/
|
||||
|
||||
import java.util.Map;
|
||||
import static jdk.testlibrary.ProcessTools.*;
|
||||
|
||||
/**
|
||||
* Launch a modular test with no class path and no CLASSPATH set.
|
||||
* The java agent appends to the "hidden" directory to the class path
|
||||
* at runtime.
|
||||
*/
|
||||
public class AppendToClassPathModuleTest {
|
||||
public static void main(String... args) throws Throwable {
|
||||
String modulepath = System.getProperty("test.module.path");
|
||||
ProcessBuilder pb =
|
||||
createJavaProcessBuilder("-javaagent:Agent.jar",
|
||||
"--module-path", modulepath,
|
||||
"-m", "test/jdk.test.Main");
|
||||
|
||||
// remove CLASSPATH environment variable
|
||||
Map<String,String> env = pb.environment();
|
||||
String value = env.remove("CLASSPATH");
|
||||
|
||||
int exitCode = executeCommand(pb).getExitValue();
|
||||
if (exitCode != 0) {
|
||||
throw new RuntimeException("Test failed: " + exitCode);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,67 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
# 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.
|
||||
#
|
||||
|
||||
if [ "${TESTSRC}" = "" ]
|
||||
then
|
||||
echo "TESTSRC not set. Test cannot execute. Failed."
|
||||
exit 1
|
||||
fi
|
||||
echo "TESTSRC=${TESTSRC}"
|
||||
|
||||
if [ "${TESTJAVA}" = "" ]
|
||||
then
|
||||
echo "TESTJAVA not set. Test cannot execute. Failed."
|
||||
exit 1
|
||||
fi
|
||||
echo "TESTJAVA=${TESTJAVA}"
|
||||
|
||||
if [ "${COMPILEJAVA}" = "" ]
|
||||
then
|
||||
COMPILEJAVA="${TESTJAVA}"
|
||||
fi
|
||||
echo "COMPILEJAVA=${COMPILEJAVA}"
|
||||
|
||||
if [ "${TESTCLASSES}" = "" ]
|
||||
then
|
||||
echo "TESTCLASSES not set. Test cannot execute. Failed."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "TESTCLASSES=${TESTCLASSES}"
|
||||
|
||||
mkdir -p hidden
|
||||
${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} \
|
||||
-d hidden ${TESTSRC}/../ExampleForClassPath.java
|
||||
|
||||
mkdir -p classes
|
||||
${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} \
|
||||
-d classes ${TESTSRC}/../InstrumentationHandoff.java
|
||||
|
||||
echo "Manifest-Version: 1.0" > Agent.mf
|
||||
echo "Class-Path: hidden/" >> Agent.mf
|
||||
echo "Premain-Class: InstrumentationHandoff" >> Agent.mf
|
||||
|
||||
${TESTJAVA}/bin/jar ${TESTTOOLVMOPTS} cvfm Agent.jar \
|
||||
Agent.mf -C classes InstrumentationHandoff.class
|
||||
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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 jdk.test;
|
||||
|
||||
/**
|
||||
* Launched by AppendToClassPathModuleTest.
|
||||
*/
|
||||
public class Main {
|
||||
public static void main(String... args) throws Exception {
|
||||
// "java.class.path" system property is expected to be empty.
|
||||
String value = System.getProperty("java.class.path");
|
||||
if (!value.isEmpty()) {
|
||||
throw new RuntimeException("Non-empty java.class.path=" + value);
|
||||
}
|
||||
|
||||
// load the "hidden" class that should be loaded by the system loader
|
||||
Class<?> c = Class.forName("ExampleForClassPath");
|
||||
if (c.getClassLoader() != ClassLoader.getSystemClassLoader()) {
|
||||
throw new RuntimeException(c + " loaderd by " + c.getClassLoader());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
module test {
|
||||
}
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -37,18 +37,11 @@ public class InvokeSeveralWays {
|
||||
failures++;
|
||||
} catch (InvocationTargetException e) {
|
||||
Throwable c = e.getCause();
|
||||
if (BootstrapMethodError.class.isInstance(c)) {
|
||||
c = c.getCause();
|
||||
if (expected.isInstance(c))
|
||||
System.out.println("EXPECTED: " + expected.getName() + ", "+ c);
|
||||
else {
|
||||
failures++;
|
||||
System.out.println("FAIL: Unexpected wrapped exception " + c);
|
||||
e.printStackTrace(System.out);
|
||||
}
|
||||
} else {
|
||||
if (expected.isInstance(c))
|
||||
System.out.println("EXPECTED: " + expected.getName() + ", "+ c);
|
||||
else {
|
||||
failures++;
|
||||
System.out.println("FAIL: Exception from MethodHandle invocation not wrapped in BootstrapMethodError " + c);
|
||||
System.out.println("FAIL: Unexpected wrapped exception " + c);
|
||||
e.printStackTrace(System.out);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
@ -80,19 +73,14 @@ public class InvokeSeveralWays {
|
||||
Invoker.invoke();
|
||||
System.out.println("FAIL: No exception throw, probably failed to load modified bytecodes for MethodSupplier");
|
||||
failures++;
|
||||
} catch (BootstrapMethodError e) {
|
||||
Throwable c = e.getCause();
|
||||
if (expected.isInstance(c))
|
||||
System.out.println("EXPECTED: " + expected.getName() + ", "+ c);
|
||||
} catch (Throwable e) {
|
||||
if (expected.isInstance(e))
|
||||
System.out.println("EXPECTED: " + expected.getName() + ", "+ e);
|
||||
else {
|
||||
failures++;
|
||||
System.out.println("FAIL: Unexpected exception has been caught " + c);
|
||||
System.out.println("FAIL: Unexpected exception has been caught " + e);
|
||||
e.printStackTrace(System.out);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
failures++;
|
||||
System.out.println("FAIL: Exception from MethodHandle invocation not wrapped in BootstrapMethodError " + e);
|
||||
e.printStackTrace(System.out);
|
||||
}
|
||||
System.out.println();
|
||||
try {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -21,32 +21,18 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package order;
|
||||
|
||||
/**
|
||||
* This class ensures the method detail section contains the methods
|
||||
* in the order as it appears in the source.
|
||||
* @author kumasrin
|
||||
/*
|
||||
* @test
|
||||
* @bug 8151099
|
||||
* @summary Verify platform MXBeans initialized properly with java.management
|
||||
* module only. No other management provider
|
||||
* @run main/othervm --limit-modules=java.management DefaultManagementProviderTest
|
||||
*/
|
||||
public class MethodOrder {
|
||||
/**
|
||||
* Method d.
|
||||
* Second line.
|
||||
*/
|
||||
public void d(){}
|
||||
/**
|
||||
* Method b.
|
||||
* Second line.
|
||||
*/
|
||||
public void b() {}
|
||||
/**
|
||||
* Method c.
|
||||
* Second line.
|
||||
*/
|
||||
public void c() {}
|
||||
/**
|
||||
* Method a.
|
||||
* Second line.
|
||||
*/
|
||||
public void a() {}
|
||||
import java.lang.management.ManagementFactory;
|
||||
|
||||
public class DefaultManagementProviderTest {
|
||||
public static void main(String[] argv) {
|
||||
ManagementFactory.getPlatformMBeanServer();
|
||||
System.out.println("Test case passed");
|
||||
}
|
||||
}
|
||||
76
jdk/test/java/net/Authenticator/GetAuthenticatorTest.java
Normal file
76
jdk/test/java/net/Authenticator/GetAuthenticatorTest.java
Normal file
@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
import java.lang.ref.Reference;
|
||||
import java.net.Authenticator;
|
||||
import java.net.NetPermission;
|
||||
import java.net.PasswordAuthentication;
|
||||
import java.security.AccessControlException;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 8169068
|
||||
* @summary Basic test for Authenticator.getDefault()
|
||||
* @run main/othervm GetAuthenticatorTest
|
||||
*/
|
||||
public class GetAuthenticatorTest {
|
||||
|
||||
static final class MyAuthenticator extends Authenticator {
|
||||
|
||||
MyAuthenticator () {
|
||||
super ();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PasswordAuthentication getPasswordAuthentication () {
|
||||
System.out.println ("Auth called");
|
||||
return (new PasswordAuthentication ("user",
|
||||
"passwordNotCheckedAnyway".toCharArray()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void main (String args[]) throws Exception {
|
||||
Authenticator defaultAuth = Authenticator.getDefault();
|
||||
if (defaultAuth != null) {
|
||||
throw new RuntimeException("Unexpected authenticator: null expected");
|
||||
}
|
||||
MyAuthenticator auth = new MyAuthenticator();
|
||||
Authenticator.setDefault(auth);
|
||||
defaultAuth = Authenticator.getDefault();
|
||||
if (defaultAuth != auth) {
|
||||
throw new RuntimeException("Unexpected authenticator: auth expected");
|
||||
}
|
||||
System.setSecurityManager(new SecurityManager());
|
||||
try {
|
||||
defaultAuth = Authenticator.getDefault();
|
||||
throw new RuntimeException("Expected security exception not raised");
|
||||
} catch (AccessControlException s) {
|
||||
System.out.println("Got expected exception: " + s);
|
||||
if (!s.getPermission().equals(new NetPermission("requestPasswordAuthentication"))) {
|
||||
throw new RuntimeException("Unexpected permission check: " + s.getPermission());
|
||||
}
|
||||
}
|
||||
System.out.println("Test passed with default authenticator "
|
||||
+ defaultAuth);
|
||||
}
|
||||
}
|
||||
@ -219,7 +219,8 @@ public class Basic {
|
||||
throw new RuntimeException("ExecutionException expected");
|
||||
} catch (ExecutionException x) {
|
||||
if (!(x.getCause() instanceof ClosedChannelException))
|
||||
throw new RuntimeException("Cause of ClosedChannelException expected");
|
||||
throw new RuntimeException("Cause of ClosedChannelException expected",
|
||||
x.getCause());
|
||||
}
|
||||
final AtomicReference<Throwable> connectException = new AtomicReference<>();
|
||||
ch.connect(server.address(), (Void)null, new CompletionHandler<Void,Void>() {
|
||||
@ -233,7 +234,8 @@ public class Basic {
|
||||
Thread.sleep(100);
|
||||
}
|
||||
if (!(connectException.get() instanceof ClosedChannelException))
|
||||
throw new RuntimeException("ClosedChannelException expected");
|
||||
throw new RuntimeException("ClosedChannelException expected",
|
||||
connectException.get());
|
||||
}
|
||||
|
||||
// test that failure to connect closes the channel
|
||||
@ -353,7 +355,8 @@ public class Basic {
|
||||
Thread.sleep(100);
|
||||
}
|
||||
if (!(writeException.get() instanceof AsynchronousCloseException))
|
||||
throw new RuntimeException("AsynchronousCloseException expected");
|
||||
throw new RuntimeException("AsynchronousCloseException expected",
|
||||
writeException.get());
|
||||
}
|
||||
}
|
||||
|
||||
@ -460,7 +463,8 @@ public class Basic {
|
||||
throw new RuntimeException("ExecutionException expected");
|
||||
} catch (ExecutionException x) {
|
||||
if (!(x.getCause() instanceof ClosedChannelException))
|
||||
throw new RuntimeException("Cause of ClosedChannelException expected");
|
||||
throw new RuntimeException("Cause of ClosedChannelException expected",
|
||||
x.getCause());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -630,7 +634,8 @@ public class Basic {
|
||||
throw new RuntimeException("ExecutionException expected");
|
||||
} catch (ExecutionException x) {
|
||||
if (!(x.getCause() instanceof ClosedChannelException))
|
||||
throw new RuntimeException("Cause of ClosedChannelException expected");
|
||||
throw new RuntimeException("Cause of ClosedChannelException expected",
|
||||
x.getCause());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -738,7 +743,8 @@ public class Basic {
|
||||
throw new RuntimeException("ClosedChannelException expected");
|
||||
} catch (ExecutionException x) {
|
||||
if (!(x.getCause() instanceof ClosedChannelException))
|
||||
throw new RuntimeException("ClosedChannelException expected");
|
||||
throw new RuntimeException("ClosedChannelException expected",
|
||||
x.getCause());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -776,7 +782,8 @@ public class Basic {
|
||||
Thread.sleep(100);
|
||||
}
|
||||
if (!(readException.get() instanceof InterruptedByTimeoutException))
|
||||
throw new RuntimeException("InterruptedByTimeoutException expected");
|
||||
throw new RuntimeException("InterruptedByTimeoutException expected",
|
||||
readException.get());
|
||||
|
||||
// after a timeout then further reading should throw unspecified runtime exception
|
||||
boolean exceptionThrown = false;
|
||||
@ -813,7 +820,8 @@ public class Basic {
|
||||
Thread.sleep(100);
|
||||
}
|
||||
if (!(writeException.get() instanceof InterruptedByTimeoutException))
|
||||
throw new RuntimeException("InterruptedByTimeoutException expected");
|
||||
throw new RuntimeException("InterruptedByTimeoutException expected",
|
||||
writeException.get());
|
||||
|
||||
// after a timeout then further writing should throw unspecified runtime exception
|
||||
boolean exceptionThrown = false;
|
||||
|
||||
@ -4,4 +4,6 @@ grant {
|
||||
permission com.sun.rmi.rmid.ExecOptionPermission "-Djava.rmi.server.useDynamicProxies=*";
|
||||
permission java.lang.RuntimePermission "selectorProvider";
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch";
|
||||
permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.port", "read";
|
||||
permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.timeout", "read";
|
||||
};
|
||||
|
||||
@ -3,4 +3,6 @@ grant {
|
||||
permission com.sun.rmi.rmid.ExecOptionPermission "-Djava.security.policy=*";
|
||||
permission java.lang.RuntimePermission "selectorProvider";
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch";
|
||||
permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.port", "read";
|
||||
permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.timeout", "read";
|
||||
};
|
||||
|
||||
@ -3,4 +3,6 @@ grant {
|
||||
permission com.sun.rmi.rmid.ExecOptionPermission "-Djava.security.policy=*";
|
||||
permission java.lang.RuntimePermission "selectorProvider";
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch";
|
||||
permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.port", "read";
|
||||
permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.timeout", "read";
|
||||
};
|
||||
|
||||
@ -3,4 +3,7 @@ grant {
|
||||
permission com.sun.rmi.rmid.ExecOptionPermission "-Djava.security.policy=*";
|
||||
permission java.lang.RuntimePermission "selectorProvider";
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch";
|
||||
permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.port", "read";
|
||||
permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.timeout", "read";
|
||||
permission java.net.SocketPermission "*:1024-", "listen,resolve,connect,accept";
|
||||
};
|
||||
|
||||
@ -3,4 +3,6 @@ grant {
|
||||
permission com.sun.rmi.rmid.ExecOptionPermission "-Djava.security.policy=*";
|
||||
permission java.lang.RuntimePermission "selectorProvider";
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch";
|
||||
permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.port", "read";
|
||||
permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.timeout", "read";
|
||||
};
|
||||
|
||||
@ -3,4 +3,6 @@ grant {
|
||||
permission com.sun.rmi.rmid.ExecOptionPermission "-Djava.security.policy=*";
|
||||
permission java.lang.RuntimePermission "selectorProvider";
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch";
|
||||
permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.port", "read";
|
||||
permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.timeout", "read";
|
||||
};
|
||||
|
||||
@ -4,4 +4,6 @@ grant {
|
||||
|
||||
permission java.lang.RuntimePermission "selectorProvider";
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch";
|
||||
permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.port", "read";
|
||||
permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.timeout", "read";
|
||||
};
|
||||
|
||||
@ -3,4 +3,7 @@ grant {
|
||||
permission com.sun.rmi.rmid.ExecOptionPermission "-Djava.security.policy=*";
|
||||
permission java.lang.RuntimePermission "selectorProvider";
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch";
|
||||
permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.port", "read";
|
||||
permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.timeout", "read";
|
||||
permission java.net.SocketPermission "*:1024-", "listen,resolve,connect,accept";
|
||||
};
|
||||
|
||||
@ -3,4 +3,6 @@ grant {
|
||||
permission com.sun.rmi.rmid.ExecOptionPermission "-Djava.security.policy=*";
|
||||
permission java.lang.RuntimePermission "selectorProvider";
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch";
|
||||
permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.port", "read";
|
||||
permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.timeout", "read";
|
||||
};
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
grant {
|
||||
permission java.lang.RuntimePermission "selectorProvider";
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch";
|
||||
permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.port", "read";
|
||||
permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.timeout", "read";
|
||||
};
|
||||
|
||||
@ -3,4 +3,6 @@ grant {
|
||||
permission com.sun.rmi.rmid.ExecOptionPermission "-Djava.security.policy=*";
|
||||
permission java.lang.RuntimePermission "selectorProvider";
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch";
|
||||
permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.port", "read";
|
||||
permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.timeout", "read";
|
||||
};
|
||||
|
||||
@ -3,4 +3,6 @@ grant {
|
||||
permission com.sun.rmi.rmid.ExecOptionPermission "-Djava.security.policy=*";
|
||||
permission java.lang.RuntimePermission "selectorProvider";
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch";
|
||||
permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.port", "read";
|
||||
permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.timeout", "read";
|
||||
};
|
||||
|
||||
@ -3,4 +3,7 @@ grant {
|
||||
permission com.sun.rmi.rmid.ExecOptionPermission "-Djava.security.policy=*";
|
||||
permission java.lang.RuntimePermission "selectorProvider";
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch";
|
||||
permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.port", "read";
|
||||
permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.timeout", "read";
|
||||
permission java.net.SocketPermission "*:1024-", "listen,resolve,connect,accept";
|
||||
};
|
||||
|
||||
@ -3,4 +3,6 @@ grant {
|
||||
permission com.sun.rmi.rmid.ExecOptionPermission "-Djava.security.policy=*";
|
||||
permission java.lang.RuntimePermission "selectorProvider";
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch";
|
||||
permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.port", "read";
|
||||
permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.timeout", "read";
|
||||
};
|
||||
|
||||
@ -3,4 +3,7 @@ grant {
|
||||
permission com.sun.rmi.rmid.ExecOptionPermission "-Djava.security.policy=*";
|
||||
permission java.lang.RuntimePermission "selectorProvider";
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch";
|
||||
permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.port", "read";
|
||||
permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.timeout", "read";
|
||||
permission java.net.SocketPermission "*:1024-", "listen,resolve,connect,accept";
|
||||
};
|
||||
|
||||
@ -4,4 +4,6 @@ grant {
|
||||
permission com.sun.rmi.rmid.ExecOptionPermission "-Ddummyname=dummyvalue";
|
||||
permission java.lang.RuntimePermission "selectorProvider";
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch";
|
||||
permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.port", "read";
|
||||
permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.timeout", "read";
|
||||
};
|
||||
|
||||
@ -3,4 +3,6 @@ grant {
|
||||
permission com.sun.rmi.rmid.ExecOptionPermission "-Djava.security.policy=*";
|
||||
permission java.lang.RuntimePermission "selectorProvider";
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch";
|
||||
permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.port", "read";
|
||||
permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.timeout", "read";
|
||||
};
|
||||
|
||||
@ -3,4 +3,6 @@ grant {
|
||||
permission com.sun.rmi.rmid.ExecOptionPermission "-Djava.security.policy=*";
|
||||
permission java.lang.RuntimePermission "selectorProvider";
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch";
|
||||
permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.port", "read";
|
||||
permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.timeout", "read";
|
||||
};
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -33,8 +33,9 @@
|
||||
* java.rmi/sun.rmi.server
|
||||
* java.rmi/sun.rmi.transport
|
||||
* java.rmi/sun.rmi.transport.tcp
|
||||
* java.base/sun.nio.ch
|
||||
* @build TestLibrary RMID ActivationLibrary
|
||||
* ActivateMe ModifyDescriptor_Stub
|
||||
* ActivateMe ModifyDescriptor_Stub RMIDSelectorProvider
|
||||
* @run main/othervm/policy=security.policy/timeout=240 ModifyDescriptor
|
||||
*/
|
||||
|
||||
|
||||
@ -3,4 +3,9 @@ grant {
|
||||
permission com.sun.rmi.rmid.ExecOptionPermission "-Djava.security.policy=*";
|
||||
permission com.sun.rmi.rmid.ExecOptionPermission "-Dtest.message=hello";
|
||||
permission com.sun.rmi.rmid.ExecOptionPermission "-Dtest.message=hello, again";
|
||||
permission java.lang.RuntimePermission "selectorProvider";
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch";
|
||||
permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.port", "read";
|
||||
permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.timeout", "read";
|
||||
permission java.net.SocketPermission "*:1024-", "listen,resolve,connect,accept";
|
||||
};
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,6 +25,7 @@ import java.io.*;
|
||||
import java.rmi.*;
|
||||
import java.rmi.activation.*;
|
||||
import java.rmi.registry.*;
|
||||
import java.time.LocalTime;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
/**
|
||||
@ -44,6 +45,15 @@ public class RMID extends JavaVM {
|
||||
private static final long STARTTIME_MS = 15_000L;
|
||||
private static final long POLLTIME_MS = 100L;
|
||||
|
||||
// when restart rmid, it may take more time than usual because of
|
||||
// "port in use" by a possible interloper (check JDK-8168975),
|
||||
// so need to set a longer timeout for restart.
|
||||
private static long restartTimeout;
|
||||
// Same reason to inheritedChannel in RMIDSelectorProvider.
|
||||
// Put it here rather than in RMIDSelectorProvider to adjust
|
||||
// both timeout values together.
|
||||
private static long inheritedChannelTimeout;
|
||||
|
||||
private static final String SYSTEM_NAME = ActivationSystem.class.getName();
|
||||
// "java.rmi.activation.ActivationSystem"
|
||||
|
||||
@ -73,7 +83,8 @@ public class RMID extends JavaVM {
|
||||
}
|
||||
|
||||
/** make test options and arguments */
|
||||
private static String makeOptions(int port, boolean debugExec) {
|
||||
private static String makeOptions(int port, boolean debugExec,
|
||||
boolean enableSelectorProvider) {
|
||||
|
||||
String options = " -Dsun.rmi.server.activation.debugExec=" +
|
||||
debugExec;
|
||||
@ -98,12 +109,24 @@ public class RMID extends JavaVM {
|
||||
// to avoid spurious timeouts on slow machines.
|
||||
options += " -Dsun.rmi.activation.execTimeout=60000";
|
||||
|
||||
if (port == 0) {
|
||||
// It's important to set handshakeTimeout to small value, for example
|
||||
// 5 sec (default is 60 sec) to avoid wasting too much time when
|
||||
// calling lookupSystem(port) in restart(), because
|
||||
// 1. If use default value of this option, it will take about 2 minutes
|
||||
// to finish lookupSystem(port) in 2 loops in restart();
|
||||
// 2. If set this option as 5 sec then lookupSystem(port) will return
|
||||
// very quickly.
|
||||
options += " -Dsun.rmi.transport.tcp.handshakeTimeout=5000";
|
||||
|
||||
if (port == 0 || enableSelectorProvider) {
|
||||
// Ephemeral port, so have the rmid child process create the
|
||||
// server socket channel and report its port number, over stdin.
|
||||
options += " -classpath " + TestParams.testClassPath;
|
||||
options += " --add-exports=java.base/sun.nio.ch=ALL-UNNAMED";
|
||||
options += " -Djava.nio.channels.spi.SelectorProvider=RMIDSelectorProvider";
|
||||
options += " -Dtest.java.rmi.testlibrary.RMIDSelectorProvider.port=" + port;
|
||||
options += " -Dtest.java.rmi.testlibrary.RMIDSelectorProvider.timeout="
|
||||
+ inheritedChannelTimeout;
|
||||
|
||||
// Disable redirection of System.err to /tmp
|
||||
options += " -Dsun.rmi.server.activation.disableErrRedirect=true";
|
||||
@ -112,6 +135,10 @@ public class RMID extends JavaVM {
|
||||
return options;
|
||||
}
|
||||
|
||||
private static String makeArgs() {
|
||||
return makeArgs(false, 0);
|
||||
}
|
||||
|
||||
private static String makeArgs(boolean includePortArg, int port) {
|
||||
String propagateManager = null;
|
||||
|
||||
@ -183,7 +210,7 @@ public class RMID extends JavaVM {
|
||||
boolean debugExec, boolean includePortArg,
|
||||
int port)
|
||||
{
|
||||
String options = makeOptions(port, debugExec);
|
||||
String options = makeOptions(port, debugExec, false);
|
||||
String args = makeArgs(includePortArg, port);
|
||||
RMID rmid = new RMID("sun.rmi.server.Activation", options, args,
|
||||
out, err, port);
|
||||
@ -193,14 +220,14 @@ public class RMID extends JavaVM {
|
||||
}
|
||||
|
||||
public static RMID createRMIDOnEphemeralPort() {
|
||||
return createRMID(System.out, System.err, true, true, 0);
|
||||
return createRMID(System.out, System.err, true, false, 0);
|
||||
}
|
||||
|
||||
public static RMID createRMIDOnEphemeralPort(OutputStream out,
|
||||
OutputStream err,
|
||||
boolean debugExec)
|
||||
{
|
||||
return createRMID(out, err, debugExec, true, 0);
|
||||
return createRMID(out, err, debugExec, false, 0);
|
||||
}
|
||||
|
||||
|
||||
@ -213,6 +240,9 @@ public class RMID extends JavaVM {
|
||||
{
|
||||
super(classname, options, args, out, err);
|
||||
this.port = port;
|
||||
long waitTime = (long)(240_000 * TestLibrary.getTimeoutFactor());
|
||||
restartTimeout = (long)(waitTime * 0.9);
|
||||
inheritedChannelTimeout = (long)(waitTime * 0.8);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -280,11 +310,11 @@ public class RMID extends JavaVM {
|
||||
// if rmid is already running, then the test will fail with
|
||||
// a well recognized exception (port already in use...).
|
||||
|
||||
mesg("Starting rmid on port " + port + ".");
|
||||
mesg("Starting rmid on port " + port + ", at " + LocalTime.now());
|
||||
int p = super.startAndGetPort();
|
||||
if (p != -1)
|
||||
port = p;
|
||||
mesg("Started rmid on port " + port + ".");
|
||||
mesg("Started rmid on port " + port + ", at " + LocalTime.now());
|
||||
|
||||
// int slopFactor = 1;
|
||||
// try {
|
||||
@ -318,6 +348,7 @@ public class RMID extends JavaVM {
|
||||
// The rmid process is alive; check to see whether
|
||||
// it responds to a remote call.
|
||||
|
||||
mesg("looking up activation system, at " + LocalTime.now());
|
||||
if (lookupSystem(port) != null) {
|
||||
/*
|
||||
* We need to set the java.rmi.activation.port value as the
|
||||
@ -328,10 +359,11 @@ public class RMID extends JavaVM {
|
||||
*/
|
||||
System.setProperty("java.rmi.activation.port", Integer.toString(port));
|
||||
mesg("Started successfully after " +
|
||||
(System.currentTimeMillis() - startTime) + "ms.");
|
||||
(System.currentTimeMillis() - startTime) + "ms, at " + LocalTime.now());
|
||||
return;
|
||||
}
|
||||
|
||||
mesg("after fail to looking up activation system, at " + LocalTime.now());
|
||||
if (System.currentTimeMillis() > deadline) {
|
||||
TestLibrary.bomb("Failed to start rmid, giving up after " +
|
||||
(System.currentTimeMillis() - startTime) + "ms.", null);
|
||||
@ -347,9 +379,10 @@ public class RMID extends JavaVM {
|
||||
*/
|
||||
public void restart() throws IOException {
|
||||
destroy();
|
||||
options = makeOptions(port, true);
|
||||
args = makeArgs(true, port);
|
||||
start();
|
||||
options = makeOptions(port, true, true);
|
||||
args = makeArgs();
|
||||
|
||||
start(restartTimeout);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -22,6 +22,7 @@
|
||||
*/
|
||||
|
||||
import java.io.*;
|
||||
import java.net.BindException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.ProtocolFamily;
|
||||
import java.nio.channels.Channel;
|
||||
@ -31,6 +32,7 @@ import java.nio.channels.ServerSocketChannel;
|
||||
import java.nio.channels.SocketChannel;
|
||||
import java.nio.channels.spi.AbstractSelector;
|
||||
import java.nio.channels.spi.SelectorProvider;
|
||||
import java.time.LocalTime;
|
||||
import static java.net.StandardSocketOptions.SO_REUSEADDR;
|
||||
import static java.net.StandardSocketOptions.SO_REUSEPORT;
|
||||
|
||||
@ -98,7 +100,37 @@ public class RMIDSelectorProvider extends SelectorProvider {
|
||||
channel.setOption(SO_REUSEPORT, true);
|
||||
}
|
||||
|
||||
channel.bind(new InetSocketAddress(0));
|
||||
// when it comes here, these properties should have been set with
|
||||
// a valid value, but assign a default value anyway.
|
||||
long timeout = Long.getLong(
|
||||
"test.java.rmi.testlibrary.RMIDSelectorProvider.timeout",
|
||||
200_000);
|
||||
long deadline = System.currentTimeMillis() + timeout;
|
||||
int port = Integer.getInteger(
|
||||
"test.java.rmi.testlibrary.RMIDSelectorProvider.port", 0);
|
||||
while (true) {
|
||||
try {
|
||||
channel.bind(new InetSocketAddress(port));
|
||||
break;
|
||||
} catch (BindException ex) {
|
||||
System.out.format("RMIDSelectorProvider: "
|
||||
+ "failed to bind to port %d due to \"%s\", at %s%n",
|
||||
port, ex.getMessage(), LocalTime.now());
|
||||
}
|
||||
if (System.currentTimeMillis() > deadline) {
|
||||
System.out.format("RMIDSelectorProvider: "
|
||||
+ "fail to bind to port %d after trying for "
|
||||
+ "%d seconds, exiting rmid process, at %s%n",
|
||||
port, timeout/1000, LocalTime.now());
|
||||
channel.close();
|
||||
// can not start rmid on specific port,
|
||||
// there is no need to continue run rmid.
|
||||
System.exit(1);
|
||||
}
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch(InterruptedException ignore) { }
|
||||
}
|
||||
|
||||
System.out.println(RMID.EPHEMERAL_MSG + channel.socket().getLocalPort());
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -53,7 +53,7 @@ import java.rmi.server.UnicastRemoteObject;
|
||||
|
||||
public class ReuseDefaultPort implements Remote {
|
||||
|
||||
private static final int PORT = TestLibrary.getUnusedRandomPort();
|
||||
private static int rmiPort = 0;
|
||||
|
||||
private ReuseDefaultPort() { }
|
||||
|
||||
@ -64,7 +64,7 @@ public class ReuseDefaultPort implements Remote {
|
||||
Remote stub = UnicastRemoteObject.exportObject(impl, 0);
|
||||
System.err.println("- exported object: " + stub);
|
||||
try {
|
||||
Registry registry = LocateRegistry.createRegistry(PORT);
|
||||
Registry registry = LocateRegistry.createRegistry(rmiPort);
|
||||
System.err.println("- exported registry: " + registry);
|
||||
System.err.println("TEST PASSED");
|
||||
} finally {
|
||||
@ -77,13 +77,15 @@ public class ReuseDefaultPort implements Remote {
|
||||
RMISocketFactory.getDefaultSocketFactory();
|
||||
SF() { }
|
||||
public Socket createSocket(String host, int port) throws IOException {
|
||||
System.err.format("in SF::createSocket: %s, %d%n", host, port);
|
||||
return defaultFactory.createSocket(host, port);
|
||||
}
|
||||
public ServerSocket createServerSocket(int port) throws IOException {
|
||||
if (port == 0) {
|
||||
port = PORT;
|
||||
}
|
||||
return defaultFactory.createServerSocket(port);
|
||||
System.err.format("in SF::createServerSocket: %d%n", port);
|
||||
ServerSocket server = defaultFactory.createServerSocket(port);
|
||||
rmiPort = server.getLocalPort();
|
||||
System.err.println("rmiPort: " + rmiPort);
|
||||
return server;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
75
jdk/test/java/security/ProtectionDomain/NullGetActions.java
Normal file
75
jdk/test/java/security/ProtectionDomain/NullGetActions.java
Normal file
@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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 8043252
|
||||
* @summary Debug of access control is obfuscated - NullPointerException in
|
||||
* ProtectionDomain
|
||||
* @run main/othervm/java.security.policy=NullGetActions.policy NullGetActions
|
||||
*/
|
||||
|
||||
import java.net.*;
|
||||
import java.security.*;
|
||||
|
||||
public class NullGetActions {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Permissions permset = new Permissions();
|
||||
permset.add(new EvilPermission("java.let.me.do.stuff"));
|
||||
|
||||
Policy.getPolicy();
|
||||
ProtectionDomain protDom = new ProtectionDomain(
|
||||
new CodeSource(new URL("http://bar"),
|
||||
(java.security.cert.Certificate[])null), permset,
|
||||
null, null);
|
||||
|
||||
System.out.println("Protection Domain:\n" + protDom);
|
||||
}
|
||||
|
||||
public static class EvilPermission extends Permission {
|
||||
public EvilPermission(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getActions() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return (obj == this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return 42;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean implies(Permission permission) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
grant {
|
||||
permission java.security.SecurityPermission "getPolicy";
|
||||
};
|
||||
101
jdk/test/java/security/SecureRandom/NoSync.java
Normal file
101
jdk/test/java/security/SecureRandom/NoSync.java
Normal file
@ -0,0 +1,101 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import java.security.Provider;
|
||||
import java.security.SecureRandom;
|
||||
import java.security.Security;
|
||||
import java.util.Date;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 7004967
|
||||
* @run main/othervm NoSync
|
||||
* @summary SecureRandom should be more explicit about threading
|
||||
*/
|
||||
public class NoSync {
|
||||
public static void main(String[] args) throws Exception {
|
||||
for (Provider p : Security.getProviders()) {
|
||||
for (Provider.Service s : p.getServices()) {
|
||||
if (s.getType().equals("SecureRandom") &&
|
||||
!s.getAlgorithm().contains("Block")) {
|
||||
test(SecureRandom.getInstance(s.getAlgorithm(), p));
|
||||
}
|
||||
}
|
||||
}
|
||||
Security.setProperty("securerandom.drbg.config", "HMAC_DRBG");
|
||||
test(SecureRandom.getInstance("DRBG"));
|
||||
Security.setProperty("securerandom.drbg.config", "CTR_DRBG");
|
||||
test(SecureRandom.getInstance("DRBG"));
|
||||
}
|
||||
|
||||
static void test(SecureRandom sr) throws Exception {
|
||||
test(sr, 20, 3000);
|
||||
// All out-of-box impl should have the ThreadSafe attribute
|
||||
String attr = sr.getProvider().getProperty("SecureRandom."
|
||||
+ sr.getAlgorithm() + " ThreadSafe");
|
||||
if (!"true".equals(attr)) {
|
||||
throw new Exception("Not ThreadSafe: " + attr);
|
||||
}
|
||||
}
|
||||
|
||||
public static void test(SecureRandom sr, int tnum, int rnum)
|
||||
throws Exception {
|
||||
|
||||
System.out.println(sr);
|
||||
System.out.println(sr.getAlgorithm() + " " + sr.getProvider().getName());
|
||||
|
||||
System.out.println(new Date());
|
||||
boolean reseed = sr.getParameters() != null;
|
||||
Thread[] threads = new Thread[tnum];
|
||||
AtomicBoolean failed = new AtomicBoolean(false);
|
||||
Thread.UncaughtExceptionHandler h = (t, e) -> {
|
||||
failed.set(true);
|
||||
e.printStackTrace();
|
||||
};
|
||||
for (int i = 0; i < threads.length; i++) {
|
||||
threads[i] = new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (int j = 0; j < rnum; j++) {
|
||||
sr.nextBytes(new byte[j%100+100]);
|
||||
sr.setSeed((long)j);
|
||||
if (reseed) {
|
||||
sr.reseed();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
threads[i].setUncaughtExceptionHandler(h);
|
||||
threads[i].start();
|
||||
}
|
||||
for (int i = 0; i < threads.length; i++) {
|
||||
threads[i].join();
|
||||
}
|
||||
System.out.println(new Date());
|
||||
System.out.println();
|
||||
if (failed.get()) {
|
||||
throw new RuntimeException("Failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
102
jdk/test/java/security/SecureRandom/ThreadSafe.java
Normal file
102
jdk/test/java/security/SecureRandom/ThreadSafe.java
Normal file
@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import java.security.Provider;
|
||||
import java.security.SecureRandom;
|
||||
import java.security.SecureRandomSpi;
|
||||
import java.util.Map;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 7004967
|
||||
* @summary SecureRandom should be more explicit about threading
|
||||
*/
|
||||
public class ThreadSafe {
|
||||
public static void main(String[] args) throws Exception {
|
||||
Provider p = new P();
|
||||
NoSync.test(SecureRandom.getInstance("S1", p), 5, 5);
|
||||
try {
|
||||
NoSync.test(SecureRandom.getInstance("S2", p), 5, 5);
|
||||
throw new Exception("Failed");
|
||||
} catch (RuntimeException re) {
|
||||
// Good
|
||||
}
|
||||
NoSync.test(SecureRandom.getInstance("S3", p), 5, 5);
|
||||
try {
|
||||
NoSync.test(SecureRandom.getInstance("S4", p), 5, 5);
|
||||
throw new Exception("Failed");
|
||||
} catch (RuntimeException re) {
|
||||
// Good
|
||||
}
|
||||
}
|
||||
|
||||
public static class P extends Provider {
|
||||
public P() {
|
||||
|
||||
super("P", 1.0d, "Haha");
|
||||
|
||||
// Good. No attribute.
|
||||
put("SecureRandom.S1", S.class.getName());
|
||||
|
||||
// Bad. Boasting ThreadSafe but isn't
|
||||
put("SecureRandom.S2", S.class.getName());
|
||||
put("SecureRandom.S2 ThreadSafe", "true");
|
||||
|
||||
// Good. No attribute.
|
||||
putService(new Service(this, "SecureRandom", "S3",
|
||||
S.class.getName(), null, null));
|
||||
|
||||
// Bad. Boasting ThreadSafe but isn't
|
||||
putService(new Service(this, "SecureRandom", "S4",
|
||||
S.class.getName(), null, Map.of("ThreadSafe", "true")));
|
||||
}
|
||||
}
|
||||
|
||||
// This implementation is not itself thread safe.
|
||||
public static class S extends SecureRandomSpi {
|
||||
@java.lang.Override
|
||||
protected void engineSetSeed(byte[] seed) {
|
||||
return;
|
||||
}
|
||||
|
||||
private volatile boolean inCall = false;
|
||||
@Override
|
||||
protected void engineNextBytes(byte[] bytes) {
|
||||
if (inCall) {
|
||||
throw new RuntimeException("IN CALL");
|
||||
}
|
||||
inCall = true;
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (Exception e) {
|
||||
// OK
|
||||
}
|
||||
inCall = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected byte[] engineGenerateSeed(int numBytes) {
|
||||
return new byte[numBytes];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -89,6 +89,9 @@ public abstract class IntlTest {
|
||||
case "-nothrow":
|
||||
nothrow = true;
|
||||
break;
|
||||
case "-exitcode":
|
||||
exitCode = true;
|
||||
break;
|
||||
default:
|
||||
Method m = testMethods.get(arg);
|
||||
if (m == null) {
|
||||
@ -138,7 +141,12 @@ public abstract class IntlTest {
|
||||
}
|
||||
}
|
||||
if (nothrow) {
|
||||
System.exit(errorCount);
|
||||
if (exitCode) {
|
||||
System.exit(errorCount);
|
||||
}
|
||||
if (errorCount > 0) {
|
||||
throw new IllegalArgumentException("encountered " + errorCount + " errors");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -243,7 +251,7 @@ public abstract class IntlTest {
|
||||
*/
|
||||
void usage() {
|
||||
System.out.println(getClass().getName() +
|
||||
": [-verbose] [-nothrow] [-prompt] [test names]");
|
||||
": [-verbose] [-nothrow] [-exitcode] [-prompt] [test names]");
|
||||
|
||||
System.out.println(" Available test names:");
|
||||
for (String methodName : testMethods.keySet()) {
|
||||
@ -254,7 +262,7 @@ public abstract class IntlTest {
|
||||
private boolean prompt;
|
||||
private boolean nothrow;
|
||||
protected boolean verbose;
|
||||
|
||||
private boolean exitCode;
|
||||
private PrintWriter log;
|
||||
private int indentLevel;
|
||||
private boolean needLineFeed;
|
||||
|
||||
@ -594,7 +594,7 @@ public class TCKDateTimeFormatterBuilder {
|
||||
@Test(dataProvider = "formatGenericTimeZonePatterns")
|
||||
public void test_appendZoneText_formatGenericTimeZonePatterns(String pattern, String input, String expected) {
|
||||
ZonedDateTime zdt = ZonedDateTime.of(LocalDateTime.now(), ZoneId.of(input));
|
||||
DateTimeFormatter df = DateTimeFormatter.ofPattern(pattern);
|
||||
DateTimeFormatter df = DateTimeFormatter.ofPattern(pattern, Locale.US);
|
||||
assertEquals(zdt.format(df), expected);
|
||||
}
|
||||
|
||||
@ -641,7 +641,7 @@ public class TCKDateTimeFormatterBuilder {
|
||||
@Test(dataProvider = "formatNonGenericTimeZonePatterns_1")
|
||||
public void test_appendZoneText_parseNonGenricTimeZonePatterns_1(String pattern, LocalDateTime ldt, String expected) {
|
||||
ZoneId zId = ZoneId.of("America/Los_Angeles");
|
||||
DateTimeFormatter df = new DateTimeFormatterBuilder().appendPattern(pattern).toFormatter();
|
||||
DateTimeFormatter df = new DateTimeFormatterBuilder().appendPattern(pattern).toFormatter(Locale.US);
|
||||
ZonedDateTime zdt = ZonedDateTime.of(ldt, zId);
|
||||
String actual = df.format(zdt);
|
||||
assertEquals(actual, expected);
|
||||
@ -668,7 +668,7 @@ public class TCKDateTimeFormatterBuilder {
|
||||
@Test(dataProvider = "formatNonGenericTimeZonePatterns_2")
|
||||
public void test_appendZoneText_parseNonGenricTimeZonePatterns_2(String pattern, LocalDateTime ldt, String expected) {
|
||||
ZoneId zId = ZoneId.of("America/Los_Angeles");
|
||||
DateTimeFormatter df = DateTimeFormatter.ofPattern(pattern).withZone(zId);
|
||||
DateTimeFormatter df = DateTimeFormatter.ofPattern(pattern, Locale.US).withZone(zId);
|
||||
String actual = df.format(ldt);
|
||||
assertEquals(actual, expected);
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -91,10 +91,11 @@ public class TCKZoneRulesProvider {
|
||||
public void test_getAvailableGroupIds() {
|
||||
Set<String> zoneIds = ZoneRulesProvider.getAvailableZoneIds();
|
||||
assertEquals(zoneIds.contains("Europe/London"), true);
|
||||
zoneIds.clear();
|
||||
assertEquals(zoneIds.size(), 0);
|
||||
Set<String> zoneIds2 = ZoneRulesProvider.getAvailableZoneIds();
|
||||
assertEquals(zoneIds2.contains("Europe/London"), true);
|
||||
}
|
||||
|
||||
@Test(expectedExceptions=UnsupportedOperationException.class)
|
||||
public void test_getAvailableGroupIds_modifyZoneId() {
|
||||
ZoneRulesProvider.getAvailableZoneIds().clear();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user