--- a/jdk/.hgtags Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/.hgtags Wed Jul 05 21:35:27 2017 +0200
@@ -356,3 +356,4 @@
b2a69d66dc65ad1d3aeb3bd362cf5bb0deba040e jdk-9+111
1565a0efe6f0ca411a6df277df1e069431c60988 jdk-9+112
68f8be44b6a6b33dfa841ec671c0ba6e4056b372 jdk-9+113
+bb8379287f3736f38c52b2d1418784e2592461d1 jdk-9+114
--- a/jdk/make/launcher/Launcher-jdk.rmic.gmk Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/make/launcher/Launcher-jdk.rmic.gmk Wed Jul 05 21:35:27 2017 +0200
@@ -26,6 +26,6 @@
include LauncherCommon.gmk
$(eval $(call SetupBuildLauncher, rmic, \
- MAIN_CLASS := jdk.rmi.rmic.Main, \
+ MAIN_CLASS := sun.rmi.rmic.Main, \
CFLAGS := -DEXPAND_CLASSPATH_WILDCARDS, \
))
--- a/jdk/make/mapfiles/libjava/mapfile-vers Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/make/mapfiles/libjava/mapfile-vers Wed Jul 05 21:35:27 2017 +0200
@@ -224,8 +224,7 @@
Java_java_lang_System_setOut0;
Java_java_lang_Thread_registerNatives;
Java_java_lang_Throwable_fillInStackTrace;
- Java_java_lang_Throwable_getStackTraceDepth;
- Java_java_lang_Throwable_getStackTraceElement;
+ Java_java_lang_Throwable_getStackTraceElements;
Java_java_security_AccessController_doPrivileged__Ljava_security_PrivilegedAction_2;
Java_java_security_AccessController_doPrivileged__Ljava_security_PrivilegedAction_2Ljava_security_AccessControlContext_2;
Java_java_security_AccessController_doPrivileged__Ljava_security_PrivilegedExceptionAction_2;
@@ -238,32 +237,32 @@
Java_jdk_internal_misc_Signal_findSignal0;
Java_jdk_internal_misc_Signal_handle0;
Java_jdk_internal_misc_Signal_raise0;
- Java_sun_reflect_ConstantPool_getClassAt0;
- Java_sun_reflect_ConstantPool_getClassAtIfLoaded0;
- Java_sun_reflect_ConstantPool_getClassRefIndexAt0;
- Java_sun_reflect_ConstantPool_getDoubleAt0;
- Java_sun_reflect_ConstantPool_getFieldAt0;
- Java_sun_reflect_ConstantPool_getFieldAtIfLoaded0;
- Java_sun_reflect_ConstantPool_getFloatAt0;
- Java_sun_reflect_ConstantPool_getIntAt0;
- Java_sun_reflect_ConstantPool_getLongAt0;
- Java_sun_reflect_ConstantPool_getMemberRefInfoAt0;
- Java_sun_reflect_ConstantPool_getMethodAt0;
- Java_sun_reflect_ConstantPool_getMethodAtIfLoaded0;
- Java_sun_reflect_ConstantPool_getNameAndTypeRefIndexAt0;
- Java_sun_reflect_ConstantPool_getNameAndTypeRefInfoAt0;
- Java_sun_reflect_ConstantPool_getSize0;
- Java_sun_reflect_ConstantPool_getStringAt0;
- Java_sun_reflect_ConstantPool_getTagAt0;
- Java_sun_reflect_ConstantPool_getUTF8At0;
+ Java_jdk_internal_reflect_ConstantPool_getClassAt0;
+ Java_jdk_internal_reflect_ConstantPool_getClassAtIfLoaded0;
+ Java_jdk_internal_reflect_ConstantPool_getClassRefIndexAt0;
+ Java_jdk_internal_reflect_ConstantPool_getDoubleAt0;
+ Java_jdk_internal_reflect_ConstantPool_getFieldAt0;
+ Java_jdk_internal_reflect_ConstantPool_getFieldAtIfLoaded0;
+ Java_jdk_internal_reflect_ConstantPool_getFloatAt0;
+ Java_jdk_internal_reflect_ConstantPool_getIntAt0;
+ Java_jdk_internal_reflect_ConstantPool_getLongAt0;
+ Java_jdk_internal_reflect_ConstantPool_getMemberRefInfoAt0;
+ Java_jdk_internal_reflect_ConstantPool_getMethodAt0;
+ Java_jdk_internal_reflect_ConstantPool_getMethodAtIfLoaded0;
+ Java_jdk_internal_reflect_ConstantPool_getNameAndTypeRefIndexAt0;
+ Java_jdk_internal_reflect_ConstantPool_getNameAndTypeRefInfoAt0;
+ Java_jdk_internal_reflect_ConstantPool_getSize0;
+ Java_jdk_internal_reflect_ConstantPool_getStringAt0;
+ Java_jdk_internal_reflect_ConstantPool_getTagAt0;
+ Java_jdk_internal_reflect_ConstantPool_getUTF8At0;
Java_java_io_Console_istty;
Java_java_io_Console_encoding;
Java_java_io_Console_echo;
- Java_sun_reflect_NativeConstructorAccessorImpl_newInstance0;
- Java_sun_reflect_NativeMethodAccessorImpl_invoke0;
- Java_sun_reflect_Reflection_getCallerClass__;
- Java_sun_reflect_Reflection_getCallerClass__I;
- Java_sun_reflect_Reflection_getClassAccessFlags;
+ Java_jdk_internal_reflect_NativeConstructorAccessorImpl_newInstance0;
+ Java_jdk_internal_reflect_NativeMethodAccessorImpl_invoke0;
+ Java_jdk_internal_reflect_Reflection_getCallerClass__;
+ Java_jdk_internal_reflect_Reflection_getCallerClass__I;
+ Java_jdk_internal_reflect_Reflection_getClassAccessFlags;
Java_jdk_internal_misc_VM_latestUserDefinedLoader;
Java_jdk_internal_misc_VM_getuid;
Java_jdk_internal_misc_VM_geteuid;
--- a/jdk/make/mapfiles/libjava/reorder-sparc Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/make/mapfiles/libjava/reorder-sparc Wed Jul 05 21:35:27 2017 +0200
@@ -78,8 +78,7 @@
text: .text%JNU_GetEnv;
text: .text%Java_java_io_UnixFileSystem_checkAccess;
text: .text%Java_java_lang_reflect_Array_newArray;
-text: .text%Java_java_lang_Throwable_getStackTraceDepth;
-text: .text%Java_java_lang_Throwable_getStackTraceElement;
+text: .text%Java_java_lang_Throwable_getStackTraceElements;
text: .text%throwFileNotFoundException;
text: .text%JNU_NotifyAll;
# Test LoadFrame
--- a/jdk/make/mapfiles/libjava/reorder-sparcv9 Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/make/mapfiles/libjava/reorder-sparcv9 Wed Jul 05 21:35:27 2017 +0200
@@ -74,8 +74,7 @@
text: .text%JNU_GetEnv;
text: .text%Java_java_io_UnixFileSystem_checkAccess;
text: .text%Java_java_lang_reflect_Array_newArray;
-text: .text%Java_java_lang_Throwable_getStackTraceDepth;
-text: .text%Java_java_lang_Throwable_getStackTraceElement;
+text: .text%Java_java_lang_Throwable_getStackTraceElements;
text: .text%throwFileNotFoundException: OUTPUTDIR/io_util.o;
text: .text%JNU_NotifyAll;
# Test LoadFrame
--- a/jdk/make/mapfiles/libjava/reorder-x86 Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/make/mapfiles/libjava/reorder-x86 Wed Jul 05 21:35:27 2017 +0200
@@ -78,8 +78,7 @@
text: .text%Java_sun_reflect_NativeMethodAccessorImpl_invoke0;
text: .text%Java_java_io_FileInputStream_available;
text: .text%Java_java_lang_reflect_Array_newArray;
-text: .text%Java_java_lang_Throwable_getStackTraceDepth;
-text: .text%Java_java_lang_Throwable_getStackTraceElement;
+text: .text%Java_java_lang_Throwable_getStackTraceElements;
text: .text%Java_java_lang_System_identityHashCode;
text: .text%JNU_NotifyAll;
# Test LoadFrame
--- a/jdk/make/mapfiles/libnio/mapfile-linux Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/make/mapfiles/libnio/mapfile-linux Wed Jul 05 21:35:27 2017 +0200
@@ -161,7 +161,9 @@
Java_sun_nio_fs_UnixNativeDispatcher_strerror;
Java_sun_nio_fs_UnixNativeDispatcher_dup;
Java_sun_nio_fs_UnixNativeDispatcher_access0;
+ Java_sun_nio_fs_UnixNativeDispatcher_exists0;
Java_sun_nio_fs_UnixNativeDispatcher_stat0;
+ Java_sun_nio_fs_UnixNativeDispatcher_stat1;
Java_sun_nio_fs_UnixNativeDispatcher_lstat0;
Java_sun_nio_fs_UnixNativeDispatcher_fstat;
Java_sun_nio_fs_UnixNativeDispatcher_fstatat0;
--- a/jdk/make/mapfiles/libnio/mapfile-macosx Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/make/mapfiles/libnio/mapfile-macosx Wed Jul 05 21:35:27 2017 +0200
@@ -138,7 +138,9 @@
Java_sun_nio_fs_UnixNativeDispatcher_strerror;
Java_sun_nio_fs_UnixNativeDispatcher_dup;
Java_sun_nio_fs_UnixNativeDispatcher_access0;
+ Java_sun_nio_fs_UnixNativeDispatcher_exists0;
Java_sun_nio_fs_UnixNativeDispatcher_stat0;
+ Java_sun_nio_fs_UnixNativeDispatcher_stat1;
Java_sun_nio_fs_UnixNativeDispatcher_lstat0;
Java_sun_nio_fs_UnixNativeDispatcher_fstat;
Java_sun_nio_fs_UnixNativeDispatcher_fstatat0;
--- a/jdk/make/mapfiles/libnio/mapfile-solaris Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/make/mapfiles/libnio/mapfile-solaris Wed Jul 05 21:35:27 2017 +0200
@@ -138,7 +138,9 @@
Java_sun_nio_fs_UnixNativeDispatcher_strerror;
Java_sun_nio_fs_UnixNativeDispatcher_dup;
Java_sun_nio_fs_UnixNativeDispatcher_access0;
+ Java_sun_nio_fs_UnixNativeDispatcher_exists0;
Java_sun_nio_fs_UnixNativeDispatcher_stat0;
+ Java_sun_nio_fs_UnixNativeDispatcher_stat1;
Java_sun_nio_fs_UnixNativeDispatcher_lstat0;
Java_sun_nio_fs_UnixNativeDispatcher_fstat;
Java_sun_nio_fs_UnixNativeDispatcher_fstatat0;
--- a/jdk/src/java.base/share/classes/com/sun/crypto/provider/AESCrypt.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/com/sun/crypto/provider/AESCrypt.java Wed Jul 05 21:35:27 2017 +0200
@@ -56,7 +56,7 @@
private boolean ROUNDS_14 = false;
/** Session and Sub keys */
- private Object[] sessionK = null;
+ private int[][] sessionK = null;
private int[] K = null;
/** Cipher encryption/decryption key */
@@ -99,7 +99,7 @@
}
// set sub key to the corresponding session Key
- this.K = (int[]) sessionK[(decrypting? 1:0)];
+ this.K = sessionK[(decrypting? 1:0)];
}
/**
@@ -680,7 +680,7 @@
limit = ROUNDS*4;
// store the expanded sub keys into 'sessionK'
- sessionK = new Object[] { expandedKe, expandedKd };
+ sessionK = new int[][] { expandedKe, expandedKd };
}
--- a/jdk/src/java.base/share/classes/com/sun/crypto/provider/DHKeyPairGenerator.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/com/sun/crypto/provider/DHKeyPairGenerator.java Wed Jul 05 21:35:27 2017 +0200
@@ -71,6 +71,17 @@
initialize(2048, null);
}
+ private static void checkKeySize(int keysize)
+ throws InvalidParameterException {
+
+ if ((keysize < 512) || (keysize > 8192) || ((keysize & 0x3F) != 0)) {
+ throw new InvalidParameterException(
+ "DH key size must be multiple of 64, and can only range " +
+ "from 512 to 8192 (inclusive). " +
+ "The specific key size " + keysize + " is not supported");
+ }
+ }
+
/**
* Initializes this key pair generator for a certain keysize and source of
* randomness.
@@ -80,16 +91,22 @@
* @param random the source of randomness
*/
public void initialize(int keysize, SecureRandom random) {
- if ((keysize < 512) || (keysize > 2048) || (keysize % 64 != 0)) {
- throw new InvalidParameterException("Keysize must be multiple "
- + "of 64, and can only range "
- + "from 512 to 2048 "
- + "(inclusive)");
+ checkKeySize(keysize);
+
+ // Use the built-in parameters (ranging from 512 to 8192)
+ // when available.
+ this.params = ParameterCache.getCachedDHParameterSpec(keysize);
+
+ // Due to performance issue, only support DH parameters generation
+ // up to 1024 bits.
+ if ((this.params == null) && (keysize > 1024)) {
+ throw new InvalidParameterException(
+ "Unsupported " + keysize + "-bit DH parameter generation");
}
+
this.pSize = keysize;
this.lSize = 0;
this.random = random;
- this.params = null;
}
/**
@@ -115,11 +132,10 @@
params = (DHParameterSpec)algParams;
pSize = params.getP().bitLength();
- if ((pSize < 512) || (pSize > 2048) ||
- (pSize % 64 != 0)) {
- throw new InvalidAlgorithmParameterException
- ("Prime size must be multiple of 64, and can only range "
- + "from 512 to 2048 (inclusive)");
+ try {
+ checkKeySize(pSize);
+ } catch (InvalidParameterException ipe) {
+ throw new InvalidAlgorithmParameterException(ipe.getMessage());
}
// exponent size is optional, could be 0
@@ -164,7 +180,7 @@
}
BigInteger x;
- BigInteger pMinus2 = p.subtract(BigInteger.valueOf(2));
+ BigInteger pMinus2 = p.subtract(BigInteger.TWO);
//
// PKCS#3 section 7.1 "Private-value generation"
--- a/jdk/src/java.base/share/classes/com/sun/crypto/provider/DHParameterGenerator.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/com/sun/crypto/provider/DHParameterGenerator.java Wed Jul 05 21:35:27 2017 +0200
@@ -25,6 +25,7 @@
package com.sun.crypto.provider;
+import java.math.BigInteger;
import java.security.*;
import java.security.spec.*;
import javax.crypto.spec.DHParameterSpec;
@@ -46,8 +47,7 @@
* @see java.security.spec.AlgorithmParameterSpec
* @see DHParameters
*/
-public final class DHParameterGenerator
-extends AlgorithmParameterGeneratorSpi {
+public final class DHParameterGenerator extends AlgorithmParameterGeneratorSpi {
// The size in bits of the prime modulus
private int primeSize = 2048;
@@ -59,12 +59,16 @@
private SecureRandom random = null;
private static void checkKeySize(int keysize)
- throws InvalidAlgorithmParameterException {
- if ((keysize != 2048) &&
- ((keysize < 512) || (keysize > 1024) || (keysize % 64 != 0))) {
- throw new InvalidAlgorithmParameterException(
- "Keysize must be multiple of 64 ranging from "
- + "512 to 1024 (inclusive), or 2048");
+ throws InvalidParameterException {
+
+ boolean supported = ((keysize == 2048) || (keysize == 3072) ||
+ ((keysize >= 512) && (keysize <= 1024) && ((keysize & 0x3F) == 0)));
+
+ if (!supported) {
+ throw new InvalidParameterException(
+ "DH key size must be multiple of 64 and range " +
+ "from 512 to 1024 (inclusive), or 2048, 3072. " +
+ "The specific key size " + keysize + " is not supported");
}
}
@@ -76,13 +80,9 @@
* @param keysize the keysize (size of prime modulus) in bits
* @param random the source of randomness
*/
+ @Override
protected void engineInit(int keysize, SecureRandom random) {
- // Re-uses DSA parameters and thus have the same range
- try {
- checkKeySize(keysize);
- } catch (InvalidAlgorithmParameterException ex) {
- throw new InvalidParameterException(ex.getMessage());
- }
+ checkKeySize(keysize);
this.primeSize = keysize;
this.random = random;
}
@@ -98,32 +98,31 @@
* @exception InvalidAlgorithmParameterException if the given parameter
* generation values are inappropriate for this parameter generator
*/
+ @Override
protected void engineInit(AlgorithmParameterSpec genParamSpec,
- SecureRandom random)
- throws InvalidAlgorithmParameterException {
+ SecureRandom random) throws InvalidAlgorithmParameterException {
+
if (!(genParamSpec instanceof DHGenParameterSpec)) {
throw new InvalidAlgorithmParameterException
("Inappropriate parameter type");
}
DHGenParameterSpec dhParamSpec = (DHGenParameterSpec)genParamSpec;
-
primeSize = dhParamSpec.getPrimeSize();
-
- // Re-uses DSA parameters and thus have the same range
- checkKeySize(primeSize);
-
exponentSize = dhParamSpec.getExponentSize();
- if (exponentSize <= 0) {
- throw new InvalidAlgorithmParameterException
- ("Exponent size must be greater than zero");
+ if ((exponentSize <= 0) || (exponentSize >= primeSize)) {
+ throw new InvalidAlgorithmParameterException(
+ "Exponent size (" + exponentSize +
+ ") must be positive and less than modulus size (" +
+ primeSize + ")");
+ }
+ try {
+ checkKeySize(primeSize);
+ } catch (InvalidParameterException ipe) {
+ throw new InvalidAlgorithmParameterException(ipe.getMessage());
}
- // Require exponentSize < primeSize
- if (exponentSize >= primeSize) {
- throw new InvalidAlgorithmParameterException
- ("Exponent size must be less than modulus size");
- }
+ this.random = random;
}
/**
@@ -131,24 +130,22 @@
*
* @return the new AlgorithmParameters object
*/
+ @Override
protected AlgorithmParameters engineGenerateParameters() {
- AlgorithmParameters algParams = null;
- if (this.exponentSize == 0) {
- this.exponentSize = this.primeSize - 1;
+ if (random == null) {
+ random = SunJCE.getRandom();
}
- if (this.random == null)
- this.random = SunJCE.getRandom();
-
+ BigInteger paramP = null;
+ BigInteger paramG = null;
try {
- AlgorithmParameterGenerator paramGen;
- DSAParameterSpec dsaParamSpec;
-
- paramGen = AlgorithmParameterGenerator.getInstance("DSA");
- paramGen.init(this.primeSize, random);
- algParams = paramGen.generateParameters();
- dsaParamSpec = algParams.getParameterSpec(DSAParameterSpec.class);
+ AlgorithmParameterGenerator dsaParamGen =
+ AlgorithmParameterGenerator.getInstance("DSA");
+ dsaParamGen.init(primeSize, random);
+ AlgorithmParameters dsaParams = dsaParamGen.generateParameters();
+ DSAParameterSpec dsaParamSpec =
+ dsaParams.getParameterSpec(DSAParameterSpec.class);
DHParameterSpec dhParamSpec;
if (this.exponentSize > 0) {
@@ -159,16 +156,13 @@
dhParamSpec = new DHParameterSpec(dsaParamSpec.getP(),
dsaParamSpec.getG());
}
- algParams = AlgorithmParameters.getInstance("DH",
- SunJCE.getInstance());
+ AlgorithmParameters algParams =
+ AlgorithmParameters.getInstance("DH", SunJCE.getInstance());
algParams.init(dhParamSpec);
- } catch (InvalidParameterSpecException e) {
- // this should never happen
- throw new RuntimeException(e.getMessage());
- } catch (NoSuchAlgorithmException e) {
- // this should never happen, because we provide it
- throw new RuntimeException(e.getMessage());
+
+ return algParams;
+ } catch (Exception ex) {
+ throw new ProviderException("Unexpected exception", ex);
}
- return algParams;
}
}
--- a/jdk/src/java.base/share/classes/java/io/ObjectStreamClass.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/io/ObjectStreamClass.java Wed Jul 05 21:35:27 2017 +0200
@@ -49,9 +49,9 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import jdk.internal.misc.Unsafe;
-import sun.reflect.CallerSensitive;
-import sun.reflect.Reflection;
-import sun.reflect.ReflectionFactory;
+import jdk.internal.reflect.CallerSensitive;
+import jdk.internal.reflect.Reflection;
+import jdk.internal.reflect.ReflectionFactory;
import sun.reflect.misc.ReflectUtil;
import static java.io.ObjectStreamField.*;
--- a/jdk/src/java.base/share/classes/java/io/ObjectStreamField.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/io/ObjectStreamField.java Wed Jul 05 21:35:27 2017 +0200
@@ -26,8 +26,8 @@
package java.io;
import java.lang.reflect.Field;
-import sun.reflect.CallerSensitive;
-import sun.reflect.Reflection;
+import jdk.internal.reflect.CallerSensitive;
+import jdk.internal.reflect.Reflection;
import sun.reflect.misc.ReflectUtil;
/**
--- a/jdk/src/java.base/share/classes/java/lang/ArrayIndexOutOfBoundsException.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/ArrayIndexOutOfBoundsException.java Wed Jul 05 21:35:27 2017 +0200
@@ -64,20 +64,4 @@
public ArrayIndexOutOfBoundsException(int index) {
super("Array index out of range: " + index);
}
-
- /**
- * Constructs a new {@code ArrayIndexOutOfBoundsException} class with
- * arguments indicating two out of bound values.
- *
- * <p>The out of bound values are included in this exception's detail
- * message. The exact presentation format of the detail message is
- * unspecified.
- *
- * @param a the first out of bound value.
- * @param b the second out of bound value.
- * @since 9
- */
- public ArrayIndexOutOfBoundsException(int a, int b) {
- super("Array indexed access out of bounds: " + a + ", " + b);
- }
}
--- a/jdk/src/java.base/share/classes/java/lang/Class.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/Class.java Wed Jul 05 21:35:27 2017 +0200
@@ -66,10 +66,10 @@
import jdk.internal.loader.BuiltinClassLoader;
import jdk.internal.misc.Unsafe;
import jdk.internal.misc.VM;
-import sun.reflect.CallerSensitive;
-import sun.reflect.ConstantPool;
-import sun.reflect.Reflection;
-import sun.reflect.ReflectionFactory;
+import jdk.internal.reflect.CallerSensitive;
+import jdk.internal.reflect.ConstantPool;
+import jdk.internal.reflect.Reflection;
+import jdk.internal.reflect.ReflectionFactory;
import sun.reflect.generics.factory.CoreReflectionFactory;
import sun.reflect.generics.factory.GenericsFactory;
import sun.reflect.generics.repository.ClassRepository;
@@ -3473,7 +3473,7 @@
if (reflectionFactory == null) {
reflectionFactory =
java.security.AccessController.doPrivileged
- (new sun.reflect.ReflectionFactory.GetReflectionFactoryAction());
+ (new ReflectionFactory.GetReflectionFactoryAction());
}
return reflectionFactory;
}
--- a/jdk/src/java.base/share/classes/java/lang/ClassLoader.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/ClassLoader.java Wed Jul 05 21:35:27 2017 +0200
@@ -60,8 +60,8 @@
import jdk.internal.misc.SharedSecrets;
import jdk.internal.misc.Unsafe;
import jdk.internal.misc.VM;
-import sun.reflect.CallerSensitive;
-import sun.reflect.Reflection;
+import jdk.internal.reflect.CallerSensitive;
+import jdk.internal.reflect.Reflection;
import sun.reflect.misc.ReflectUtil;
import sun.security.util.SecurityConstants;
--- a/jdk/src/java.base/share/classes/java/lang/Deprecated.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/Deprecated.java Wed Jul 05 21:35:27 2017 +0200
@@ -29,14 +29,44 @@
import static java.lang.annotation.ElementType.*;
/**
- * A program element annotated @Deprecated is one that programmers
- * are discouraged from using, typically because it is dangerous,
- * or because a better alternative exists. Compilers warn when a
- * deprecated program element is used or overridden in non-deprecated code.
+ * A program element annotated {@code @Deprecated} is one that programmers
+ * are discouraged from using. An element may be deprecated for any of several
+ * reasons, for example, its usage is likely to lead to errors; it may
+ * be changed incompatibly or removed in a future version; it has been
+ * superseded by a newer, usually preferable alternative; or it is obsolete.
+ *
+ * <p>Compilers issue warnings when a deprecated program element is used or
+ * overridden in non-deprecated code. Use of the {@code @Deprecated}
+ * annotation on a local variable declaration or on a parameter declaration
+ * or a package declaration has no effect on the warnings issued by a compiler.
+ *
+ * <p>This annotation type has a string-valued element {@code since}. The value
+ * of this element indicates the version in which the annotated program element
+ * was first deprecated.
*
- * <p>Use of the @Deprecated annotation on a local variable
- * declaration or on a parameter declaration or a package declaration
- * has no effect on the warnings issued by a compiler.
+ * <p>This annotation type has a boolean-valued element {@code forRemoval}.
+ * A value of {@code true} indicates intent to remove the annotated program
+ * element in a future version. A value of {@code false} indicates that use of
+ * the annotated program element is discouraged, but at the time the program
+ * element was annotated, there was no specific intent to remove it.
+ *
+ * @apiNote
+ * It is strongly recommended that the reason for deprecating a program element
+ * be explained in the documentation, using the {@code @deprecated}
+ * javadoc tag. The documentation should also suggest and link to a
+ * recommended replacement API, if applicable. A replacement API often
+ * has subtly different semantics, so such issues should be discussed as
+ * well.
+ *
+ * <p>It is recommended that a {@code since} value be provided with all newly
+ * annotated program elements. Note that {@code since} cannot be mandatory,
+ * as there are many existing annotations that lack this element value.
+ *
+ * <p>There is no defined order among annotation elements. As a matter of
+ * style, the {@code since} element should be placed first.
+ *
+ * <p>The {@code @Deprecated} annotation should always be present if
+ * the {@code @deprecated} javadoc tag is present, and vice-versa.
*
* @author Neal Gafter
* @since 1.5
@@ -46,4 +76,23 @@
@Retention(RetentionPolicy.RUNTIME)
@Target(value={CONSTRUCTOR, FIELD, LOCAL_VARIABLE, METHOD, PACKAGE, PARAMETER, TYPE})
public @interface Deprecated {
+ /**
+ * Returns the version in which the annotated element became deprecated.
+ * The version string is in the same format and namespace as the value of
+ * the {@code @since} javadoc tag. The default value is the empty
+ * string.
+ *
+ * @return the version string
+ * @since 9
+ */
+ String since() default "";
+
+ /**
+ * Indicates whether the annotated element is subject to removal in a
+ * future version. The default value is {@code false}.
+ *
+ * @return whether the element is subject to removal
+ * @since 9
+ */
+ boolean forRemoval() default false;
}
--- a/jdk/src/java.base/share/classes/java/lang/IndexOutOfBoundsException.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/IndexOutOfBoundsException.java Wed Jul 05 21:35:27 2017 +0200
@@ -67,21 +67,4 @@
public IndexOutOfBoundsException(int index) {
super("Index out of range: " + index);
}
-
- /**
- * Constructs an {@code IndexOutOfBoundsException} with arguments indicating
- * two out of bound values.
- *
- * <p>The out of bound values are included in this exception's detail
- * message. The exact presentation format of the detail message is
- * unspecified.
- *
- * @param a the first out of bound value
- * @param b the second out of bound value
- * @since 9
- */
- public IndexOutOfBoundsException(int a, int b) {
- super("Indexed access out of bounds: " + a + ", " + b);
- }
-
}
--- a/jdk/src/java.base/share/classes/java/lang/Math.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/Math.java Wed Jul 05 21:35:27 2017 +0200
@@ -25,6 +25,7 @@
package java.lang;
+import java.math.BigDecimal;
import java.util.Random;
import jdk.internal.math.FloatConsts;
import jdk.internal.math.DoubleConsts;
@@ -1450,6 +1451,199 @@
}
/**
+ * Returns the fused multiply add of the three arguments; that is,
+ * returns the exact product of the first two arguments summed
+ * with the third argument and then rounded once to the nearest
+ * {@code double}.
+ *
+ * The rounding is done using the {@linkplain
+ * java.math.RoundingMode#HALF_EVEN round to nearest even
+ * rounding mode}.
+ *
+ * In contrast, if {@code a * b + c} is evaluated as a regular
+ * floating-point expression, two rounding errors are involved,
+ * the first for the multiply operation, the second for the
+ * addition operation.
+ *
+ * <p>Special cases:
+ * <ul>
+ * <li> If any argument is NaN, the result is NaN.
+ *
+ * <li> If one of the first two arguments is infinite and the
+ * other is zero, the result is NaN.
+ *
+ * <li> If the exact product of the first two arguments is infinite
+ * (in other words, at least one of the arguments is infinite and
+ * the other is neither zero nor NaN) and the third argument is an
+ * infinity of the opposite sign, the result is NaN.
+ *
+ * </ul>
+ *
+ * <p>Note that {@code fma(a, 1.0, c)} returns the same
+ * result as ({@code a + c}). However,
+ * {@code fma(a, b, +0.0)} does <em>not</em> always return the
+ * same result as ({@code a * b}) since
+ * {@code fma(-0.0, +0.0, +0.0)} is {@code +0.0} while
+ * ({@code -0.0 * +0.0}) is {@code -0.0}; {@code fma(a, b, -0.0)} is
+ * equivalent to ({@code a * b}) however.
+ *
+ * @apiNote This method corresponds to the fusedMultiplyAdd
+ * operation defined in IEEE 754-2008.
+ *
+ * @param a a value
+ * @param b a value
+ * @param c a value
+ *
+ * @return (<i>a</i> × <i>b</i> + <i>c</i>)
+ * computed, as if with unlimited range and precision, and rounded
+ * once to the nearest {@code double} value
+ */
+ // @HotSpotIntrinsicCandidate
+ public static double fma(double a, double b, double c) {
+ /*
+ * Infinity and NaN arithmetic is not quite the same with two
+ * roundings as opposed to just one so the simple expression
+ * "a * b + c" cannot always be used to compute the correct
+ * result. With two roundings, the product can overflow and
+ * if the addend is infinite, a spurious NaN can be produced
+ * if the infinity from the overflow and the infinite addend
+ * have opposite signs.
+ */
+
+ // First, screen for and handle non-finite input values whose
+ // arithmetic is not supported by BigDecimal.
+ if (Double.isNaN(a) || Double.isNaN(b) || Double.isNaN(c)) {
+ return Double.NaN;
+ } else { // All inputs non-NaN
+ boolean infiniteA = Double.isInfinite(a);
+ boolean infiniteB = Double.isInfinite(b);
+ boolean infiniteC = Double.isInfinite(c);
+ double result;
+
+ if (infiniteA || infiniteB || infiniteC) {
+ if (infiniteA && b == 0.0 ||
+ infiniteB && a == 0.0 ) {
+ return Double.NaN;
+ }
+ // Store product in a double field to cause an
+ // overflow even if non-strictfp evaluation is being
+ // used.
+ double product = a * b;
+ if (Double.isInfinite(product) && !infiniteA && !infiniteB) {
+ // Intermediate overflow; might cause a
+ // spurious NaN if added to infinite c.
+ assert Double.isInfinite(c);
+ return c;
+ } else {
+ result = product + c;
+ assert !Double.isFinite(result);
+ return result;
+ }
+ } else { // All inputs finite
+ BigDecimal product = (new BigDecimal(a)).multiply(new BigDecimal(b));
+ if (c == 0.0) { // Positive or negative zero
+ // If the product is an exact zero, use a
+ // floating-point expression to compute the sign
+ // of the zero final result. The product is an
+ // exact zero if and only if at least one of a and
+ // b is zero.
+ if (a == 0.0 || b == 0.0) {
+ return a * b + c;
+ } else {
+ // The sign of a zero addend doesn't matter if
+ // the product is nonzero. The sign of a zero
+ // addend is not factored in the result if the
+ // exact product is nonzero but underflows to
+ // zero; see IEEE-754 2008 section 6.3 "The
+ // sign bit".
+ return product.doubleValue();
+ }
+ } else {
+ return product.add(new BigDecimal(c)).doubleValue();
+ }
+ }
+ }
+ }
+
+ /**
+ * Returns the fused multiply add of the three arguments; that is,
+ * returns the exact product of the first two arguments summed
+ * with the third argument and then rounded once to the nearest
+ * {@code float}.
+ *
+ * The rounding is done using the {@linkplain
+ * java.math.RoundingMode#HALF_EVEN round to nearest even
+ * rounding mode}.
+ *
+ * In contrast, if {@code a * b + c} is evaluated as a regular
+ * floating-point expression, two rounding errors are involved,
+ * the first for the multiply operation, the second for the
+ * addition operation.
+ *
+ * <p>Special cases:
+ * <ul>
+ * <li> If any argument is NaN, the result is NaN.
+ *
+ * <li> If one of the first two arguments is infinite and the
+ * other is zero, the result is NaN.
+ *
+ * <li> If the exact product of the first two arguments is infinite
+ * (in other words, at least one of the arguments is infinite and
+ * the other is neither zero nor NaN) and the third argument is an
+ * infinity of the opposite sign, the result is NaN.
+ *
+ * </ul>
+ *
+ * <p>Note that {@code fma(a, 1.0f, c)} returns the same
+ * result as ({@code a + c}). However,
+ * {@code fma(a, b, +0.0f)} does <em>not</em> always return the
+ * same result as ({@code a * b}) since
+ * {@code fma(-0.0f, +0.0f, +0.0f)} is {@code +0.0f} while
+ * ({@code -0.0f * +0.0f}) is {@code -0.0f}; {@code fma(a, b, -0.0f)} is
+ * equivalent to ({@code a * b}) however.
+ *
+ * @apiNote This method corresponds to the fusedMultiplyAdd
+ * operation defined in IEEE 754-2008.
+ *
+ * @param a a value
+ * @param b a value
+ * @param c a value
+ *
+ * @return (<i>a</i> × <i>b</i> + <i>c</i>)
+ * computed, as if with unlimited range and precision, and rounded
+ * once to the nearest {@code float} value
+ */
+ // @HotSpotIntrinsicCandidate
+ public static float fma(float a, float b, float c) {
+ /*
+ * Since the double format has more than twice the precision
+ * of the float format, the multiply of a * b is exact in
+ * double. The add of c to the product then incurs one
+ * rounding error. Since the double format moreover has more
+ * than (2p + 2) precision bits compared to the p bits of the
+ * float format, the two roundings of (a * b + c), first to
+ * the double format and then secondarily to the float format,
+ * are equivalent to rounding the intermediate result directly
+ * to the float format.
+ *
+ * In terms of strictfp vs default-fp concerns related to
+ * overflow and underflow, since
+ *
+ * (Float.MAX_VALUE * Float.MAX_VALUE) << Double.MAX_VALUE
+ * (Float.MIN_VALUE * Float.MIN_VALUE) >> Double.MIN_VALUE
+ *
+ * neither the multiply nor add will overflow or underflow in
+ * double. Therefore, it is not necessary for this method to
+ * be declared strictfp to have reproducible
+ * behavior. However, it is necessary to explicitly store down
+ * to a float variable to avoid returning a value in the float
+ * extended value set.
+ */
+ float result = (float)(((double) a * (double) b ) + (double) c);
+ return result;
+ }
+
+ /**
* Returns the size of an ulp of the argument. An ulp, unit in
* the last place, of a {@code double} value is the positive
* distance between this floating-point value and the {@code
--- a/jdk/src/java.base/share/classes/java/lang/Package.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/Package.java Wed Jul 05 21:35:27 2017 +0200
@@ -36,8 +36,8 @@
import java.util.Objects;
import jdk.internal.loader.BootLoader;
-import sun.reflect.CallerSensitive;
-import sun.reflect.Reflection;
+import jdk.internal.reflect.CallerSensitive;
+import jdk.internal.reflect.Reflection;
/**
--- a/jdk/src/java.base/share/classes/java/lang/ProcessHandleImpl.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/ProcessHandleImpl.java Wed Jul 05 21:35:27 2017 +0200
@@ -52,6 +52,11 @@
*/
final class ProcessHandleImpl implements ProcessHandle {
/**
+ * Default size of stack for reaper processes.
+ */
+ private static long REAPER_DEFAULT_STACKSIZE = 128 * 1024;
+
+ /**
* Cache the ProcessHandle of this process.
*/
private static final ProcessHandleImpl current;
@@ -79,10 +84,12 @@
ThreadGroup tg = Thread.currentThread().getThreadGroup();
while (tg.getParent() != null) tg = tg.getParent();
ThreadGroup systemThreadGroup = tg;
+ final long stackSize = Boolean.getBoolean("jdk.lang.processReaperUseDefaultStackSize")
+ ? 0 : REAPER_DEFAULT_STACKSIZE;
ThreadFactory threadFactory = grimReaper -> {
- long stackSize = Boolean.getBoolean("jdk.lang.processReaperUseDefaultStackSize") ? 0 : 32768;
- Thread t = new Thread(systemThreadGroup, grimReaper, "process reaper", stackSize);
+ Thread t = new Thread(systemThreadGroup, grimReaper,
+ "process reaper", stackSize, false);
t.setDaemon(true);
// A small attempt (probably futile) to avoid priority inversion
t.setPriority(Thread.MAX_PRIORITY);
--- a/jdk/src/java.base/share/classes/java/lang/Runtime.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/Runtime.java Wed Jul 05 21:35:27 2017 +0200
@@ -27,8 +27,8 @@
import java.io.*;
import java.util.StringTokenizer;
-import sun.reflect.CallerSensitive;
-import sun.reflect.Reflection;
+import jdk.internal.reflect.CallerSensitive;
+import jdk.internal.reflect.Reflection;
/**
* Every Java application has a single instance of class
--- a/jdk/src/java.base/share/classes/java/lang/SecurityManager.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/SecurityManager.java Wed Jul 05 21:35:27 2017 +0200
@@ -38,7 +38,7 @@
import java.lang.reflect.*;
import java.net.URL;
-import sun.reflect.CallerSensitive;
+import jdk.internal.reflect.CallerSensitive;
import sun.security.util.SecurityConstants;
/**
--- a/jdk/src/java.base/share/classes/java/lang/StackStreamFactory.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/StackStreamFactory.java Wed Jul 05 21:35:27 2017 +0200
@@ -25,6 +25,7 @@
package java.lang;
import jdk.internal.misc.VM;
+import jdk.internal.reflect.MethodAccessor;
import java.io.PrintStream;
import java.lang.StackWalker.Option;
@@ -1081,13 +1082,13 @@
}
private static boolean isReflectionFrame(Class<?> c) {
- if (c.getName().startsWith("sun.reflect") &&
- !sun.reflect.MethodAccessor.class.isAssignableFrom(c)) {
- throw new InternalError("Not sun.reflect.MethodAccessor: " + c.toString());
+ if (c.getName().startsWith("jdk.internal.reflect") &&
+ !MethodAccessor.class.isAssignableFrom(c)) {
+ throw new InternalError("Not jdk.internal.reflect.MethodAccessor: " + c.toString());
}
// ## should filter all @Hidden frames?
return c == Method.class ||
- sun.reflect.MethodAccessor.class.isAssignableFrom(c) ||
+ MethodAccessor.class.isAssignableFrom(c) ||
c.getName().startsWith("java.lang.invoke.LambdaForm");
}
--- a/jdk/src/java.base/share/classes/java/lang/StackTraceElement.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/StackTraceElement.java Wed Jul 05 21:35:27 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 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
@@ -112,6 +112,12 @@
this.lineNumber = lineNumber;
}
+
+ /**
+ * Creates an empty stack frame element to be filled in by Throwable.
+ */
+ StackTraceElement() { }
+
/**
* Returns the name of the source file containing the execution point
* represented by this stack trace element. Generally, this corresponds
--- a/jdk/src/java.base/share/classes/java/lang/StackWalker.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/StackWalker.java Wed Jul 05 21:35:27 2017 +0200
@@ -24,7 +24,7 @@
*/
package java.lang;
-import sun.reflect.CallerSensitive;
+import jdk.internal.reflect.CallerSensitive;
import java.util.*;
import java.util.function.Consumer;
--- a/jdk/src/java.base/share/classes/java/lang/StrictMath.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/StrictMath.java Wed Jul 05 21:35:27 2017 +0200
@@ -1135,6 +1135,110 @@
}
/**
+ * Returns the fused multiply add of the three arguments; that is,
+ * returns the exact product of the first two arguments summed
+ * with the third argument and then rounded once to the nearest
+ * {@code double}.
+ *
+ * The rounding is done using the {@linkplain
+ * java.math.RoundingMode#HALF_EVEN round to nearest even
+ * rounding mode}.
+ *
+ * In contrast, if {@code a * b + c} is evaluated as a regular
+ * floating-point expression, two rounding errors are involved,
+ * the first for the multiply operation, the second for the
+ * addition operation.
+ *
+ * <p>Special cases:
+ * <ul>
+ * <li> If any argument is NaN, the result is NaN.
+ *
+ * <li> If one of the first two arguments is infinite and the
+ * other is zero, the result is NaN.
+ *
+ * <li> If the exact product of the first two arguments is infinite
+ * (in other words, at least one of the arguments is infinite and
+ * the other is neither zero nor NaN) and the third argument is an
+ * infinity of the opposite sign, the result is NaN.
+ *
+ * </ul>
+ *
+ * <p>Note that {@code fusedMac(a, 1.0, c)} returns the same
+ * result as ({@code a + c}). However,
+ * {@code fusedMac(a, b, +0.0)} does <em>not</em> always return the
+ * same result as ({@code a * b}) since
+ * {@code fusedMac(-0.0, +0.0, +0.0)} is {@code +0.0} while
+ * ({@code -0.0 * +0.0}) is {@code -0.0}; {@code fusedMac(a, b, -0.0)} is
+ * equivalent to ({@code a * b}) however.
+ *
+ * @apiNote This method corresponds to the fusedMultiplyAdd
+ * operation defined in IEEE 754-2008.
+ *
+ * @param a a value
+ * @param b a value
+ * @param c a value
+ *
+ * @return (<i>a</i> × <i>b</i> + <i>c</i>)
+ * computed, as if with unlimited range and precision, and rounded
+ * once to the nearest {@code double} value
+ */
+ public static double fma(double a, double b, double c) {
+ return Math.fma(a, b, c);
+ }
+
+ /**
+ * Returns the fused multiply add of the three arguments; that is,
+ * returns the exact product of the first two arguments summed
+ * with the third argument and then rounded once to the nearest
+ * {@code float}.
+ *
+ * The rounding is done using the {@linkplain
+ * java.math.RoundingMode#HALF_EVEN round to nearest even
+ * rounding mode}.
+ *
+ * In contrast, if {@code a * b + c} is evaluated as a regular
+ * floating-point expression, two rounding errors are involved,
+ * the first for the multiply operation, the second for the
+ * addition operation.
+ *
+ * <p>Special cases:
+ * <ul>
+ * <li> If any argument is NaN, the result is NaN.
+ *
+ * <li> If one of the first two arguments is infinite and the
+ * other is zero, the result is NaN.
+ *
+ * <li> If the exact product of the first two arguments is infinite
+ * (in other words, at least one of the arguments is infinite and
+ * the other is neither zero nor NaN) and the third argument is an
+ * infinity of the opposite sign, the result is NaN.
+ *
+ * </ul>
+ *
+ * <p>Note that {@code fma(a, 1.0f, c)} returns the same
+ * result as ({@code a + c}). However,
+ * {@code fma(a, b, +0.0f)} does <em>not</em> always return the
+ * same result as ({@code a * b}) since
+ * {@code fma(-0.0f, +0.0f, +0.0f)} is {@code +0.0f} while
+ * ({@code -0.0f * +0.0f}) is {@code -0.0f}; {@code fma(a, b, -0.0f)} is
+ * equivalent to ({@code a * b}) however.
+ *
+ * @apiNote This method corresponds to the fusedMultiplyAdd
+ * operation defined in IEEE 754-2008.
+ *
+ * @param a a value
+ * @param b a value
+ * @param c a value
+ *
+ * @return (<i>a</i> × <i>b</i> + <i>c</i>)
+ * computed, as if with unlimited range and precision, and rounded
+ * once to the nearest {@code float} value
+ */
+ public static float fma(float a, float b, float c) {
+ return Math.fma(a, b, c);
+ }
+
+ /**
* Returns the size of an ulp of the argument. An ulp, unit in
* the last place, of a {@code double} value is the positive
* distance between this floating-point value and the {@code
--- a/jdk/src/java.base/share/classes/java/lang/StringIndexOutOfBoundsException.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/StringIndexOutOfBoundsException.java Wed Jul 05 21:35:27 2017 +0200
@@ -67,20 +67,4 @@
public StringIndexOutOfBoundsException(int index) {
super("String index out of range: " + index);
}
-
- /**
- * Constructs a new {@code StringIndexOutOfBoundsException} class with
- * arguments indicating two out of bound values.
- *
- * <p>The out of bound values are included in this exception's detail
- * message. The exact presentation format of the detail message is
- * unspecified.
- *
- * @param a the first out of bound value.
- * @param b the second out of bound value.
- * @since 9
- */
- public StringIndexOutOfBoundsException(int a, int b) {
- super("String indexed access out of bounds: " + a + ", " + b);
- }
}
--- a/jdk/src/java.base/share/classes/java/lang/System.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/System.java Wed Jul 05 21:35:27 2017 +0200
@@ -56,8 +56,8 @@
import java.util.ResourceBundle;
import java.util.function.Supplier;
import sun.nio.ch.Interruptible;
-import sun.reflect.CallerSensitive;
-import sun.reflect.Reflection;
+import jdk.internal.reflect.CallerSensitive;
+import jdk.internal.reflect.Reflection;
import sun.security.util.SecurityConstants;
import sun.reflect.annotation.AnnotationType;
import jdk.internal.HotSpotIntrinsicCandidate;
@@ -1978,7 +1978,7 @@
private static void setJavaLangAccess() {
// Allow privileged classes outside of java.lang
SharedSecrets.setJavaLangAccess(new JavaLangAccess(){
- public sun.reflect.ConstantPool getConstantPool(Class<?> klass) {
+ public jdk.internal.reflect.ConstantPool getConstantPool(Class<?> klass) {
return klass.getConstantPool();
}
public boolean casAnnotationType(Class<?> klass, AnnotationType oldType, AnnotationType newType) {
--- a/jdk/src/java.base/share/classes/java/lang/Thread.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/Thread.java Wed Jul 05 21:35:27 2017 +0200
@@ -37,8 +37,8 @@
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.locks.LockSupport;
import sun.nio.ch.Interruptible;
-import sun.reflect.CallerSensitive;
-import sun.reflect.Reflection;
+import jdk.internal.reflect.CallerSensitive;
+import jdk.internal.reflect.Reflection;
import sun.security.util.SecurityConstants;
import jdk.internal.HotSpotIntrinsicCandidate;
--- a/jdk/src/java.base/share/classes/java/lang/Throwable.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/Throwable.java Wed Jul 05 21:35:27 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 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 @@
private static final long serialVersionUID = -3042686055658047285L;
/**
- * Native code saves some indication of the stack backtrace in this slot.
+ * The JVM saves some indication of the stack backtrace in this slot.
*/
private transient Object backtrace;
@@ -211,6 +211,11 @@
*/
private StackTraceElement[] stackTrace = UNASSIGNED_STACK;
+ /**
+ * The JVM code sets the depth of the backtrace for later retrieval
+ */
+ private transient int depth;
+
// Setting this static field introduces an acceptable
// initialization dependency on a few java.util classes.
private static final List<Throwable> SUPPRESSED_SENTINEL = Collections.emptyList();
@@ -828,10 +833,11 @@
if (backtrace instanceof StackStreamFactory.StackTrace) {
stackTrace = ((StackStreamFactory.StackTrace)backtrace).getStackTraceElements();
} else {
- int depth = getStackTraceDepth();
stackTrace = new StackTraceElement[depth];
- for (int i = 0; i < depth; i++)
- stackTrace[i] = getStackTraceElement(i);
+ for (int i = 0; i < depth; i++) {
+ stackTrace[i] = new StackTraceElement();
+ }
+ getStackTraceElements(stackTrace);
}
} else if (stackTrace == null) {
return UNASSIGNED_STACK;
@@ -884,23 +890,11 @@
}
/**
- * Returns the number of elements in the stack trace (or 0 if the stack
- * trace is unavailable).
- *
- * package-protection for use by SharedSecrets.
+ * Gets the stack trace elements.
+ * @param elements
+ * @throws IndexOutOfBoundsException if {@code elements.length != depth }
*/
- native int getStackTraceDepth();
-
- /**
- * Returns the specified element of the stack trace.
- *
- * package-protection for use by SharedSecrets.
- *
- * @param index index of the element to return.
- * @throws IndexOutOfBoundsException if {@code index < 0 ||
- * index >= getStackTraceDepth() }
- */
- native StackTraceElement getStackTraceElement(int index);
+ private native void getStackTraceElements(StackTraceElement[] elements);
/**
* Reads a {@code Throwable} from a stream, enforcing
--- a/jdk/src/java.base/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java Wed Jul 05 21:35:27 2017 +0200
@@ -89,8 +89,7 @@
static {
final String key = "jdk.internal.lambda.dumpProxyClasses";
String path = AccessController.doPrivileged(
- new GetPropertyAction(key), null,
- new PropertyPermission(key , "read"));
+ new GetPropertyAction(key));
dumper = (null == path) ? null : ProxyClassesDumper.getInstance(path);
}
--- a/jdk/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java Wed Jul 05 21:35:27 2017 +0200
@@ -655,6 +655,8 @@
mv.visitAnnotation(DONTINLINE_SIG, true);
}
+ constantPlaceholder(lambdaForm); // keep LambdaForm instance & its compiled form lifetime tightly coupled.
+
if (lambdaForm.customized != null) {
// Since LambdaForm is customized for a particular MethodHandle, it's safe to substitute
// receiver MethodHandle (at slot #0) with an embedded constant and use it instead.
--- a/jdk/src/java.base/share/classes/java/lang/invoke/Invokers.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/Invokers.java Wed Jul 05 21:35:27 2017 +0200
@@ -131,11 +131,11 @@
MethodType mtype = targetType;
MethodType invokerType = mtype.insertParameterTypes(0, VarHandle.class);
- LambdaForm lform = varHandleMethodGenericInvokerHandleForm(ak.name(), mtype);
+ LambdaForm lform = varHandleMethodGenericInvokerHandleForm(ak.methodName(), mtype);
VarHandle.AccessDescriptor ad = new VarHandle.AccessDescriptor(mtype, ak.at.ordinal(), ak.ordinal());
MethodHandle invoker = BoundMethodHandle.bindSingle(invokerType, lform, ad);
- invoker = invoker.withInternalMemberName(MemberName.makeVarHandleMethodInvoke(ak.name(), mtype), false);
+ invoker = invoker.withInternalMemberName(MemberName.makeVarHandleMethodInvoke(ak.methodName(), mtype), false);
assert(checkVarHandleInvoker(invoker));
maybeCompileToBytecode(invoker);
@@ -146,11 +146,11 @@
MethodType mtype = targetType;
MethodType invokerType = mtype.insertParameterTypes(0, VarHandle.class);
- LambdaForm lform = varHandleMethodExactInvokerHandleForm(ak.name(), mtype);
+ LambdaForm lform = varHandleMethodExactInvokerHandleForm(ak.methodName(), mtype);
VarHandle.AccessDescriptor ad = new VarHandle.AccessDescriptor(mtype, ak.at.ordinal(), ak.ordinal());
MethodHandle invoker = BoundMethodHandle.bindSingle(invokerType, lform, ad);
- invoker = invoker.withInternalMemberName(MemberName.makeVarHandleMethodInvoke(ak.name(), mtype), false);
+ invoker = invoker.withInternalMemberName(MemberName.makeVarHandleMethodInvoke(ak.methodName(), mtype), false);
assert(checkVarHandleInvoker(invoker));
maybeCompileToBytecode(invoker);
--- a/jdk/src/java.base/share/classes/java/lang/invoke/MemberName.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MemberName.java Wed Jul 05 21:35:27 2017 +0200
@@ -374,7 +374,7 @@
}
public static boolean isVarHandleMethodInvokeName(String name) {
try {
- VarHandle.AccessMode.valueOf(name);
+ VarHandle.AccessMode.valueFromMethodName(name);
return true;
} catch (IllegalArgumentException e) {
return false;
--- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandle.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandle.java Wed Jul 05 21:35:27 2017 +0200
@@ -219,7 +219,8 @@
* Method handles produced by lookups or constant loads from methods or
* constructors with the variable arity modifier bit ({@code 0x0080})
* have a corresponding variable arity, as if they were defined with
- * the help of {@link #asVarargsCollector asVarargsCollector}.
+ * the help of {@link #asVarargsCollector asVarargsCollector}
+ * or {@link #withVarargs withVarargs}.
* <p>
* A method reference may refer either to a static or non-static method.
* In the non-static case, the method handle type includes an explicit
@@ -972,6 +973,36 @@
throw newIllegalArgumentException("array length is not legal for long[] or double[]", arrayLength);
}
}
+ /**
+ * Adapts this method handle to be {@linkplain #asVarargsCollector variable arity}
+ * if the boolean flag is true, else {@linkplain #asFixedArity fixed arity}.
+ * If the method handle is already of the proper arity mode, it is returned
+ * unchanged.
+ * @apiNote
+ * <p>This method is sometimes useful when adapting a method handle that
+ * may be variable arity, to ensure that the resulting adapter is also
+ * variable arity if and only if the original handle was. For example,
+ * this code changes the first argument of a handle {@code mh} to {@code int} without
+ * disturbing its variable arity property:
+ * {@code mh.asType(mh.type().changeParameterType(0,int.class))
+ * .withVarargs(mh.isVarargsCollector())}
+ * @param makeVarargs true if the return method handle should have variable arity behavior
+ * @return a method handle of the same type, with possibly adjusted variable arity behavior
+ * @throws IllegalArgumentException if {@code makeVarargs} is true and
+ * this method handle does not have a trailing array parameter
+ * @since 9
+ * @see #asVarargsCollector
+ * @see #asFixedArity
+ */
+ public MethodHandle withVarargs(boolean makeVarargs) {
+ if (!makeVarargs) {
+ return asFixedArity();
+ } else if (!isVarargsCollector()) {
+ return asVarargsCollector(type().lastParameterType());
+ } else {
+ return this;
+ }
+ }
/**
* Makes an <em>array-collecting</em> method handle, which accepts a given number of trailing
@@ -1000,7 +1031,8 @@
* to allow the target to use a simple {@code Object} as its last parameter type.)
* <p>
* In order to create a collecting adapter which is not restricted to a particular
- * number of collected arguments, use {@link #asVarargsCollector asVarargsCollector} instead.
+ * number of collected arguments, use {@link #asVarargsCollector asVarargsCollector}
+ * or {@link #withVarargs withVarargs} instead.
* <p>
* Here are some examples of array-collecting method handles:
* <blockquote><pre>{@code
@@ -1216,7 +1248,7 @@
* <p>
* No method handle transformations produce new method handles with
* variable arity, unless they are documented as doing so.
- * Therefore, besides {@code asVarargsCollector},
+ * Therefore, besides {@code asVarargsCollector} and {@code withVarargs},
* all methods in {@code MethodHandle} and {@code MethodHandles}
* will return a method handle with fixed arity,
* except in the cases where they are specified to return their original
@@ -1273,6 +1305,7 @@
* or {@code arrayType} is not assignable to this method handle's trailing parameter type
* @see #asCollector
* @see #isVarargsCollector
+ * @see #withVarargs
* @see #asFixedArity
*/
public MethodHandle asVarargsCollector(Class<?> arrayType) {
@@ -1344,6 +1377,7 @@
* @return a new method handle which accepts only a fixed number of arguments
* @see #asVarargsCollector
* @see #isVarargsCollector
+ * @see #withVarargs
*/
public MethodHandle asFixedArity() {
assert(!isVarargsCollector());
@@ -1428,11 +1462,11 @@
/*non-public*/
MethodHandle setVarargs(MemberName member) throws IllegalAccessException {
if (!member.isVarargs()) return this;
- Class<?> arrayType = type().lastParameterType();
- if (arrayType.isArray()) {
- return MethodHandleImpl.makeVarargsCollector(this, arrayType);
+ try {
+ return this.withVarargs(true);
+ } catch (IllegalArgumentException ex) {
+ throw member.makeAccessException("cannot make variable arity", null);
}
- throw member.makeAccessException("cannot make variable arity", null);
}
/*non-public*/
--- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java Wed Jul 05 21:35:27 2017 +0200
@@ -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
@@ -33,13 +33,13 @@
import java.util.List;
import java.util.function.Function;
+import jdk.internal.reflect.CallerSensitive;
+import jdk.internal.reflect.Reflection;
import jdk.internal.vm.annotation.Stable;
import sun.invoke.empty.Empty;
import sun.invoke.util.ValueConversions;
import sun.invoke.util.VerifyType;
import sun.invoke.util.Wrapper;
-import sun.reflect.CallerSensitive;
-import sun.reflect.Reflection;
import static java.lang.invoke.LambdaForm.*;
import static java.lang.invoke.MethodHandleStatics.*;
import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP;
@@ -1055,7 +1055,7 @@
if (!method.getInvocationType().equals(mh.type()))
throw new InternalError(method.toString());
mh = mh.withInternalMemberName(method, false);
- mh = mh.asVarargsCollector(Object[].class);
+ mh = mh.withVarargs(true);
assert(method.isVarargs());
FAKE_METHOD_HANDLE_INVOKE[idx] = mh;
return mh;
@@ -1754,6 +1754,18 @@
}
/**
+ * This method is bound as a filter in {@linkplain MethodHandles#countedLoop(MethodHandle, MethodHandle, MethodHandle,
+ * MethodHandle) counting loops} to pass the correct counter value to the body.
+ *
+ * @param counter the loop counter.
+ *
+ * @return the loop counter decremented by 1.
+ */
+ static int decrementCounter(int counter) {
+ return counter - 1;
+ }
+
+ /**
* This is bound to initialize the loop-local iterator in {@linkplain MethodHandles#iteratedLoop iterating loops}.
*
* @param it the {@link Iterable} over which the loop iterates.
@@ -1879,7 +1891,8 @@
MH_iterateNext = 11,
MH_tryFinallyExec = 12,
MH_tryFinallyVoidExec = 13,
- MH_LIMIT = 14;
+ MH_decrementCounter = 14,
+ MH_LIMIT = 15;
static MethodHandle getConstantHandle(int idx) {
MethodHandle handle = HANDLES[idx];
@@ -1949,6 +1962,9 @@
case MH_tryFinallyVoidExec:
return IMPL_LOOKUP.findStatic(MethodHandleImpl.class, "tryFinallyVoidExecutor",
MethodType.methodType(void.class, MethodHandle.class, MethodHandle.class, Object[].class));
+ case MH_decrementCounter:
+ return IMPL_LOOKUP.findStatic(MethodHandleImpl.class, "decrementCounter",
+ MethodType.methodType(int.class, int.class));
}
} catch (ReflectiveOperationException ex) {
throw newInternalError(ex);
--- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleNatives.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleNatives.java Wed Jul 05 21:35:27 2017 +0200
@@ -423,7 +423,7 @@
// Get the access kind from the method name
VarHandle.AccessMode ak;
try {
- ak = VarHandle.AccessMode.valueOf(name);
+ ak = VarHandle.AccessMode.valueFromMethodName(name);
} catch (IllegalArgumentException e) {
throw MethodHandleStatics.newInternalError(e);
}
--- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleProxies.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleProxies.java Wed Jul 05 21:35:27 2017 +0200
@@ -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
@@ -30,8 +30,8 @@
import java.security.PrivilegedAction;
import sun.invoke.WrapperInstance;
import java.util.ArrayList;
-import sun.reflect.CallerSensitive;
-import sun.reflect.Reflection;
+import jdk.internal.reflect.CallerSensitive;
+import jdk.internal.reflect.Reflection;
import sun.reflect.misc.ReflectUtil;
import static java.lang.invoke.MethodHandleStatics.*;
@@ -216,13 +216,7 @@
}
private static MethodHandle bindCaller(MethodHandle target, Class<?> hostClass) {
- MethodHandle cbmh = MethodHandleImpl.bindCaller(target, hostClass);
- if (target.isVarargsCollector()) {
- MethodType type = cbmh.type();
- int arity = type.parameterCount();
- return cbmh.asVarargsCollector(type.parameterType(arity-1));
- }
- return cbmh;
+ return MethodHandleImpl.bindCaller(target, hostClass).withVarargs(target.isVarargsCollector());
}
/**
--- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java Wed Jul 05 21:35:27 2017 +0200
@@ -37,13 +37,12 @@
import sun.invoke.util.ValueConversions;
import sun.invoke.util.VerifyAccess;
import sun.invoke.util.Wrapper;
-import sun.reflect.CallerSensitive;
-import sun.reflect.Reflection;
+import jdk.internal.reflect.CallerSensitive;
+import jdk.internal.reflect.Reflection;
import sun.reflect.misc.ReflectUtil;
import sun.security.util.SecurityConstants;
import java.lang.invoke.LambdaForm.BasicType;
-import static java.lang.invoke.MethodHandleStatics.*;
import static java.lang.invoke.MethodHandleImpl.Intrinsic;
import static java.lang.invoke.MethodHandleNatives.Constants.*;
import java.util.concurrent.ConcurrentHashMap;
@@ -53,8 +52,6 @@
import jdk.internal.org.objectweb.asm.ClassWriter;
import jdk.internal.org.objectweb.asm.Opcodes;
-import static java.lang.invoke.MethodHandleImpl.Intrinsic;
-import static java.lang.invoke.MethodHandleNatives.Constants.*;
import static java.lang.invoke.MethodHandleStatics.newIllegalArgumentException;
/**
@@ -952,7 +949,7 @@
}
private MethodHandle findVirtualForVH(String name, MethodType type) {
try {
- return varHandleInvoker(VarHandle.AccessMode.valueOf(name), type);
+ return varHandleInvoker(VarHandle.AccessMode.valueFromMethodName(name), type);
} catch (IllegalArgumentException e) {
return null;
}
@@ -1355,9 +1352,7 @@
...
MethodHandle mh0 = lookup().findVirtual(defc, name, type);
MethodHandle mh1 = mh0.bindTo(receiver);
-MethodType mt1 = mh1.type();
-if (mh0.isVarargsCollector())
- mh1 = mh1.asVarargsCollector(mt1.parameterType(mt1.parameterCount()-1));
+mh1 = mh1.withVarargs(mh0.isVarargsCollector());
return mh1;
* }</pre></blockquote>
* where {@code defc} is either {@code receiver.getClass()} or a super
@@ -2954,9 +2949,55 @@
if (ident.type().returnType() == type)
return ident;
// something like identity(Foo.class); do not bother to intern these
- assert(btw == Wrapper.OBJECT);
+ assert (btw == Wrapper.OBJECT);
return makeIdentity(type);
}
+
+ /**
+ * Produces a constant method handle of the requested return type which
+ * returns the default value for that type every time it is invoked.
+ * The resulting constant method handle will have no side effects.
+ * <p>The returned method handle is equivalent to {@code empty(methodType(type))}.
+ * It is also equivalent to {@code explicitCastArguments(constant(Object.class, null), methodType(type))},
+ * since {@code explicitCastArguments} converts {@code null} to default values.
+ * @param type the expected return type of the desired method handle
+ * @return a constant method handle that takes no arguments
+ * and returns the default value of the given type (or void, if the type is void)
+ * @throws NullPointerException if the argument is null
+ * @see MethodHandles#constant
+ * @see MethodHandles#empty
+ * @since 9
+ */
+ public static MethodHandle zero(Class<?> type) {
+ Objects.requireNonNull(type);
+ return type.isPrimitive() ? zero(Wrapper.forPrimitiveType(type), type) : zero(Wrapper.OBJECT, type);
+ }
+
+ private static MethodHandle identityOrVoid(Class<?> type) {
+ return type == void.class ? zero(type) : identity(type);
+ }
+
+ /**
+ * Produces a method handle of the requested type which ignores any arguments, does nothing,
+ * and returns a suitable default depending on the return type.
+ * That is, it returns a zero primitive value, a {@code null}, or {@code void}.
+ * <p>The returned method handle is equivalent to
+ * {@code dropArguments(zero(type.returnType()), 0, type.parameterList())}.
+ * <p>
+ * @apiNote Given a predicate and target, a useful "if-then" construct can be produced as
+ * {@code guardWithTest(pred, target, empty(target.type())}.
+ * @param type the type of the desired method handle
+ * @return a constant method handle of the given type, which returns a default value of the given return type
+ * @throws NullPointerException if the argument is null
+ * @see MethodHandles#zero
+ * @see MethodHandles#constant
+ * @since 9
+ */
+ public static MethodHandle empty(MethodType type) {
+ Objects.requireNonNull(type);
+ return dropArguments(zero(type.returnType()), 0, type.parameterList());
+ }
+
private static final MethodHandle[] IDENTITY_MHS = new MethodHandle[Wrapper.values().length];
private static MethodHandle makeIdentity(Class<?> ptype) {
MethodType mtype = MethodType.methodType(ptype, ptype);
@@ -3148,8 +3189,7 @@
* If {@code pos} is zero, the dummy arguments will precede
* the target's real arguments; if {@code pos} is <i>N</i>
* they will come after.
- * <p>
- * <b>Example:</b>
+ * @apiNote
* <blockquote><pre>{@code
import static java.lang.invoke.MethodHandles.*;
import static java.lang.invoke.MethodType.*;
@@ -3188,6 +3228,99 @@
return dropArguments(target, pos, Arrays.asList(valueTypes));
}
+ // private version which allows caller some freedom with error handling
+ private static MethodHandle dropArgumentsToMatch(MethodHandle target, int skip, List<Class<?>> newTypes, int pos,
+ boolean nullOnFailure) {
+ List<Class<?>> oldTypes = target.type().parameterList();
+ int match = oldTypes.size();
+ if (skip != 0) {
+ if (skip < 0 || skip > match) {
+ throw newIllegalArgumentException("illegal skip", skip, target);
+ }
+ oldTypes = oldTypes.subList(skip, match);
+ match -= skip;
+ }
+ List<Class<?>> addTypes = newTypes;
+ int add = addTypes.size();
+ if (pos != 0) {
+ if (pos < 0 || pos > add) {
+ throw newIllegalArgumentException("illegal pos", pos, newTypes);
+ }
+ addTypes = addTypes.subList(pos, add);
+ add -= pos; assert(addTypes.size() == add);
+ }
+ // Do not add types which already match the existing arguments.
+ if (match > add || !oldTypes.equals(addTypes.subList(0, match))) {
+ if (nullOnFailure) {
+ return null;
+ }
+ throw newIllegalArgumentException("argument lists do not match", oldTypes, newTypes);
+ }
+ addTypes = addTypes.subList(match, add);
+ add -= match; assert(addTypes.size() == add);
+ // newTypes: ( P*[pos], M*[match], A*[add] )
+ // target: ( S*[skip], M*[match] )
+ MethodHandle adapter = target;
+ if (add > 0) {
+ adapter = dropArguments(adapter, skip+ match, addTypes);
+ }
+ // adapter: (S*[skip], M*[match], A*[add] )
+ if (pos > 0) {
+ adapter = dropArguments(adapter, skip, newTypes.subList(0, pos));
+ }
+ // adapter: (S*[skip], P*[pos], M*[match], A*[add] )
+ return adapter;
+ }
+
+ /**
+ * Adapts a target method handle to match the given parameter type list, if necessary, by adding dummy arguments.
+ * Some leading parameters are first skipped; they will be left unchanged and are otherwise ignored.
+ * The remaining types in the target's parameter type list must be contained as a sub-list of the given type list,
+ * at the given position.
+ * Any non-matching parameter types (before or after the matching sub-list) are inserted in corresponding
+ * positions of the target method handle's parameters, as if by {@link #dropArguments}.
+ * (More precisely, elements in the new list before {@code pos} are inserted into the target list at {@code skip},
+ * while elements in the new list after the match beginning at {@code pos} are inserted at the end of the
+ * target list.)
+ * The target's return type will be unchanged.
+ * @apiNote
+ * Two method handles whose argument lists are "effectively identical" (i.e., identical
+ * in a common prefix) may be mutually converted to a common type
+ * by two calls to {@code dropArgumentsToMatch}, as follows:
+ * <blockquote><pre>{@code
+import static java.lang.invoke.MethodHandles.*;
+import static java.lang.invoke.MethodType.*;
+...
+...
+MethodHandle h0 = constant(boolean.class, true);
+MethodHandle h1 = lookup().findVirtual(String.class, "concat", methodType(String.class, String.class));
+MethodType bigType = h1.type().insertParameterTypes(1, String.class, int.class);
+MethodHandle h2 = dropArguments(h1, 0, bigType.parameterList());
+if (h1.type().parameterCount() < h2.type().parameterCount())
+ h1 = dropArgumentsToMatch(h1, 0, h2.type().parameterList(), 0); // lengthen h1
+else
+ h2 = dropArgumentsToMatch(h2, 0, h1.type().parameterList(), 0); // lengthen h2
+MethodHandle h3 = guardWithTest(h0, h1, h2);
+assertEquals("xy", h3.invoke("x", "y", 1, "a", "b", "c"));
+ * }</pre></blockquote>
+ * @param target the method handle to adapt
+ * @param skip number of targets parameters to disregard (they will be unchanged)
+ * @param newTypes the desired argument list of the method handle
+ * @param pos place in {@code newTypes} where the non-skipped target parameters must occur
+ * @return a possibly adapted method handle
+ * @throws NullPointerException if either argument is null
+ * @throws IllegalArgumentException
+ * if either index is out of range in its corresponding list, or
+ * if the non-skipped target parameter types match the new types at {@code pos}
+ * @since 9
+ */
+ public static
+ MethodHandle dropArgumentsToMatch(MethodHandle target, int skip, List<Class<?>> newTypes, int pos) {
+ Objects.requireNonNull(target);
+ Objects.requireNonNull(newTypes);
+ return dropArgumentsToMatch(target, skip, newTypes, pos, false);
+ }
+
/**
* Adapts a target method handle by pre-processing
* one or more of its arguments, each with its own unary filter function,
@@ -3699,13 +3832,9 @@
if (gtype.returnType() != boolean.class)
throw newIllegalArgumentException("guard type is not a predicate "+gtype);
List<Class<?>> targs = ttype.parameterList();
- List<Class<?>> gargs = gtype.parameterList();
- if (!targs.equals(gargs)) {
- int gpc = gargs.size(), tpc = targs.size();
- if (gpc >= tpc || !targs.subList(0, gpc).equals(gargs))
- throw misMatchedTypes("target and test types", ttype, gtype);
- test = dropArguments(test, gpc, targs.subList(gpc, tpc));
- gtype = test.type();
+ test = dropArgumentsToMatch(test, 0, targs, 0, true);
+ if (test == null) {
+ throw misMatchedTypes("target and test types", ttype, gtype);
}
return MethodHandleImpl.makeGuardWithTest(test, target, fallback);
}
@@ -3777,15 +3906,9 @@
throw newIllegalArgumentException("handler does not accept exception type "+exType);
if (htype.returnType() != ttype.returnType())
throw misMatchedTypes("target and handler return types", ttype, htype);
- List<Class<?>> targs = ttype.parameterList();
- List<Class<?>> hargs = htype.parameterList();
- hargs = hargs.subList(1, hargs.size()); // omit leading parameter from handler
- if (!targs.equals(hargs)) {
- int hpc = hargs.size(), tpc = targs.size();
- if (hpc >= tpc || !targs.subList(0, hpc).equals(hargs))
- throw misMatchedTypes("target and handler types", ttype, htype);
- handler = dropArguments(handler, 1+hpc, targs.subList(hpc, tpc));
- htype = handler.type();
+ handler = dropArgumentsToMatch(handler, 1, ttype.parameterList(), 0, true);
+ if (handler == null) {
+ throw misMatchedTypes("target and handler types", ttype, htype);
}
return MethodHandleImpl.makeGuardWithCatch(target, exType, handler);
}
@@ -4043,16 +4166,16 @@
for (int i = 0; i < nclauses; ++i) {
Class<?> t = iterationVariableTypes.get(i);
if (init.get(i) == null) {
- init.set(i, zeroHandle(t));
+ init.set(i, empty(MethodType.methodType(t, commonSuffix)));
}
if (step.get(i) == null) {
- step.set(i, dropArguments(t == void.class ? zeroHandle(t) : identity(t), 0, commonPrefix.subList(0, i)));
+ step.set(i, dropArgumentsToMatch(identityOrVoid(t), 0, commonParameterSequence, i));
}
if (pred.get(i) == null) {
- pred.set(i, constant(boolean.class, true));
+ pred.set(i, dropArguments(constant(boolean.class, true), 0, commonParameterSequence));
}
if (fini.get(i) == null) {
- fini.set(i, zeroHandle(t));
+ fini.set(i, empty(MethodType.methodType(t, commonParameterSequence)));
}
}
@@ -4146,7 +4269,7 @@
* @since 9
*/
public static MethodHandle whileLoop(MethodHandle init, MethodHandle pred, MethodHandle body) {
- MethodHandle fin = init == null ? zeroHandle(void.class) : identity(init.type().returnType());
+ MethodHandle fin = init == null ? zero(void.class) : identity(init.type().returnType());
MethodHandle[] checkExit = {null, null, pred, fin};
MethodHandle[] varBody = {init, body};
return loop(checkExit, varBody);
@@ -4212,7 +4335,7 @@
* @since 9
*/
public static MethodHandle doWhileLoop(MethodHandle init, MethodHandle body, MethodHandle pred) {
- MethodHandle fin = init == null ? zeroHandle(void.class) : identity(init.type().returnType());
+ MethodHandle fin = init == null ? zero(void.class) : identity(init.type().returnType());
MethodHandle[] clause = {init, body, pred, fin};
return loop(clause);
}
@@ -4322,11 +4445,13 @@
* <blockquote><pre>{@code
* MethodHandle countedLoop(MethodHandle start, MethodHandle end, MethodHandle init, MethodHandle body) {
* MethodHandle returnVar = dropArguments(identity(init.type().returnType()), 0, int.class, int.class);
- * // assume MH_increment and MH_lessThan are handles to x+1 and x<y of type int
+ * // assume MH_increment and MH_lessThan are handles to x+1 and x<y of type int,
+ * // assume MH_decrement is a handle to x-1 of type int
* MethodHandle[]
* indexVar = {start, MH_increment}, // i = start; i = i+1
* loopLimit = {end, null, MH_lessThan, returnVar }, // i<end
- * bodyClause = {init, dropArguments(body, 1, int.class)}; // v = body(i, v);
+ * bodyClause = {init,
+ * filterArgument(dropArguments(body, 1, int.class), 0, MH_decrement}; // v = body(i-1, v)
* return loop(indexVar, loopLimit, bodyClause);
* }
* }</pre></blockquote>
@@ -4347,11 +4472,13 @@
* @since 9
*/
public static MethodHandle countedLoop(MethodHandle start, MethodHandle end, MethodHandle init, MethodHandle body) {
- MethodHandle returnVar = dropArguments(init == null ? zeroHandle(void.class) : identity(init.type().returnType()),
+ MethodHandle returnVar = dropArguments(init == null ? zero(void.class) : identity(init.type().returnType()),
0, int.class, int.class);
MethodHandle[] indexVar = {start, MethodHandleImpl.getConstantHandle(MethodHandleImpl.MH_countedLoopStep)};
MethodHandle[] loopLimit = {end, null, MethodHandleImpl.getConstantHandle(MethodHandleImpl.MH_countedLoopPred), returnVar};
- MethodHandle[] bodyClause = {init, dropArguments(body, 1, int.class)};
+ MethodHandle[] bodyClause = {init,
+ filterArgument(dropArguments(body, 1, int.class), 0,
+ MethodHandleImpl.getConstantHandle(MethodHandleImpl.MH_decrementCounter))};
return loop(indexVar, loopLimit, bodyClause);
}
@@ -4448,7 +4575,7 @@
Class<?> ttype = body.type().parameterType(0);
MethodHandle returnVar =
- dropArguments(init == null ? zeroHandle(void.class) : identity(init.type().returnType()), 0, itype);
+ dropArguments(init == null ? zero(void.class) : identity(init.type().returnType()), 0, itype);
MethodHandle initnx = MethodHandleImpl.getConstantHandle(MethodHandleImpl.MH_iterateNext);
MethodHandle nextVal = initnx.asType(initnx.type().changeReturnType(ttype));
@@ -4542,15 +4669,11 @@
checkTryFinally(target, cleanup);
// Match parameter lists: if the cleanup has a shorter parameter list than the target, add ignored arguments.
- int tpSize = targetParamTypes.size();
- int cpPrefixLength = rtype == void.class ? 1 : 2;
- int cpSize = cleanupParamTypes.size();
- MethodHandle aCleanup = cpSize - cpPrefixLength < tpSize ?
- dropArguments(cleanup, cpSize, targetParamTypes.subList(tpSize - (cpSize - cpPrefixLength), tpSize)) :
- cleanup;
-
+ // The cleanup parameter list (minus the leading Throwable and result parameters) must be a sublist of the
+ // target parameter list.
+ cleanup = dropArgumentsToMatch(cleanup, (rtype == void.class ? 1 : 2), targetParamTypes, 0);
MethodHandle aTarget = target.asSpreader(Object[].class, target.type().parameterCount());
- aCleanup = aCleanup.asSpreader(Object[].class, tpSize);
+ MethodHandle aCleanup = cleanup.asSpreader(Object[].class, targetParamTypes.size());
return MethodHandleImpl.makeTryFinally(aTarget, aCleanup, rtype, targetParamTypes);
}
@@ -4641,16 +4764,6 @@
return result;
}
- /**
- * Wrap creation of a proper zero handle for a given type.
- *
- * @param type the type.
- *
- * @return a zero value for the given type.
- */
- static MethodHandle zeroHandle(Class<?> type) {
- return type.isPrimitive() ? zero(Wrapper.forPrimitiveType(type), type) : zero(Wrapper.OBJECT, type);
- }
private static void checkLoop0(MethodHandle[][] clauses) {
if (clauses == null || clauses.length == 0) {
--- a/jdk/src/java.base/share/classes/java/lang/invoke/StringConcatFactory.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/StringConcatFactory.java Wed Jul 05 21:35:27 2017 +0200
@@ -34,11 +34,11 @@
import java.lang.invoke.MethodHandles.Lookup;
import java.security.AccessController;
-import java.security.PrivilegedAction;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.function.Function;
+import sun.security.action.GetPropertyAction;
import static jdk.internal.org.objectweb.asm.Opcodes.*;
@@ -188,20 +188,14 @@
private static final ProxyClassesDumper DUMPER;
static {
- // Poke the privileged block once, taking everything we need:
- final Object[] values = new Object[4];
- AccessController.doPrivileged((PrivilegedAction<Object>) () -> {
- values[0] = System.getProperty("java.lang.invoke.stringConcat");
- values[1] = Boolean.getBoolean("java.lang.invoke.stringConcat.cache");
- values[2] = Boolean.getBoolean("java.lang.invoke.stringConcat.debug");
- values[3] = System.getProperty("java.lang.invoke.stringConcat.dumpClasses");
- return null;
- });
-
- final String strategy = (String) values[0];
- CACHE_ENABLE = (Boolean) values[1];
- DEBUG = (Boolean) values[2];
- final String dumpPath = (String) values[3];
+ final String strategy = AccessController.doPrivileged(
+ new GetPropertyAction("java.lang.invoke.stringConcat"));
+ CACHE_ENABLE = Boolean.parseBoolean(AccessController.doPrivileged(
+ new GetPropertyAction("java.lang.invoke.stringConcat.cache")));
+ DEBUG = Boolean.parseBoolean(AccessController.doPrivileged(
+ new GetPropertyAction("java.lang.invoke.stringConcat.debug")));
+ final String dumpPath = AccessController.doPrivileged(
+ new GetPropertyAction("java.lang.invoke.stringConcat.dumpClasses"));
STRATEGY = (strategy == null) ? DEFAULT_STRATEGY : Strategy.valueOf(strategy);
CACHE = CACHE_ENABLE ? new ConcurrentHashMap<>() : null;
--- a/jdk/src/java.base/share/classes/java/lang/invoke/VarForm.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/VarForm.java Wed Jul 05 21:35:27 2017 +0200
@@ -69,13 +69,10 @@
for (Class<?> c = implClass; c != VarHandle.class; c = c.getSuperclass()) {
for (Method m : c.getDeclaredMethods()) {
if (Modifier.isStatic(m.getModifiers())) {
- try {
- AccessMode am = AccessMode.valueOf(m.getName());
+ AccessMode am = AccessMode.methodNameToAccessMode.get(m.getName());
+ if (am != null) {
assert table[am.ordinal()] == null;
table[am.ordinal()] = new MemberName(m);
- } catch (IllegalArgumentException ex) {
- // Ignore. Note the try/catch will be removed when
- // AccessMode enum constant names are renamed
}
}
}
--- a/jdk/src/java.base/share/classes/java/lang/invoke/VarHandle.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/VarHandle.java Wed Jul 05 21:35:27 2017 +0200
@@ -31,8 +31,12 @@
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
+import java.util.Objects;
import java.util.function.BiFunction;
+import java.util.function.Function;
import static java.lang.invoke.MethodHandleStatics.UNSAFE;
import static java.lang.invoke.MethodHandleStatics.newInternalError;
@@ -152,7 +156,9 @@
* supported, which may also include documenting restrictions based on the
* variable type and whether a variable is read-only. If an access mode is not
* supported then the corresponding signature-polymorphic method will on
- * invocation throw an {@code UnsupportedOperationException}.
+ * invocation throw an {@code UnsupportedOperationException}. Factory methods
+ * should document any additional undeclared exceptions that may be thrown by
+ * access mode methods.
* The {@link #get get} access mode is supported for all
* VarHandle instances and the corresponding method never throws
* {@code UnsupportedOperationException}.
@@ -166,7 +172,7 @@
* Unless stated otherwise in the documentation of a factory method, the access
* modes {@code get} and {@code set} (if supported) provide atomic access for
* reference types and all primitives types, with the exception of {@code long}
- * and {@code double} on 32-bit platforms
+ * and {@code double} on 32-bit platforms.
*
* <p>Access modes will override any memory ordering effects specified at
* the declaration site of a variable. For example, a VarHandle accessing a
@@ -272,7 +278,7 @@
* <pre> {@code
* MethodHandle mh = MethodHandles.lookup().findVirtual(
* VarHandle.class,
- * VarHandle.AccessMode.{access-mode}.name(),
+ * VarHandle.AccessMode.{access-mode}.methodName(),
* MethodType.methodType(R, p1, p2, ..., pN));
*
* R r = (R) mh.invokeExact(vh, p1, p2, ..., pN)
@@ -465,6 +471,8 @@
* , statically represented using {@code Object}.
* @throws WrongMethodTypeException if the access mode type is not
* compatible with the caller's symbolic type descriptor.
+ * @throws ClassCastException if the access mode type is compatible with the
+ * caller's symbolic type descriptor, but a reference cast fails.
*/
public final native
@MethodHandle.PolymorphicSignature
@@ -489,6 +497,8 @@
* for this VarHandle.
* @throws WrongMethodTypeException if the access mode type is not
* compatible with the caller's symbolic type descriptor.
+ * @throws ClassCastException if the access mode type is compatible with the
+ * caller's symbolic type descriptor, but a reference cast fails.
*/
public final native
@MethodHandle.PolymorphicSignature
@@ -518,6 +528,8 @@
* for this VarHandle.
* @throws WrongMethodTypeException if the access mode type is not
* compatible with the caller's symbolic type descriptor.
+ * @throws ClassCastException if the access mode type is compatible with the
+ * caller's symbolic type descriptor, but a reference cast fails.
*/
public final native
@MethodHandle.PolymorphicSignature
@@ -534,6 +546,10 @@
* must match the access mode type that is the result of calling
* {@code accessModeType(VarHandle.AccessMode.setVolatile)} on this VarHandle.
*
+ * @apiNote
+ * Ignoring the many semantic differences from C and C++, this method has
+ * memory ordering effects compatible with {@code memory_order_seq_cst}.
+ *
* @param args the signature-polymorphic parameter list of the form
* {@code (CT, T newValue)}
* , statically represented using varargs.
@@ -541,9 +557,8 @@
* for this VarHandle.
* @throws WrongMethodTypeException if the access mode type is not
* compatible with the caller's symbolic type descriptor.
- * @apiNote Ignoring the many semantic differences from C and C++, this
- * method has memory ordering effects compatible with
- * {@code memory_order_seq_cst}.
+ * @throws ClassCastException if the access mode type is compatible with the
+ * caller's symbolic type descriptor, but a reference cast fails.
*/
public final native
@MethodHandle.PolymorphicSignature
@@ -571,6 +586,8 @@
* for this VarHandle.
* @throws WrongMethodTypeException if the access mode type is not
* compatible with the caller's symbolic type descriptor.
+ * @throws ClassCastException if the access mode type is compatible with the
+ * caller's symbolic type descriptor, but a reference cast fails.
*/
public final native
@MethodHandle.PolymorphicSignature
@@ -595,6 +612,8 @@
* for this VarHandle.
* @throws WrongMethodTypeException if the access mode type is not
* compatible with the caller's symbolic type descriptor.
+ * @throws ClassCastException if the access mode type is compatible with the
+ * caller's symbolic type descriptor, but a reference cast fails.
*/
public final native
@MethodHandle.PolymorphicSignature
@@ -614,6 +633,11 @@
* must match the access mode type that is the result of calling
* {@code accessModeType(VarHandle.AccessMode.getAcquire)} on this VarHandle.
*
+ * @apiNote
+ * Ignoring the many semantic differences from C and C++, this method has
+ * memory ordering effects compatible with {@code memory_order_acquire}
+ * ordering.
+ *
* @param args the signature-polymorphic parameter list of the form
* {@code (CT)}
* , statically represented using varargs.
@@ -624,9 +648,8 @@
* for this VarHandle.
* @throws WrongMethodTypeException if the access mode type is not
* compatible with the caller's symbolic type descriptor.
- * @apiNote Ignoring the many semantic differences from C and C++, this
- * method has memory ordering effects compatible with
- * {@code memory_order_acquire} ordering.
+ * @throws ClassCastException if the access mode type is compatible with the
+ * caller's symbolic type descriptor, but a reference cast fails.
*/
public final native
@MethodHandle.PolymorphicSignature
@@ -643,6 +666,11 @@
* must match the access mode type that is the result of calling
* {@code accessModeType(VarHandle.AccessMode.setRelease)} on this VarHandle.
*
+ * @apiNote
+ * Ignoring the many semantic differences from C and C++, this method has
+ * memory ordering effects compatible with {@code memory_order_release}
+ * ordering.
+ *
* @param args the signature-polymorphic parameter list of the form
* {@code (CT, T newValue)}
* , statically represented using varargs.
@@ -650,9 +678,8 @@
* for this VarHandle.
* @throws WrongMethodTypeException if the access mode type is not
* compatible with the caller's symbolic type descriptor.
- * @apiNote Ignoring the many semantic differences from C and C++, this
- * method has memory ordering effects compatible with
- * {@code memory_order_release} ordering.
+ * @throws ClassCastException if the access mode type is compatible with the
+ * caller's symbolic type descriptor, but a reference cast fails.
*/
public final native
@MethodHandle.PolymorphicSignature
@@ -685,6 +712,8 @@
* for this VarHandle.
* @throws WrongMethodTypeException if the access mode type is not
* compatible with the caller's symbolic type descriptor.
+ * @throws ClassCastException if the access mode type is compatible with the
+ * caller's symbolic type descriptor, but a reference cast fails.
* @see #setVolatile(Object...)
* @see #getVolatile(Object...)
*/
@@ -718,6 +747,8 @@
* for this VarHandle.
* @throws WrongMethodTypeException if the access mode type is not
* compatible with the caller's symbolic type descriptor.
+ * @throws ClassCastException if the access mode type is compatible with the
+ * caller's symbolic type descriptor, but a reference cast fails.
* @see #setVolatile(Object...)
* @see #getVolatile(Object...)
*/
@@ -751,6 +782,8 @@
* for this VarHandle.
* @throws WrongMethodTypeException if the access mode type is not
* compatible with the caller's symbolic type descriptor.
+ * @throws ClassCastException if the access mode type is compatible with the
+ * caller's symbolic type descriptor, but a reference cast fails.
* @see #set(Object...)
* @see #getAcquire(Object...)
*/
@@ -783,6 +816,8 @@
* for this VarHandle.
* @throws WrongMethodTypeException if the access mode type is not
* compatible with the caller's symbolic type descriptor.
+ * @throws ClassCastException if the access mode type is compatible with the
+ * caller's symbolic type descriptor, but a reference cast fails.
* @see #setRelease(Object...)
* @see #get(Object...)
*/
@@ -820,6 +855,8 @@
* for this VarHandle.
* @throws WrongMethodTypeException if the access mode type is not
* compatible with the caller's symbolic type descriptor.
+ * @throws ClassCastException if the access mode type is compatible with the
+ * caller's symbolic type descriptor, but a reference cast fails.
* @see #set(Object...)
* @see #get(Object...)
*/
@@ -855,6 +892,8 @@
* for this VarHandle.
* @throws WrongMethodTypeException if the access mode type is not
* compatible with the caller's symbolic type descriptor.
+ * @throws ClassCastException if the access mode type is compatible with the
+ * caller's symbolic type descriptor, but a reference cast fails.
* @see #set(Object...)
* @see #getAcquire(Object...)
*/
@@ -890,6 +929,8 @@
* for this VarHandle.
* @throws WrongMethodTypeException if the access mode type is not
* compatible with the caller's symbolic type descriptor.
+ * @throws ClassCastException if the access mode type is compatible with the
+ * caller's symbolic type descriptor, but a reference cast fails.
* @see #setRelease(Object...)
* @see #get(Object...)
*/
@@ -920,6 +961,8 @@
* for this VarHandle.
* @throws WrongMethodTypeException if the access mode type is not
* compatible with the caller's symbolic type descriptor.
+ * @throws ClassCastException if the access mode type is compatible with the
+ * caller's symbolic type descriptor, but a reference cast fails.
* @see #setVolatile(Object...)
* @see #getVolatile(Object...)
*/
@@ -954,6 +997,8 @@
* for this VarHandle.
* @throws WrongMethodTypeException if the access mode type is not
* compatible with the caller's symbolic type descriptor.
+ * @throws ClassCastException if the access mode type is compatible with the
+ * caller's symbolic type descriptor, but a reference cast fails.
* @see #setVolatile(Object...)
* @see #getVolatile(Object...)
*/
@@ -984,6 +1029,8 @@
* for this VarHandle.
* @throws WrongMethodTypeException if the access mode type is not
* compatible with the caller's symbolic type descriptor.
+ * @throws ClassCastException if the access mode type is compatible with the
+ * caller's symbolic type descriptor, but a reference cast fails.
* @see #setVolatile(Object...)
* @see #getVolatile(Object...)
*/
@@ -993,11 +1040,11 @@
Object addAndGet(Object... args);
enum AccessType {
- get, // 0
- set, // 1
- compareAndSwap, // 2
- compareAndExchange, // 3
- getAndUpdate; // 4
+ GET, // 0
+ SET, // 1
+ COMPARE_AND_SWAP, // 2
+ COMPARE_AND_EXCHANGE, // 3
+ GET_AND_UPDATE; // 4
MethodType getMethodType(VarHandle vh) {
return getMethodType(this.ordinal(), vh);
@@ -1036,126 +1083,179 @@
* method
* {@link VarHandle#get VarHandle.get}
*/
- get(AccessType.get, Object.class), // 0
+ GET("get", AccessType.GET, Object.class), // 0
/**
* The access mode whose access is specified by the corresponding
* method
* {@link VarHandle#set VarHandle.set}
*/
- set(AccessType.set, void.class), // 1
+ SET("set", AccessType.SET, void.class), // 1
/**
* The access mode whose access is specified by the corresponding
* method
* {@link VarHandle#getVolatile VarHandle.getVolatile}
*/
- getVolatile(AccessType.get, Object.class), // 2
+ GET_VOLATILE("getVolatile", AccessType.GET, Object.class), // 2
/**
* The access mode whose access is specified by the corresponding
* method
* {@link VarHandle#setVolatile VarHandle.setVolatile}
*/
- setVolatile(AccessType.set, void.class), // 3
+ SET_VOLATILE("setVolatile", AccessType.SET, void.class), // 3
/**
* The access mode whose access is specified by the corresponding
* method
* {@link VarHandle#getAcquire VarHandle.getAcquire}
*/
- getAcquire(AccessType.get, Object.class), // 4
+ GET_ACQUIRE("getAcquire", AccessType.GET, Object.class), // 4
/**
* The access mode whose access is specified by the corresponding
* method
* {@link VarHandle#setRelease VarHandle.setRelease}
*/
- setRelease(AccessType.set, void.class), // 5
+ SET_RELEASE("setRelease", AccessType.SET, void.class), // 5
/**
* The access mode whose access is specified by the corresponding
* method
* {@link VarHandle#getOpaque VarHandle.getOpaque}
*/
- getOpaque(AccessType.get, Object.class), // 6
+ GET_OPAQUE("getOpaque", AccessType.GET, Object.class), // 6
/**
* The access mode whose access is specified by the corresponding
* method
* {@link VarHandle#setOpaque VarHandle.setOpaque}
*/
- setOpaque(AccessType.set, void.class), // 7
+ SET_OPAQUE("setOpaque", AccessType.SET, void.class), // 7
/**
* The access mode whose access is specified by the corresponding
* method
* {@link VarHandle#compareAndSet VarHandle.compareAndSet}
*/
- compareAndSet(AccessType.compareAndSwap, boolean.class), // 8
+ COMPARE_AND_SET("compareAndSet", AccessType.COMPARE_AND_SWAP, boolean.class), // 8
/**
* The access mode whose access is specified by the corresponding
* method
* {@link VarHandle#compareAndExchangeVolatile VarHandle.compareAndExchangeVolatile}
*/
- compareAndExchangeVolatile(AccessType.compareAndExchange, Object.class), // 9
+ COMPARE_AND_EXCHANGE_VOLATILE("compareAndExchangeVolatile", AccessType.COMPARE_AND_EXCHANGE, Object.class), // 9
/**
* The access mode whose access is specified by the corresponding
* method
* {@link VarHandle#compareAndExchangeAcquire VarHandle.compareAndExchangeAcquire}
*/
- compareAndExchangeAcquire(AccessType.compareAndExchange, Object.class), // 10
+ COMPARE_AND_EXCHANGE_ACQUIRE("compareAndExchangeAcquire", AccessType.COMPARE_AND_EXCHANGE, Object.class), // 10
/**
* The access mode whose access is specified by the corresponding
* method
* {@link VarHandle#compareAndExchangeRelease VarHandle.compareAndExchangeRelease}
*/
- compareAndExchangeRelease(AccessType.compareAndExchange, Object.class), // 11
+ COMPARE_AND_EXCHANGE_RELEASE("compareAndExchangeRelease", AccessType.COMPARE_AND_EXCHANGE, Object.class), // 11
/**
* The access mode whose access is specified by the corresponding
* method
* {@link VarHandle#weakCompareAndSet VarHandle.weakCompareAndSet}
*/
- weakCompareAndSet(AccessType.compareAndSwap, boolean.class), // 12
+ WEAK_COMPARE_AND_SET("weakCompareAndSet", AccessType.COMPARE_AND_SWAP, boolean.class), // 12
/**
* The access mode whose access is specified by the corresponding
* method
* {@link VarHandle#weakCompareAndSetAcquire VarHandle.weakCompareAndSetAcquire}
*/
- weakCompareAndSetAcquire(AccessType.compareAndSwap, boolean.class), // 13
+ WEAK_COMPARE_AND_SET_ACQUIRE("weakCompareAndSetAcquire", AccessType.COMPARE_AND_SWAP, boolean.class), // 13
/**
* The access mode whose access is specified by the corresponding
* method
* {@link VarHandle#weakCompareAndSetRelease VarHandle.weakCompareAndSetRelease}
*/
- weakCompareAndSetRelease(AccessType.compareAndSwap, boolean.class), // 14
+ WEAK_COMPARE_AND_SET_RELEASE("weakCompareAndSetRelease", AccessType.COMPARE_AND_SWAP, boolean.class), // 14
/**
* The access mode whose access is specified by the corresponding
* method
* {@link VarHandle#getAndSet VarHandle.getAndSet}
*/
- getAndSet(AccessType.getAndUpdate, Object.class), // 15
+ GET_AND_SET("getAndSet", AccessType.GET_AND_UPDATE, Object.class), // 15
/**
* The access mode whose access is specified by the corresponding
* method
* {@link VarHandle#getAndAdd VarHandle.getAndAdd}
*/
- getAndAdd(AccessType.getAndUpdate, Object.class), // 16
+ GET_AND_ADD("getAndAdd", AccessType.GET_AND_UPDATE, Object.class), // 16
/**
* The access mode whose access is specified by the corresponding
* method
* {@link VarHandle#addAndGet VarHandle.addAndGet}
*/
- addAndGet(AccessType.getAndUpdate, Object.class), // 17
+ ADD_AND_GET("addAndGet", AccessType.GET_AND_UPDATE, Object.class), // 17
;
+ static final Map<String, AccessMode> methodNameToAccessMode;
+ static {
+ // Initial capacity of # values is sufficient to avoid resizes
+ // for the smallest table size (32)
+ methodNameToAccessMode = new HashMap<>(AccessMode.values().length);
+ for (AccessMode am : AccessMode.values()) {
+ methodNameToAccessMode.put(am.methodName, am);
+ }
+ }
+
+ final String methodName;
final AccessType at;
final boolean isPolyMorphicInReturnType;
final Class<?> returnType;
- AccessMode(AccessType at, Class<?> returnType) {
+ AccessMode(final String methodName, AccessType at, Class<?> returnType) {
+ this.methodName = methodName;
this.at = at;
+ // Assert method name is correctly derived from value name
+ assert methodName.equals(toMethodName(name()));
// Assert that return type is correct
// Otherwise, when disabled avoid using reflection
- assert returnType == getReturnType(name());
+ assert returnType == getReturnType(methodName);
this.returnType = returnType;
isPolyMorphicInReturnType = returnType != Object.class;
}
+ /**
+ * Returns the {@code VarHandle} signature-polymorphic method name
+ * associated with this {@code AccessMode} value
+ *
+ * @return the signature-polymorphic method name
+ * @see #valueFromMethodName
+ */
+ public String methodName() {
+ return methodName;
+ }
+
+ /**
+ * Returns the {@code AccessMode} value associated with the specified
+ * {@code VarHandle} signature-polymorphic method name.
+ *
+ * @param methodName the signature-polymorphic method name
+ * @return the {@code AccessMode} value
+ * @throws IllegalArgumentException if there is no {@code AccessMode}
+ * value associated with method name (indicating the method
+ * name does not correspond to a {@code VarHandle}
+ * signature-polymorphic method name).
+ * @see #methodName
+ */
+ public static AccessMode valueFromMethodName(String methodName) {
+ AccessMode am = methodNameToAccessMode.get(methodName);
+ if (am != null) return am;
+ throw new IllegalArgumentException("No AccessMode value for method name " + methodName);
+ }
+
+ private static String toMethodName(String name) {
+ StringBuilder s = new StringBuilder(name.toLowerCase());
+ int i;
+ while ((i = s.indexOf("_")) != -1) {
+ s.deleteCharAt(i);
+ s.setCharAt(i, Character.toUpperCase(s.charAt(i)));
+ }
+ return s.toString();
+ }
+
private static Class<?> getReturnType(String name) {
try {
Method m = VarHandle.class.getMethod(name, Object[].class);
@@ -1279,12 +1379,14 @@
UNSAFE.fullFence();
}
- static final BiFunction<Integer, Integer, ArrayIndexOutOfBoundsException> AIOOBE_SUPPLIER = new BiFunction<>() {
- @Override
- public ArrayIndexOutOfBoundsException apply(Integer a, Integer b) {
- return new ArrayIndexOutOfBoundsException(a, b);
- }
- };
+ static final BiFunction<String, List<Integer>, ArrayIndexOutOfBoundsException>
+ AIOOBE_SUPPLIER = Objects.outOfBoundsExceptionFormatter(
+ new Function<String, ArrayIndexOutOfBoundsException>() {
+ @Override
+ public ArrayIndexOutOfBoundsException apply(String s) {
+ return new ArrayIndexOutOfBoundsException(s);
+ }
+ });
private static final long VFORM_OFFSET;
--- a/jdk/src/java.base/share/classes/java/lang/reflect/AccessibleObject.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/reflect/AccessibleObject.java Wed Jul 05 21:35:27 2017 +0200
@@ -27,9 +27,9 @@
import java.security.AccessController;
-import sun.reflect.CallerSensitive;
-import sun.reflect.Reflection;
-import sun.reflect.ReflectionFactory;
+import jdk.internal.reflect.CallerSensitive;
+import jdk.internal.reflect.Reflection;
+import jdk.internal.reflect.ReflectionFactory;
import java.lang.annotation.Annotation;
/**
@@ -230,7 +230,7 @@
// very early in the bootstrapping process.
static final ReflectionFactory reflectionFactory =
AccessController.doPrivileged(
- new sun.reflect.ReflectionFactory.GetReflectionFactoryAction());
+ new ReflectionFactory.GetReflectionFactoryAction());
/**
* @throws NullPointerException {@inheritDoc}
--- a/jdk/src/java.base/share/classes/java/lang/reflect/Constructor.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/reflect/Constructor.java Wed Jul 05 21:35:27 2017 +0200
@@ -26,9 +26,9 @@
package java.lang.reflect;
import jdk.internal.misc.SharedSecrets;
-import sun.reflect.CallerSensitive;
-import sun.reflect.ConstructorAccessor;
-import sun.reflect.Reflection;
+import jdk.internal.reflect.CallerSensitive;
+import jdk.internal.reflect.ConstructorAccessor;
+import jdk.internal.reflect.Reflection;
import sun.reflect.annotation.TypeAnnotation;
import sun.reflect.annotation.TypeAnnotationParser;
import sun.reflect.generics.repository.ConstructorRepository;
--- a/jdk/src/java.base/share/classes/java/lang/reflect/Field.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/reflect/Field.java Wed Jul 05 21:35:27 2017 +0200
@@ -26,9 +26,9 @@
package java.lang.reflect;
import jdk.internal.misc.SharedSecrets;
-import sun.reflect.CallerSensitive;
-import sun.reflect.FieldAccessor;
-import sun.reflect.Reflection;
+import jdk.internal.reflect.CallerSensitive;
+import jdk.internal.reflect.FieldAccessor;
+import jdk.internal.reflect.Reflection;
import sun.reflect.generics.repository.FieldRepository;
import sun.reflect.generics.factory.CoreReflectionFactory;
import sun.reflect.generics.factory.GenericsFactory;
--- a/jdk/src/java.base/share/classes/java/lang/reflect/Method.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/reflect/Method.java Wed Jul 05 21:35:27 2017 +0200
@@ -27,9 +27,9 @@
import jdk.internal.HotSpotIntrinsicCandidate;
import jdk.internal.misc.SharedSecrets;
-import sun.reflect.CallerSensitive;
-import sun.reflect.MethodAccessor;
-import sun.reflect.Reflection;
+import jdk.internal.reflect.CallerSensitive;
+import jdk.internal.reflect.MethodAccessor;
+import jdk.internal.reflect.Reflection;
import sun.reflect.generics.repository.MethodRepository;
import sun.reflect.generics.factory.CoreReflectionFactory;
import sun.reflect.generics.factory.GenericsFactory;
--- a/jdk/src/java.base/share/classes/java/lang/reflect/Modifier.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/reflect/Modifier.java Wed Jul 05 21:35:27 2017 +0200
@@ -27,8 +27,8 @@
import java.security.AccessController;
import java.util.StringJoiner;
-import sun.reflect.LangReflectAccess;
-import sun.reflect.ReflectionFactory;
+import jdk.internal.reflect.LangReflectAccess;
+import jdk.internal.reflect.ReflectionFactory;
/**
* The Modifier class provides {@code static} methods and
@@ -51,8 +51,7 @@
* packages
*/
static {
- sun.reflect.ReflectionFactory factory =
- AccessController.doPrivileged(
+ ReflectionFactory factory = AccessController.doPrivileged(
new ReflectionFactory.GetReflectionFactoryAction());
factory.setLangReflectAccess(new java.lang.reflect.ReflectAccess());
}
--- a/jdk/src/java.base/share/classes/java/lang/reflect/Module.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/reflect/Module.java Wed Jul 05 21:35:27 2017 +0200
@@ -56,8 +56,8 @@
import jdk.internal.misc.JavaLangReflectModuleAccess;
import jdk.internal.misc.SharedSecrets;
import jdk.internal.module.ServicesCatalog;
-import sun.reflect.CallerSensitive;
-import sun.reflect.Reflection;
+import jdk.internal.reflect.CallerSensitive;
+import jdk.internal.reflect.Reflection;
import sun.security.util.SecurityConstants;
/**
--- a/jdk/src/java.base/share/classes/java/lang/reflect/Proxy.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/reflect/Proxy.java Wed Jul 05 21:35:27 2017 +0200
@@ -47,8 +47,8 @@
import jdk.internal.module.Modules;
import jdk.internal.misc.Unsafe;
import jdk.internal.misc.VM;
-import sun.reflect.CallerSensitive;
-import sun.reflect.Reflection;
+import jdk.internal.reflect.CallerSensitive;
+import jdk.internal.reflect.Reflection;
import sun.reflect.misc.ReflectUtil;
import sun.security.util.SecurityConstants;
@@ -689,13 +689,14 @@
}
/*
- * Returns all types referenced by all public method signatures of
+ * Returns all types referenced by all public non-static method signatures of
* the proxy interfaces
*/
private static Set<Class<?>> referencedTypes(ClassLoader loader,
List<Class<?>> interfaces) {
return interfaces.stream()
.flatMap(intf -> Stream.of(intf.getMethods())
+ .filter(m -> !Modifier.isStatic(m.getModifiers()))
.flatMap(ProxyBuilder::methodRefTypes)
.map(ProxyBuilder::getElementType)
.filter(t -> !t.isPrimitive()))
@@ -795,26 +796,13 @@
// map to dynamic proxy module and add reads edge and qualified exports, if necessary
Module target = getDynamicModule(loader);
- // set up proxy class access to proxy interfaces and superinterfaces
- Deque<Class<?>> deque = new LinkedList<>(interfaces);
- Set<Class<?>> visited = new HashSet<>();
- while (!deque.isEmpty()) {
- Class<?> c = deque.poll();
- if (!visited.add(c)) {
- continue;
- }
+ // set up proxy class access to proxy interfaces and types
+ // referenced in the method signature
+ Set<Class<?>> types = new HashSet<>(interfaces);
+ types.addAll(refTypes);
+ for (Class<?> c : types) {
ensureAccess(target, c);
-
- // add all superinterfaces
- for (Class<?> intf : c.getInterfaces()) {
- deque.add(intf);
- }
}
-
- // set up proxy class access to types referenced in the method signature
- refTypes.stream()
- .filter(t -> !visited.contains(t))
- .forEach(t -> ensureAccess(target, t));
return target;
}
--- a/jdk/src/java.base/share/classes/java/lang/reflect/ReflectAccess.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/reflect/ReflectAccess.java Wed Jul 05 21:35:27 2017 +0200
@@ -25,14 +25,14 @@
package java.lang.reflect;
-import sun.reflect.MethodAccessor;
-import sun.reflect.ConstructorAccessor;
+import jdk.internal.reflect.MethodAccessor;
+import jdk.internal.reflect.ConstructorAccessor;
/** Package-private class implementing the
sun.reflect.LangReflectAccess interface, allowing the java.lang
package to instantiate objects in this package. */
-class ReflectAccess implements sun.reflect.LangReflectAccess {
+class ReflectAccess implements jdk.internal.reflect.LangReflectAccess {
public Field newField(Class<?> declaringClass,
String name,
Class<?> type,
--- a/jdk/src/java.base/share/classes/java/net/InetAddress.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/net/InetAddress.java Wed Jul 05 21:35:27 2017 +0200
@@ -894,19 +894,17 @@
*/
private static final class PlatformNameService implements NameService {
- public InetAddress[] lookupAllHostAddr(String host)
- throws UnknownHostException {
-
- return impl.lookupAllHostAddr(host);
-
- }
-
- public String getHostByAddr(byte[] addr) throws UnknownHostException {
-
- return impl.getHostByAddr(addr);
-
+ public InetAddress[] lookupAllHostAddr(String host)
+ throws UnknownHostException
+ {
+ return impl.lookupAllHostAddr(host);
}
+ public String getHostByAddr(byte[] addr)
+ throws UnknownHostException
+ {
+ return impl.getHostByAddr(addr);
+ }
}
/**
@@ -991,7 +989,6 @@
return host;
}
-
/**
* <p>Lookup a host mapping by name. Retrieve the IP addresses
* associated with a host.
@@ -1004,7 +1001,6 @@
* @throws UnknownHostException
* if no IP address for the {@code host} could be found
*/
-
public InetAddress[] lookupAllHostAddr(String host)
throws UnknownHostException {
String hostEntry;
--- a/jdk/src/java.base/share/classes/java/net/URLClassLoader.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/net/URLClassLoader.java Wed Jul 05 21:35:27 2017 +0200
@@ -465,23 +465,21 @@
}
/**
- * Defines a new package by name in this ClassLoader. The attributes
- * contained in the specified Manifest will be used to obtain package
- * version and sealing information. For sealed packages, the additional
- * URL specifies the code source URL from which the package was loaded.
+ * Defines a new package by name in this {@code URLClassLoader}.
+ * The attributes contained in the specified {@code Manifest}
+ * will be used to obtain package version and sealing information.
+ * For sealed packages, the additional URL specifies the code source URL
+ * from which the package was loaded.
*
* @param name the package name
- * @param man the Manifest containing package version and sealing
+ * @param man the {@code Manifest} containing package version and sealing
* information
* @param url the code source url for the package, or null if none
- * @exception IllegalArgumentException if the package name duplicates
- * an existing package either in this class loader or one
- * of its ancestors
- * @return the newly defined Package object
+ * @throws IllegalArgumentException if the package name is
+ * already defined by this class loader
+ * @return the newly defined {@code Package} object
*/
- protected Package definePackage(String name, Manifest man, URL url)
- throws IllegalArgumentException
- {
+ protected Package definePackage(String name, Manifest man, URL url) {
String path = name.replace('.', '/').concat("/");
String specTitle = null, specVersion = null, specVendor = null;
String implTitle = null, implVersion = null, implVendor = null;
--- a/jdk/src/java.base/share/classes/java/nio/file/Files.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/nio/file/Files.java Wed Jul 05 21:35:27 2017 +0200
@@ -77,6 +77,8 @@
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
+import sun.nio.fs.AbstractFileSystemProvider;
+
/**
* This class consists exclusively of static methods that operate on files,
* directories, or other types of files.
@@ -2193,6 +2195,12 @@
* method denies read access to the file.
*/
public static boolean isDirectory(Path path, LinkOption... options) {
+ if (options.length == 0) {
+ FileSystemProvider provider = provider(path);
+ if (provider instanceof AbstractFileSystemProvider)
+ return ((AbstractFileSystemProvider)provider).isDirectory(path);
+ }
+
try {
return readAttributes(path, BasicFileAttributes.class, options).isDirectory();
} catch (IOException ioe) {
@@ -2230,6 +2238,12 @@
* method denies read access to the file.
*/
public static boolean isRegularFile(Path path, LinkOption... options) {
+ if (options.length == 0) {
+ FileSystemProvider provider = provider(path);
+ if (provider instanceof AbstractFileSystemProvider)
+ return ((AbstractFileSystemProvider)provider).isRegularFile(path);
+ }
+
try {
return readAttributes(path, BasicFileAttributes.class, options).isRegularFile();
} catch (IOException ioe) {
@@ -2385,6 +2399,12 @@
* @see #notExists
*/
public static boolean exists(Path path, LinkOption... options) {
+ if (options.length == 0) {
+ FileSystemProvider provider = provider(path);
+ if (provider instanceof AbstractFileSystemProvider)
+ return ((AbstractFileSystemProvider)provider).exists(path);
+ }
+
try {
if (followLinks(options)) {
provider(path).checkAccess(path);
--- a/jdk/src/java.base/share/classes/java/security/AccessController.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/security/AccessController.java Wed Jul 05 21:35:27 2017 +0200
@@ -26,8 +26,8 @@
package java.security;
import sun.security.util.Debug;
-import sun.reflect.CallerSensitive;
-import sun.reflect.Reflection;
+import jdk.internal.reflect.CallerSensitive;
+import jdk.internal.reflect.Reflection;
/**
* <p> The AccessController class is used for access control operations
--- a/jdk/src/java.base/share/classes/java/security/AlgorithmParameterGenerator.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/security/AlgorithmParameterGenerator.java Wed Jul 05 21:35:27 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2015, 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
@@ -140,7 +140,8 @@
*
* @implNote
* The JDK Reference Implementation additionally uses the
- * {@code jdk.security.provider.preferred} property to determine
+ * {@code jdk.security.provider.preferred}
+ * {@link Security#getProperty(String) Security} property to determine
* the preferred provider order for the specified algorithm. This
* may be different than the order of providers returned by
* {@link Security#getProviders() Security.getProviders()}.
--- a/jdk/src/java.base/share/classes/java/security/AlgorithmParameters.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/security/AlgorithmParameters.java Wed Jul 05 21:35:27 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2015, 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
@@ -128,7 +128,8 @@
*
* @implNote
* The JDK Reference Implementation additionally uses the
- * {@code jdk.security.provider.preferred} property to determine
+ * {@code jdk.security.provider.preferred}
+ * {@link Security#getProperty(String) Security} property to determine
* the preferred provider order for the specified algorithm. This
* may be different than the order of providers returned by
* {@link Security#getProviders() Security.getProviders()}.
--- a/jdk/src/java.base/share/classes/java/security/KeyFactory.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/security/KeyFactory.java Wed Jul 05 21:35:27 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2015, 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
@@ -155,7 +155,8 @@
*
* @implNote
* The JDK Reference Implementation additionally uses the
- * {@code jdk.security.provider.preferred} property to determine
+ * {@code jdk.security.provider.preferred}
+ * {@link Security#getProperty(String) Security} property to determine
* the preferred provider order for the specified algorithm. This
* may be different than the order of providers returned by
* {@link Security#getProviders() Security.getProviders()}.
--- a/jdk/src/java.base/share/classes/java/security/KeyPairGenerator.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/security/KeyPairGenerator.java Wed Jul 05 21:35:27 2017 +0200
@@ -197,7 +197,8 @@
*
* @implNote
* The JDK Reference Implementation additionally uses the
- * {@code jdk.security.provider.preferred} property to determine
+ * {@code jdk.security.provider.preferred}
+ * {@link Security#getProperty(String) Security} property to determine
* the preferred provider order for the specified algorithm. This
* may be different than the order of providers returned by
* {@link Security#getProviders() Security.getProviders()}.
--- a/jdk/src/java.base/share/classes/java/security/KeyStore.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/security/KeyStore.java Wed Jul 05 21:35:27 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2015, 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
@@ -843,7 +843,8 @@
*
* @implNote
* The JDK Reference Implementation additionally uses the
- * {@code jdk.security.provider.preferred} property to determine
+ * {@code jdk.security.provider.preferred}
+ * {@link Security#getProperty(String) Security} property to determine
* the preferred provider order for the specified algorithm. This
* may be different than the order of providers returned by
* {@link Security#getProviders() Security.getProviders()}.
--- a/jdk/src/java.base/share/classes/java/security/MessageDigest.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/security/MessageDigest.java Wed Jul 05 21:35:27 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 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
@@ -148,7 +148,8 @@
*
* @implNote
* The JDK Reference Implementation additionally uses the
- * {@code jdk.security.provider.preferred} property to determine
+ * {@code jdk.security.provider.preferred}
+ * {@link Security#getProperty(String) Security} property to determine
* the preferred provider order for the specified algorithm. This
* may be different than the order of providers returned by
* {@link Security#getProviders() Security.getProviders()}.
--- a/jdk/src/java.base/share/classes/java/security/Policy.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/security/Policy.java Wed Jul 05 21:35:27 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2015, 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
@@ -357,7 +357,8 @@
*
* @implNote
* The JDK Reference Implementation additionally uses the
- * {@code jdk.security.provider.preferred} property to determine
+ * {@code jdk.security.provider.preferred}
+ * {@link Security#getProperty(String) Security} property to determine
* the preferred provider order for the specified algorithm. This
* may be different than the order of providers returned by
* {@link Security#getProviders() Security.getProviders()}.
--- a/jdk/src/java.base/share/classes/java/security/SecureRandom.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/security/SecureRandom.java Wed Jul 05 21:35:27 2017 +0200
@@ -270,7 +270,8 @@
*
* @implNote
* The JDK Reference Implementation additionally uses the
- * {@code jdk.security.provider.preferred} property to determine
+ * {@code jdk.security.provider.preferred}
+ * {@link Security#getProperty(String) Security} property to determine
* the preferred provider order for the specified algorithm. This
* may be different than the order of providers returned by
* {@link Security#getProviders() Security.getProviders()}.
--- a/jdk/src/java.base/share/classes/java/security/Signature.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/security/Signature.java Wed Jul 05 21:35:27 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 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
@@ -205,7 +205,8 @@
*
* @implNote
* The JDK Reference Implementation additionally uses the
- * {@code jdk.security.provider.preferred} property to determine
+ * {@code jdk.security.provider.preferred}
+ * {@link Security#getProperty(String) Security} property to determine
* the preferred provider order for the specified algorithm. This
* may be different than the order of providers returned by
* {@link Security#getProviders() Security.getProviders()}.
--- a/jdk/src/java.base/share/classes/java/security/cert/CertPathBuilder.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/security/cert/CertPathBuilder.java Wed Jul 05 21:35:27 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 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
@@ -144,7 +144,8 @@
*
* @implNote
* The JDK Reference Implementation additionally uses the
- * {@code jdk.security.provider.preferred} property to determine
+ * {@code jdk.security.provider.preferred}
+ * {@link Security#getProperty(String) Security} property to determine
* the preferred provider order for the specified algorithm. This
* may be different than the order of providers returned by
* {@link Security#getProviders() Security.getProviders()}.
--- a/jdk/src/java.base/share/classes/java/security/cert/CertPathValidator.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/security/cert/CertPathValidator.java Wed Jul 05 21:35:27 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 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
@@ -145,7 +145,8 @@
*
* @implNote
* The JDK Reference Implementation additionally uses the
- * {@code jdk.security.provider.preferred} property to determine
+ * {@code jdk.security.provider.preferred}
+ * {@link Security#getProperty(String) Security} property to determine
* the preferred provider order for the specified algorithm. This
* may be different than the order of providers returned by
* {@link Security#getProviders() Security.getProviders()}.
--- a/jdk/src/java.base/share/classes/java/security/cert/CertStore.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/security/cert/CertStore.java Wed Jul 05 21:35:27 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 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
@@ -203,7 +203,8 @@
*
* @implNote
* The JDK Reference Implementation additionally uses the
- * {@code jdk.security.provider.preferred} property to determine
+ * {@code jdk.security.provider.preferred}
+ * {@link Security#getProperty(String) Security} property to determine
* the preferred provider order for the specified algorithm. This
* may be different than the order of providers returned by
* {@link Security#getProviders() Security.getProviders()}.
--- a/jdk/src/java.base/share/classes/java/security/cert/CertificateFactory.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/security/cert/CertificateFactory.java Wed Jul 05 21:35:27 2017 +0200
@@ -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
@@ -165,7 +165,8 @@
*
* @implNote
* The JDK Reference Implementation additionally uses the
- * {@code jdk.security.provider.preferred} property to determine
+ * {@code jdk.security.provider.preferred}
+ * {@link Security#getProperty(String) Security} property to determine
* the preferred provider order for the specified algorithm. This
* may be different than the order of providers returned by
* {@link Security#getProviders() Security.getProviders()}.
--- a/jdk/src/java.base/share/classes/java/time/Duration.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/time/Duration.java Wed Jul 05 21:35:27 2017 +0200
@@ -1350,6 +1350,48 @@
return nanos;
}
+
+ //-----------------------------------------------------------------------
+ /**
+ * Returns a copy of this {@code Duration} truncated to the specified unit.
+ * <p>
+ * Truncating the duration returns a copy of the original with conceptual fields
+ * smaller than the specified unit set to zero.
+ * For example, truncating with the {@link ChronoUnit#MINUTES MINUTES} unit will
+ * round down to the nearest minute, setting the seconds and nanoseconds to zero.
+ * <p>
+ * The unit must have a {@linkplain TemporalUnit#getDuration() duration}
+ * that divides into the length of a standard day without remainder.
+ * This includes all supplied time units on {@link ChronoUnit} and
+ * {@link ChronoUnit#DAYS DAYS}. Other ChronoUnits throw an exception.
+ * <p>
+ * This instance is immutable and unaffected by this method call.
+ *
+ * @param unit the unit to truncate to, not null
+ * @return a {@code Duration} based on this duration with the time truncated, not null
+ * @throws DateTimeException if the unit is invalid for truncation
+ * @throws UnsupportedTemporalTypeException if the unit is not supported
+ */
+ public Duration truncatedTo(TemporalUnit unit) {
+ Objects.requireNonNull(unit, "unit");
+ if (unit == ChronoUnit.SECONDS && (seconds >= 0 || nanos == 0)) {
+ return new Duration(seconds, 0);
+ } else if (unit == ChronoUnit.NANOS) {
+ return this;
+ }
+ Duration unitDur = unit.getDuration();
+ if (unitDur.getSeconds() > LocalTime.SECONDS_PER_DAY) {
+ throw new UnsupportedTemporalTypeException("Unit is too large to be used for truncation");
+ }
+ long dur = unitDur.toNanos();
+ if ((LocalTime.NANOS_PER_DAY % dur) != 0) {
+ throw new UnsupportedTemporalTypeException("Unit must divide into a standard day without remainder");
+ }
+ long nod = (seconds % LocalTime.SECONDS_PER_DAY) * LocalTime.NANOS_PER_SECOND + nanos;
+ long result = (nod / dur) * dur ;
+ return plusNanos(result - nod);
+ }
+
//-----------------------------------------------------------------------
/**
* Compares this duration to the specified {@code Duration}.
--- a/jdk/src/java.base/share/classes/java/util/Objects.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/util/Objects.java Wed Jul 05 21:35:27 2017 +0200
@@ -25,26 +25,28 @@
package java.util;
+import jdk.internal.HotSpotIntrinsicCandidate;
+
import java.util.function.BiFunction;
+import java.util.function.Function;
import java.util.function.Supplier;
-import jdk.internal.HotSpotIntrinsicCandidate;
/**
* This class consists of {@code static} utility methods for operating
* on objects, or checking certain conditions before operation. These utilities
* include {@code null}-safe or {@code null}-tolerant methods for computing the
* hash code of an object, returning a string for an object, comparing two
- * objects, and checking if indexes or sub-range values are out of bounds.
+ * objects, and checking if indexes or sub-range values are out-of-bounds.
*
* @apiNote
* Static methods such as {@link Objects#checkIndex},
* {@link Objects#checkFromToIndex}, and {@link Objects#checkFromIndexSize} are
* provided for the convenience of checking if values corresponding to indexes
- * and sub-ranges are out of bounds.
+ * and sub-ranges are out-of-bounds.
* Variations of these static methods support customization of the runtime
* exception, and corresponding exception detail message, that is thrown when
- * values are out of bounds. Such methods accept a functional interface
- * argument, instances of {@code BiFunction}, that maps out of bound values to a
+ * values are out-of-bounds. Such methods accept a functional interface
+ * argument, instances of {@code BiFunction}, that maps out-of-bound values to a
* runtime exception. Care should be taken when using such methods in
* combination with an argument that is a lambda expression, method reference or
* class that capture values. In such cases the cost of capture, related to
@@ -347,29 +349,176 @@
}
/**
- * Maps out of bounds values to a runtime exception.
+ * Maps out-of-bounds values to a runtime exception.
*
- * @param a the first out of bound value
- * @param b the second out of bound value
- * @param oobe the exception mapping function that when applied with out of
- * bounds arguments returns a runtime exception. If {@code null}
- * then, it is as if an exception mapping function was supplied that
- * returns {@link IndexOutOfBoundsException} for any given arguments.
+ * @param checkKind the kind of bounds check, whose name may correspond
+ * to the name of one of the range check methods, checkIndex,
+ * checkFromToIndex, checkFromIndexSize
+ * @param args the out-of-bounds arguments that failed the range check.
+ * If the checkKind corresponds a the name of a range check method
+ * then the bounds arguments are those that can be passed in order
+ * to the method.
+ * @param oobef the exception formatter that when applied with a checkKind
+ * and a list out-of-bounds arguments returns a runtime exception.
+ * If {@code null} then, it is as if an exception formatter was
+ * supplied that returns {@link IndexOutOfBoundsException} for any
+ * given arguments.
* @return the runtime exception
*/
private static RuntimeException outOfBounds(
- int a, int b, BiFunction<Integer, Integer, ? extends RuntimeException> oobe) {
- RuntimeException e = oobe == null
- ? null : oobe.apply(a, b);
+ BiFunction<String, List<Integer>, ? extends RuntimeException> oobef,
+ String checkKind,
+ Integer... args) {
+ List<Integer> largs = List.of(args);
+ RuntimeException e = oobef == null
+ ? null : oobef.apply(checkKind, largs);
return e == null
- ? new IndexOutOfBoundsException(a, b) : e;
+ ? new IndexOutOfBoundsException(outOfBoundsMessage(checkKind, largs)) : e;
+ }
+
+ // Specific out-of-bounds exception producing methods that avoid
+ // the varargs-based code in the critical methods there by reducing their
+ // the byte code size, and therefore less likely to peturb inlining
+
+ private static RuntimeException outOfBoundsCheckIndex(
+ BiFunction<String, List<Integer>, ? extends RuntimeException> oobe,
+ int index, int length) {
+ return outOfBounds(oobe, "checkIndex", index, length);
+ }
+
+ private static RuntimeException outOfBoundsCheckFromToIndex(
+ BiFunction<String, List<Integer>, ? extends RuntimeException> oobe,
+ int fromIndex, int toIndex, int length) {
+ return outOfBounds(oobe, "checkFromToIndex", fromIndex, toIndex, length);
+ }
+
+ private static RuntimeException outOfBoundsCheckFromIndexSize(
+ BiFunction<String, List<Integer>, ? extends RuntimeException> oobe,
+ int fromIndex, int size, int length) {
+ return outOfBounds(oobe, "checkFromIndexSize", fromIndex, size, length);
+ }
+
+ /**
+ * Returns an out-of-bounds exception formatter from an given exception
+ * factory. The exception formatter is a function that formats an
+ * out-of-bounds message from its arguments and applies that message to the
+ * given exception factory to produce and relay an exception.
+ *
+ * <p>The exception formatter accepts two arguments: a {@code String}
+ * describing the out-of-bounds range check that failed, referred to as the
+ * <em>check kind</em>; and a {@code List<Integer>} containing the
+ * out-of-bound integer values that failed the check. The list of
+ * out-of-bound values is not modified.
+ *
+ * <p>Three check kinds are supported {@code checkIndex},
+ * {@code checkFromToIndex} and {@code checkFromIndexSize} corresponding
+ * respectively to the specified application of an exception formatter as an
+ * argument to the out-of-bounds range check methods
+ * {@link #checkIndex(int, int, BiFunction) checkIndex},
+ * {@link #checkFromToIndex(int, int, int, BiFunction) checkFromToIndex}, and
+ * {@link #checkFromIndexSize(int, int, int, BiFunction) checkFromIndexSize}.
+ * Thus a supported check kind corresponds to a method name and the
+ * out-of-bound integer values correspond to method argument values, in
+ * order, preceding the exception formatter argument (similar in many
+ * respects to the form of arguments required for a reflective invocation of
+ * such a range check method).
+ *
+ * <p>Formatter arguments conforming to such supported check kinds will
+ * produce specific exception messages describing failed out-of-bounds
+ * checks. Otherwise, more generic exception messages will be produced in
+ * any of the following cases: the check kind is supported but fewer
+ * or more out-of-bounds values are supplied, the check kind is not
+ * supported, the check kind is {@code null}, or the list of out-of-bound
+ * values is {@code null}.
+ *
+ * @apiNote
+ * This method produces an out-of-bounds exception formatter that can be
+ * passed as an argument to any of the supported out-of-bounds range check
+ * methods declared by {@code Objects}. For example, a formatter producing
+ * an {@code ArrayIndexOutOfBoundsException} may be produced and stored on a
+ * {@code static final} field as follows:
+ * <pre>{@code
+ * static final
+ * BiFunction<String, List<Integer>, ArrayIndexOutOfBoundsException> AIOOBEF =
+ * outOfBoundsExceptionFormatter(ArrayIndexOutOfBoundsException::new);
+ * }</pre>
+ * The formatter instance {@code AIOOBEF} may be passed as an argument to an
+ * out-of-bounds range check method, such as checking if an {@code index}
+ * is within the bounds of a {@code limit}:
+ * <pre>{@code
+ * checkIndex(index, limit, AIOOBEF);
+ * }</pre>
+ * If the bounds check fails then the range check method will throw an
+ * {@code ArrayIndexOutOfBoundsException} with an appropriate exception
+ * message that is a produced from {@code AIOOBEF} as follows:
+ * <pre>{@code
+ * AIOOBEF.apply("checkIndex", List.of(index, limit));
+ * }</pre>
+ *
+ * @param f the exception factory, that produces an exception from a message
+ * where the message is produced and formatted by the returned
+ * exception formatter. If this factory is stateless and side-effect
+ * free then so is the returned formatter.
+ * Exceptions thrown by the factory are relayed to the caller
+ * of the returned formatter.
+ * @param <X> the type of runtime exception to be returned by the given
+ * exception factory and relayed by the exception formatter
+ * @return the out-of-bounds exception formatter
+ */
+ public static <X extends RuntimeException>
+ BiFunction<String, List<Integer>, X> outOfBoundsExceptionFormatter(Function<String, X> f) {
+ // Use anonymous class to avoid bootstrap issues if this method is
+ // used early in startup
+ return new BiFunction<String, List<Integer>, X>() {
+ @Override
+ public X apply(String checkKind, List<Integer> args) {
+ return f.apply(outOfBoundsMessage(checkKind, args));
+ }
+ };
+ }
+
+ private static String outOfBoundsMessage(String checkKind, List<Integer> args) {
+ if (checkKind == null && args == null) {
+ return String.format("Range check failed");
+ } else if (checkKind == null) {
+ return String.format("Range check failed: %s", args);
+ } else if (args == null) {
+ return String.format("Range check failed: %s", checkKind);
+ }
+
+ int argSize = 0;
+ switch (checkKind) {
+ case "checkIndex":
+ argSize = 2;
+ break;
+ case "checkFromToIndex":
+ case "checkFromIndexSize":
+ argSize = 3;
+ break;
+ default:
+ }
+
+ // Switch to default if fewer or more arguments than required are supplied
+ switch ((args.size() != argSize) ? "" : checkKind) {
+ case "checkIndex":
+ return String.format("Index %d out-of-bounds for length %d",
+ args.get(0), args.get(1));
+ case "checkFromToIndex":
+ return String.format("Range [%d, %d) out-of-bounds for length %d",
+ args.get(0), args.get(1), args.get(2));
+ case "checkFromIndexSize":
+ return String.format("Range [%d, %<d + %d) out-of-bounds for length %d",
+ args.get(0), args.get(1), args.get(2));
+ default:
+ return String.format("Range check failed: %s %s", checkKind, args);
+ }
}
/**
* Checks if the {@code index} is within the bounds of the range from
* {@code 0} (inclusive) to {@code length} (exclusive).
*
- * <p>The {@code index} is defined to be out of bounds if any of the
+ * <p>The {@code index} is defined to be out-of-bounds if any of the
* following inequalities is true:
* <ul>
* <li>{@code index < 0}</li>
@@ -377,14 +526,20 @@
* <li>{@code length < 0}, which is implied from the former inequalities</li>
* </ul>
*
+ * <p>This method behaves as if {@link #checkIndex(int, int, BiFunction)}
+ * was called with same out-of-bounds arguments and an exception formatter
+ * argument produced from an invocation of
+ * {@code outOfBoundsExceptionFormatter(IndexOutOfBounds::new)} (though it may
+ * be more efficient).
+ *
* @param index the index
* @param length the upper-bound (exclusive) of the range
* @return {@code index} if it is within bounds of the range
- * @throws IndexOutOfBoundsException if the {@code index} is out of bounds
+ * @throws IndexOutOfBoundsException if the {@code index} is out-of-bounds
* @since 9
*/
public static
- int checkIndex(int index, int length) throws IndexOutOfBoundsException {
+ int checkIndex(int index, int length) {
return checkIndex(index, length, null);
}
@@ -392,7 +547,7 @@
* Checks if the {@code index} is within the bounds of the range from
* {@code 0} (inclusive) to {@code length} (exclusive).
*
- * <p>The {@code index} is defined to be out of bounds if any of the
+ * <p>The {@code index} is defined to be out-of-bounds if any of the
* following inequalities is true:
* <ul>
* <li>{@code index < 0}</li>
@@ -400,40 +555,42 @@
* <li>{@code length < 0}, which is implied from the former inequalities</li>
* </ul>
*
- * <p>If the {@code index} is out of bounds, then a runtime exception is
- * thrown that is the result of applying the arguments {@code index} and
- * {@code length} to the given exception mapping function.
+ * <p>If the {@code index} is out-of-bounds, then a runtime exception is
+ * thrown that is the result of applying the following arguments to the
+ * exception formatter: the name of this method, {@code checkIndex};
+ * and an unmodifiable list integers whose values are, in order, the
+ * out-of-bounds arguments {@code index} and {@code length}.
*
- * @param <T> the type of runtime exception to throw if the arguments are
- * out of bounds
+ * @param <X> the type of runtime exception to throw if the arguments are
+ * out-of-bounds
* @param index the index
* @param length the upper-bound (exclusive) of the range
- * @param oobe the exception mapping function that when applied with out
- * of bounds arguments returns a runtime exception. If {@code null}
- * or returns {@code null} then, it is as if an exception mapping
- * function was supplied that returns
- * {@link IndexOutOfBoundsException} for any given arguments.
- * Exceptions thrown by the function are relayed to the caller.
+ * @param oobef the exception formatter that when applied with this
+ * method name and out-of-bounds arguments returns a runtime
+ * exception. If {@code null} or returns {@code null} then, it is as
+ * if an exception formatter produced from an invocation of
+ * {@code outOfBoundsExceptionFormatter(IndexOutOfBounds::new)} is used
+ * instead (though it may be more efficient).
+ * Exceptions thrown by the formatter are relayed to the caller.
* @return {@code index} if it is within bounds of the range
- * @throws T if the {@code index} is out of bounds, then a runtime exception
- * is thrown that is the result of applying the out of bounds
- * arguments to the exception mapping function.
- * @throws IndexOutOfBoundsException if the {@code index} is out of bounds
- * and the exception mapping function is {@code null}
+ * @throws X if the {@code index} is out-of-bounds and the exception
+ * formatter is non-{@code null}
+ * @throws IndexOutOfBoundsException if the {@code index} is out-of-bounds
+ * and the exception formatter is {@code null}
* @since 9
*
* @implNote
- * This method is made intrinsic in optimizing compilers to guide
- * them to perform unsigned comparisons of the index and length
- * when it is known the length is a non-negative value (such as
- * that of an array length or from the upper bound of a loop)
+ * This method is made intrinsic in optimizing compilers to guide them to
+ * perform unsigned comparisons of the index and length when it is known the
+ * length is a non-negative value (such as that of an array length or from
+ * the upper bound of a loop)
*/
@HotSpotIntrinsicCandidate
- public static <T extends RuntimeException>
+ public static <X extends RuntimeException>
int checkIndex(int index, int length,
- BiFunction<Integer, Integer, T> oobe) throws T, IndexOutOfBoundsException {
+ BiFunction<String, List<Integer>, X> oobef) {
if (index < 0 || index >= length)
- throw outOfBounds(index, length, oobe);
+ throw outOfBoundsCheckIndex(oobef, index, length);
return index;
}
@@ -442,7 +599,7 @@
* {@code toIndex} (exclusive) is within the bounds of range from {@code 0}
* (inclusive) to {@code length} (exclusive).
*
- * <p>The sub-range is defined to be out of bounds if any of the following
+ * <p>The sub-range is defined to be out-of-bounds if any of the following
* inequalities is true:
* <ul>
* <li>{@code fromIndex < 0}</li>
@@ -451,15 +608,21 @@
* <li>{@code length < 0}, which is implied from the former inequalities</li>
* </ul>
*
+ * <p>This method behaves as if {@link #checkFromToIndex(int, int, int, BiFunction)}
+ * was called with same out-of-bounds arguments and an exception formatter
+ * argument produced from an invocation of
+ * {@code outOfBoundsExceptionFormatter(IndexOutOfBounds::new)} (though it may
+ * be more efficient).
+ *
* @param fromIndex the lower-bound (inclusive) of the sub-range
* @param toIndex the upper-bound (exclusive) of the sub-range
* @param length the upper-bound (exclusive) the range
* @return {@code fromIndex} if the sub-range within bounds of the range
- * @throws IndexOutOfBoundsException if the sub-range is out of bounds
+ * @throws IndexOutOfBoundsException if the sub-range is out-of-bounds
* @since 9
*/
public static
- int checkFromToIndex(int fromIndex, int toIndex, int length) throws IndexOutOfBoundsException {
+ int checkFromToIndex(int fromIndex, int toIndex, int length) {
return checkFromToIndex(fromIndex, toIndex, length, null);
}
@@ -468,7 +631,7 @@
* {@code toIndex} (exclusive) is within the bounds of range from {@code 0}
* (inclusive) to {@code length} (exclusive).
*
- * <p>The sub-range is defined to be out of bounds if any of the following
+ * <p>The sub-range is defined to be out-of-bounds if any of the following
* inequalities is true:
* <ul>
* <li>{@code fromIndex < 0}</li>
@@ -477,34 +640,36 @@
* <li>{@code length < 0}, which is implied from the former inequalities</li>
* </ul>
*
- * <p>If the sub-range is out of bounds, then a runtime exception is thrown
- * that is the result of applying the arguments {@code fromIndex} and
- * {@code toIndex} to the given exception mapping function.
+ * <p>If the sub-range is out-of-bounds, then a runtime exception is
+ * thrown that is the result of applying the following arguments to the
+ * exception formatter: the name of this method, {@code checkFromToIndex};
+ * and an unmodifiable list integers whose values are, in order, the
+ * out-of-bounds arguments {@code fromIndex}, {@code toIndex}, and {@code length}.
*
- * @param <T> the type of runtime exception to throw if the arguments are
- * out of bounds
+ * @param <X> the type of runtime exception to throw if the arguments are
+ * out-of-bounds
* @param fromIndex the lower-bound (inclusive) of the sub-range
* @param toIndex the upper-bound (exclusive) of the sub-range
* @param length the upper-bound (exclusive) the range
- * @param oobe the exception mapping function that when applied with out
- * of bounds arguments returns a runtime exception. If {@code null}
- * or returns {@code null} then, it is as if an exception mapping
- * function was supplied that returns
- * {@link IndexOutOfBoundsException} for any given arguments.
- * Exceptions thrown by the function are relayed to the caller.
+ * @param oobef the exception formatter that when applied with this
+ * method name and out-of-bounds arguments returns a runtime
+ * exception. If {@code null} or returns {@code null} then, it is as
+ * if an exception formatter produced from an invocation of
+ * {@code outOfBoundsExceptionFormatter(IndexOutOfBounds::new)} is used
+ * instead (though it may be more efficient).
+ * Exceptions thrown by the formatter are relayed to the caller.
* @return {@code fromIndex} if the sub-range within bounds of the range
- * @throws T if the sub-range is out of bounds, then a runtime exception is
- * thrown that is the result of applying the out of bounds arguments
- * to the exception mapping function.
- * @throws IndexOutOfBoundsException if the sub-range is out of bounds and
- * the exception mapping function is {@code null}
+ * @throws X if the sub-range is out-of-bounds and the exception factory
+ * function is non-{@code null}
+ * @throws IndexOutOfBoundsException if the sub-range is out-of-bounds and
+ * the exception factory function is {@code null}
* @since 9
*/
- public static <T extends RuntimeException>
+ public static <X extends RuntimeException>
int checkFromToIndex(int fromIndex, int toIndex, int length,
- BiFunction<Integer, Integer, T> oobe) throws T, IndexOutOfBoundsException {
+ BiFunction<String, List<Integer>, X> oobef) {
if (fromIndex < 0 || fromIndex > toIndex || toIndex > length)
- throw outOfBounds(fromIndex, toIndex, oobe);
+ throw outOfBoundsCheckFromToIndex(oobef, fromIndex, toIndex, length);
return fromIndex;
}
@@ -513,7 +678,7 @@
* {@code fromIndex + size} (exclusive) is within the bounds of range from
* {@code 0} (inclusive) to {@code length} (exclusive).
*
- * <p>The sub-range is defined to be out of bounds if any of the following
+ * <p>The sub-range is defined to be out-of-bounds if any of the following
* inequalities is true:
* <ul>
* <li>{@code fromIndex < 0}</li>
@@ -522,15 +687,21 @@
* <li>{@code length < 0}, which is implied from the former inequalities</li>
* </ul>
*
+ * <p>This method behaves as if {@link #checkFromIndexSize(int, int, int, BiFunction)}
+ * was called with same out-of-bounds arguments and an exception formatter
+ * argument produced from an invocation of
+ * {@code outOfBoundsExceptionFormatter(IndexOutOfBounds::new)} (though it may
+ * be more efficient).
+ *
* @param fromIndex the lower-bound (inclusive) of the sub-interval
* @param size the size of the sub-range
* @param length the upper-bound (exclusive) of the range
* @return {@code fromIndex} if the sub-range within bounds of the range
- * @throws IndexOutOfBoundsException if the sub-range is out of bounds
+ * @throws IndexOutOfBoundsException if the sub-range is out-of-bounds
* @since 9
*/
public static
- int checkFromIndexSize(int fromIndex, int size, int length) throws IndexOutOfBoundsException {
+ int checkFromIndexSize(int fromIndex, int size, int length) {
return checkFromIndexSize(fromIndex, size, length, null);
}
@@ -539,7 +710,7 @@
* {@code fromIndex + size} (exclusive) is within the bounds of range from
* {@code 0} (inclusive) to {@code length} (exclusive).
*
- * <p>The sub-range is defined to be out of bounds if any of the following
+ * <p>The sub-range is defined to be out-of-bounds if any of the following
* inequalities is true:
* <ul>
* <li>{@code fromIndex < 0}</li>
@@ -548,34 +719,37 @@
* <li>{@code length < 0}, which is implied from the former inequalities</li>
* </ul>
*
- * <p>If the sub-range is out of bounds then, a runtime exception is thrown
- * that is the result of applying the arguments {@code fromIndex} and
- * {@code size} to the given exception mapping function.
+ * <p>If the sub-range is out-of-bounds, then a runtime exception is
+ * thrown that is the result of applying the following arguments to the
+ * exception formatter: the name of this method, {@code checkFromIndexSize};
+ * and an unmodifiable list integers whose values are, in order, the
+ * out-of-bounds arguments {@code fromIndex}, {@code size}, and
+ * {@code length}.
*
- * @param <T> the type of runtime exception to throw if the arguments are
- * out of bounds
+ * @param <X> the type of runtime exception to throw if the arguments are
+ * out-of-bounds
* @param fromIndex the lower-bound (inclusive) of the sub-interval
* @param size the size of the sub-range
* @param length the upper-bound (exclusive) of the range
- * @param oobe the exception mapping function that when applied with out
- * of bounds arguments returns a runtime exception. If {@code null}
- * or returns {@code null} then, it is as if an exception mapping
- * function was supplied that returns
- * {@link IndexOutOfBoundsException} for any given arguments.
- * Exceptions thrown by the function are relayed to the caller.
+ * @param oobef the exception formatter that when applied with this
+ * method name and out-of-bounds arguments returns a runtime
+ * exception. If {@code null} or returns {@code null} then, it is as
+ * if an exception formatter produced from an invocation of
+ * {@code outOfBoundsExceptionFormatter(IndexOutOfBounds::new)} is used
+ * instead (though it may be more efficient).
+ * Exceptions thrown by the formatter are relayed to the caller.
* @return {@code fromIndex} if the sub-range within bounds of the range
- * @throws T if the sub-range is out of bounds, then a runtime exception is
- * thrown that is the result of applying the out of bounds arguments
- * to the exception mapping function.
- * @throws IndexOutOfBoundsException if the sub-range is out of bounds and
- * the exception mapping function is {@code null}
+ * @throws X if the sub-range is out-of-bounds and the exception factory
+ * function is non-{@code null}
+ * @throws IndexOutOfBoundsException if the sub-range is out-of-bounds and
+ * the exception factory function is {@code null}
* @since 9
*/
- public static <T extends RuntimeException>
+ public static <X extends RuntimeException>
int checkFromIndexSize(int fromIndex, int size, int length,
- BiFunction<Integer, Integer, T> oobe) throws T, IndexOutOfBoundsException {
+ BiFunction<String, List<Integer>, X> oobef) {
if ((length | fromIndex | size) < 0 || size > length - fromIndex)
- throw outOfBounds(fromIndex, size, oobe);
+ throw outOfBoundsCheckFromIndexSize(oobef, fromIndex, size, length);
return fromIndex;
}
}
--- a/jdk/src/java.base/share/classes/java/util/ResourceBundle.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/util/ResourceBundle.java Wed Jul 05 21:35:27 2017 +0200
@@ -64,8 +64,8 @@
import jdk.internal.misc.JavaUtilResourceBundleAccess;
import jdk.internal.misc.SharedSecrets;
-import sun.reflect.CallerSensitive;
-import sun.reflect.Reflection;
+import jdk.internal.reflect.CallerSensitive;
+import jdk.internal.reflect.Reflection;
import sun.util.locale.BaseLocale;
import sun.util.locale.LocaleObjectCache;
import sun.util.locale.provider.ResourceBundleProviderSupport;
--- a/jdk/src/java.base/share/classes/java/util/ServiceLoader.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/util/ServiceLoader.java Wed Jul 05 21:35:27 2017 +0200
@@ -51,8 +51,8 @@
import jdk.internal.module.ServicesCatalog;
import jdk.internal.module.ServicesCatalog.ServiceProvider;
-import sun.reflect.CallerSensitive;
-import sun.reflect.Reflection;
+import jdk.internal.reflect.CallerSensitive;
+import jdk.internal.reflect.Reflection;
/**
--- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java Wed Jul 05 21:35:27 2017 +0200
@@ -42,8 +42,8 @@
import java.security.PrivilegedExceptionAction;
import java.util.function.IntBinaryOperator;
import java.util.function.IntUnaryOperator;
-import sun.reflect.CallerSensitive;
-import sun.reflect.Reflection;
+import jdk.internal.reflect.CallerSensitive;
+import jdk.internal.reflect.Reflection;
/**
* A reflection-based utility that enables atomic updates to
--- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongFieldUpdater.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongFieldUpdater.java Wed Jul 05 21:35:27 2017 +0200
@@ -42,8 +42,8 @@
import java.security.PrivilegedExceptionAction;
import java.util.function.LongBinaryOperator;
import java.util.function.LongUnaryOperator;
-import sun.reflect.CallerSensitive;
-import sun.reflect.Reflection;
+import jdk.internal.reflect.CallerSensitive;
+import jdk.internal.reflect.Reflection;
/**
* A reflection-based utility that enables atomic updates to
--- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java Wed Jul 05 21:35:27 2017 +0200
@@ -42,8 +42,8 @@
import java.security.PrivilegedExceptionAction;
import java.util.function.BinaryOperator;
import java.util.function.UnaryOperator;
-import sun.reflect.CallerSensitive;
-import sun.reflect.Reflection;
+import jdk.internal.reflect.CallerSensitive;
+import jdk.internal.reflect.Reflection;
/**
* A reflection-based utility that enables atomic updates to
--- a/jdk/src/java.base/share/classes/java/util/jar/JarFile.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/util/jar/JarFile.java Wed Jul 05 21:35:27 2017 +0200
@@ -894,7 +894,8 @@
private static final byte[] CLASSPATH_LASTOCC;
private static final byte[] MULTIRELEASE_CHARS =
- {'M','U','L','T','I','-','R','E','L','E', 'A', 'S', 'E', ':', ' '};
+ {'M','U','L','T','I','-','R','E','L','E', 'A', 'S', 'E', ':',
+ ' ', 'T', 'R', 'U', 'E'};
// The bad character shift for "multi-release: "
private static final byte[] MULTIRELEASE_LASTOCC;
@@ -914,17 +915,17 @@
MULTIRELEASE_LASTOCC = new byte[64];
MULTIRELEASE_LASTOCC[(int)'M' - 32] = 1;
- MULTIRELEASE_LASTOCC[(int)'U' - 32] = 2;
- MULTIRELEASE_LASTOCC[(int)'T' - 32] = 4;
MULTIRELEASE_LASTOCC[(int)'I' - 32] = 5;
MULTIRELEASE_LASTOCC[(int)'-' - 32] = 6;
- MULTIRELEASE_LASTOCC[(int)'R' - 32] = 7;
MULTIRELEASE_LASTOCC[(int)'L' - 32] = 9;
MULTIRELEASE_LASTOCC[(int)'A' - 32] = 11;
MULTIRELEASE_LASTOCC[(int)'S' - 32] = 12;
- MULTIRELEASE_LASTOCC[(int)'E' - 32] = 13;
MULTIRELEASE_LASTOCC[(int)':' - 32] = 14;
MULTIRELEASE_LASTOCC[(int)' ' - 32] = 15;
+ MULTIRELEASE_LASTOCC[(int)'T' - 32] = 16;
+ MULTIRELEASE_LASTOCC[(int)'R' - 32] = 17;
+ MULTIRELEASE_LASTOCC[(int)'U' - 32] = 18;
+ MULTIRELEASE_LASTOCC[(int)'E' - 32] = 19;
}
private JarEntry getManEntry() {
@@ -966,7 +967,7 @@
* Since there are no repeated substring in our search strings,
* the good suffix shifts can be replaced with a comparison.
*/
- private boolean match(byte[] src, byte[] b, byte[] lastOcc) {
+ private int match(byte[] src, byte[] b, byte[] lastOcc) {
int len = src.length;
int last = b.length - len;
int i = 0;
@@ -990,9 +991,9 @@
continue next;
}
}
- return true;
+ return i;
}
- return false;
+ return -1;
}
/**
@@ -1011,11 +1012,35 @@
if (manEntry != null) {
byte[] b = getBytes(manEntry);
hasClassPathAttribute = match(CLASSPATH_CHARS, b,
- CLASSPATH_LASTOCC);
+ CLASSPATH_LASTOCC) != -1;
// is this a multi-release jar file
if (MULTI_RELEASE_ENABLED && version != BASE_VERSION) {
- isMultiRelease = match(MULTIRELEASE_CHARS, b,
- MULTIRELEASE_LASTOCC);
+ int i = match(MULTIRELEASE_CHARS, b, MULTIRELEASE_LASTOCC);
+ if (i != -1) {
+ i += MULTIRELEASE_CHARS.length;
+ if (i < b.length) {
+ byte c = b[i++];
+ // Check that the value is followed by a newline
+ // and does not have a continuation
+ if (c == '\n' &&
+ (i == b.length || b[i] != ' ')) {
+ isMultiRelease = true;
+ } else if (c == '\r') {
+ if (i == b.length) {
+ isMultiRelease = true;
+ } else {
+ c = b[i++];
+ if (c == '\n') {
+ if (i == b.length || b[i] != ' ') {
+ isMultiRelease = true;
+ }
+ } else if (c != ' ') {
+ isMultiRelease = true;
+ }
+ }
+ }
+ }
+ }
}
}
hasCheckedSpecialAttributes = true;
--- a/jdk/src/java.base/share/classes/javax/crypto/Cipher.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/javax/crypto/Cipher.java Wed Jul 05 21:35:27 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2015, 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
@@ -480,7 +480,8 @@
*
* @implNote
* The JDK Reference Implementation additionally uses the
- * {@code jdk.security.provider.preferred} property to determine
+ * {@code jdk.security.provider.preferred}
+ * {@link Security#getProperty(String) Security} property to determine
* the preferred provider order for the specified algorithm. This
* may be different than the order of providers returned by
* {@link Security#getProviders() Security.getProviders()}.
--- a/jdk/src/java.base/share/classes/javax/crypto/ExemptionMechanism.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/javax/crypto/ExemptionMechanism.java Wed Jul 05 21:35:27 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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
@@ -114,7 +114,8 @@
*
* @implNote
* The JDK Reference Implementation additionally uses the
- * {@code jdk.security.provider.preferred} property to determine
+ * {@code jdk.security.provider.preferred}
+ * {@link Security#getProperty(String) Security} property to determine
* the preferred provider order for the specified algorithm. This
* may be different than the order of providers returned by
* {@link Security#getProviders() Security.getProviders()}.
--- a/jdk/src/java.base/share/classes/javax/crypto/KeyAgreement.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/javax/crypto/KeyAgreement.java Wed Jul 05 21:35:27 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2015, 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
@@ -152,7 +152,8 @@
*
* @implNote
* The JDK Reference Implementation additionally uses the
- * {@code jdk.security.provider.preferred} property to determine
+ * {@code jdk.security.provider.preferred}
+ * {@link Security#getProperty(String) Security} property to determine
* the preferred provider order for the specified algorithm. This
* may be different than the order of providers returned by
* {@link Security#getProviders() Security.getProviders()}.
--- a/jdk/src/java.base/share/classes/javax/crypto/KeyGenerator.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/javax/crypto/KeyGenerator.java Wed Jul 05 21:35:27 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2015, 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
@@ -204,7 +204,8 @@
*
* @implNote
* The JDK Reference Implementation additionally uses the
- * {@code jdk.security.provider.preferred} property to determine
+ * {@code jdk.security.provider.preferred}
+ * {@link Security#getProperty(String) Security} property to determine
* the preferred provider order for the specified algorithm. This
* may be different than the order of providers returned by
* {@link Security#getProviders() Security.getProviders()}.
--- a/jdk/src/java.base/share/classes/javax/crypto/Mac.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/javax/crypto/Mac.java Wed Jul 05 21:35:27 2017 +0200
@@ -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
@@ -154,7 +154,8 @@
*
* @implNote
* The JDK Reference Implementation additionally uses the
- * {@code jdk.security.provider.preferred} property to determine
+ * {@code jdk.security.provider.preferred}
+ * {@link Security#getProperty(String) Security} property to determine
* the preferred provider order for the specified algorithm. This
* may be different than the order of providers returned by
* {@link Security#getProviders() Security.getProviders()}.
--- a/jdk/src/java.base/share/classes/javax/crypto/SecretKeyFactory.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/javax/crypto/SecretKeyFactory.java Wed Jul 05 21:35:27 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2015, 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
@@ -139,7 +139,8 @@
*
* @implNote
* The JDK Reference Implementation additionally uses the
- * {@code jdk.security.provider.preferred} property to determine
+ * {@code jdk.security.provider.preferred}
+ * {@link Security#getProperty(String) Security} property to determine
* the preferred provider order for the specified algorithm. This
* may be different than the order of providers returned by
* {@link Security#getProviders() Security.getProviders()}.
--- a/jdk/src/java.base/share/classes/javax/net/ssl/KeyManagerFactory.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/javax/net/ssl/KeyManagerFactory.java Wed Jul 05 21:35:27 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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,8 @@
*
* @implNote
* The JDK Reference Implementation additionally uses the
- * {@code jdk.security.provider.preferred} property to determine
+ * {@code jdk.security.provider.preferred}
+ * {@link Security#getProperty(String) Security} property to determine
* the preferred provider order for the specified algorithm. This
* may be different than the order of providers returned by
* {@link Security#getProviders() Security.getProviders()}.
--- a/jdk/src/java.base/share/classes/javax/net/ssl/SSLContext.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/javax/net/ssl/SSLContext.java Wed Jul 05 21:35:27 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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
@@ -138,7 +138,8 @@
*
* @implNote
* The JDK Reference Implementation additionally uses the
- * {@code jdk.security.provider.preferred} property to determine
+ * {@code jdk.security.provider.preferred}
+ * {@link Security#getProperty(String) Security} property to determine
* the preferred provider order for the specified algorithm. This
* may be different than the order of providers returned by
* {@link Security#getProviders() Security.getProviders()}.
--- a/jdk/src/java.base/share/classes/javax/net/ssl/TrustManagerFactory.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/javax/net/ssl/TrustManagerFactory.java Wed Jul 05 21:35:27 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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
@@ -132,7 +132,8 @@
*
* @implNote
* The JDK Reference Implementation additionally uses the
- * {@code jdk.security.provider.preferred} property to determine
+ * {@code jdk.security.provider.preferred}
+ * {@link Security#getProperty(String) Security} property to determine
* the preferred provider order for the specified algorithm. This
* may be different than the order of providers returned by
* {@link Security#getProviders() Security.getProviders()}.
--- a/jdk/src/java.base/share/classes/javax/security/auth/login/Configuration.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/javax/security/auth/login/Configuration.java Wed Jul 05 21:35:27 2017 +0200
@@ -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
@@ -313,7 +313,8 @@
*
* @implNote
* The JDK Reference Implementation additionally uses the
- * {@code jdk.security.provider.preferred} property to determine
+ * {@code jdk.security.provider.preferred}
+ * {@link Security#getProperty(String) Security} property to determine
* the preferred provider order for the specified algorithm. This
* may be different than the order of providers returned by
* {@link Security#getProviders() Security.getProviders()}.
--- a/jdk/src/java.base/share/classes/jdk/internal/jimage/BasicImageReader.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/jdk/internal/jimage/BasicImageReader.java Wed Jul 05 21:35:27 2017 +0200
@@ -288,22 +288,24 @@
return buffer;
} else {
+ if (channel == null) {
+ throw new InternalError("Image file channel not open");
+ }
+
ByteBuffer buffer = ImageBufferCache.getBuffer(size);
- int read = 0;
-
+ int read;
try {
- if (channel == null) {
- throw new InternalError("Image file channel not open");
- }
-
read = channel.read(buffer, offset);
buffer.rewind();
} catch (IOException ex) {
+ ImageBufferCache.releaseBuffer(buffer);
throw new RuntimeException(ex);
}
if (read != size) {
ImageBufferCache.releaseBuffer(buffer);
+ throw new RuntimeException("Short read: " + read +
+ " instead of " + size + " bytes");
}
return buffer;
--- a/jdk/src/java.base/share/classes/jdk/internal/jimage/ImageBufferCache.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/jdk/internal/jimage/ImageBufferCache.java Wed Jul 05 21:35:27 2017 +0200
@@ -24,110 +24,112 @@
*/
package jdk.internal.jimage;
+import java.lang.ref.WeakReference;
import java.nio.ByteBuffer;
-import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
/**
* @implNote This class needs to maintain JDK 8 source compatibility.
*
* It is used internally in the JDK to implement jimage/jrtfs access,
- * but also compiled and delivered as part of the jrtfs.jar to support access
+ * but also compiled and delivered as part of the jrt-fs.jar to support access
* to the jimage file provided by the shipped JDK by tools running on JDK 8.
*/
class ImageBufferCache {
- private static final int MAX_FREE_BUFFERS = 3;
+ private static final int MAX_CACHED_BUFFERS = 3;
private static final int LARGE_BUFFER = 0x10000;
- private static final ThreadLocal<ArrayList<ImageBufferCache>>
- threadLocal = new ThreadLocal<>();
+ private static final ThreadLocal<BufferReference[]> CACHE =
+ new ThreadLocal<BufferReference[]>() {
+ @Override
+ protected BufferReference[] initialValue() {
+ // 1 extra slot to simplify logic of releaseBuffer()
+ return new BufferReference[MAX_CACHED_BUFFERS + 1];
+ }
+ };
- private final ByteBuffer buffer;
- private boolean isUsed;
+ private static ByteBuffer allocateBuffer(long size) {
+ return ByteBuffer.allocateDirect((int)((size + 0xFFF) & ~0xFFF));
+ }
static ByteBuffer getBuffer(long size) {
if (size < 0 || Integer.MAX_VALUE < size) {
throw new IndexOutOfBoundsException("size");
}
- ByteBuffer buffer = null;
+ ByteBuffer result = null;
if (size > LARGE_BUFFER) {
- buffer = ByteBuffer.allocateDirect((int)((size + 0xFFF) & ~0xFFF));
+ result = allocateBuffer(size);
} else {
- ArrayList<ImageBufferCache> buffers = threadLocal.get();
+ BufferReference[] cache = CACHE.get();
+
+ // buffers are ordered by decreasing capacity
+ // cache[MAX_CACHED_BUFFERS] is always null
+ for (int i = MAX_CACHED_BUFFERS - 1; i >= 0; i--) {
+ BufferReference reference = cache[i];
- if (buffers == null) {
- buffers = new ArrayList<>(MAX_FREE_BUFFERS);
- threadLocal.set(buffers);
+ if (reference != null) {
+ ByteBuffer buffer = reference.get();
+
+ if (buffer != null && size <= buffer.capacity()) {
+ cache[i] = null;
+ result = buffer;
+ result.rewind();
+ break;
+ }
+ }
}
- int i = 0, j = buffers.size();
- for (ImageBufferCache imageBuffer : buffers) {
- if (size <= imageBuffer.capacity()) {
- j = i;
-
- if (!imageBuffer.isUsed) {
- imageBuffer.isUsed = true;
- buffer = imageBuffer.buffer;
-
- break;
- }
- } else {
- break;
- }
-
- i++;
- }
-
- if (buffer == null) {
- ImageBufferCache imageBuffer = new ImageBufferCache((int)size);
- buffers.add(j, imageBuffer);
- buffer = imageBuffer.buffer;
+ if (result == null) {
+ result = allocateBuffer(size);
}
}
- buffer.rewind();
- buffer.limit((int)size);
+ result.limit((int)size);
- return buffer;
+ return result;
}
static void releaseBuffer(ByteBuffer buffer) {
- ArrayList<ImageBufferCache> buffers = threadLocal.get();
-
- if (buffers == null) {
- return;
- }
-
if (buffer.capacity() > LARGE_BUFFER) {
return;
}
- int i = 0, j = buffers.size();
- for (ImageBufferCache imageBuffer : buffers) {
- if (!imageBuffer.isUsed) {
- j = Math.min(j, i);
- }
+ BufferReference[] cache = CACHE.get();
- if (imageBuffer.buffer == buffer) {
- imageBuffer.isUsed = false;
- j = Math.min(j, i);
-
- break;
+ // expunge cleared BufferRef(s)
+ for (int i = 0; i < MAX_CACHED_BUFFERS; i++) {
+ BufferReference reference = cache[i];
+ if (reference != null && reference.get() == null) {
+ cache[i] = null;
}
}
- if (buffers.size() > MAX_FREE_BUFFERS && j != buffers.size()) {
- buffers.remove(j);
- }
+ // insert buffer back with new BufferRef wrapping it
+ cache[MAX_CACHED_BUFFERS] = new BufferReference(buffer);
+ Arrays.sort(cache, DECREASING_CAPACITY_NULLS_LAST);
+ // squeeze the smallest one out
+ cache[MAX_CACHED_BUFFERS] = null;
}
- private ImageBufferCache(int needed) {
- this.buffer = ByteBuffer.allocateDirect((needed + 0xFFF) & ~0xFFF);
- this.isUsed = true;
- this.buffer.limit(needed);
- }
+ private static Comparator<BufferReference> DECREASING_CAPACITY_NULLS_LAST =
+ new Comparator<BufferReference>() {
+ @Override
+ public int compare(BufferReference br1, BufferReference br2) {
+ return Integer.compare(br2 == null ? 0 : br2.capacity,
+ br1 == null ? 0 : br1.capacity);
+ }
+ };
- private long capacity() {
- return buffer.capacity();
+ private static class BufferReference extends WeakReference<ByteBuffer> {
+ // saved capacity so that DECREASING_CAPACITY_NULLS_LAST comparator
+ // is stable in the presence of GC clearing the WeakReference concurrently
+ final int capacity;
+
+ BufferReference(ByteBuffer buffer) {
+ super(buffer);
+ capacity = buffer.capacity();
+ }
}
}
--- a/jdk/src/java.base/share/classes/jdk/internal/jimage/ImageReader.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/jdk/internal/jimage/ImageReader.java Wed Jul 05 21:35:27 2017 +0200
@@ -136,7 +136,7 @@
private final BasicFileAttributes fileAttrs;
private boolean completed;
- Node(String name, BasicFileAttributes fileAttrs) {
+ protected Node(String name, BasicFileAttributes fileAttrs) {
this.name = Objects.requireNonNull(name);
this.fileAttrs = Objects.requireNonNull(fileAttrs);
}
--- a/jdk/src/java.base/share/classes/jdk/internal/jrtfs/AbstractJrtFileAttributes.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,84 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * 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.internal.jrtfs;
-
-import java.nio.file.attribute.BasicFileAttributes;
-import java.util.Formatter;
-
-/**
- * Base class for file attributes supported by jrt file systems.
- *
- * @implNote This class needs to maintain JDK 8 source compatibility.
- *
- * It is used internally in the JDK to implement jimage/jrtfs access,
- * but also compiled and delivered as part of the jrtfs.jar to support access
- * to the jimage file provided by the shipped JDK by tools running on JDK 8.
- */
-public abstract class AbstractJrtFileAttributes implements BasicFileAttributes {
-
- // jrt fs specific attributes
- /**
- * Compressed resource file. If not available or not applicable, 0L is
- * returned.
- *
- * @return the compressed resource size for compressed resources.
- */
- public abstract long compressedSize();
-
- /**
- * "file" extension of a file resource.
- *
- * @return extension string for the file resource
- */
- public abstract String extension();
-
- @Override
- public final String toString() {
- StringBuilder sb = new StringBuilder(1024);
- try (Formatter fm = new Formatter(sb)) {
- if (creationTime() != null) {
- fm.format(" creationTime : %tc%n", creationTime().toMillis());
- } else {
- fm.format(" creationTime : null%n");
- }
-
- if (lastAccessTime() != null) {
- fm.format(" lastAccessTime : %tc%n", lastAccessTime().toMillis());
- } else {
- fm.format(" lastAccessTime : null%n");
- }
- fm.format(" lastModifiedTime: %tc%n", lastModifiedTime().toMillis());
- fm.format(" isRegularFile : %b%n", isRegularFile());
- fm.format(" isDirectory : %b%n", isDirectory());
- fm.format(" isSymbolicLink : %b%n", isSymbolicLink());
- fm.format(" isOther : %b%n", isOther());
- fm.format(" fileKey : %s%n", fileKey());
- fm.format(" size : %d%n", size());
- fm.format(" compressedSize : %d%n", compressedSize());
- fm.format(" extension : %s%n", extension());
- }
- return sb.toString();
- }
-}
--- a/jdk/src/java.base/share/classes/jdk/internal/jrtfs/AbstractJrtFileSystem.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,372 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * 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.internal.jrtfs;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.nio.ByteBuffer;
-import java.nio.channels.Channels;
-import java.nio.channels.FileChannel;
-import java.nio.channels.NonWritableChannelException;
-import java.nio.channels.ReadableByteChannel;
-import java.nio.channels.SeekableByteChannel;
-import java.nio.charset.Charset;
-import java.nio.file.ClosedFileSystemException;
-import java.nio.file.CopyOption;
-import java.nio.file.FileStore;
-import java.nio.file.FileSystem;
-import java.nio.file.FileSystemNotFoundException;
-import java.nio.file.Files;
-import java.nio.file.LinkOption;
-import java.nio.file.OpenOption;
-import java.nio.file.Path;
-import java.nio.file.PathMatcher;
-import java.nio.file.ReadOnlyFileSystemException;
-import java.nio.file.StandardOpenOption;
-import java.nio.file.WatchService;
-import java.nio.file.attribute.FileAttribute;
-import java.nio.file.attribute.FileTime;
-import java.nio.file.attribute.UserPrincipalLookupService;
-import java.nio.file.spi.FileSystemProvider;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-import java.util.regex.Pattern;
-
-/**
- * Base class for jrt file systems. jrt filesystem implementations are currently
- * available on top of .jimage file and on top "exploded" build directories.
- *
- * @implNote This class needs to maintain JDK 8 source compatibility.
- *
- * It is used internally in the JDK to implement jimage/jrtfs access,
- * but also compiled and delivered as part of the jrtfs.jar to support access
- * to the jimage file provided by the shipped JDK by tools running on JDK 8.
- */
-abstract class AbstractJrtFileSystem extends FileSystem {
-
- private final JrtFileSystemProvider provider;
-
- AbstractJrtFileSystem(JrtFileSystemProvider provider, Map<String, ?> options) {
- this.provider = provider;
- }
-
- private static final Charset UTF_8 = Charset.forName("UTF-8");
-
- // static utility methods
- static ReadOnlyFileSystemException readOnly() {
- return new ReadOnlyFileSystemException();
- }
-
- // if a Path does not exist, throw exception
- static void checkExists(Path path) {
- if (Files.notExists(path)) {
- throw new FileSystemNotFoundException(path.toString());
- }
- }
-
- static byte[] getBytes(String name) {
- return name.getBytes(UTF_8);
- }
-
- static String getString(byte[] name) {
- return new String(name, UTF_8);
- }
-
- // do the supplied options imply that we have to chase symlinks?
- static boolean followLinks(LinkOption... options) {
- if (options != null) {
- for (LinkOption lo : options) {
- if (lo == LinkOption.NOFOLLOW_LINKS) {
- return false;
- } else if (lo == null) {
- throw new NullPointerException();
- } else {
- throw new AssertionError("should not reach here");
- }
- }
- }
- return true;
- }
-
- // check that the options passed are supported by (read-only) jrt file system
- static void checkOptions(Set<? extends OpenOption> options) {
- // check for options of null type and option is an intance of StandardOpenOption
- for (OpenOption option : options) {
- if (option == null) {
- throw new NullPointerException();
- }
- if (!(option instanceof StandardOpenOption)) {
- throw new IllegalArgumentException();
- }
- }
-
- if (options.contains(StandardOpenOption.WRITE)
- || options.contains(StandardOpenOption.APPEND)) {
- throw readOnly();
- }
- }
-
- // FileSystem method implementations
- @Override
- public FileSystemProvider provider() {
- return provider;
- }
-
- @Override
- public Iterable<Path> getRootDirectories() {
- ArrayList<Path> pathArr = new ArrayList<>();
- pathArr.add(getRootPath());
- return pathArr;
- }
-
- @Override
- public AbstractJrtPath getPath(String first, String... more) {
- String path;
- if (more.length == 0) {
- path = first;
- } else {
- StringBuilder sb = new StringBuilder();
- sb.append(first);
- for (String segment : more) {
- if (segment.length() > 0) {
- if (sb.length() > 0) {
- sb.append('/');
- }
- sb.append(segment);
- }
- }
- path = sb.toString();
- }
- return getRootPath().newJrtPath(getBytes(path));
- }
-
- @Override
- public final boolean isReadOnly() {
- return true;
- }
-
- @Override
- public final UserPrincipalLookupService getUserPrincipalLookupService() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public final WatchService newWatchService() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public final Iterable<FileStore> getFileStores() {
- ArrayList<FileStore> list = new ArrayList<>(1);
- list.add(getFileStore(getRootPath()));
- return list;
- }
-
- private static final Set<String> supportedFileAttributeViews
- = Collections.unmodifiableSet(
- new HashSet<String>(Arrays.asList("basic", "jrt")));
-
- @Override
- public final Set<String> supportedFileAttributeViews() {
- return supportedFileAttributeViews;
- }
-
- @Override
- public final String toString() {
- return "jrt:/";
- }
-
- @Override
- public final String getSeparator() {
- return "/";
- }
-
- private static final String GLOB_SYNTAX = "glob";
- private static final String REGEX_SYNTAX = "regex";
-
- @Override
- public PathMatcher getPathMatcher(String syntaxAndInput) {
- int pos = syntaxAndInput.indexOf(':');
- if (pos <= 0 || pos == syntaxAndInput.length()) {
- throw new IllegalArgumentException();
- }
- String syntax = syntaxAndInput.substring(0, pos);
- String input = syntaxAndInput.substring(pos + 1);
- String expr;
- if (syntax.equalsIgnoreCase(GLOB_SYNTAX)) {
- expr = JrtUtils.toRegexPattern(input);
- } else {
- if (syntax.equalsIgnoreCase(REGEX_SYNTAX)) {
- expr = input;
- } else {
- throw new UnsupportedOperationException("Syntax '" + syntax
- + "' not recognized");
- }
- }
- // return matcher
- final Pattern pattern = Pattern.compile(expr);
- return (Path path) -> pattern.matcher(path.toString()).matches();
- }
-
- // These methods throw read only file system exception
- final void setTimes(AbstractJrtPath jrtPath, FileTime mtime, FileTime atime, FileTime ctime)
- throws IOException {
- throw readOnly();
- }
-
- final void createDirectory(AbstractJrtPath jrtPath, FileAttribute<?>... attrs) throws IOException {
- throw readOnly();
- }
-
- final void deleteFile(AbstractJrtPath jrtPath, boolean failIfNotExists)
- throws IOException {
- throw readOnly();
- }
-
- final OutputStream newOutputStream(AbstractJrtPath jrtPath, OpenOption... options)
- throws IOException {
- throw readOnly();
- }
-
- final void copyFile(boolean deletesrc, AbstractJrtPath srcPath, AbstractJrtPath dstPath, CopyOption... options)
- throws IOException {
- throw readOnly();
- }
-
- final FileChannel newFileChannel(AbstractJrtPath jrtPath,
- Set<? extends OpenOption> options,
- FileAttribute<?>... attrs)
- throws IOException {
- throw new UnsupportedOperationException("newFileChannel");
- }
-
- final InputStream newInputStream(AbstractJrtPath jrtPath) throws IOException {
- return new ByteArrayInputStream(getFileContent(jrtPath));
- }
-
- final SeekableByteChannel newByteChannel(AbstractJrtPath jrtPath,
- Set<? extends OpenOption> options,
- FileAttribute<?>... attrs)
- throws IOException {
- checkOptions(options);
-
- byte[] buf = getFileContent(jrtPath);
- final ReadableByteChannel rbc
- = Channels.newChannel(new ByteArrayInputStream(buf));
- final long size = buf.length;
- return new SeekableByteChannel() {
- long read = 0;
-
- @Override
- public boolean isOpen() {
- return rbc.isOpen();
- }
-
- @Override
- public long position() throws IOException {
- return read;
- }
-
- @Override
- public SeekableByteChannel position(long pos)
- throws IOException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public int read(ByteBuffer dst) throws IOException {
- int n = rbc.read(dst);
- if (n > 0) {
- read += n;
- }
- return n;
- }
-
- @Override
- public SeekableByteChannel truncate(long size)
- throws IOException {
- throw new NonWritableChannelException();
- }
-
- @Override
- public int write(ByteBuffer src) throws IOException {
- throw new NonWritableChannelException();
- }
-
- @Override
- public long size() throws IOException {
- return size;
- }
-
- @Override
- public void close() throws IOException {
- rbc.close();
- }
- };
- }
-
- final JrtFileStore getFileStore(AbstractJrtPath jrtPath) {
- return new JrtFileStore(jrtPath);
- }
-
- final void ensureOpen() throws IOException {
- if (!isOpen()) {
- throw new ClosedFileSystemException();
- }
- }
-
- // abstract methods to be implemented by a particular jrt file system
- abstract AbstractJrtPath getRootPath();
-
- abstract boolean isSameFile(AbstractJrtPath jrtPath1, AbstractJrtPath jrtPath2) throws IOException;
-
- abstract boolean isLink(AbstractJrtPath jrtPath) throws IOException;
-
- abstract AbstractJrtPath resolveLink(AbstractJrtPath jrtPath) throws IOException;
-
- abstract AbstractJrtFileAttributes getFileAttributes(AbstractJrtPath jrtPath, LinkOption... options) throws IOException;
-
- abstract boolean exists(AbstractJrtPath jrtPath) throws IOException;
-
- abstract boolean isDirectory(AbstractJrtPath jrtPath, boolean resolveLinks) throws IOException;
-
- /**
- * returns the list of child paths of the given directory "path"
- *
- * @param path name of the directory whose content is listed
- * @return iterator for child paths of the given directory path
- */
- abstract Iterator<Path> iteratorOf(AbstractJrtPath jrtPath) throws IOException;
-
- // returns the content of the file resource specified by the path
- abstract byte[] getFileContent(AbstractJrtPath jrtPath) throws IOException;
-}
--- a/jdk/src/java.base/share/classes/jdk/internal/jrtfs/AbstractJrtPath.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,935 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * 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.internal.jrtfs;
-
-import java.io.*;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.nio.channels.*;
-import java.nio.file.*;
-import java.nio.file.DirectoryStream.Filter;
-import java.nio.file.attribute.*;
-import java.util.*;
-import static java.nio.file.StandardOpenOption.*;
-import static java.nio.file.StandardCopyOption.*;
-
-/**
- * Base class for Path implementation of jrt file systems.
- *
- * @implNote This class needs to maintain JDK 8 source compatibility.
- *
- * It is used internally in the JDK to implement jimage/jrtfs access,
- * but also compiled and delivered as part of the jrtfs.jar to support access
- * to the jimage file provided by the shipped JDK by tools running on JDK 8.
- */
-abstract class AbstractJrtPath implements Path {
-
- protected final AbstractJrtFileSystem jrtfs;
- private final byte[] path;
- private volatile int[] offsets;
- private int hashcode = 0; // cached hashcode (created lazily)
-
- AbstractJrtPath(AbstractJrtFileSystem jrtfs, byte[] path) {
- this(jrtfs, path, false);
- this.resolved = null;
- }
-
- AbstractJrtPath(AbstractJrtFileSystem jrtfs, byte[] path, boolean normalized) {
- this.resolved = null;
- this.jrtfs = jrtfs;
- if (normalized) {
- this.path = path;
- } else {
- this.path = normalize(path);
- }
- }
-
- // factory methods to create subtypes of AbstractJrtPath
- protected abstract AbstractJrtPath newJrtPath(byte[] path);
-
- protected abstract AbstractJrtPath newJrtPath(byte[] path, boolean normalized);
-
- final byte[] getName() {
- return path;
- }
-
- @Override
- public final AbstractJrtPath getRoot() {
- if (this.isAbsolute()) {
- return jrtfs.getRootPath();
- } else {
- return null;
- }
- }
-
- @Override
- public final AbstractJrtPath getFileName() {
- initOffsets();
- int count = offsets.length;
- if (count == 0) {
- return null; // no elements so no name
- }
- if (count == 1 && path[0] != '/') {
- return this;
- }
- int lastOffset = offsets[count - 1];
- int len = path.length - lastOffset;
- byte[] result = new byte[len];
- System.arraycopy(path, lastOffset, result, 0, len);
- return newJrtPath(result);
- }
-
- @Override
- public final AbstractJrtPath getParent() {
- initOffsets();
- int count = offsets.length;
- if (count == 0) // no elements so no parent
- {
- return null;
- }
- int len = offsets[count - 1] - 1;
- if (len <= 0) // parent is root only (may be null)
- {
- return getRoot();
- }
- byte[] result = new byte[len];
- System.arraycopy(path, 0, result, 0, len);
- return newJrtPath(result);
- }
-
- @Override
- public final int getNameCount() {
- initOffsets();
- return offsets.length;
- }
-
- @Override
- public final AbstractJrtPath getName(int index) {
- initOffsets();
- if (index < 0 || index >= offsets.length) {
- throw new IllegalArgumentException();
- }
- int begin = offsets[index];
- int len;
- if (index == (offsets.length - 1)) {
- len = path.length - begin;
- } else {
- len = offsets[index + 1] - begin - 1;
- }
- // construct result
- byte[] result = new byte[len];
- System.arraycopy(path, begin, result, 0, len);
- return newJrtPath(result);
- }
-
- @Override
- public final AbstractJrtPath subpath(int beginIndex, int endIndex) {
- initOffsets();
- if (beginIndex < 0
- || beginIndex >= offsets.length
- || endIndex > offsets.length
- || beginIndex >= endIndex) {
- throw new IllegalArgumentException();
- }
-
- // starting offset and length
- int begin = offsets[beginIndex];
- int len;
- if (endIndex == offsets.length) {
- len = path.length - begin;
- } else {
- len = offsets[endIndex] - begin - 1;
- }
- // construct result
- byte[] result = new byte[len];
- System.arraycopy(path, begin, result, 0, len);
- return newJrtPath(result);
- }
-
- @Override
- public final AbstractJrtPath toRealPath(LinkOption... options) throws IOException {
- AbstractJrtPath realPath = newJrtPath(getResolvedPath()).toAbsolutePath();
- realPath = JrtFileSystem.followLinks(options) ? jrtfs.resolveLink(this) : realPath;
- realPath.checkAccess();
- return realPath;
- }
-
- final AbstractJrtPath readSymbolicLink() throws IOException {
- if (!jrtfs.isLink(this)) {
- throw new IOException("not a symbolic link");
- }
-
- return jrtfs.resolveLink(this);
- }
-
- final boolean isHidden() {
- return false;
- }
-
- @Override
- public final AbstractJrtPath toAbsolutePath() {
- if (isAbsolute()) {
- return this;
- } else {
- //add / bofore the existing path
- byte[] tmp = new byte[path.length + 1];
- tmp[0] = '/';
- System.arraycopy(path, 0, tmp, 1, path.length);
- return newJrtPath(tmp).normalize();
- }
- }
-
- @Override
- public final URI toUri() {
- try {
- return new URI("jrt",
- JrtFileSystem.getString(toAbsolutePath().path),
- null);
- } catch (URISyntaxException ex) {
- throw new AssertionError(ex);
- }
- }
-
- private boolean equalsNameAt(AbstractJrtPath other, int index) {
- int mbegin = offsets[index];
- int mlen;
- if (index == (offsets.length - 1)) {
- mlen = path.length - mbegin;
- } else {
- mlen = offsets[index + 1] - mbegin - 1;
- }
- int obegin = other.offsets[index];
- int olen;
- if (index == (other.offsets.length - 1)) {
- olen = other.path.length - obegin;
- } else {
- olen = other.offsets[index + 1] - obegin - 1;
- }
- if (mlen != olen) {
- return false;
- }
- int n = 0;
- while (n < mlen) {
- if (path[mbegin + n] != other.path[obegin + n]) {
- return false;
- }
- n++;
- }
- return true;
- }
-
- @Override
- public final AbstractJrtPath relativize(Path other) {
- final AbstractJrtPath o = checkPath(other);
- if (o.equals(this)) {
- return newJrtPath(new byte[0], true);
- }
- if (/* this.getFileSystem() != o.getFileSystem() || */this.isAbsolute() != o.isAbsolute()) {
- throw new IllegalArgumentException();
- }
- int mc = this.getNameCount();
- int oc = o.getNameCount();
- int n = Math.min(mc, oc);
- int i = 0;
- while (i < n) {
- if (!equalsNameAt(o, i)) {
- break;
- }
- i++;
- }
- int dotdots = mc - i;
- int len = dotdots * 3 - 1;
- if (i < oc) {
- len += (o.path.length - o.offsets[i] + 1);
- }
- byte[] result = new byte[len];
-
- int pos = 0;
- while (dotdots > 0) {
- result[pos++] = (byte) '.';
- result[pos++] = (byte) '.';
- if (pos < len) // no tailing slash at the end
- {
- result[pos++] = (byte) '/';
- }
- dotdots--;
- }
- if (i < oc) {
- System.arraycopy(o.path, o.offsets[i],
- result, pos,
- o.path.length - o.offsets[i]);
- }
- return newJrtPath(result);
- }
-
- @Override
- public AbstractJrtFileSystem getFileSystem() {
- return jrtfs;
- }
-
- @Override
- public final boolean isAbsolute() {
- return (this.path.length > 0 && path[0] == '/');
- }
-
- @Override
- public final AbstractJrtPath resolve(Path other) {
- final AbstractJrtPath o = checkPath(other);
- if (o.isAbsolute()) {
- return o;
- }
- byte[] res;
- if (this.path[path.length - 1] == '/') {
- res = new byte[path.length + o.path.length];
- System.arraycopy(path, 0, res, 0, path.length);
- System.arraycopy(o.path, 0, res, path.length, o.path.length);
- } else {
- res = new byte[path.length + 1 + o.path.length];
- System.arraycopy(path, 0, res, 0, path.length);
- res[path.length] = '/';
- System.arraycopy(o.path, 0, res, path.length + 1, o.path.length);
- }
- return newJrtPath(res);
- }
-
- @Override
- public final Path resolveSibling(Path other) {
- if (other == null) {
- throw new NullPointerException();
- }
- Path parent = getParent();
- return (parent == null) ? other : parent.resolve(other);
- }
-
- @Override
- public final boolean startsWith(Path other) {
- final AbstractJrtPath o = checkPath(other);
- if (o.isAbsolute() != this.isAbsolute()
- || o.path.length > this.path.length) {
- return false;
- }
- int olast = o.path.length;
- for (int i = 0; i < olast; i++) {
- if (o.path[i] != this.path[i]) {
- return false;
- }
- }
- olast--;
- return o.path.length == this.path.length
- || o.path[olast] == '/'
- || this.path[olast + 1] == '/';
- }
-
- @Override
- public final boolean endsWith(Path other) {
- final AbstractJrtPath o = checkPath(other);
- int olast = o.path.length - 1;
- if (olast > 0 && o.path[olast] == '/') {
- olast--;
- }
- int last = this.path.length - 1;
- if (last > 0 && this.path[last] == '/') {
- last--;
- }
- if (olast == -1) // o.path.length == 0
- {
- return last == -1;
- }
- if ((o.isAbsolute() && (!this.isAbsolute() || olast != last))
- || (last < olast)) {
- return false;
- }
- for (; olast >= 0; olast--, last--) {
- if (o.path[olast] != this.path[last]) {
- return false;
- }
- }
- return o.path[olast + 1] == '/'
- || last == -1 || this.path[last] == '/';
- }
-
- @Override
- public final AbstractJrtPath resolve(String other) {
- return resolve(getFileSystem().getPath(other));
- }
-
- @Override
- public final Path resolveSibling(String other) {
- return resolveSibling(getFileSystem().getPath(other));
- }
-
- @Override
- public final boolean startsWith(String other) {
- return startsWith(getFileSystem().getPath(other));
- }
-
- @Override
- public final boolean endsWith(String other) {
- return endsWith(getFileSystem().getPath(other));
- }
-
- @Override
- public final AbstractJrtPath normalize() {
- byte[] res = getResolved();
- if (res == path) // no change
- {
- return this;
- }
- return newJrtPath(res, true);
- }
-
- private AbstractJrtPath checkPath(Path path) {
- if (path == null) {
- throw new NullPointerException();
- }
- if (!(path instanceof AbstractJrtPath)) {
- throw new ProviderMismatchException();
- }
- return (AbstractJrtPath) path;
- }
-
- // create offset list if not already created
- private void initOffsets() {
- if (offsets == null) {
- int count, index;
- // count names
- count = 0;
- index = 0;
- while (index < path.length) {
- byte c = path[index++];
- if (c != '/') {
- count++;
- while (index < path.length && path[index] != '/') {
- index++;
- }
- }
- }
- // populate offsets
- int[] result = new int[count];
- count = 0;
- index = 0;
- while (index < path.length) {
- byte c = path[index];
- if (c == '/') {
- index++;
- } else {
- result[count++] = index++;
- while (index < path.length && path[index] != '/') {
- index++;
- }
- }
- }
- synchronized (this) {
- if (offsets == null) {
- offsets = result;
- }
- }
- }
- }
-
- private volatile byte[] resolved;
-
- final byte[] getResolvedPath() {
- byte[] r = resolved;
- if (r == null) {
- if (isAbsolute()) {
- r = getResolved();
- } else {
- r = toAbsolutePath().getResolvedPath();
- }
- resolved = r;
- }
- return resolved;
- }
-
- // removes redundant slashs, replace "\" to separator "/"
- // and check for invalid characters
- private static byte[] normalize(byte[] path) {
- if (path.length == 0) {
- return path;
- }
- byte prevC = 0;
- for (int i = 0; i < path.length; i++) {
- byte c = path[i];
- if (c == '\\') {
- return normalize(path, i);
- }
- if (c == (byte) '/' && prevC == '/') {
- return normalize(path, i - 1);
- }
- if (c == '\u0000') {
- throw new InvalidPathException(JrtFileSystem.getString(path),
- "Path: nul character not allowed");
- }
- prevC = c;
- }
-
- if (path.length > 1 && path[path.length - 1] == '/') {
- return Arrays.copyOf(path, path.length - 1);
- }
-
- return path;
- }
-
- private static byte[] normalize(byte[] path, int off) {
- byte[] to = new byte[path.length];
- int n = 0;
- while (n < off) {
- to[n] = path[n];
- n++;
- }
- int m = n;
- byte prevC = 0;
- while (n < path.length) {
- byte c = path[n++];
- if (c == (byte) '\\') {
- c = (byte) '/';
- }
- if (c == (byte) '/' && prevC == (byte) '/') {
- continue;
- }
- if (c == '\u0000') {
- throw new InvalidPathException(JrtFileSystem.getString(path),
- "Path: nul character not allowed");
- }
- to[m++] = c;
- prevC = c;
- }
- if (m > 1 && to[m - 1] == '/') {
- m--;
- }
- return (m == to.length) ? to : Arrays.copyOf(to, m);
- }
-
- // Remove DotSlash(./) and resolve DotDot (..) components
- private byte[] getResolved() {
- if (path.length == 0) {
- return path;
- }
- for (int i = 0; i < path.length; i++) {
- byte c = path[i];
- if (c == (byte) '.') {
- return resolve0();
- }
- }
-
- return path;
- }
-
- // TBD: performance, avoid initOffsets
- private byte[] resolve0() {
- byte[] to = new byte[path.length];
- int nc = getNameCount();
- int[] lastM = new int[nc];
- int lastMOff = -1;
- int m = 0;
- for (int i = 0; i < nc; i++) {
- int n = offsets[i];
- int len = (i == offsets.length - 1)
- ? (path.length - n) : (offsets[i + 1] - n - 1);
- if (len == 1 && path[n] == (byte) '.') {
- if (m == 0 && path[0] == '/') // absolute path
- {
- to[m++] = '/';
- }
- continue;
- }
- if (len == 2 && path[n] == '.' && path[n + 1] == '.') {
- if (lastMOff >= 0) {
- m = lastM[lastMOff--]; // retreat
- continue;
- }
- if (path[0] == '/') { // "/../xyz" skip
- if (m == 0) {
- to[m++] = '/';
- }
- } else { // "../xyz" -> "../xyz"
- if (m != 0 && to[m - 1] != '/') {
- to[m++] = '/';
- }
- while (len-- > 0) {
- to[m++] = path[n++];
- }
- }
- continue;
- }
- if (m == 0 && path[0] == '/' || // absolute path
- m != 0 && to[m - 1] != '/') { // not the first name
- to[m++] = '/';
- }
- lastM[++lastMOff] = m;
- while (len-- > 0) {
- to[m++] = path[n++];
- }
- }
- if (m > 1 && to[m - 1] == '/') {
- m--;
- }
- return (m == to.length) ? to : Arrays.copyOf(to, m);
- }
-
- @Override
- public final String toString() {
- return JrtFileSystem.getString(path);
- }
-
- @Override
- public final int hashCode() {
- int h = hashcode;
- if (h == 0) {
- hashcode = h = Arrays.hashCode(path);
- }
- return h;
- }
-
- @Override
- public final boolean equals(Object obj) {
- return obj != null
- && obj instanceof AbstractJrtPath
- && this.jrtfs == ((AbstractJrtPath) obj).jrtfs
- && compareTo((Path) obj) == 0;
- }
-
- @Override
- public final int compareTo(Path other) {
- final AbstractJrtPath o = checkPath(other);
- int len1 = this.path.length;
- int len2 = o.path.length;
-
- int n = Math.min(len1, len2);
- byte v1[] = this.path;
- byte v2[] = o.path;
-
- int k = 0;
- while (k < n) {
- int c1 = v1[k] & 0xff;
- int c2 = v2[k] & 0xff;
- if (c1 != c2) {
- return c1 - c2;
- }
- k++;
- }
- return len1 - len2;
- }
-
- @Override
- public final WatchKey register(
- WatchService watcher,
- WatchEvent.Kind<?>[] events,
- WatchEvent.Modifier... modifiers) {
- if (watcher == null || events == null || modifiers == null) {
- throw new NullPointerException();
- }
- throw new UnsupportedOperationException();
- }
-
- @Override
- public final WatchKey register(WatchService watcher, WatchEvent.Kind<?>... events) {
- return register(watcher, events, new WatchEvent.Modifier[0]);
- }
-
- @Override
- public final File toFile() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public final Iterator<Path> iterator() {
- return new Iterator<Path>() {
- private int i = 0;
-
- @Override
- public boolean hasNext() {
- return (i < getNameCount());
- }
-
- @Override
- public Path next() {
- if (i < getNameCount()) {
- Path result = getName(i);
- i++;
- return result;
- } else {
- throw new NoSuchElementException();
- }
- }
-
- @Override
- public void remove() {
- throw new ReadOnlyFileSystemException();
- }
- };
- }
-
- /////////////////////////////////////////////////////////////////////
- // Helpers for JrtFileSystemProvider and JrtFileSystem
- final int getPathLength() {
- return path.length;
- }
-
- final void createDirectory(FileAttribute<?>... attrs)
- throws IOException {
- jrtfs.createDirectory(this, attrs);
- }
-
- final InputStream newInputStream(OpenOption... options) throws IOException {
- if (options.length > 0) {
- for (OpenOption opt : options) {
- if (opt != READ) {
- throw new UnsupportedOperationException("'" + opt + "' not allowed");
- }
- }
- }
- return jrtfs.newInputStream(this);
- }
-
- final DirectoryStream<Path> newDirectoryStream(Filter<? super Path> filter)
- throws IOException {
- return new JrtDirectoryStream(this, filter);
- }
-
- final void delete() throws IOException {
- jrtfs.deleteFile(this, true);
- }
-
- final void deleteIfExists() throws IOException {
- jrtfs.deleteFile(this, false);
- }
-
- final AbstractJrtFileAttributes getAttributes(LinkOption... options) throws IOException {
- AbstractJrtFileAttributes zfas = jrtfs.getFileAttributes(this, options);
- if (zfas == null) {
- throw new NoSuchFileException(toString());
- }
- return zfas;
- }
-
- final void setAttribute(String attribute, Object value, LinkOption... options)
- throws IOException {
- String type;
- String attr;
- int colonPos = attribute.indexOf(':');
- if (colonPos == -1) {
- type = "basic";
- attr = attribute;
- } else {
- type = attribute.substring(0, colonPos++);
- attr = attribute.substring(colonPos);
- }
- JrtFileAttributeView view = JrtFileAttributeView.get(this, type, options);
- if (view == null) {
- throw new UnsupportedOperationException("view <" + view + "> is not supported");
- }
- view.setAttribute(attr, value);
- }
-
- final void setTimes(FileTime mtime, FileTime atime, FileTime ctime)
- throws IOException {
- jrtfs.setTimes(this, mtime, atime, ctime);
- }
-
- final Map<String, Object> readAttributes(String attributes, LinkOption... options)
- throws IOException {
- String view;
- String attrs;
- int colonPos = attributes.indexOf(':');
- if (colonPos == -1) {
- view = "basic";
- attrs = attributes;
- } else {
- view = attributes.substring(0, colonPos++);
- attrs = attributes.substring(colonPos);
- }
- JrtFileAttributeView jrtfv = JrtFileAttributeView.get(this, view, options);
- if (jrtfv == null) {
- throw new UnsupportedOperationException("view not supported");
- }
- return jrtfv.readAttributes(attrs);
- }
-
- final FileStore getFileStore() throws IOException {
- // each JrtFileSystem only has one root (as requested for now)
- if (exists()) {
- return jrtfs.getFileStore(this);
- }
- throw new NoSuchFileException(JrtFileSystem.getString(path));
- }
-
- final boolean isSameFile(Path other) throws IOException {
- if (this.equals(other)) {
- return true;
- }
- if (other == null
- || this.getFileSystem() != other.getFileSystem()) {
- return false;
- }
- this.checkAccess();
- AbstractJrtPath target = (AbstractJrtPath) other;
- target.checkAccess();
- return Arrays.equals(this.getResolvedPath(), target.getResolvedPath())
- || jrtfs.isSameFile(this, target);
- }
-
- final SeekableByteChannel newByteChannel(Set<? extends OpenOption> options,
- FileAttribute<?>... attrs)
- throws IOException {
- return jrtfs.newByteChannel(this, options, attrs);
- }
-
- final FileChannel newFileChannel(Set<? extends OpenOption> options,
- FileAttribute<?>... attrs)
- throws IOException {
- return jrtfs.newFileChannel(this, options, attrs);
- }
-
- final void checkAccess(AccessMode... modes) throws IOException {
- boolean w = false;
- boolean x = false;
- for (AccessMode mode : modes) {
- switch (mode) {
- case READ:
- break;
- case WRITE:
- w = true;
- break;
- case EXECUTE:
- x = true;
- break;
- default:
- throw new UnsupportedOperationException();
- }
- }
-
- BasicFileAttributes attrs = jrtfs.getFileAttributes(this);
- if (attrs == null && (path.length != 1 || path[0] != '/')) {
- throw new NoSuchFileException(toString());
- }
- if (w) {
-// if (jrtfs.isReadOnly())
- throw new AccessDeniedException(toString());
- }
- if (x) {
- throw new AccessDeniedException(toString());
- }
- }
-
- final boolean exists() {
- try {
- return jrtfs.exists(this);
- } catch (IOException x) {
- }
- return false;
- }
-
- final OutputStream newOutputStream(OpenOption... options) throws IOException {
- if (options.length == 0) {
- return jrtfs.newOutputStream(this,
- CREATE_NEW, WRITE);
- }
- return jrtfs.newOutputStream(this, options);
- }
-
- final void move(AbstractJrtPath target, CopyOption... options)
- throws IOException {
- if (this.jrtfs == target.jrtfs) {
- jrtfs.copyFile(true,
- this, target,
- options);
- } else {
- copyToTarget(target, options);
- delete();
- }
- }
-
- final void copy(AbstractJrtPath target, CopyOption... options)
- throws IOException {
- if (this.jrtfs == target.jrtfs) {
- jrtfs.copyFile(false,
- this, target,
- options);
- } else {
- copyToTarget(target, options);
- }
- }
-
- private void copyToTarget(AbstractJrtPath target, CopyOption... options)
- throws IOException {
- boolean replaceExisting = false;
- boolean copyAttrs = false;
- for (CopyOption opt : options) {
- if (opt == REPLACE_EXISTING) {
- replaceExisting = true;
- } else if (opt == COPY_ATTRIBUTES) {
- copyAttrs = true;
- }
- }
- // attributes of source file
- BasicFileAttributes jrtfas = getAttributes();
- // check if target exists
- boolean exists;
- if (replaceExisting) {
- try {
- target.deleteIfExists();
- exists = false;
- } catch (DirectoryNotEmptyException x) {
- exists = true;
- }
- } else {
- exists = target.exists();
- }
- if (exists) {
- throw new FileAlreadyExistsException(target.toString());
- }
-
- if (jrtfas.isDirectory()) {
- // create directory or file
- target.createDirectory();
- } else {
- try (InputStream is = jrtfs.newInputStream(this); OutputStream os = target.newOutputStream()) {
- byte[] buf = new byte[8192];
- int n;
- while ((n = is.read(buf)) != -1) {
- os.write(buf, 0, n);
- }
- }
- }
- if (copyAttrs) {
- BasicFileAttributeView view
- = JrtFileAttributeView.get(target, BasicFileAttributeView.class);
- try {
- view.setTimes(jrtfas.lastModifiedTime(),
- jrtfas.lastAccessTime(),
- jrtfas.creationTime());
- } catch (IOException x) {
- // rollback?
- try {
- target.delete();
- } catch (IOException ignore) {
- }
- throw x;
- }
- }
- }
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/jrtfs/ExplodedImage.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,295 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.jrtfs;
+
+import java.io.IOException;
+import java.nio.file.DirectoryStream;
+import java.nio.file.FileSystem;
+import java.nio.file.FileSystemException;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.attribute.BasicFileAttributes;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import jdk.internal.jimage.ImageReader.Node;
+
+/**
+ * A jrt file system built on $JAVA_HOME/modules directory ('exploded modules
+ * build')
+ *
+ * @implNote This class needs to maintain JDK 8 source compatibility.
+ *
+ * It is used internally in the JDK to implement jimage/jrtfs access,
+ * but also compiled and delivered as part of the jrtfs.jar to support access
+ * to the jimage file provided by the shipped JDK by tools running on JDK 8.
+ */
+class ExplodedImage extends SystemImage {
+
+ private static final String MODULES = "/modules/";
+ private static final String PACKAGES = "/packages/";
+ private static final int PACKAGES_LEN = PACKAGES.length();
+
+ private final FileSystem defaultFS;
+ private final String separator;
+ private final Map<String, PathNode> nodes = Collections.synchronizedMap(new HashMap<>());
+ private final BasicFileAttributes modulesDirAttrs;
+
+ ExplodedImage(Path modulesDir) throws IOException {
+ defaultFS = FileSystems.getDefault();
+ String str = defaultFS.getSeparator();
+ separator = str.equals("/") ? null : str;
+ modulesDirAttrs = Files.readAttributes(modulesDir, BasicFileAttributes.class);
+ initNodes();
+ }
+
+ // A Node that is backed by actual default file system Path
+ private final class PathNode extends Node {
+
+ // Path in underlying default file system
+ private Path path;
+ private PathNode link;
+ private List<Node> children;
+
+ PathNode(String name, Path path, BasicFileAttributes attrs) { // path
+ super(name, attrs);
+ this.path = path;
+ }
+
+ PathNode(String name, Node link) { // link
+ super(name, link.getFileAttributes());
+ this.link = (PathNode)link;
+ }
+
+ PathNode(String name, List<Node> children) { // dir
+ super(name, modulesDirAttrs);
+ this.children = children;
+ }
+
+ @Override
+ public boolean isDirectory() {
+ return children != null ||
+ (link == null && getFileAttributes().isDirectory());
+ }
+
+ @Override
+ public boolean isLink() {
+ return link != null;
+ }
+
+ @Override
+ public PathNode resolveLink(boolean recursive) {
+ if (link == null)
+ return this;
+ return recursive && link.isLink() ? link.resolveLink(true) : link;
+ }
+
+ byte[] getContent() throws IOException {
+ if (!getFileAttributes().isRegularFile())
+ throw new FileSystemException(getName() + " is not file");
+ return Files.readAllBytes(path);
+ }
+
+ @Override
+ public List<Node> getChildren() {
+ if (!isDirectory())
+ throw new IllegalArgumentException("not a directory: " + getNameString());
+ if (children == null) {
+ List<Node> list = new ArrayList<>();
+ try (DirectoryStream<Path> stream = Files.newDirectoryStream(path)) {
+ for (Path p : stream) {
+ p = explodedModulesDir.relativize(p);
+ String pName = MODULES + nativeSlashToFrontSlash(p.toString());
+ Node node = findNode(pName);
+ if (node != null) { // findNode may choose to hide certain files!
+ list.add(node);
+ }
+ }
+ } catch (IOException x) {
+ return null;
+ }
+ children = list;
+ }
+ return children;
+ }
+ }
+
+ @Override
+ public void close() throws IOException {
+ nodes.clear();
+ }
+
+ @Override
+ public byte[] getResource(Node node) throws IOException {
+ return ((PathNode)node).getContent();
+ }
+
+ // find Node for the given Path
+ @Override
+ public synchronized Node findNode(String str) {
+ Node node = findModulesNode(str);
+ if (node != null) {
+ return node;
+ }
+ // lazily created for paths like /packages/<package>/<module>/xyz
+ // For example /packages/java.lang/java.base/java/lang/
+ if (str.startsWith(PACKAGES)) {
+ // pkgEndIdx marks end of <package> part
+ int pkgEndIdx = str.indexOf('/', PACKAGES_LEN);
+ if (pkgEndIdx != -1) {
+ // modEndIdx marks end of <module> part
+ int modEndIdx = str.indexOf('/', pkgEndIdx + 1);
+ if (modEndIdx != -1) {
+ // make sure we have such module link!
+ // ie., /packages/<package>/<module> is valid
+ Node linkNode = nodes.get(str.substring(0, modEndIdx));
+ if (linkNode == null || !linkNode.isLink()) {
+ return null;
+ }
+ // map to "/modules/zyz" path and return that node
+ // For example, "/modules/java.base/java/lang" for
+ // "/packages/java.lang/java.base/java/lang".
+ String mod = MODULES + str.substring(pkgEndIdx + 1);
+ return findModulesNode(mod);
+ }
+ }
+ }
+ return null;
+ }
+
+ // find a Node for a path that starts like "/modules/..."
+ Node findModulesNode(String str) {
+ PathNode node = nodes.get(str);
+ if (node != null) {
+ return node;
+ }
+ // lazily created "/modules/xyz/abc/" Node
+ // This is mapped to default file system path "<JDK_MODULES_DIR>/xyz/abc"
+ Path p = underlyingPath(str);
+ if (p != null) {
+ try {
+ BasicFileAttributes attrs = Files.readAttributes(p, BasicFileAttributes.class);
+ if (attrs.isRegularFile()) {
+ Path f = p.getFileName();
+ if (f.toString().startsWith("_the."))
+ return null;
+ }
+ node = new PathNode(str, p, attrs);
+ nodes.put(str, node);
+ return node;
+ } catch (IOException x) {
+ // does not exists or unable to determine
+ }
+ }
+ return null;
+ }
+
+ Path underlyingPath(String str) {
+ if (str.startsWith(MODULES)) {
+ str = frontSlashToNativeSlash(str.substring("/modules".length()));
+ return defaultFS.getPath(explodedModulesDir.toString(), str);
+ }
+ return null;
+ }
+
+ // convert "/" to platform path separator
+ private String frontSlashToNativeSlash(String str) {
+ return separator == null ? str : str.replace("/", separator);
+ }
+
+ // convert platform path separator to "/"
+ private String nativeSlashToFrontSlash(String str) {
+ return separator == null ? str : str.replace(separator, "/");
+ }
+
+ // convert "/"s to "."s
+ private String slashesToDots(String str) {
+ return str.replace(separator != null ? separator : "/", ".");
+ }
+
+ // initialize file system Nodes
+ private void initNodes() throws IOException {
+ // same package prefix may exist in mutliple modules. This Map
+ // is filled by walking "jdk modules" directory recursively!
+ Map<String, List<String>> packageToModules = new HashMap<>();
+ try (DirectoryStream<Path> stream = Files.newDirectoryStream(explodedModulesDir)) {
+ for (Path module : stream) {
+ if (Files.isDirectory(module)) {
+ String moduleName = module.getFileName().toString();
+ // make sure "/modules/<moduleName>" is created
+ findModulesNode(MODULES + moduleName);
+ Files.walk(module).filter(Files::isDirectory).forEach((p) -> {
+ p = module.relativize(p);
+ String pkgName = slashesToDots(p.toString());
+ // skip META-INFO and empty strings
+ if (!pkgName.isEmpty() && !pkgName.startsWith("META-INF")) {
+ List<String> moduleNames = packageToModules.get(pkgName);
+ if (moduleNames == null) {
+ moduleNames = new ArrayList<>();
+ packageToModules.put(pkgName, moduleNames);
+ }
+ moduleNames.add(moduleName);
+ }
+ });
+ }
+ }
+ }
+ // create "/modules" directory
+ // "nodes" map contains only /modules/<foo> nodes only so far and so add all as children of /modules
+ PathNode modulesDir = new PathNode("/modules", new ArrayList<>(nodes.values()));
+ nodes.put(modulesDir.getName(), modulesDir);
+
+ // create children under "/packages"
+ List<Node> packagesChildren = new ArrayList<>(packageToModules.size());
+ for (Map.Entry<String, List<String>> entry : packageToModules.entrySet()) {
+ String pkgName = entry.getKey();
+ List<String> moduleNameList = entry.getValue();
+ List<Node> moduleLinkNodes = new ArrayList<>(moduleNameList.size());
+ for (String moduleName : moduleNameList) {
+ Node moduleNode = findModulesNode(MODULES + moduleName);
+ PathNode linkNode = new PathNode(PACKAGES + pkgName + "/" + moduleName, moduleNode);
+ nodes.put(linkNode.getName(), linkNode);
+ moduleLinkNodes.add(linkNode);
+ }
+ PathNode pkgDir = new PathNode(PACKAGES + pkgName, moduleLinkNodes);
+ nodes.put(pkgDir.getName(), pkgDir);
+ packagesChildren.add(pkgDir);
+ }
+ // "/packages" dir
+ PathNode packagesDir = new PathNode("/packages", packagesChildren);
+ nodes.put(packagesDir.getName(), packagesDir);
+
+ // finally "/" dir!
+ List<Node> rootChildren = new ArrayList<>();
+ rootChildren.add(packagesDir);
+ rootChildren.add(modulesDir);
+ PathNode root = new PathNode("/", rootChildren);
+ nodes.put(root.getName(), root);
+ }
+}
--- a/jdk/src/java.base/share/classes/jdk/internal/jrtfs/JrtDirectoryStream.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/jdk/internal/jrtfs/JrtDirectoryStream.java Wed Jul 05 21:35:27 2017 +0200
@@ -30,6 +30,7 @@
import java.nio.file.NotDirectoryException;
import java.nio.file.Path;
import java.util.Iterator;
+import java.util.Objects;
import java.util.NoSuchElementException;
import java.io.IOException;
@@ -44,115 +45,47 @@
*/
final class JrtDirectoryStream implements DirectoryStream<Path> {
- private final AbstractJrtFileSystem jrtfs;
- private final AbstractJrtPath dir;
+ private final JrtPath dir;
private final DirectoryStream.Filter<? super Path> filter;
private volatile boolean isClosed;
private volatile Iterator<Path> itr;
- JrtDirectoryStream(AbstractJrtPath jrtPath,
+ JrtDirectoryStream(JrtPath dir,
DirectoryStream.Filter<? super java.nio.file.Path> filter)
- throws IOException {
- this.jrtfs = jrtPath.getFileSystem();
- this.dir = jrtPath;
- // sanity check
- if (!jrtfs.isDirectory(dir, true)) {
- throw new NotDirectoryException(jrtPath.toString());
+ throws IOException
+ {
+ this.dir = dir;
+ if (!dir.jrtfs.isDirectory(dir, true)) { // sanity check
+ throw new NotDirectoryException(dir.toString());
}
-
this.filter = filter;
}
@Override
public synchronized Iterator<Path> iterator() {
- if (isClosed) {
+ if (isClosed)
throw new ClosedDirectoryStreamException();
- }
- if (itr != null) {
+ if (itr != null)
throw new IllegalStateException("Iterator has already been returned");
- }
-
try {
- itr = jrtfs.iteratorOf(dir);
+ itr = dir.jrtfs.iteratorOf(dir, filter);
} catch (IOException e) {
throw new IllegalStateException(e);
}
return new Iterator<Path>() {
- /*
- * next Path value to return from this iterator.
- * null value means hasNext() not called yet
- * or last hasNext() returned false or resulted
- * in exception. If last hasNext() returned true,
- * then this field has non-null value.
- */
private Path next;
-
- // get-and-clear and set-next by these methods
- private Path getAndClearNext() {
- assert next != null;
- Path result = this.next;
- this.next = null;
- return result;
- }
-
- private void setNext(Path path) {
- assert path != null;
- this.next = path;
- }
-
- // if hasNext() returns true, 'next' field has non-null Path
@Override
public synchronized boolean hasNext() {
- if (next != null) {
- return true;
- }
-
- if (isClosed) {
+ if (isClosed)
return false;
- }
-
- if (filter == null) {
- if (itr.hasNext()) {
- setNext(itr.next());
- return true;
- } else {
- return false;
- }
- } else {
- while (itr.hasNext()) {
- Path tmpPath = itr.next();
- try {
- if (filter.accept(tmpPath)) {
- setNext(tmpPath);
- return true;
- }
- } catch (IOException ioe) {
- throw new DirectoryIteratorException(ioe);
- }
- }
-
- return false;
- }
+ return itr.hasNext();
}
@Override
public synchronized Path next() {
- if (next != null) {
- return getAndClearNext();
- }
-
- if (isClosed) {
+ if (isClosed)
throw new NoSuchElementException();
- }
-
- if (next == null && itr.hasNext()) {
- // missing hasNext() between next() calls.
- if (hasNext()) {
- return getAndClearNext();
- }
- }
-
- throw new NoSuchElementException();
+ return itr.next();
}
@Override
--- a/jdk/src/java.base/share/classes/jdk/internal/jrtfs/JrtExplodedFileAttributes.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,106 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * 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.internal.jrtfs;
-
-import java.io.IOException;
-import java.nio.file.attribute.BasicFileAttributes;
-import java.nio.file.attribute.FileTime;
-import jdk.internal.jrtfs.JrtExplodedFileSystem.Node;
-
-/**
- * jrt file system attributes implementation on top of 'exploded file system'
- * Node.
- *
- * @implNote This class needs to maintain JDK 8 source compatibility.
- *
- * It is used internally in the JDK to implement jimage/jrtfs access,
- * but also compiled and delivered as part of the jrtfs.jar to support access
- * to the jimage file provided by the shipped JDK by tools running on JDK 8.
- */
-final class JrtExplodedFileAttributes extends AbstractJrtFileAttributes {
-
- private final Node node;
- private final BasicFileAttributes attrs;
-
- JrtExplodedFileAttributes(Node node) throws IOException {
- this.node = node;
- this.attrs = node.getBasicAttrs();
- }
-
- @Override
- public FileTime creationTime() {
- return attrs.creationTime();
- }
-
- @Override
- public boolean isDirectory() {
- return node.isDirectory();
- }
-
- @Override
- public boolean isOther() {
- return false;
- }
-
- @Override
- public boolean isRegularFile() {
- return node.isFile();
- }
-
- @Override
- public FileTime lastAccessTime() {
- return attrs.lastAccessTime();
- }
-
- @Override
- public FileTime lastModifiedTime() {
- return attrs.lastModifiedTime();
- }
-
- @Override
- public long size() {
- return isRegularFile() ? attrs.size() : 0L;
- }
-
- @Override
- public boolean isSymbolicLink() {
- return node.isLink();
- }
-
- @Override
- public Object fileKey() {
- return node.resolveLink(true);
- }
-
- @Override
- public long compressedSize() {
- return 0L;
- }
-
- @Override
- public String extension() {
- return node.getExtension();
- }
-}
--- a/jdk/src/java.base/share/classes/jdk/internal/jrtfs/JrtExplodedFileSystem.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,528 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * 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.internal.jrtfs;
-
-import java.io.IOException;
-import java.nio.file.DirectoryStream;
-import java.nio.file.FileSystem;
-import java.nio.file.FileSystemException;
-import java.nio.file.FileSystems;
-import java.nio.file.Files;
-import java.nio.file.LinkOption;
-import java.nio.file.NoSuchFileException;
-import java.nio.file.NotDirectoryException;
-import java.nio.file.Path;
-import java.nio.file.attribute.BasicFileAttributes;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.function.Function;
-import static java.util.stream.Collectors.toList;
-import static jdk.internal.jrtfs.AbstractJrtFileSystem.getString;
-
-/**
- * A jrt file system built on $JAVA_HOME/modules directory ('exploded modules
- * build')
- *
- * @implNote This class needs to maintain JDK 8 source compatibility.
- *
- * It is used internally in the JDK to implement jimage/jrtfs access,
- * but also compiled and delivered as part of the jrtfs.jar to support access
- * to the jimage file provided by the shipped JDK by tools running on JDK 8.
- */
-class JrtExplodedFileSystem extends AbstractJrtFileSystem {
-
- private static final String MODULES = "/modules/";
- private static final String PACKAGES = "/packages/";
- private static final int PACKAGES_LEN = PACKAGES.length();
-
- // root path
- private final JrtExplodedPath rootPath;
- private volatile boolean isOpen;
- private final FileSystem defaultFS;
- private final String separator;
- private final Map<String, Node> nodes = Collections.synchronizedMap(new HashMap<>());
- private final BasicFileAttributes modulesDirAttrs;
-
- JrtExplodedFileSystem(JrtFileSystemProvider provider,
- Map<String, ?> env)
- throws IOException {
-
- super(provider, env);
- checkExists(SystemImages.explodedModulesDir());
- byte[] root = new byte[]{'/'};
- rootPath = new JrtExplodedPath(this, root);
- isOpen = true;
- defaultFS = FileSystems.getDefault();
- String str = defaultFS.getSeparator();
- separator = str.equals(getSeparator()) ? null : str;
- modulesDirAttrs = Files.readAttributes(SystemImages.explodedModulesDir(), BasicFileAttributes.class);
- initNodes();
- }
-
- @Override
- public void close() throws IOException {
- cleanup();
- }
-
- @Override
- public boolean isOpen() {
- return isOpen;
- }
-
- @Override
- protected void finalize() throws Throwable {
- cleanup();
- super.finalize();
- }
-
- private synchronized void cleanup() {
- isOpen = false;
- nodes.clear();
- }
-
- @Override
- JrtExplodedPath getRootPath() {
- return rootPath;
- }
-
- // Base class for Nodes of this file system
- abstract class Node {
-
- private final String name;
-
- Node(String name) {
- this.name = name;
- }
-
- final String getName() {
- return name;
- }
-
- final String getExtension() {
- if (isFile()) {
- final int index = name.lastIndexOf(".");
- if (index != -1) {
- return name.substring(index + 1);
- }
- }
-
- return null;
- }
-
- BasicFileAttributes getBasicAttrs() throws IOException {
- return modulesDirAttrs;
- }
-
- boolean isLink() {
- return false;
- }
-
- boolean isDirectory() {
- return false;
- }
-
- boolean isFile() {
- return false;
- }
-
- byte[] getContent() throws IOException {
- if (!isFile()) {
- throw new FileSystemException(name + " is not file");
- }
-
- throw new AssertionError("ShouldNotReachHere");
- }
-
- List<Node> getChildren() throws IOException {
- if (!isDirectory()) {
- throw new NotDirectoryException(name);
- }
-
- throw new AssertionError("ShouldNotReachHere");
- }
-
- final Node resolveLink() {
- return resolveLink(false);
- }
-
- Node resolveLink(boolean recursive) {
- return this;
- }
- }
-
- // A Node that is backed by actual default file system Path
- private final class PathNode extends Node {
-
- // Path in underlying default file system
- private final Path path;
- private final boolean file;
- // lazily initialized, don't read attributes unless required!
- private BasicFileAttributes attrs;
-
- PathNode(String name, Path path) {
- super(name);
- this.path = path;
- this.file = Files.isRegularFile(path);
- }
-
- @Override
- synchronized BasicFileAttributes getBasicAttrs() throws IOException {
- if (attrs == null) {
- attrs = Files.readAttributes(path, BasicFileAttributes.class);
- }
- return attrs;
- }
-
- @Override
- boolean isDirectory() {
- return !file;
- }
-
- @Override
- boolean isFile() {
- return file;
- }
-
- @Override
- byte[] getContent() throws IOException {
- if (!isFile()) {
- throw new FileSystemException(getName() + " is not file");
- }
-
- return Files.readAllBytes(path);
- }
-
- @Override
- List<Node> getChildren() throws IOException {
- if (!isDirectory()) {
- throw new NotDirectoryException(getName());
- }
-
- List<Node> children = new ArrayList<>();
- try (DirectoryStream<Path> stream = Files.newDirectoryStream(path)) {
- for (Path cp : stream) {
- cp = SystemImages.explodedModulesDir().relativize(cp);
- String cpName = MODULES + nativeSlashToFrontSlash(cp.toString());
- try {
- children.add(findNode(cpName));
- } catch (NoSuchFileException nsfe) {
- // findNode may choose to hide certain files!
- }
- }
- }
-
- return children;
- }
- }
-
- // A Node that links to another Node
- private final class LinkNode extends Node {
-
- // underlying linked Node
- private final Node link;
-
- LinkNode(String name, Node link) {
- super(name);
- this.link = link;
- }
-
- @Override
- BasicFileAttributes getBasicAttrs() throws IOException {
- return link.getBasicAttrs();
- }
-
- @Override
- public boolean isLink() {
- return true;
- }
-
- @Override
- Node resolveLink(boolean recursive) {
- return recursive && (link instanceof LinkNode) ? ((LinkNode) link).resolveLink(true) : link;
- }
- }
-
- // A directory Node with it's children Nodes
- private final class DirNode extends Node {
-
- // children Nodes of this Node.
- private final List<Node> children;
-
- DirNode(String name, List<Node> children) {
- super(name);
- this.children = children;
- }
-
- @Override
- boolean isDirectory() {
- return true;
- }
-
- @Override
- List<Node> getChildren() throws IOException {
- return children;
- }
- }
-
- private JrtExplodedPath toJrtExplodedPath(String path) {
- return toJrtExplodedPath(getBytes(path));
- }
-
- private JrtExplodedPath toJrtExplodedPath(byte[] path) {
- return new JrtExplodedPath(this, path);
- }
-
- @Override
- boolean isSameFile(AbstractJrtPath jrtPath1, AbstractJrtPath jrtPath2) throws IOException {
- Node n1 = checkNode(jrtPath1);
- Node n2 = checkNode(jrtPath2);
- return n1 == n2;
- }
-
- @Override
- boolean isLink(AbstractJrtPath jrtPath) throws IOException {
- return checkNode(jrtPath).isLink();
- }
-
- @Override
- AbstractJrtPath resolveLink(AbstractJrtPath jrtPath) throws IOException {
- String name = checkNode(jrtPath).resolveLink().getName();
- return toJrtExplodedPath(name);
- }
-
- @Override
- AbstractJrtFileAttributes getFileAttributes(AbstractJrtPath jrtPath, LinkOption... options) throws IOException {
- Node node = checkNode(jrtPath);
- if (node.isLink() && followLinks(options)) {
- node = node.resolveLink(true);
- }
- return new JrtExplodedFileAttributes(node);
- }
-
- @Override
- boolean exists(AbstractJrtPath jrtPath) throws IOException {
- try {
- checkNode(jrtPath);
- return true;
- } catch (NoSuchFileException nsfe) {
- return false;
- }
- }
-
- @Override
- boolean isDirectory(AbstractJrtPath jrtPath, boolean resolveLinks) throws IOException {
- Node node = checkNode(jrtPath);
- return resolveLinks && node.isLink()
- ? node.resolveLink(true).isDirectory()
- : node.isDirectory();
- }
-
- @Override
- Iterator<Path> iteratorOf(AbstractJrtPath dir) throws IOException {
- Node node = checkNode(dir).resolveLink(true);
- if (!node.isDirectory()) {
- throw new NotDirectoryException(getString(dir.getName()));
- }
-
- Function<Node, Path> nodeToPath =
- child -> dir.resolve(
- toJrtExplodedPath(child.getName()).
- getFileName());
-
- return node.getChildren().stream().
- map(nodeToPath).collect(toList()).
- iterator();
- }
-
- @Override
- byte[] getFileContent(AbstractJrtPath jrtPath) throws IOException {
- return checkNode(jrtPath).getContent();
- }
-
- private Node checkNode(AbstractJrtPath jrtPath) throws IOException {
- return checkNode(jrtPath.getResolvedPath());
- }
-
- private Node checkNode(byte[] path) throws IOException {
- ensureOpen();
- return findNode(path);
- }
-
- synchronized Node findNode(byte[] path) throws IOException {
- return findNode(getString(path));
- }
-
- // find Node for the given Path
- synchronized Node findNode(String str) throws IOException {
- Node node = findModulesNode(str);
- if (node != null) {
- return node;
- }
-
- // lazily created for paths like /packages/<package>/<module>/xyz
- // For example /packages/java.lang/java.base/java/lang/
- if (str.startsWith(PACKAGES)) {
- // pkgEndIdx marks end of <package> part
- int pkgEndIdx = str.indexOf('/', PACKAGES_LEN);
- if (pkgEndIdx != -1) {
- // modEndIdx marks end of <module> part
- int modEndIdx = str.indexOf('/', pkgEndIdx + 1);
- if (modEndIdx != -1) {
- // make sure we have such module link!
- // ie., /packages/<package>/<module> is valid
- Node linkNode = nodes.get(str.substring(0, modEndIdx));
- if (linkNode == null || !linkNode.isLink()) {
- throw new NoSuchFileException(str);
- }
-
- // map to "/modules/zyz" path and return that node
- // For example, "/modules/java.base/java/lang" for
- // "/packages/java.lang/java.base/java/lang".
- String mod = MODULES + str.substring(pkgEndIdx + 1);
- return findNode(mod);
- }
- }
- }
-
- throw new NoSuchFileException(str);
- }
-
- // find a Node for a path that starts like "/modules/..."
- synchronized Node findModulesNode(String str) throws IOException {
- Node node = nodes.get(str);
- if (node != null) {
- return node;
- }
-
- // lazily created "/modules/xyz/abc/" Node
- // This is mapped to default file system path "<JDK_MODULES_DIR>/xyz/abc"
- Path p = underlyingPath(str);
- if (p != null) {
- if (Files.isRegularFile(p)) {
- Path file = p.getFileName();
- if (file.toString().startsWith("_the.")) {
- return null;
- }
- }
- node = new PathNode(str, p);
- nodes.put(str, node);
- return node;
- }
-
- return null;
- }
-
- Path underlyingPath(String str) {
- if (str.startsWith(MODULES)) {
- str = frontSlashToNativeSlash(str.substring("/modules".length()));
- return defaultFS.getPath(SystemImages.explodedModulesDir().toString(), str);
- }
- return null;
- }
-
- // convert "/" to platform path separator
- private String frontSlashToNativeSlash(String str) {
- return separator == null ? str : str.replace("/", separator);
- }
-
- // convert platform path separator to "/"
- private String nativeSlashToFrontSlash(String str) {
- return separator == null ? str : str.replace(separator, "/");
- }
-
- // convert "/"s to "."s
- private String slashesToDots(String str) {
- return str.replace(separator != null ? separator : "/", ".");
- }
-
- // initialize file system Nodes
- private void initNodes() throws IOException {
- // same package prefix may exist in mutliple modules. This Map
- // is filled by walking "jdk modules" directory recursively!
- Map<String, List<String>> packageToModules = new HashMap<>();
-
- try (DirectoryStream<Path> stream = Files.newDirectoryStream(SystemImages.explodedModulesDir())) {
- for (Path module : stream) {
- if (Files.isDirectory(module)) {
- String moduleName = module.getFileName().toString();
- // make sure "/modules/<moduleName>" is created
- findModulesNode(MODULES + moduleName);
-
- Files.walk(module).filter(Files::isDirectory).forEach((p) -> {
- p = module.relativize(p);
- String pkgName = slashesToDots(p.toString());
- // skip META-INFO and empty strings
- if (!pkgName.isEmpty() && !pkgName.startsWith("META-INF")) {
- List<String> moduleNames = packageToModules.get(pkgName);
- if (moduleNames == null) {
- moduleNames = new ArrayList<>();
- packageToModules.put(pkgName, moduleNames);
- }
- moduleNames.add(moduleName);
- }
- });
- }
- }
- }
-
- // create "/modules" directory
- // "nodes" map contains only /modules/<foo> nodes only so far and so add all as children of /modules
- DirNode modulesDir = new DirNode("/modules", new ArrayList<>(nodes.values()));
- nodes.put(modulesDir.getName(), modulesDir);
-
- // create children under "/packages"
- List<Node> packagesChildren = new ArrayList<>(packageToModules.size());
- for (Map.Entry<String, List<String>> entry : packageToModules.entrySet()) {
- String pkgName = entry.getKey();
- List<String> moduleNameList = entry.getValue();
- List<Node> moduleLinkNodes = new ArrayList<>(moduleNameList.size());
- for (String moduleName : moduleNameList) {
- Node moduleNode = findModulesNode(MODULES + moduleName);
- LinkNode linkNode = new LinkNode(PACKAGES + pkgName + "/" + moduleName, moduleNode);
- nodes.put(linkNode.getName(), linkNode);
- moduleLinkNodes.add(linkNode);
- }
-
- DirNode pkgDir = new DirNode(PACKAGES + pkgName, moduleLinkNodes);
- nodes.put(pkgDir.getName(), pkgDir);
- packagesChildren.add(pkgDir);
- }
-
- // "/packages" dir
- DirNode packagesDir = new DirNode("/packages", packagesChildren);
- nodes.put(packagesDir.getName(), packagesDir);
-
- // finally "/" dir!
- List<Node> rootChildren = new ArrayList<>();
- rootChildren.add(modulesDir);
- rootChildren.add(packagesDir);
- DirNode root = new DirNode("/", rootChildren);
- nodes.put(root.getName(), root);
- }
-}
--- a/jdk/src/java.base/share/classes/jdk/internal/jrtfs/JrtExplodedPath.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,60 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * 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.internal.jrtfs;
-
-/**
- * Path implementation for jrt file system on JDK exploded modules build.
- *
- * @implNote This class needs to maintain JDK 8 source compatibility.
- *
- * It is used internally in the JDK to implement jimage/jrtfs access,
- * but also compiled and delivered as part of the jrtfs.jar to support access
- * to the jimage file provided by the shipped JDK by tools running on JDK 8.
- */
-final class JrtExplodedPath extends AbstractJrtPath {
-
- JrtExplodedPath(AbstractJrtFileSystem jrtfs, byte[] path) {
- super(jrtfs, path);
- }
-
- JrtExplodedPath(AbstractJrtFileSystem jrtfs, byte[] path, boolean normalized) {
- super(jrtfs, path, normalized);
- }
-
- @Override
- protected AbstractJrtPath newJrtPath(byte[] path) {
- return new JrtExplodedPath(jrtfs, path);
- }
-
- @Override
- protected AbstractJrtPath newJrtPath(byte[] path, boolean normalized) {
- return new JrtExplodedPath(jrtfs, path, normalized);
- }
-
- @Override
- public JrtExplodedFileSystem getFileSystem() {
- return (JrtExplodedFileSystem) jrtfs;
- }
-}
--- a/jdk/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileAttributeView.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileAttributeView.java Wed Jul 05 21:35:27 2017 +0200
@@ -29,6 +29,7 @@
import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.Map;
+import java.util.Objects;
/**
* File attribute view for jrt file system.
@@ -42,7 +43,6 @@
final class JrtFileAttributeView implements BasicFileAttributeView {
private static enum AttrID {
-
size,
creationTime,
lastAccessTime,
@@ -56,21 +56,19 @@
extension
};
- private final AbstractJrtPath path;
+ private final JrtPath path;
private final boolean isJrtView;
private final LinkOption[] options;
- private JrtFileAttributeView(AbstractJrtPath path, boolean isJrtView, LinkOption... options) {
+ private JrtFileAttributeView(JrtPath path, boolean isJrtView, LinkOption... options) {
this.path = path;
this.isJrtView = isJrtView;
this.options = options;
}
@SuppressWarnings("unchecked") // Cast to V
- static <V extends FileAttributeView> V get(AbstractJrtPath path, Class<V> type, LinkOption... options) {
- if (type == null) {
- throw new NullPointerException();
- }
+ static <V extends FileAttributeView> V get(JrtPath path, Class<V> type, LinkOption... options) {
+ Objects.requireNonNull(type);
if (type == BasicFileAttributeView.class) {
return (V) new JrtFileAttributeView(path, false, options);
}
@@ -80,10 +78,8 @@
return null;
}
- static JrtFileAttributeView get(AbstractJrtPath path, String type, LinkOption... options) {
- if (type == null) {
- throw new NullPointerException();
- }
+ static JrtFileAttributeView get(JrtPath path, String type, LinkOption... options) {
+ Objects.requireNonNull(type);
if (type.equals("basic")) {
return new JrtFileAttributeView(path, false, options);
}
@@ -99,61 +95,74 @@
}
@Override
- public AbstractJrtFileAttributes readAttributes() throws IOException {
+ public JrtFileAttributes readAttributes() throws IOException {
return path.getAttributes(options);
}
@Override
public void setTimes(FileTime lastModifiedTime,
- FileTime lastAccessTime,
- FileTime createTime)
- throws IOException {
+ FileTime lastAccessTime,
+ FileTime createTime) throws IOException {
path.setTimes(lastModifiedTime, lastAccessTime, createTime);
}
- void setAttribute(String attribute, Object value)
+ static void setAttribute(JrtPath path, String attribute, Object value)
throws IOException {
- try {
- if (AttrID.valueOf(attribute) == AttrID.lastModifiedTime) {
- setTimes((FileTime) value, null, null);
+ int colonPos = attribute.indexOf(':');
+ if (colonPos != -1) { // type = "basic", if no ":"
+ String type = attribute.substring(0, colonPos++);
+ if (!type.equals("basic") && !type.equals("jrt")) {
+ throw new UnsupportedOperationException(
+ "view <" + type + "> is not supported");
}
- if (AttrID.valueOf(attribute) == AttrID.lastAccessTime) {
- setTimes(null, (FileTime) value, null);
- }
- if (AttrID.valueOf(attribute) == AttrID.creationTime) {
- setTimes(null, null, (FileTime) value);
+ attribute = attribute.substring(colonPos);
+ }
+ try {
+ AttrID id = AttrID.valueOf(attribute);
+ if (id == AttrID.lastModifiedTime) {
+ path.setTimes((FileTime) value, null, null);
+ } else if (id == AttrID.lastAccessTime) {
+ path.setTimes(null, (FileTime) value, null);
+ } else if (id == AttrID.creationTime) {
+ path.setTimes(null, null, (FileTime) value);
}
return;
- } catch (IllegalArgumentException x) {
- }
+ } catch (IllegalArgumentException x) {}
throw new UnsupportedOperationException("'" + attribute
+ "' is unknown or read-only attribute");
}
- Map<String, Object> readAttributes(String attributes)
+ static Map<String, Object> readAttributes(JrtPath path, String attributes,
+ LinkOption... options)
throws IOException {
- AbstractJrtFileAttributes jrtfas = readAttributes();
+ int colonPos = attributes.indexOf(':');
+ boolean isJrtView = false;
+ if (colonPos != -1) { // type = "basic", if no ":"
+ String type = attributes.substring(0, colonPos++);
+ if (!type.equals("basic") && !type.equals("jrt")) {
+ throw new UnsupportedOperationException("view <" + type +
+ "> is not supported");
+ }
+ isJrtView = true;
+ attributes = attributes.substring(colonPos);
+ }
+ JrtFileAttributes jrtfas = path.getAttributes();
LinkedHashMap<String, Object> map = new LinkedHashMap<>();
if ("*".equals(attributes)) {
for (AttrID id : AttrID.values()) {
- try {
- map.put(id.name(), attribute(id, jrtfas));
- } catch (IllegalArgumentException x) {
- }
+ map.put(id.name(), attribute(id, jrtfas, isJrtView));
}
} else {
String[] as = attributes.split(",");
for (String a : as) {
- try {
- map.put(a, attribute(AttrID.valueOf(a), jrtfas));
- } catch (IllegalArgumentException x) {
- }
+ //throw IllegalArgumentException
+ map.put(a, attribute(AttrID.valueOf(a), jrtfas, isJrtView));
}
}
return map;
}
- Object attribute(AttrID id, AbstractJrtFileAttributes jrtfas) {
+ static Object attribute(AttrID id, JrtFileAttributes jrtfas, boolean isJrtView) {
switch (id) {
case size:
return jrtfas.size();
--- a/jdk/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileAttributes.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileAttributes.java Wed Jul 05 21:35:27 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, 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
@@ -24,7 +24,9 @@
*/
package jdk.internal.jrtfs;
+import java.nio.file.attribute.BasicFileAttributes;
import java.nio.file.attribute.FileTime;
+import java.util.Formatter;
import jdk.internal.jimage.ImageReader.Node;
/**
@@ -36,7 +38,7 @@
* but also compiled and delivered as part of the jrtfs.jar to support access
* to the jimage file provided by the shipped JDK by tools running on JDK 8.
*/
-final class JrtFileAttributes extends AbstractJrtFileAttributes {
+final class JrtFileAttributes implements BasicFileAttributes {
private final Node node;
@@ -90,14 +92,50 @@
return node.resolveLink(true);
}
- ///////// jrt entry attributes ///////////
- @Override
+ ///////// jrtfs specific attributes ///////////
+ /**
+ * Compressed resource file. If not available or not applicable, 0L is
+ * returned.
+ *
+ * @return the compressed resource size for compressed resources.
+ */
public long compressedSize() {
return node.compressedSize();
}
- @Override
+ /**
+ * "file" extension of a file resource.
+ *
+ * @return extension string for the file resource
+ */
public String extension() {
return node.extension();
}
+
+ @Override
+ public final String toString() {
+ StringBuilder sb = new StringBuilder(1024);
+ try (Formatter fm = new Formatter(sb)) {
+ if (creationTime() != null) {
+ fm.format(" creationTime : %tc%n", creationTime().toMillis());
+ } else {
+ fm.format(" creationTime : null%n");
+ }
+ if (lastAccessTime() != null) {
+ fm.format(" lastAccessTime : %tc%n", lastAccessTime().toMillis());
+ } else {
+ fm.format(" lastAccessTime : null%n");
+ }
+ fm.format(" lastModifiedTime: %tc%n", lastModifiedTime().toMillis());
+ fm.format(" isRegularFile : %b%n", isRegularFile());
+ fm.format(" isDirectory : %b%n", isDirectory());
+ fm.format(" isSymbolicLink : %b%n", isSymbolicLink());
+ fm.format(" isOther : %b%n", isOther());
+ fm.format(" fileKey : %s%n", fileKey());
+ fm.format(" size : %d%n", size());
+ fm.format(" compressedSize : %d%n", compressedSize());
+ fm.format(" extension : %s%n", extension());
+ }
+ return sb.toString();
+ }
}
--- a/jdk/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileStore.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileStore.java Wed Jul 05 21:35:27 2017 +0200
@@ -30,6 +30,7 @@
import java.nio.file.attribute.FileAttributeView;
import java.nio.file.attribute.BasicFileAttributeView;
import java.nio.file.attribute.FileStoreAttributeView;
+import java.util.Objects;
/**
* File store implementation for jrt file systems.
@@ -44,7 +45,7 @@
protected final FileSystem jrtfs;
- JrtFileStore(AbstractJrtPath jrtPath) {
+ JrtFileStore(JrtPath jrtPath) {
this.jrtfs = jrtPath.getFileSystem();
}
@@ -71,9 +72,7 @@
@Override
@SuppressWarnings("unchecked")
public <V extends FileStoreAttributeView> V getFileStoreAttributeView(Class<V> type) {
- if (type == null) {
- throw new NullPointerException();
- }
+ Objects.requireNonNull(type, "type");
return (V) null;
}
@@ -99,7 +98,7 @@
@Override
public boolean supportsFileAttributeView(Class<? extends FileAttributeView> type) {
- return (type == BasicFileAttributeView.class
- || type == JrtFileAttributeView.class);
+ return type == BasicFileAttributeView.class ||
+ type == JrtFileAttributeView.class;
}
}
--- a/jdk/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileSystem.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileSystem.java Wed Jul 05 21:35:27 2017 +0200
@@ -24,23 +24,47 @@
*/
package jdk.internal.jrtfs;
+import java.io.ByteArrayInputStream;
import java.io.IOException;
-import java.nio.file.LinkOption;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.nio.ByteBuffer;
+import java.nio.channels.Channels;
+import java.nio.channels.FileChannel;
+import java.nio.channels.NonWritableChannelException;
+import java.nio.channels.ReadableByteChannel;
+import java.nio.channels.SeekableByteChannel;
+import java.nio.file.ClosedFileSystemException;
+import java.nio.file.CopyOption;
+import java.nio.file.DirectoryStream;
+import java.nio.file.FileStore;
+import java.nio.file.FileSystem;
import java.nio.file.FileSystemException;
import java.nio.file.InvalidPathException;
+import java.nio.file.LinkOption;
import java.nio.file.NoSuchFileException;
import java.nio.file.NotDirectoryException;
+import java.nio.file.OpenOption;
import java.nio.file.Path;
+import java.nio.file.PathMatcher;
+import java.nio.file.ReadOnlyFileSystemException;
+import java.nio.file.StandardOpenOption;
+import java.nio.file.WatchService;
+import java.nio.file.attribute.FileAttribute;
+import java.nio.file.attribute.FileTime;
+import java.nio.file.attribute.UserPrincipalLookupService;
+import java.nio.file.spi.FileSystemProvider;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
import java.util.Iterator;
-import java.util.List;
import java.util.Map;
-import java.util.function.Function;
+import java.util.Objects;
+import java.util.Set;
+import java.util.regex.Pattern;
+import jdk.internal.jimage.ImageReader.Node;
import static java.util.stream.Collectors.toList;
-import jdk.internal.jimage.ImageReader;
-import jdk.internal.jimage.ImageReader.Node;
-
/**
* jrt file system implementation built on System jimage files.
@@ -51,33 +75,21 @@
* but also compiled and delivered as part of the jrtfs.jar to support access
* to the jimage file provided by the shipped JDK by tools running on JDK 8.
*/
-class JrtFileSystem extends AbstractJrtFileSystem {
+class JrtFileSystem extends FileSystem {
- // System image reader
- private ImageReader bootImage;
- // root path
- private final JrtPath rootPath;
+ private final JrtFileSystemProvider provider;
+ private final JrtPath rootPath = new JrtPath(this, "/");
private volatile boolean isOpen;
+ private volatile boolean isClosable;
+ private SystemImage image;
- // open a .jimage and build directory structure
- private static ImageReader openImage(Path path) throws IOException {
- ImageReader image = ImageReader.open(path);
- image.getRootDirectory();
- return image;
- }
-
- JrtFileSystem(JrtFileSystemProvider provider,
- Map<String, ?> env)
- throws IOException {
- super(provider, env);
- checkExists(SystemImages.moduleImageFile());
-
- // open image file
- this.bootImage = openImage(SystemImages.moduleImageFile());
-
- byte[] root = new byte[]{'/'};
- rootPath = new JrtPath(this, root);
- isOpen = true;
+ JrtFileSystem(JrtFileSystemProvider provider, Map<String, ?> env)
+ throws IOException
+ {
+ this.provider = provider;
+ this.image = SystemImage.open(); // open image file
+ this.isOpen = true;
+ this.isClosable = env != null;
}
// FileSystem method implementations
@@ -88,6 +100,8 @@
@Override
public void close() throws IOException {
+ if (!isClosable)
+ throw new UnsupportedOperationException();
cleanup();
}
@@ -95,237 +109,397 @@
protected void finalize() throws Throwable {
try {
cleanup();
- } catch (IOException ignored) {
- }
- super.finalize();
+ } catch (IOException ignored) {}
}
- // AbstractJrtFileSystem method implementations
@Override
- JrtPath getRootPath() {
- return rootPath;
+ public FileSystemProvider provider() {
+ return provider;
+ }
+
+ @Override
+ public Iterable<Path> getRootDirectories() {
+ ArrayList<Path> dirs = new ArrayList<>();
+ dirs.add(getRootPath());
+ return dirs;
}
@Override
- boolean isSameFile(AbstractJrtPath p1, AbstractJrtPath p2) throws IOException {
- ensureOpen();
- Node node1 = findNode(p1);
- Node node2 = findNode(p2);
- return node1.equals(node2);
+ public JrtPath getPath(String first, String... more) {
+ if (more.length == 0) {
+ return new JrtPath(this, first);
+ }
+ StringBuilder sb = new StringBuilder();
+ sb.append(first);
+ for (String path : more) {
+ if (path.length() > 0) {
+ if (sb.length() > 0) {
+ sb.append('/');
+ }
+ sb.append(path);
+ }
+ }
+ return new JrtPath(this, sb.toString());
+ }
+
+ @Override
+ public final boolean isReadOnly() {
+ return true;
+ }
+
+ @Override
+ public final UserPrincipalLookupService getUserPrincipalLookupService() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public final WatchService newWatchService() {
+ throw new UnsupportedOperationException();
}
@Override
- boolean isLink(AbstractJrtPath jrtPath) throws IOException {
- return checkNode(jrtPath).isLink();
+ public final Iterable<FileStore> getFileStores() {
+ ArrayList<FileStore> list = new ArrayList<>(1);
+ list.add(getFileStore(getRootPath()));
+ return list;
+ }
+
+ private static final Set<String> supportedFileAttributeViews
+ = Collections.unmodifiableSet(
+ new HashSet<String>(Arrays.asList("basic", "jrt")));
+
+ @Override
+ public final Set<String> supportedFileAttributeViews() {
+ return supportedFileAttributeViews;
+ }
+
+ @Override
+ public final String toString() {
+ return "jrt:/";
+ }
+
+ @Override
+ public final String getSeparator() {
+ return "/";
}
@Override
- AbstractJrtPath resolveLink(AbstractJrtPath jrtPath) throws IOException {
- Node node = checkNode(jrtPath);
+ public PathMatcher getPathMatcher(String syntaxAndInput) {
+ int pos = syntaxAndInput.indexOf(':');
+ if (pos <= 0 || pos == syntaxAndInput.length()) {
+ throw new IllegalArgumentException();
+ }
+ String syntax = syntaxAndInput.substring(0, pos);
+ String input = syntaxAndInput.substring(pos + 1);
+ String expr;
+ if (syntax.equalsIgnoreCase("glob")) {
+ expr = JrtUtils.toRegexPattern(input);
+ } else if (syntax.equalsIgnoreCase("regex")) {
+ expr = input;
+ } else {
+ throw new UnsupportedOperationException("Syntax '" + syntax
+ + "' not recognized");
+ }
+ // return matcher
+ final Pattern pattern = Pattern.compile(expr);
+ return (Path path) -> pattern.matcher(path.toString()).matches();
+ }
+
+ JrtPath resolveLink(JrtPath path) throws IOException {
+ Node node = checkNode(path);
if (node.isLink()) {
node = node.resolveLink();
- return toJrtPath(getBytes(node.getName()));
+ return new JrtPath(this, node.getName()); // TBD, normalized?
}
-
- return jrtPath;
+ return path;
}
- @Override
- JrtFileAttributes getFileAttributes(AbstractJrtPath jrtPath, LinkOption... options)
+ JrtFileAttributes getFileAttributes(JrtPath path, LinkOption... options)
throws IOException {
- Node node = checkNode(jrtPath);
+ Node node = checkNode(path);
if (node.isLink() && followLinks(options)) {
return new JrtFileAttributes(node.resolveLink(true));
}
return new JrtFileAttributes(node);
}
- @Override
- boolean exists(AbstractJrtPath jrtPath) throws IOException {
+ /**
+ * returns the list of child paths of the given directory "path"
+ *
+ * @param path name of the directory whose content is listed
+ * @return iterator for child paths of the given directory path
+ */
+ Iterator<Path> iteratorOf(JrtPath path, DirectoryStream.Filter<? super Path> filter)
+ throws IOException {
+ Node node = checkNode(path).resolveLink(true);
+ if (!node.isDirectory()) {
+ throw new NotDirectoryException(path.getName());
+ }
+ if (filter == null) {
+ return node.getChildren()
+ .stream()
+ .map(child -> (Path)(path.resolve(new JrtPath(this, child.getNameString()).getFileName())))
+ .iterator();
+ }
+ return node.getChildren()
+ .stream()
+ .map(child -> (Path)(path.resolve(new JrtPath(this, child.getNameString()).getFileName())))
+ .filter(p -> { try { return filter.accept(p);
+ } catch (IOException x) {}
+ return false;
+ })
+ .iterator();
+ }
+
+ // returns the content of the file resource specified by the path
+ byte[] getFileContent(JrtPath path) throws IOException {
+ Node node = checkNode(path);
+ if (node.isDirectory()) {
+ throw new FileSystemException(path + " is a directory");
+ }
+ //assert node.isResource() : "resource node expected here";
+ return image.getResource(node);
+ }
+
+ /////////////// Implementation details below this point //////////
+
+ // static utility methods
+ static ReadOnlyFileSystemException readOnly() {
+ return new ReadOnlyFileSystemException();
+ }
+
+ // do the supplied options imply that we have to chase symlinks?
+ static boolean followLinks(LinkOption... options) {
+ if (options != null) {
+ for (LinkOption lo : options) {
+ Objects.requireNonNull(lo);
+ if (lo == LinkOption.NOFOLLOW_LINKS) {
+ return false;
+ } else {
+ throw new AssertionError("should not reach here");
+ }
+ }
+ }
+ return true;
+ }
+
+ // check that the options passed are supported by (read-only) jrt file system
+ static void checkOptions(Set<? extends OpenOption> options) {
+ // check for options of null type and option is an intance of StandardOpenOption
+ for (OpenOption option : options) {
+ Objects.requireNonNull(option);
+ if (!(option instanceof StandardOpenOption)) {
+ throw new IllegalArgumentException();
+ }
+ }
+ if (options.contains(StandardOpenOption.WRITE) ||
+ options.contains(StandardOpenOption.APPEND)) {
+ throw readOnly();
+ }
+ }
+
+ // clean up this file system - called from finalize and close
+ void cleanup() throws IOException {
+ if (!isOpen) {
+ return;
+ }
+ synchronized (this) {
+ isOpen = false;
+ // close image reader and null out
+ image.close();
+ image = null;
+ }
+ }
+
+ // These methods throw read only file system exception
+ final void setTimes(JrtPath jrtPath, FileTime mtime, FileTime atime, FileTime ctime)
+ throws IOException {
+ throw readOnly();
+ }
+
+ // These methods throw read only file system exception
+ final void createDirectory(JrtPath jrtPath, FileAttribute<?>... attrs) throws IOException {
+ throw readOnly();
+ }
+
+ final void deleteFile(JrtPath jrtPath, boolean failIfNotExists)
+ throws IOException {
+ throw readOnly();
+ }
+
+ final OutputStream newOutputStream(JrtPath jrtPath, OpenOption... options)
+ throws IOException {
+ throw readOnly();
+ }
+
+ final void copyFile(boolean deletesrc, JrtPath srcPath, JrtPath dstPath, CopyOption... options)
+ throws IOException {
+ throw readOnly();
+ }
+
+ final FileChannel newFileChannel(JrtPath path,
+ Set<? extends OpenOption> options,
+ FileAttribute<?>... attrs)
+ throws IOException {
+ throw new UnsupportedOperationException("newFileChannel");
+ }
+
+ final InputStream newInputStream(JrtPath path) throws IOException {
+ return new ByteArrayInputStream(getFileContent(path));
+ }
+
+ final SeekableByteChannel newByteChannel(JrtPath path,
+ Set<? extends OpenOption> options,
+ FileAttribute<?>... attrs)
+ throws IOException {
+ checkOptions(options);
+
+ byte[] buf = getFileContent(path);
+ final ReadableByteChannel rbc
+ = Channels.newChannel(new ByteArrayInputStream(buf));
+ final long size = buf.length;
+ return new SeekableByteChannel() {
+ long read = 0;
+
+ @Override
+ public boolean isOpen() {
+ return rbc.isOpen();
+ }
+
+ @Override
+ public long position() throws IOException {
+ return read;
+ }
+
+ @Override
+ public SeekableByteChannel position(long pos)
+ throws IOException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public int read(ByteBuffer dst) throws IOException {
+ int n = rbc.read(dst);
+ if (n > 0) {
+ read += n;
+ }
+ return n;
+ }
+
+ @Override
+ public SeekableByteChannel truncate(long size)
+ throws IOException {
+ throw new NonWritableChannelException();
+ }
+
+ @Override
+ public int write(ByteBuffer src) throws IOException {
+ throw new NonWritableChannelException();
+ }
+
+ @Override
+ public long size() throws IOException {
+ return size;
+ }
+
+ @Override
+ public void close() throws IOException {
+ rbc.close();
+ }
+ };
+ }
+
+ final JrtFileStore getFileStore(JrtPath path) {
+ return new JrtFileStore(path);
+ }
+
+ final void ensureOpen() throws IOException {
+ if (!isOpen()) {
+ throw new ClosedFileSystemException();
+ }
+ }
+
+ final JrtPath getRootPath() {
+ return rootPath;
+ }
+
+ boolean isSameFile(JrtPath path1, JrtPath path2) throws IOException {
+ return checkNode(path1) == checkNode(path2);
+ }
+
+ boolean isLink(JrtPath path) throws IOException {
+ return checkNode(path).isLink();
+ }
+
+ boolean exists(JrtPath path) throws IOException {
try {
- checkNode(jrtPath);
+ checkNode(path);
} catch (NoSuchFileException exp) {
return false;
}
return true;
}
- @Override
- boolean isDirectory(AbstractJrtPath jrtPath, boolean resolveLinks)
+ boolean isDirectory(JrtPath path, boolean resolveLinks)
throws IOException {
- Node node = checkNode(jrtPath);
+ Node node = checkNode(path);
return resolveLinks && node.isLink()
? node.resolveLink(true).isDirectory()
: node.isDirectory();
}
- @Override
- Iterator<Path> iteratorOf(AbstractJrtPath jrtPath) throws IOException {
- Node node = checkNode(jrtPath).resolveLink(true);
- if (!node.isDirectory()) {
- throw new NotDirectoryException(getString(jrtPath.getName()));
+ JrtPath toRealPath(JrtPath path, LinkOption... options)
+ throws IOException {
+ Node node = checkNode(path);
+ if (followLinks(options) && node.isLink()) {
+ node = node.resolveLink();
}
-
- if (node.isRootDir()) {
- return rootDirIterator(jrtPath);
- } else if (node.isModulesDir()) {
- return modulesDirIterator(jrtPath);
- } else if (node.isPackagesDir()) {
- return packagesDirIterator(jrtPath);
- }
-
- return nodesToIterator(jrtPath, node.getChildren());
+ // image node holds the real/absolute path name
+ return new JrtPath(this, node.getName(), true);
}
- @Override
- byte[] getFileContent(AbstractJrtPath jrtPath) throws IOException {
- final Node node = checkResource(jrtPath);
- return bootImage.getResource(node);
- }
-
- // Implementation details below this point
- // clean up this file system - called from finalize and close
- private void cleanup() throws IOException {
- if (!isOpen) {
- return;
- }
-
- synchronized (this) {
- isOpen = false;
-
- // close all image reader and null out
- bootImage.close();
- bootImage = null;
+ private Node lookup(String path) {
+ try {
+ return image.findNode(path);
+ } catch (RuntimeException re) {
+ throw new InvalidPathException(path, re.toString());
}
}
- private Node lookup(byte[] path) {
- Node node = null;
- try {
- node = bootImage.findNode(getString(path));
- } catch (RuntimeException re) {
- throw new InvalidPathException(getString(path), re.toString());
+ private Node lookupSymbolic(String path) {
+ int i = 1;
+ while (i < path.length()) {
+ i = path.indexOf('/', i);
+ if (i == -1) {
+ break;
+ }
+ String prefix = path.substring(0, i);
+ Node node = lookup(prefix);
+ if (node == null) {
+ break;
+ }
+ if (node.isLink()) {
+ Node link = node.resolveLink(true);
+ // resolved symbolic path concatenated to the rest of the path
+ String resPath = link.getName() + path.substring(i);
+ node = lookup(resPath);
+ return node != null ? node : lookupSymbolic(resPath);
+ }
+ i++;
}
- return node;
- }
-
- private Node lookupSymbolic(byte[] path) {
- for (int i = 1; i < path.length; i++) {
- if (path[i] == (byte) '/') {
- byte[] prefix = Arrays.copyOfRange(path, 0, i);
- Node node = lookup(prefix);
- if (node == null) {
- break;
- }
-
- if (node.isLink()) {
- Node link = node.resolveLink(true);
- // resolved symbolic path concatenated to the rest of the path
- String resPath = link.getName() + getString(path).substring(i);
- byte[] resPathBytes = getBytes(resPath);
- node = lookup(resPathBytes);
- return node != null ? node : lookupSymbolic(resPathBytes);
- }
- }
- }
-
return null;
}
- private Node findNode(AbstractJrtPath jrtPath) throws IOException {
- return findNode(jrtPath.getResolvedPath());
- }
-
- private Node findNode(byte[] path) throws IOException {
- Node node = lookup(path);
+ Node checkNode(JrtPath path) throws IOException {
+ ensureOpen();
+ String p = path.getResolvedPath();
+ Node node = lookup(p);
if (node == null) {
- node = lookupSymbolic(path);
+ node = lookupSymbolic(p);
if (node == null) {
- throw new NoSuchFileException(getString(path));
+ throw new NoSuchFileException(p);
}
}
return node;
}
-
- private Node checkNode(AbstractJrtPath jrtPath) throws IOException {
- return checkNode(jrtPath.getResolvedPath());
- }
-
- private Node checkNode(byte[] path) throws IOException {
- ensureOpen();
- return findNode(path);
- }
-
- private Node checkResource(AbstractJrtPath jrtPath) throws IOException {
- return checkResource(jrtPath.getResolvedPath());
- }
-
- private Node checkResource(byte[] path) throws IOException {
- Node node = checkNode(path);
- if (node.isDirectory()) {
- throw new FileSystemException(getString(path) + " is a directory");
- }
-
- assert node.isResource() : "resource node expected here";
- return node;
- }
-
- private JrtPath toJrtPath(String path) {
- return toJrtPath(getBytes(path));
- }
-
- private JrtPath toJrtPath(byte[] path) {
- return new JrtPath(this, path);
- }
-
- private Iterator<Path> nodesToIterator(AbstractJrtPath dir, List<Node> childNodes) {
- Function<Node, Path> nodeToPath =
- child -> dir.resolve(
- toJrtPath(child.getNameString()).getFileName());
- return childNodes.stream().
- map(nodeToPath).collect(toList()).
- iterator();
- }
-
- private List<Node> rootChildren;
-
- private synchronized void initRootChildren(AbstractJrtPath jrtPath) throws IOException {
- if (rootChildren == null) {
- rootChildren = new ArrayList<>();
- rootChildren.addAll(findNode(jrtPath).getChildren());
- }
- }
-
- private Iterator<Path> rootDirIterator(AbstractJrtPath jrtPath) throws IOException {
- initRootChildren(jrtPath);
- return nodesToIterator(jrtPath, rootChildren);
- }
-
- private List<Node> modulesChildren;
-
- private synchronized void initModulesChildren(AbstractJrtPath jrtPath) throws IOException {
- if (modulesChildren == null) {
- modulesChildren = new ArrayList<>();
- modulesChildren.addAll(findNode(jrtPath).getChildren());
- }
- }
-
- private Iterator<Path> modulesDirIterator(AbstractJrtPath jrtPath) throws IOException {
- initModulesChildren(jrtPath);
- return nodesToIterator(jrtPath, modulesChildren);
- }
-
- private List<Node> packagesChildren;
-
- private synchronized void initPackagesChildren(AbstractJrtPath jrtPath) throws IOException {
- if (packagesChildren == null) {
- packagesChildren = new ArrayList<>();
- packagesChildren.addAll(findNode(jrtPath).getChildren());
- }
- }
-
- private Iterator<Path> packagesDirIterator(AbstractJrtPath jrtPath) throws IOException {
- initPackagesChildren(jrtPath);
- return nodesToIterator(jrtPath, packagesChildren);
- }
}
--- a/jdk/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileSystemProvider.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileSystemProvider.java Wed Jul 05 21:35:27 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, 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
@@ -70,7 +70,7 @@
private void checkPermission() {
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
- String home = SystemImages.RUNTIME_HOME;
+ String home = SystemImage.RUNTIME_HOME;
FilePermission perm
= new FilePermission(home + File.separator + "-", "read");
sm.checkPermission(perm);
@@ -107,9 +107,7 @@
if (env != null && env.containsKey("java.home")) {
return newFileSystem((String)env.get("java.home"), uri, env);
} else {
- return SystemImages.hasModulesImage()
- ? new JrtFileSystem(this, env)
- : new JrtExplodedFileSystem(this, env);
+ return new JrtFileSystem(this, env);
}
}
@@ -121,7 +119,6 @@
if (Files.notExists(jrtfs)) {
throw new IOException(jrtfs.toString() + " not exist");
}
-
Map<String,?> newEnv = new HashMap<>(env);
newEnv.remove("java.home");
ClassLoader cl = newJrtFsLoader(jrtfs);
@@ -139,7 +136,6 @@
JrtFsLoader(URL[] urls) {
super(urls);
}
-
@Override
protected Class<?> loadClass(String cn, boolean resolve)
throws ClassNotFoundException
@@ -208,21 +204,7 @@
fs = this.theFileSystem;
if (fs == null) {
try {
- if (SystemImages.hasModulesImage()) {
- this.theFileSystem = fs = new JrtFileSystem(this, null) {
- @Override
- public void close() {
- throw new UnsupportedOperationException();
- }
- };
- } else {
- this.theFileSystem = fs = new JrtExplodedFileSystem(this, null) {
- @Override
- public void close() {
- throw new UnsupportedOperationException();
- }
- };
- }
+ this.theFileSystem = fs = new JrtFileSystem(this, null);
} catch (IOException ioe) {
throw new InternalError(ioe);
}
@@ -240,69 +222,67 @@
}
// Checks that the given file is a JrtPath
- static final AbstractJrtPath toAbstractJrtPath(Path path) {
- if (path == null) {
- throw new NullPointerException();
- }
- if (!(path instanceof AbstractJrtPath)) {
+ static final JrtPath toJrtPath(Path path) {
+ Objects.requireNonNull(path, "path");
+ if (!(path instanceof JrtPath)) {
throw new ProviderMismatchException();
}
- return (AbstractJrtPath) path;
+ return (JrtPath) path;
}
@Override
public void checkAccess(Path path, AccessMode... modes) throws IOException {
- toAbstractJrtPath(path).checkAccess(modes);
+ toJrtPath(path).checkAccess(modes);
}
@Override
public Path readSymbolicLink(Path link) throws IOException {
- return toAbstractJrtPath(link).readSymbolicLink();
+ return toJrtPath(link).readSymbolicLink();
}
@Override
public void copy(Path src, Path target, CopyOption... options)
throws IOException {
- toAbstractJrtPath(src).copy(toAbstractJrtPath(target), options);
+ toJrtPath(src).copy(toJrtPath(target), options);
}
@Override
public void createDirectory(Path path, FileAttribute<?>... attrs)
throws IOException {
- toAbstractJrtPath(path).createDirectory(attrs);
+ toJrtPath(path).createDirectory(attrs);
}
@Override
public final void delete(Path path) throws IOException {
- toAbstractJrtPath(path).delete();
+ toJrtPath(path).delete();
}
@Override
@SuppressWarnings("unchecked")
public <V extends FileAttributeView> V
getFileAttributeView(Path path, Class<V> type, LinkOption... options) {
- return JrtFileAttributeView.get(toAbstractJrtPath(path), type, options);
+ return JrtFileAttributeView.get(toJrtPath(path), type, options);
}
@Override
public FileStore getFileStore(Path path) throws IOException {
- return toAbstractJrtPath(path).getFileStore();
+ return toJrtPath(path).getFileStore();
}
@Override
public boolean isHidden(Path path) {
- return toAbstractJrtPath(path).isHidden();
+ return toJrtPath(path).isHidden();
}
@Override
public boolean isSameFile(Path path, Path other) throws IOException {
- return toAbstractJrtPath(path).isSameFile(other);
+ return toJrtPath(path).isSameFile(other);
}
@Override
public void move(Path src, Path target, CopyOption... options)
throws IOException {
- toAbstractJrtPath(src).move(toAbstractJrtPath(target), options);
+ toJrtPath(src).move(toJrtPath(target), options);
}
@Override
@@ -319,13 +299,13 @@
Set<? extends OpenOption> options,
FileAttribute<?>... attrs)
throws IOException {
- return toAbstractJrtPath(path).newByteChannel(options, attrs);
+ return toJrtPath(path).newByteChannel(options, attrs);
}
@Override
public DirectoryStream<Path> newDirectoryStream(
Path path, Filter<? super Path> filter) throws IOException {
- return toAbstractJrtPath(path).newDirectoryStream(filter);
+ return toJrtPath(path).newDirectoryStream(filter);
}
@Override
@@ -333,19 +313,19 @@
Set<? extends OpenOption> options,
FileAttribute<?>... attrs)
throws IOException {
- return toAbstractJrtPath(path).newFileChannel(options, attrs);
+ return toJrtPath(path).newFileChannel(options, attrs);
}
@Override
public InputStream newInputStream(Path path, OpenOption... options)
throws IOException {
- return toAbstractJrtPath(path).newInputStream(options);
+ return toJrtPath(path).newInputStream(options);
}
@Override
public OutputStream newOutputStream(Path path, OpenOption... options)
throws IOException {
- return toAbstractJrtPath(path).newOutputStream(options);
+ return toJrtPath(path).newOutputStream(options);
}
@Override
@@ -354,7 +334,7 @@
readAttributes(Path path, Class<A> type, LinkOption... options)
throws IOException {
if (type == BasicFileAttributes.class || type == JrtFileAttributes.class) {
- return (A) toAbstractJrtPath(path).getAttributes(options);
+ return (A) toJrtPath(path).getAttributes(options);
}
return null;
}
@@ -363,13 +343,13 @@
public Map<String, Object>
readAttributes(Path path, String attribute, LinkOption... options)
throws IOException {
- return toAbstractJrtPath(path).readAttributes(attribute, options);
+ return toJrtPath(path).readAttributes(attribute, options);
}
@Override
public void setAttribute(Path path, String attribute,
Object value, LinkOption... options)
throws IOException {
- toAbstractJrtPath(path).setAttribute(attribute, value, options);
+ toJrtPath(path).setAttribute(attribute, value, options);
}
}
--- a/jdk/src/java.base/share/classes/jdk/internal/jrtfs/JrtPath.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/jdk/internal/jrtfs/JrtPath.java Wed Jul 05 21:35:27 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -24,8 +24,30 @@
*/
package jdk.internal.jrtfs;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.nio.channels.FileChannel;
+import java.nio.channels.SeekableByteChannel;
+import java.nio.file.*;
+import java.nio.file.DirectoryStream.Filter;;
+import java.nio.file.attribute.BasicFileAttributes;
+import java.nio.file.attribute.BasicFileAttributeView;
+import java.nio.file.attribute.FileAttribute;
+import java.nio.file.attribute.FileTime;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.NoSuchElementException;
+import java.util.Objects;
+import java.util.Set;
+import static java.nio.file.StandardOpenOption.*;
+import static java.nio.file.StandardCopyOption.*;
+
/**
- * jrt Path implementation for jrt on .jimage files.
+ * Base class for Path implementation of jrt file systems.
*
* @implNote This class needs to maintain JDK 8 source compatibility.
*
@@ -33,23 +55,756 @@
* but also compiled and delivered as part of the jrtfs.jar to support access
* to the jimage file provided by the shipped JDK by tools running on JDK 8.
*/
-final class JrtPath extends AbstractJrtPath {
+final class JrtPath implements Path {
+
+ final JrtFileSystem jrtfs;
+ private final String path;
+ private volatile int[] offsets;
+
+ JrtPath(JrtFileSystem jrtfs, String path) {
+ this.jrtfs = jrtfs;
+ this.path = normalize(path);
+ this.resolved = null;
+ }
+
+ JrtPath(JrtFileSystem jrtfs, String path, boolean normalized) {
+ this.jrtfs = jrtfs;
+ this.path = normalized ? path : normalize(path);
+ this.resolved = null;
+ }
+
+ final String getName() {
+ return path;
+ }
+
+ @Override
+ public final JrtPath getRoot() {
+ if (this.isAbsolute()) {
+ return jrtfs.getRootPath();
+ } else {
+ return null;
+ }
+ }
+
+ @Override
+ public final JrtPath getFileName() {
+ if (path.length() == 0)
+ return this;
+ if (path.length() == 1 && path.charAt(0) == '/')
+ return null;
+ int off = path.lastIndexOf('/');
+ if (off == -1)
+ return this;
+ return new JrtPath(jrtfs, path.substring(off + 1), true);
+ }
+
+ @Override
+ public final JrtPath getParent() {
+ initOffsets();
+ int count = offsets.length;
+ if (count == 0) { // no elements so no parent
+ return null;
+ }
+ int off = offsets[count - 1] - 1;
+ if (off <= 0) { // parent is root only (may be null)
+ return getRoot();
+ }
+ return new JrtPath(jrtfs, path.substring(0, off));
+ }
+
+ @Override
+ public final int getNameCount() {
+ initOffsets();
+ return offsets.length;
+ }
- JrtPath(AbstractJrtFileSystem jrtfs, byte[] path) {
- this(jrtfs, path, false);
+ @Override
+ public final JrtPath getName(int index) {
+ initOffsets();
+ if (index < 0 || index >= offsets.length) {
+ throw new IllegalArgumentException();
+ }
+ int begin = offsets[index];
+ int end;
+ if (index == (offsets.length - 1)) {
+ end = path.length();
+ } else {
+ end = offsets[index + 1];
+ }
+ return new JrtPath(jrtfs, path.substring(begin, end));
+ }
+
+ @Override
+ public final JrtPath subpath(int beginIndex, int endIndex) {
+ initOffsets();
+ if (beginIndex < 0 || endIndex > offsets.length ||
+ beginIndex >= endIndex) {
+ throw new IllegalArgumentException();
+ }
+ // starting/ending offsets
+ int begin = offsets[beginIndex];
+ int end;
+ if (endIndex == offsets.length) {
+ end = path.length();
+ } else {
+ end = offsets[endIndex];
+ }
+ return new JrtPath(jrtfs, path.substring(begin, end));
+ }
+
+ @Override
+ public final JrtPath toRealPath(LinkOption... options) throws IOException {
+ return jrtfs.toRealPath(this, options);
+ }
+
+ @Override
+ public final JrtPath toAbsolutePath() {
+ if (isAbsolute())
+ return this;
+ return new JrtPath(jrtfs, "/" + path, true);
+ }
+
+ @Override
+ public final URI toUri() {
+ try {
+ return new URI("jrt", toAbsolutePath().path, null);
+ } catch (URISyntaxException ex) {
+ throw new AssertionError(ex);
+ }
+ }
+
+ private boolean equalsNameAt(JrtPath other, int index) {
+ int mbegin = offsets[index];
+ int mlen;
+ if (index == (offsets.length - 1)) {
+ mlen = path.length() - mbegin;
+ } else {
+ mlen = offsets[index + 1] - mbegin - 1;
+ }
+ int obegin = other.offsets[index];
+ int olen;
+ if (index == (other.offsets.length - 1)) {
+ olen = other.path.length() - obegin;
+ } else {
+ olen = other.offsets[index + 1] - obegin - 1;
+ }
+ if (mlen != olen) {
+ return false;
+ }
+ int n = 0;
+ while (n < mlen) {
+ if (path.charAt(mbegin + n) != other.path.charAt(obegin + n)) {
+ return false;
+ }
+ n++;
+ }
+ return true;
}
- JrtPath(AbstractJrtFileSystem jrtfs, byte[] path, boolean normalized) {
- super(jrtfs, path, normalized);
+ @Override
+ public final JrtPath relativize(Path other) {
+ final JrtPath o = checkPath(other);
+ if (o.equals(this)) {
+ return new JrtPath(jrtfs, "", true);
+ }
+ if (path.length() == 0) {
+ return o;
+ }
+ if (jrtfs != o.jrtfs || isAbsolute() != o.isAbsolute()) {
+ throw new IllegalArgumentException();
+ }
+ final String tp = this.path;
+ final String op = o.path;
+ if (op.startsWith(tp)) { // fast path
+ int off = tp.length();
+ if (op.charAt(off - 1) == '/')
+ return new JrtPath(jrtfs, op.substring(off), true);
+ if (op.charAt(off) == '/')
+ return new JrtPath(jrtfs, op.substring(off + 1), true);
+ }
+ int mc = this.getNameCount();
+ int oc = o.getNameCount();
+ int n = Math.min(mc, oc);
+ int i = 0;
+ while (i < n) {
+ if (!equalsNameAt(o, i)) {
+ break;
+ }
+ i++;
+ }
+ int dotdots = mc - i;
+ int len = dotdots * 3 - 1;
+ if (i < oc) {
+ len += (o.path.length() - o.offsets[i] + 1);
+ }
+ StringBuilder sb = new StringBuilder(len);
+ while (dotdots > 0) {
+ sb.append("..");
+ if (sb.length() < len) { // no tailing slash at the end
+ sb.append('/');
+ }
+ dotdots--;
+ }
+ if (i < oc) {
+ sb.append(o.path, o.offsets[i], o.path.length());
+ }
+ return new JrtPath(jrtfs, sb.toString(), true);
+ }
+
+ @Override
+ public JrtFileSystem getFileSystem() {
+ return jrtfs;
+ }
+
+ @Override
+ public final boolean isAbsolute() {
+ return path.length() > 0 && path.charAt(0) == '/';
+ }
+
+ @Override
+ public final JrtPath resolve(Path other) {
+ final JrtPath o = checkPath(other);
+ if (this.path.length() == 0 || o.isAbsolute()) {
+ return o;
+ }
+ if (o.path.length() == 0) {
+ return this;
+ }
+ StringBuilder sb = new StringBuilder(path.length() + o.path.length());
+ sb.append(path);
+ if (path.charAt(path.length() - 1) != '/')
+ sb.append('/');
+ sb.append(o.path);
+ return new JrtPath(jrtfs, sb.toString(), true);
+ }
+
+ @Override
+ public final Path resolveSibling(Path other) {
+ Objects.requireNonNull(other, "other");
+ Path parent = getParent();
+ return (parent == null) ? other : parent.resolve(other);
+ }
+
+ @Override
+ public final boolean startsWith(Path other) {
+ if (!(Objects.requireNonNull(other) instanceof JrtPath))
+ return false;
+ final JrtPath o = (JrtPath)other;
+ final String tp = this.path;
+ final String op = o.path;
+ if (isAbsolute() != o.isAbsolute() || !tp.startsWith(op)) {
+ return false;
+ }
+ int off = op.length();
+ if (off == 0) {
+ return tp.length() == 0;
+ }
+ // check match is on name boundary
+ return tp.length() == off || tp.charAt(off) == '/' ||
+ off == 0 || op.charAt(off - 1) == '/';
+ }
+
+ @Override
+ public final boolean endsWith(Path other) {
+ if (!(Objects.requireNonNull(other) instanceof JrtPath))
+ return false;
+ final JrtPath o = (JrtPath)other;
+ final JrtPath t = this;
+ int olast = o.path.length() - 1;
+ if (olast > 0 && o.path.charAt(olast) == '/') {
+ olast--;
+ }
+ int last = t.path.length() - 1;
+ if (last > 0 && t.path.charAt(last) == '/') {
+ last--;
+ }
+ if (olast == -1) { // o.path.length == 0
+ return last == -1;
+ }
+ if ((o.isAbsolute() && (!t.isAbsolute() || olast != last))
+ || last < olast) {
+ return false;
+ }
+ for (; olast >= 0; olast--, last--) {
+ if (o.path.charAt(olast) != t.path.charAt(last)) {
+ return false;
+ }
+ }
+ return o.path.charAt(olast + 1) == '/' ||
+ last == -1 || t.path.charAt(last) == '/';
+ }
+
+ @Override
+ public final JrtPath resolve(String other) {
+ return resolve(getFileSystem().getPath(other));
+ }
+
+ @Override
+ public final Path resolveSibling(String other) {
+ return resolveSibling(getFileSystem().getPath(other));
+ }
+
+ @Override
+ public final boolean startsWith(String other) {
+ return startsWith(getFileSystem().getPath(other));
+ }
+
+ @Override
+ public final boolean endsWith(String other) {
+ return endsWith(getFileSystem().getPath(other));
}
@Override
- protected JrtPath newJrtPath(byte[] path) {
- return new JrtPath(jrtfs, path);
+ public final JrtPath normalize() {
+ String res = getResolved();
+ if (res == path) { // no change
+ return this;
+ }
+ return new JrtPath(jrtfs, res, true);
+ }
+
+ private JrtPath checkPath(Path path) {
+ Objects.requireNonNull(path);
+ if (!(path instanceof JrtPath))
+ throw new ProviderMismatchException();
+ return (JrtPath) path;
+ }
+
+ // create offset list if not already created
+ private void initOffsets() {
+ if (this.offsets == null) {
+ int len = path.length();
+ // count names
+ int count = 0;
+ int off = 0;
+ while (off < len) {
+ char c = path.charAt(off++);
+ if (c != '/') {
+ count++;
+ off = path.indexOf('/', off);
+ if (off == -1)
+ break;
+ }
+ }
+ // populate offsets
+ int[] offsets = new int[count];
+ count = 0;
+ off = 0;
+ while (off < len) {
+ char c = path.charAt(off);
+ if (c == '/') {
+ off++;
+ } else {
+ offsets[count++] = off++;
+ off = path.indexOf('/', off);
+ if (off == -1)
+ break;
+ }
+ }
+ this.offsets = offsets;
+ }
+ }
+
+ private volatile String resolved;
+
+ final String getResolvedPath() {
+ String r = resolved;
+ if (r == null) {
+ if (isAbsolute()) {
+ r = getResolved();
+ } else {
+ r = toAbsolutePath().getResolvedPath();
+ }
+ resolved = r;
+ }
+ return r;
+ }
+
+ // removes redundant slashs, replace "\" to separator "/"
+ // and check for invalid characters
+ private static String normalize(String path) {
+ int len = path.length();
+ if (len == 0) {
+ return path;
+ }
+ char prevC = 0;
+ for (int i = 0; i < len; i++) {
+ char c = path.charAt(i);
+ if (c == '\\' || c == '\u0000') {
+ return normalize(path, i);
+ }
+ if (c == '/' && prevC == '/') {
+ return normalize(path, i - 1);
+ }
+ prevC = c;
+ }
+ if (prevC == '/' && len > 1) {
+ return path.substring(0, len - 1);
+ }
+ return path;
+ }
+
+ private static String normalize(String path, int off) {
+ int len = path.length();
+ StringBuilder to = new StringBuilder(len);
+ to.append(path, 0, off);
+ char prevC = 0;
+ while (off < len) {
+ char c = path.charAt(off++);
+ if (c == '\\') {
+ c = '/';
+ }
+ if (c == '/' && prevC == '/') {
+ continue;
+ }
+ if (c == '\u0000') {
+ throw new InvalidPathException(path,
+ "Path: nul character not allowed");
+ }
+ to.append(c);
+ prevC = c;
+ }
+ len = to.length();
+ if (len > 1 && to.charAt(len - 1) == '/') {
+ to.deleteCharAt(len - 1);
+ }
+ return to.toString();
+ }
+
+ // Remove DotSlash(./) and resolve DotDot (..) components
+ private String getResolved() {
+ if (path.length() == 0) {
+ return path;
+ }
+ if (path.indexOf('.') == -1) {
+ return path;
+ }
+ int length = path.length();
+ char[] to = new char[length];
+ int nc = getNameCount();
+ int[] lastM = new int[nc];
+ int lastMOff = -1;
+ int m = 0;
+ for (int i = 0; i < nc; i++) {
+ int n = offsets[i];
+ int len = (i == offsets.length - 1) ? length - n
+ : offsets[i + 1] - n - 1;
+ if (len == 1 && path.charAt(n) == '.') {
+ if (m == 0 && path.charAt(0) == '/') // absolute path
+ to[m++] = '/';
+ continue;
+ }
+ if (len == 2 && path.charAt(n) == '.' && path.charAt(n + 1) == '.') {
+ if (lastMOff >= 0) {
+ m = lastM[lastMOff--]; // retreat
+ continue;
+ }
+ if (path.charAt(0) == '/') { // "/../xyz" skip
+ if (m == 0)
+ to[m++] = '/';
+ } else { // "../xyz" -> "../xyz"
+ if (m != 0 && to[m-1] != '/')
+ to[m++] = '/';
+ while (len-- > 0)
+ to[m++] = path.charAt(n++);
+ }
+ continue;
+ }
+ if (m == 0 && path.charAt(0) == '/' || // absolute path
+ m != 0 && to[m-1] != '/') { // not the first name
+ to[m++] = '/';
+ }
+ lastM[++lastMOff] = m;
+ while (len-- > 0)
+ to[m++] = path.charAt(n++);
+ }
+ if (m > 1 && to[m - 1] == '/')
+ m--;
+ return (m == to.length) ? new String(to) : new String(to, 0, m);
+ }
+
+ @Override
+ public final String toString() {
+ return path;
+ }
+
+ @Override
+ public final int hashCode() {
+ return path.hashCode();
+ }
+
+ @Override
+ public final boolean equals(Object obj) {
+ return obj instanceof JrtPath &&
+ this.path.equals(((JrtPath) obj).path);
+ }
+
+ @Override
+ public final int compareTo(Path other) {
+ final JrtPath o = checkPath(other);
+ return path.compareTo(o.path);
+ }
+
+ @Override
+ public final WatchKey register(
+ WatchService watcher,
+ WatchEvent.Kind<?>[] events,
+ WatchEvent.Modifier... modifiers) {
+ Objects.requireNonNull(watcher, "watcher");
+ Objects.requireNonNull(events, "events");
+ Objects.requireNonNull(modifiers, "modifiers");
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public final WatchKey register(WatchService watcher, WatchEvent.Kind<?>... events) {
+ return register(watcher, events, new WatchEvent.Modifier[0]);
+ }
+
+ @Override
+ public final File toFile() {
+ throw new UnsupportedOperationException();
}
@Override
- protected JrtPath newJrtPath(byte[] path, boolean normalized) {
- return new JrtPath(jrtfs, path, normalized);
+ public final Iterator<Path> iterator() {
+ return new Iterator<Path>() {
+ private int i = 0;
+
+ @Override
+ public boolean hasNext() {
+ return (i < getNameCount());
+ }
+
+ @Override
+ public Path next() {
+ if (i < getNameCount()) {
+ Path result = getName(i);
+ i++;
+ return result;
+ } else {
+ throw new NoSuchElementException();
+ }
+ }
+
+ @Override
+ public void remove() {
+ throw new ReadOnlyFileSystemException();
+ }
+ };
+ }
+
+ // Helpers for JrtFileSystemProvider and JrtFileSystem
+
+ final JrtPath readSymbolicLink() throws IOException {
+ if (!jrtfs.isLink(this)) {
+ throw new IOException("not a symbolic link");
+ }
+ return jrtfs.resolveLink(this);
+ }
+
+ final boolean isHidden() {
+ return false;
+ }
+
+ final void createDirectory(FileAttribute<?>... attrs)
+ throws IOException {
+ jrtfs.createDirectory(this, attrs);
+ }
+
+ final InputStream newInputStream(OpenOption... options) throws IOException {
+ if (options.length > 0) {
+ for (OpenOption opt : options) {
+ if (opt != READ) {
+ throw new UnsupportedOperationException("'" + opt + "' not allowed");
+ }
+ }
+ }
+ return jrtfs.newInputStream(this);
+ }
+
+ final DirectoryStream<Path> newDirectoryStream(Filter<? super Path> filter)
+ throws IOException {
+ return new JrtDirectoryStream(this, filter);
+ }
+
+ final void delete() throws IOException {
+ jrtfs.deleteFile(this, true);
+ }
+
+ final void deleteIfExists() throws IOException {
+ jrtfs.deleteFile(this, false);
+ }
+
+ final JrtFileAttributes getAttributes(LinkOption... options) throws IOException {
+ JrtFileAttributes zfas = jrtfs.getFileAttributes(this, options);
+ if (zfas == null) {
+ throw new NoSuchFileException(toString());
+ }
+ return zfas;
+ }
+
+ final void setAttribute(String attribute, Object value, LinkOption... options)
+ throws IOException {
+ JrtFileAttributeView.setAttribute(this, attribute, value);
+ }
+
+ final Map<String, Object> readAttributes(String attributes, LinkOption... options)
+ throws IOException {
+ return JrtFileAttributeView.readAttributes(this, attributes, options);
+ }
+
+ final void setTimes(FileTime mtime, FileTime atime, FileTime ctime)
+ throws IOException {
+ jrtfs.setTimes(this, mtime, atime, ctime);
+ }
+
+ final FileStore getFileStore() throws IOException {
+ // each JrtFileSystem only has one root (as requested for now)
+ if (exists()) {
+ return jrtfs.getFileStore(this);
+ }
+ throw new NoSuchFileException(path);
+ }
+
+ final boolean isSameFile(Path other) throws IOException {
+ if (this == other || this.equals(other)) {
+ return true;
+ }
+ if (other == null || this.getFileSystem() != other.getFileSystem()) {
+ return false;
+ }
+ this.checkAccess();
+ JrtPath o = (JrtPath) other;
+ o.checkAccess();
+ return this.getResolvedPath().equals(o.getResolvedPath()) ||
+ jrtfs.isSameFile(this, o);
+ }
+
+ final SeekableByteChannel newByteChannel(Set<? extends OpenOption> options,
+ FileAttribute<?>... attrs)
+ throws IOException
+ {
+ return jrtfs.newByteChannel(this, options, attrs);
+ }
+
+ final FileChannel newFileChannel(Set<? extends OpenOption> options,
+ FileAttribute<?>... attrs)
+ throws IOException {
+ return jrtfs.newFileChannel(this, options, attrs);
+ }
+
+ final void checkAccess(AccessMode... modes) throws IOException {
+ if (modes.length == 0) { // check if the path exists
+ jrtfs.checkNode(this); // no need to follow link. the "link" node
+ // is built from real node under "/module"
+ } else {
+ boolean w = false;
+ for (AccessMode mode : modes) {
+ switch (mode) {
+ case READ:
+ break;
+ case WRITE:
+ w = true;
+ break;
+ case EXECUTE:
+ throw new AccessDeniedException(toString());
+ default:
+ throw new UnsupportedOperationException();
+ }
+ }
+ jrtfs.checkNode(this);
+ if (w && jrtfs.isReadOnly()) {
+ throw new AccessDeniedException(toString());
+ }
+ }
+ }
+
+ final boolean exists() {
+ try {
+ return jrtfs.exists(this);
+ } catch (IOException x) {}
+ return false;
+ }
+
+ final OutputStream newOutputStream(OpenOption... options) throws IOException {
+ if (options.length == 0) {
+ return jrtfs.newOutputStream(this, CREATE_NEW, WRITE);
+ }
+ return jrtfs.newOutputStream(this, options);
+ }
+
+ final void move(JrtPath target, CopyOption... options) throws IOException {
+ if (this.jrtfs == target.jrtfs) {
+ jrtfs.copyFile(true, this, target, options);
+ } else {
+ copyToTarget(target, options);
+ delete();
+ }
+ }
+
+ final void copy(JrtPath target, CopyOption... options) throws IOException {
+ if (this.jrtfs == target.jrtfs) {
+ jrtfs.copyFile(false, this, target, options);
+ } else {
+ copyToTarget(target, options);
+ }
+ }
+
+ private void copyToTarget(JrtPath target, CopyOption... options)
+ throws IOException {
+ boolean replaceExisting = false;
+ boolean copyAttrs = false;
+ for (CopyOption opt : options) {
+ if (opt == REPLACE_EXISTING) {
+ replaceExisting = true;
+ } else if (opt == COPY_ATTRIBUTES) {
+ copyAttrs = true;
+ }
+ }
+ // attributes of source file
+ BasicFileAttributes jrtfas = getAttributes();
+ // check if target exists
+ boolean exists;
+ if (replaceExisting) {
+ try {
+ target.deleteIfExists();
+ exists = false;
+ } catch (DirectoryNotEmptyException x) {
+ exists = true;
+ }
+ } else {
+ exists = target.exists();
+ }
+ if (exists) {
+ throw new FileAlreadyExistsException(target.toString());
+ }
+ if (jrtfas.isDirectory()) {
+ // create directory or file
+ target.createDirectory();
+ } else {
+ try (InputStream is = jrtfs.newInputStream(this);
+ OutputStream os = target.newOutputStream()) {
+ byte[] buf = new byte[8192];
+ int n;
+ while ((n = is.read(buf)) != -1) {
+ os.write(buf, 0, n);
+ }
+ }
+ }
+ if (copyAttrs) {
+ BasicFileAttributeView view =
+ Files.getFileAttributeView(target, BasicFileAttributeView.class);
+ try {
+ view.setTimes(jrtfas.lastModifiedTime(),
+ jrtfas.lastAccessTime(),
+ jrtfas.creationTime());
+ } catch (IOException x) {
+ try {
+ target.delete(); // rollback?
+ } catch (IOException ignore) {}
+ throw x;
+ }
+ }
}
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/jrtfs/SystemImage.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.jrtfs;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.FileSystem;
+import java.nio.file.FileSystems;
+import java.nio.file.FileSystemNotFoundException;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.security.AccessController;
+import java.security.CodeSource;
+import java.security.PrivilegedAction;
+
+import jdk.internal.jimage.ImageReader;
+import jdk.internal.jimage.ImageReader.Node;
+
+/**
+ * @implNote This class needs to maintain JDK 8 source compatibility.
+ *
+ * It is used internally in the JDK to implement jimage/jrtfs access,
+ * but also compiled and delivered as part of the jrtfs.jar to support access
+ * to the jimage file provided by the shipped JDK by tools running on JDK 8.
+ */
+abstract class SystemImage {
+
+ abstract Node findNode(String path);
+ abstract byte[] getResource(Node node) throws IOException;
+ abstract void close() throws IOException;
+
+ static SystemImage open() throws IOException {
+ if (modulesImageExists) {
+ // open a .jimage and build directory structure
+ final ImageReader image = ImageReader.open(moduleImageFile);
+ image.getRootDirectory();
+ return new SystemImage() {
+ @Override
+ Node findNode(String path) {
+ return image.findNode(path);
+ }
+ @Override
+ byte[] getResource(Node node) throws IOException {
+ return image.getResource(node);
+ }
+ @Override
+ void close() throws IOException {
+ image.close();
+ }
+ };
+ }
+ if (Files.notExists(explodedModulesDir))
+ throw new FileSystemNotFoundException(explodedModulesDir.toString());
+ return new ExplodedImage(explodedModulesDir);
+ }
+
+ static final String RUNTIME_HOME;
+ // "modules" jimage file Path
+ final static Path moduleImageFile;
+ // "modules" jimage exists or not?
+ final static boolean modulesImageExists;
+ // <JAVA_HOME>/modules directory Path
+ static final Path explodedModulesDir;
+
+ static {
+ PrivilegedAction<String> pa = SystemImage::findHome;
+ RUNTIME_HOME = AccessController.doPrivileged(pa);
+
+ FileSystem fs = FileSystems.getDefault();
+ moduleImageFile = fs.getPath(RUNTIME_HOME, "lib", "modules");
+ explodedModulesDir = fs.getPath(RUNTIME_HOME, "modules");
+
+ modulesImageExists = AccessController.doPrivileged(
+ new PrivilegedAction<Boolean>() {
+ @Override
+ public Boolean run() {
+ return Files.isRegularFile(moduleImageFile);
+ }
+ });
+ }
+
+ /**
+ * Returns the appropriate JDK home for this usage of the FileSystemProvider.
+ * When the CodeSource is null (null loader) then jrt:/ is the current runtime,
+ * otherwise the JDK home is located relative to jrt-fs.jar.
+ */
+ private static String findHome() {
+ CodeSource cs = SystemImage.class.getProtectionDomain().getCodeSource();
+ if (cs == null)
+ return System.getProperty("java.home");
+
+ // assume loaded from $TARGETJDK/jrt-fs.jar
+ URL url = cs.getLocation();
+ if (!url.getProtocol().equalsIgnoreCase("file"))
+ throw new RuntimeException(url + " loaded in unexpected way");
+ try {
+ return Paths.get(url.toURI()).getParent().toString();
+ } catch (URISyntaxException e) {
+ throw new InternalError(e);
+ }
+ }
+}
--- a/jdk/src/java.base/share/classes/jdk/internal/jrtfs/SystemImages.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,106 +0,0 @@
-/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * 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.internal.jrtfs;
-
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.nio.file.Files;
-import java.nio.file.FileSystem;
-import java.nio.file.FileSystems;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.security.AccessController;
-import java.security.CodeSource;
-import java.security.PrivilegedAction;
-
-/**
- * @implNote This class needs to maintain JDK 8 source compatibility.
- *
- * It is used internally in the JDK to implement jimage/jrtfs access,
- * but also compiled and delivered as part of the jrtfs.jar to support access
- * to the jimage file provided by the shipped JDK by tools running on JDK 8.
- */
-final class SystemImages {
- private SystemImages() {}
-
-
- static final String RUNTIME_HOME;
- // "modules" jimage file Path
- private static final Path moduleImageFile;
- // "modules" jimage exists or not?
- private static final boolean modulesImageExists;
- // <JAVA_HOME>/modules directory Path
- private static final Path explodedModulesDir;
-
- static {
- PrivilegedAction<String> pa = SystemImages::findHome;
- RUNTIME_HOME = AccessController.doPrivileged(pa);
-
- FileSystem fs = FileSystems.getDefault();
- moduleImageFile = fs.getPath(RUNTIME_HOME, "lib", "modules");
- explodedModulesDir = fs.getPath(RUNTIME_HOME, "modules");
-
- modulesImageExists = AccessController.doPrivileged(
- new PrivilegedAction<Boolean>() {
- @Override
- public Boolean run() {
- return Files.isRegularFile(moduleImageFile);
- }
- });
- }
-
- static boolean hasModulesImage() {
- return modulesImageExists;
- }
-
- static Path moduleImageFile() {
- return moduleImageFile;
- }
-
- static Path explodedModulesDir() {
- return explodedModulesDir;
- }
-
- /**
- * Returns the appropriate JDK home for this usage of the FileSystemProvider.
- * When the CodeSource is null (null loader) then jrt:/ is the current runtime,
- * otherwise the JDK home is located relative to jrt-fs.jar.
- */
- private static String findHome() {
- CodeSource cs = SystemImages.class.getProtectionDomain().getCodeSource();
- if (cs == null)
- return System.getProperty("java.home");
-
- // assume loaded from $TARGETJDK/jrt-fs.jar
- URL url = cs.getLocation();
- if (!url.getProtocol().equalsIgnoreCase("file"))
- throw new RuntimeException(url + " loaded in unexpected way");
- try {
- return Paths.get(url.toURI()).getParent().toString();
- } catch (URISyntaxException e) {
- throw new InternalError(e);
- }
- }
-}
--- a/jdk/src/java.base/share/classes/jdk/internal/misc/JavaLangAccess.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/jdk/internal/misc/JavaLangAccess.java Wed Jul 05 21:35:27 2017 +0200
@@ -37,7 +37,7 @@
import java.util.stream.Stream;
import jdk.internal.module.ServicesCatalog;
-import sun.reflect.ConstantPool;
+import jdk.internal.reflect.ConstantPool;
import sun.reflect.annotation.AnnotationType;
import sun.nio.ch.Interruptible;
--- a/jdk/src/java.base/share/classes/jdk/internal/misc/Unsafe.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/jdk/internal/misc/Unsafe.java Wed Jul 05 21:35:27 2017 +0200
@@ -28,8 +28,8 @@
import java.lang.reflect.Field;
import java.security.ProtectionDomain;
-import sun.reflect.CallerSensitive;
-import sun.reflect.Reflection;
+import jdk.internal.reflect.CallerSensitive;
+import jdk.internal.reflect.Reflection;
import jdk.internal.misc.VM;
import jdk.internal.HotSpotIntrinsicCandidate;
@@ -58,7 +58,7 @@
private static native void registerNatives();
static {
registerNatives();
- sun.reflect.Reflection.registerMethodsToFilter(Unsafe.class, "getUnsafe");
+ Reflection.registerMethodsToFilter(Unsafe.class, "getUnsafe");
}
private Unsafe() {}
--- a/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/RemappingAnnotationAdapter.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/RemappingAnnotationAdapter.java Wed Jul 05 21:35:27 2017 +0200
@@ -65,10 +65,10 @@
/**
* An {@link AnnotationVisitor} adapter for type remapping.
*
- * //@deprecated use {@link AnnotationRemapper} instead.
+ * @deprecated use {@link AnnotationRemapper} instead.
* @author Eugene Kuleshov
*/
-//@Deprecated
+@Deprecated
public class RemappingAnnotationAdapter extends AnnotationVisitor {
protected final Remapper remapper;
--- a/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/RemappingMethodAdapter.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/RemappingMethodAdapter.java Wed Jul 05 21:35:27 2017 +0200
@@ -69,10 +69,10 @@
/**
* A {@link LocalVariablesSorter} for type mapping.
*
- * //@deprecated use {@link MethodRemapper} instead.
+ * @deprecated use {@link MethodRemapper} instead.
* @author Eugene Kuleshov
*/
-//@Deprecated
+@Deprecated
public class RemappingMethodAdapter extends LocalVariablesSorter {
protected final Remapper remapper;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/AccessorGenerator.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,723 @@
+/*
+ * Copyright (c) 2001, 2013, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+import java.lang.reflect.*;
+import jdk.internal.misc.Unsafe;
+
+/** Shared functionality for all accessor generators */
+
+class AccessorGenerator implements ClassFileConstants {
+ static final Unsafe unsafe = Unsafe.getUnsafe();
+
+ // Constants because there's no way to say "short integer constant",
+ // i.e., "1S"
+ protected static final short S0 = (short) 0;
+ protected static final short S1 = (short) 1;
+ protected static final short S2 = (short) 2;
+ protected static final short S3 = (short) 3;
+ protected static final short S4 = (short) 4;
+ protected static final short S5 = (short) 5;
+ protected static final short S6 = (short) 6;
+
+ // Instance variables for shared functionality between
+ // FieldAccessorGenerator and MethodAccessorGenerator
+ protected ClassFileAssembler asm;
+ protected int modifiers;
+ protected short thisClass;
+ protected short superClass;
+ protected short targetClass;
+ // Common constant pool entries to FieldAccessor and MethodAccessor
+ protected short throwableClass;
+ protected short classCastClass;
+ protected short nullPointerClass;
+ protected short illegalArgumentClass;
+ protected short invocationTargetClass;
+ protected short initIdx;
+ protected short initNameAndTypeIdx;
+ protected short initStringNameAndTypeIdx;
+ protected short nullPointerCtorIdx;
+ protected short illegalArgumentCtorIdx;
+ protected short illegalArgumentStringCtorIdx;
+ protected short invocationTargetCtorIdx;
+ protected short superCtorIdx;
+ protected short objectClass;
+ protected short toStringIdx;
+ protected short codeIdx;
+ protected short exceptionsIdx;
+ // Boxing
+ protected short valueOfIdx;
+ protected short booleanIdx;
+ protected short booleanBoxIdx;
+ protected short booleanUnboxIdx;
+ protected short byteIdx;
+ protected short byteBoxIdx;
+ protected short byteUnboxIdx;
+ protected short characterIdx;
+ protected short characterBoxIdx;
+ protected short characterUnboxIdx;
+ protected short doubleIdx;
+ protected short doubleBoxIdx;
+ protected short doubleUnboxIdx;
+ protected short floatIdx;
+ protected short floatBoxIdx;
+ protected short floatUnboxIdx;
+ protected short integerIdx;
+ protected short integerBoxIdx;
+ protected short integerUnboxIdx;
+ protected short longIdx;
+ protected short longBoxIdx;
+ protected short longUnboxIdx;
+ protected short shortIdx;
+ protected short shortBoxIdx;
+ protected short shortUnboxIdx;
+
+ protected final short NUM_COMMON_CPOOL_ENTRIES = (short) 30;
+ protected final short NUM_BOXING_CPOOL_ENTRIES = (short) 73;
+
+ // Requires that superClass has been set up
+ protected void emitCommonConstantPoolEntries() {
+ // + [UTF-8] "java/lang/Throwable"
+ // + [CONSTANT_Class_info] for above
+ // + [UTF-8] "java/lang/ClassCastException"
+ // + [CONSTANT_Class_info] for above
+ // + [UTF-8] "java/lang/NullPointerException"
+ // + [CONSTANT_Class_info] for above
+ // + [UTF-8] "java/lang/IllegalArgumentException"
+ // + [CONSTANT_Class_info] for above
+ // + [UTF-8] "java/lang/InvocationTargetException"
+ // + [CONSTANT_Class_info] for above
+ // + [UTF-8] "<init>"
+ // + [UTF-8] "()V"
+ // + [CONSTANT_NameAndType_info] for above
+ // + [CONSTANT_Methodref_info] for NullPointerException's constructor
+ // + [CONSTANT_Methodref_info] for IllegalArgumentException's constructor
+ // + [UTF-8] "(Ljava/lang/String;)V"
+ // + [CONSTANT_NameAndType_info] for "<init>(Ljava/lang/String;)V"
+ // + [CONSTANT_Methodref_info] for IllegalArgumentException's constructor taking a String
+ // + [UTF-8] "(Ljava/lang/Throwable;)V"
+ // + [CONSTANT_NameAndType_info] for "<init>(Ljava/lang/Throwable;)V"
+ // + [CONSTANT_Methodref_info] for InvocationTargetException's constructor
+ // + [CONSTANT_Methodref_info] for "super()"
+ // + [UTF-8] "java/lang/Object"
+ // + [CONSTANT_Class_info] for above
+ // + [UTF-8] "toString"
+ // + [UTF-8] "()Ljava/lang/String;"
+ // + [CONSTANT_NameAndType_info] for "toString()Ljava/lang/String;"
+ // + [CONSTANT_Methodref_info] for Object's toString method
+ // + [UTF-8] "Code"
+ // + [UTF-8] "Exceptions"
+ asm.emitConstantPoolUTF8("java/lang/Throwable");
+ asm.emitConstantPoolClass(asm.cpi());
+ throwableClass = asm.cpi();
+ asm.emitConstantPoolUTF8("java/lang/ClassCastException");
+ asm.emitConstantPoolClass(asm.cpi());
+ classCastClass = asm.cpi();
+ asm.emitConstantPoolUTF8("java/lang/NullPointerException");
+ asm.emitConstantPoolClass(asm.cpi());
+ nullPointerClass = asm.cpi();
+ asm.emitConstantPoolUTF8("java/lang/IllegalArgumentException");
+ asm.emitConstantPoolClass(asm.cpi());
+ illegalArgumentClass = asm.cpi();
+ asm.emitConstantPoolUTF8("java/lang/reflect/InvocationTargetException");
+ asm.emitConstantPoolClass(asm.cpi());
+ invocationTargetClass = asm.cpi();
+ asm.emitConstantPoolUTF8("<init>");
+ initIdx = asm.cpi();
+ asm.emitConstantPoolUTF8("()V");
+ asm.emitConstantPoolNameAndType(initIdx, asm.cpi());
+ initNameAndTypeIdx = asm.cpi();
+ asm.emitConstantPoolMethodref(nullPointerClass, initNameAndTypeIdx);
+ nullPointerCtorIdx = asm.cpi();
+ asm.emitConstantPoolMethodref(illegalArgumentClass, initNameAndTypeIdx);
+ illegalArgumentCtorIdx = asm.cpi();
+ asm.emitConstantPoolUTF8("(Ljava/lang/String;)V");
+ asm.emitConstantPoolNameAndType(initIdx, asm.cpi());
+ initStringNameAndTypeIdx = asm.cpi();
+ asm.emitConstantPoolMethodref(illegalArgumentClass, initStringNameAndTypeIdx);
+ illegalArgumentStringCtorIdx = asm.cpi();
+ asm.emitConstantPoolUTF8("(Ljava/lang/Throwable;)V");
+ asm.emitConstantPoolNameAndType(initIdx, asm.cpi());
+ asm.emitConstantPoolMethodref(invocationTargetClass, asm.cpi());
+ invocationTargetCtorIdx = asm.cpi();
+ asm.emitConstantPoolMethodref(superClass, initNameAndTypeIdx);
+ superCtorIdx = asm.cpi();
+ asm.emitConstantPoolUTF8("java/lang/Object");
+ asm.emitConstantPoolClass(asm.cpi());
+ objectClass = asm.cpi();
+ asm.emitConstantPoolUTF8("toString");
+ asm.emitConstantPoolUTF8("()Ljava/lang/String;");
+ asm.emitConstantPoolNameAndType(sub(asm.cpi(), S1), asm.cpi());
+ asm.emitConstantPoolMethodref(objectClass, asm.cpi());
+ toStringIdx = asm.cpi();
+ asm.emitConstantPoolUTF8("Code");
+ codeIdx = asm.cpi();
+ asm.emitConstantPoolUTF8("Exceptions");
+ exceptionsIdx = asm.cpi();
+ }
+
+ /** Constant pool entries required to be able to box/unbox primitive
+ types. Note that we don't emit these if we don't need them. */
+ protected void emitBoxingContantPoolEntries() {
+ // * [UTF-8] "valueOf"
+ // * [UTF-8] "java/lang/Boolean"
+ // * [CONSTANT_Class_info] for above
+ // * [UTF-8] "(Z)Ljava/lang/Boolean;"
+ // * [CONSTANT_NameAndType_info] for above
+ // * [CONSTANT_Methodref_info] for above
+ // * [UTF-8] "booleanValue"
+ // * [UTF-8] "()Z"
+ // * [CONSTANT_NameAndType_info] for above
+ // * [CONSTANT_Methodref_info] for above
+ // * [UTF-8] "java/lang/Byte"
+ // * [CONSTANT_Class_info] for above
+ // * [UTF-8] "(B)Ljava/lang/Byte;"
+ // * [CONSTANT_NameAndType_info] for above
+ // * [CONSTANT_Methodref_info] for above
+ // * [UTF-8] "byteValue"
+ // * [UTF-8] "()B"
+ // * [CONSTANT_NameAndType_info] for above
+ // * [CONSTANT_Methodref_info] for above
+ // * [UTF-8] "java/lang/Character"
+ // * [CONSTANT_Class_info] for above
+ // * [UTF-8] "(C)Ljava/lang/Character;"
+ // * [CONSTANT_NameAndType_info] for above
+ // * [CONSTANT_Methodref_info] for above
+ // * [UTF-8] "charValue"
+ // * [UTF-8] "()C"
+ // * [CONSTANT_NameAndType_info] for above
+ // * [CONSTANT_Methodref_info] for above
+ // * [UTF-8] "java/lang/Double"
+ // * [CONSTANT_Class_info] for above
+ // * [UTF-8] "(D)Ljava/lang/Double;"
+ // * [CONSTANT_NameAndType_info] for above
+ // * [CONSTANT_Methodref_info] for above
+ // * [UTF-8] "doubleValue"
+ // * [UTF-8] "()D"
+ // * [CONSTANT_NameAndType_info] for above
+ // * [CONSTANT_Methodref_info] for above
+ // * [UTF-8] "java/lang/Float"
+ // * [CONSTANT_Class_info] for above
+ // * [UTF-8] "(F)Ljava/lang/Float;"
+ // * [CONSTANT_NameAndType_info] for above
+ // * [CONSTANT_Methodref_info] for above
+ // * [UTF-8] "floatValue"
+ // * [UTF-8] "()F"
+ // * [CONSTANT_NameAndType_info] for above
+ // * [CONSTANT_Methodref_info] for above
+ // * [UTF-8] "java/lang/Integer"
+ // * [CONSTANT_Class_info] for above
+ // * [UTF-8] "(I)Ljava/lang/Integer;"
+ // * [CONSTANT_NameAndType_info] for above
+ // * [CONSTANT_Methodref_info] for above
+ // * [UTF-8] "intValue"
+ // * [UTF-8] "()I"
+ // * [CONSTANT_NameAndType_info] for above
+ // * [CONSTANT_Methodref_info] for above
+ // * [UTF-8] "java/lang/Long"
+ // * [CONSTANT_Class_info] for above
+ // * [UTF-8] "(J)Ljava/lang/Long;"
+ // * [CONSTANT_NameAndType_info] for above
+ // * [CONSTANT_Methodref_info] for above
+ // * [UTF-8] "longValue"
+ // * [UTF-8] "()J"
+ // * [CONSTANT_NameAndType_info] for above
+ // * [CONSTANT_Methodref_info] for above
+ // * [UTF-8] "java/lang/Short"
+ // * [CONSTANT_Class_info] for above
+ // * [UTF-8] "(S)Ljava/lang/Short;"
+ // * [CONSTANT_NameAndType_info] for above
+ // * [CONSTANT_Methodref_info] for above
+ // * [UTF-8] "shortValue"
+ // * [UTF-8] "()S"
+ // * [CONSTANT_NameAndType_info] for above
+ // * [CONSTANT_Methodref_info] for above
+
+ // valueOf-method name
+ asm.emitConstantPoolUTF8("valueOf");
+ valueOfIdx = asm.cpi();
+
+ // Boolean
+ asm.emitConstantPoolUTF8("java/lang/Boolean");
+ asm.emitConstantPoolClass(asm.cpi());
+ booleanIdx = asm.cpi();
+ asm.emitConstantPoolUTF8("(Z)Ljava/lang/Boolean;");
+ asm.emitConstantPoolNameAndType(valueOfIdx, asm.cpi());
+ asm.emitConstantPoolMethodref(sub(asm.cpi(), S2), asm.cpi());
+ booleanBoxIdx = asm.cpi();
+ asm.emitConstantPoolUTF8("booleanValue");
+ asm.emitConstantPoolUTF8("()Z");
+ asm.emitConstantPoolNameAndType(sub(asm.cpi(), S1), asm.cpi());
+ asm.emitConstantPoolMethodref(sub(asm.cpi(), S6), asm.cpi());
+ booleanUnboxIdx = asm.cpi();
+
+ // Byte
+ asm.emitConstantPoolUTF8("java/lang/Byte");
+ asm.emitConstantPoolClass(asm.cpi());
+ byteIdx = asm.cpi();
+ asm.emitConstantPoolUTF8("(B)Ljava/lang/Byte;");
+ asm.emitConstantPoolNameAndType(valueOfIdx, asm.cpi());
+ asm.emitConstantPoolMethodref(sub(asm.cpi(), S2), asm.cpi());
+ byteBoxIdx = asm.cpi();
+ asm.emitConstantPoolUTF8("byteValue");
+ asm.emitConstantPoolUTF8("()B");
+ asm.emitConstantPoolNameAndType(sub(asm.cpi(), S1), asm.cpi());
+ asm.emitConstantPoolMethodref(sub(asm.cpi(), S6), asm.cpi());
+ byteUnboxIdx = asm.cpi();
+
+ // Character
+ asm.emitConstantPoolUTF8("java/lang/Character");
+ asm.emitConstantPoolClass(asm.cpi());
+ characterIdx = asm.cpi();
+ asm.emitConstantPoolUTF8("(C)Ljava/lang/Character;");
+ asm.emitConstantPoolNameAndType(valueOfIdx, asm.cpi());
+ asm.emitConstantPoolMethodref(sub(asm.cpi(), S2), asm.cpi());
+ characterBoxIdx = asm.cpi();
+ asm.emitConstantPoolUTF8("charValue");
+ asm.emitConstantPoolUTF8("()C");
+ asm.emitConstantPoolNameAndType(sub(asm.cpi(), S1), asm.cpi());
+ asm.emitConstantPoolMethodref(sub(asm.cpi(), S6), asm.cpi());
+ characterUnboxIdx = asm.cpi();
+
+ // Double
+ asm.emitConstantPoolUTF8("java/lang/Double");
+ asm.emitConstantPoolClass(asm.cpi());
+ doubleIdx = asm.cpi();
+ asm.emitConstantPoolUTF8("(D)Ljava/lang/Double;");
+ asm.emitConstantPoolNameAndType(valueOfIdx, asm.cpi());
+ asm.emitConstantPoolMethodref(sub(asm.cpi(), S2), asm.cpi());
+ doubleBoxIdx = asm.cpi();
+ asm.emitConstantPoolUTF8("doubleValue");
+ asm.emitConstantPoolUTF8("()D");
+ asm.emitConstantPoolNameAndType(sub(asm.cpi(), S1), asm.cpi());
+ asm.emitConstantPoolMethodref(sub(asm.cpi(), S6), asm.cpi());
+ doubleUnboxIdx = asm.cpi();
+
+ // Float
+ asm.emitConstantPoolUTF8("java/lang/Float");
+ asm.emitConstantPoolClass(asm.cpi());
+ floatIdx = asm.cpi();
+ asm.emitConstantPoolUTF8("(F)Ljava/lang/Float;");
+ asm.emitConstantPoolNameAndType(valueOfIdx, asm.cpi());
+ asm.emitConstantPoolMethodref(sub(asm.cpi(), S2), asm.cpi());
+ floatBoxIdx = asm.cpi();
+ asm.emitConstantPoolUTF8("floatValue");
+ asm.emitConstantPoolUTF8("()F");
+ asm.emitConstantPoolNameAndType(sub(asm.cpi(), S1), asm.cpi());
+ asm.emitConstantPoolMethodref(sub(asm.cpi(), S6), asm.cpi());
+ floatUnboxIdx = asm.cpi();
+
+ // Integer
+ asm.emitConstantPoolUTF8("java/lang/Integer");
+ asm.emitConstantPoolClass(asm.cpi());
+ integerIdx = asm.cpi();
+ asm.emitConstantPoolUTF8("(I)Ljava/lang/Integer;");
+ asm.emitConstantPoolNameAndType(valueOfIdx, asm.cpi());
+ asm.emitConstantPoolMethodref(sub(asm.cpi(), S2), asm.cpi());
+ integerBoxIdx = asm.cpi();
+ asm.emitConstantPoolUTF8("intValue");
+ asm.emitConstantPoolUTF8("()I");
+ asm.emitConstantPoolNameAndType(sub(asm.cpi(), S1), asm.cpi());
+ asm.emitConstantPoolMethodref(sub(asm.cpi(), S6), asm.cpi());
+ integerUnboxIdx = asm.cpi();
+
+ // Long
+ asm.emitConstantPoolUTF8("java/lang/Long");
+ asm.emitConstantPoolClass(asm.cpi());
+ longIdx = asm.cpi();
+ asm.emitConstantPoolUTF8("(J)Ljava/lang/Long;");
+ asm.emitConstantPoolNameAndType(valueOfIdx, asm.cpi());
+ asm.emitConstantPoolMethodref(sub(asm.cpi(), S2), asm.cpi());
+ longBoxIdx = asm.cpi();
+ asm.emitConstantPoolUTF8("longValue");
+ asm.emitConstantPoolUTF8("()J");
+ asm.emitConstantPoolNameAndType(sub(asm.cpi(), S1), asm.cpi());
+ asm.emitConstantPoolMethodref(sub(asm.cpi(), S6), asm.cpi());
+ longUnboxIdx = asm.cpi();
+
+ // Short
+ asm.emitConstantPoolUTF8("java/lang/Short");
+ asm.emitConstantPoolClass(asm.cpi());
+ shortIdx = asm.cpi();
+ asm.emitConstantPoolUTF8("(S)Ljava/lang/Short;");
+ asm.emitConstantPoolNameAndType(valueOfIdx, asm.cpi());
+ asm.emitConstantPoolMethodref(sub(asm.cpi(), S2), asm.cpi());
+ shortBoxIdx = asm.cpi();
+ asm.emitConstantPoolUTF8("shortValue");
+ asm.emitConstantPoolUTF8("()S");
+ asm.emitConstantPoolNameAndType(sub(asm.cpi(), S1), asm.cpi());
+ asm.emitConstantPoolMethodref(sub(asm.cpi(), S6), asm.cpi());
+ shortUnboxIdx = asm.cpi();
+ }
+
+ // Necessary because of Java's annoying promotion rules
+ protected static short add(short s1, short s2) {
+ return (short) (s1 + s2);
+ }
+
+ protected static short sub(short s1, short s2) {
+ return (short) (s1 - s2);
+ }
+
+ protected boolean isStatic() {
+ return Modifier.isStatic(modifiers);
+ }
+
+ protected boolean isPrivate() {
+ return Modifier.isPrivate(modifiers);
+ }
+
+ /** Returns class name in "internal" form (i.e., '/' separators
+ instead of '.') */
+ protected static String getClassName
+ (Class<?> c, boolean addPrefixAndSuffixForNonPrimitiveTypes)
+ {
+ if (c.isPrimitive()) {
+ if (c == Boolean.TYPE) {
+ return "Z";
+ } else if (c == Byte.TYPE) {
+ return "B";
+ } else if (c == Character.TYPE) {
+ return "C";
+ } else if (c == Double.TYPE) {
+ return "D";
+ } else if (c == Float.TYPE) {
+ return "F";
+ } else if (c == Integer.TYPE) {
+ return "I";
+ } else if (c == Long.TYPE) {
+ return "J";
+ } else if (c == Short.TYPE) {
+ return "S";
+ } else if (c == Void.TYPE) {
+ return "V";
+ }
+ throw new InternalError("Should have found primitive type");
+ } else if (c.isArray()) {
+ return "[" + getClassName(c.getComponentType(), true);
+ } else {
+ if (addPrefixAndSuffixForNonPrimitiveTypes) {
+ return internalize("L" + c.getName() + ";");
+ } else {
+ return internalize(c.getName());
+ }
+ }
+ }
+
+ private static String internalize(String className) {
+ return className.replace('.', '/');
+ }
+
+ protected void emitConstructor() {
+ // Generate code into fresh code buffer
+ ClassFileAssembler cb = new ClassFileAssembler();
+ // 0 incoming arguments
+ cb.setMaxLocals(1);
+ cb.opc_aload_0();
+ cb.opc_invokespecial(superCtorIdx, 0, 0);
+ cb.opc_return();
+
+ // Emit method
+ emitMethod(initIdx, cb.getMaxLocals(), cb, null, null);
+ }
+
+ // The descriptor's index in the constant pool must be (1 +
+ // nameIdx). "numArgs" must indicate ALL arguments, including the
+ // implicit "this" argument; double and long arguments each count
+ // as 2 in this count. The code buffer must NOT contain the code
+ // length. The exception table may be null, but if non-null must
+ // NOT contain the exception table's length. The checked exception
+ // indices may be null.
+ protected void emitMethod(short nameIdx,
+ int numArgs,
+ ClassFileAssembler code,
+ ClassFileAssembler exceptionTable,
+ short[] checkedExceptionIndices)
+ {
+ int codeLen = code.getLength();
+ int excLen = 0;
+ if (exceptionTable != null) {
+ excLen = exceptionTable.getLength();
+ if ((excLen % 8) != 0) {
+ throw new IllegalArgumentException("Illegal exception table");
+ }
+ }
+ int attrLen = 12 + codeLen + excLen;
+ excLen = excLen / 8; // No-op if no exception table
+
+ asm.emitShort(ACC_PUBLIC);
+ asm.emitShort(nameIdx);
+ asm.emitShort(add(nameIdx, S1));
+ if (checkedExceptionIndices == null) {
+ // Code attribute only
+ asm.emitShort(S1);
+ } else {
+ // Code and Exceptions attributes
+ asm.emitShort(S2);
+ }
+ // Code attribute
+ asm.emitShort(codeIdx);
+ asm.emitInt(attrLen);
+ asm.emitShort(code.getMaxStack());
+ asm.emitShort((short) Math.max(numArgs, code.getMaxLocals()));
+ asm.emitInt(codeLen);
+ asm.append(code);
+ asm.emitShort((short) excLen);
+ if (exceptionTable != null) {
+ asm.append(exceptionTable);
+ }
+ asm.emitShort(S0); // No additional attributes for Code attribute
+ if (checkedExceptionIndices != null) {
+ // Exceptions attribute
+ asm.emitShort(exceptionsIdx);
+ asm.emitInt(2 + 2 * checkedExceptionIndices.length);
+ asm.emitShort((short) checkedExceptionIndices.length);
+ for (int i = 0; i < checkedExceptionIndices.length; i++) {
+ asm.emitShort(checkedExceptionIndices[i]);
+ }
+ }
+ }
+
+ protected short indexForPrimitiveType(Class<?> type) {
+ if (type == Boolean.TYPE) {
+ return booleanIdx;
+ } else if (type == Byte.TYPE) {
+ return byteIdx;
+ } else if (type == Character.TYPE) {
+ return characterIdx;
+ } else if (type == Double.TYPE) {
+ return doubleIdx;
+ } else if (type == Float.TYPE) {
+ return floatIdx;
+ } else if (type == Integer.TYPE) {
+ return integerIdx;
+ } else if (type == Long.TYPE) {
+ return longIdx;
+ } else if (type == Short.TYPE) {
+ return shortIdx;
+ }
+ throw new InternalError("Should have found primitive type");
+ }
+
+ protected short boxingMethodForPrimitiveType(Class<?> type) {
+ if (type == Boolean.TYPE) {
+ return booleanBoxIdx;
+ } else if (type == Byte.TYPE) {
+ return byteBoxIdx;
+ } else if (type == Character.TYPE) {
+ return characterBoxIdx;
+ } else if (type == Double.TYPE) {
+ return doubleBoxIdx;
+ } else if (type == Float.TYPE) {
+ return floatBoxIdx;
+ } else if (type == Integer.TYPE) {
+ return integerBoxIdx;
+ } else if (type == Long.TYPE) {
+ return longBoxIdx;
+ } else if (type == Short.TYPE) {
+ return shortBoxIdx;
+ }
+ throw new InternalError("Should have found primitive type");
+ }
+
+ /** Returns true for widening or identity conversions for primitive
+ types only */
+ protected static boolean canWidenTo(Class<?> type, Class<?> otherType) {
+ if (!type.isPrimitive()) {
+ return false;
+ }
+
+ // Widening conversions (from JVM spec):
+ // byte to short, int, long, float, or double
+ // short to int, long, float, or double
+ // char to int, long, float, or double
+ // int to long, float, or double
+ // long to float or double
+ // float to double
+
+ if (type == Boolean.TYPE) {
+ if (otherType == Boolean.TYPE) {
+ return true;
+ }
+ } else if (type == Byte.TYPE) {
+ if ( otherType == Byte.TYPE
+ || otherType == Short.TYPE
+ || otherType == Integer.TYPE
+ || otherType == Long.TYPE
+ || otherType == Float.TYPE
+ || otherType == Double.TYPE) {
+ return true;
+ }
+ } else if (type == Short.TYPE) {
+ if ( otherType == Short.TYPE
+ || otherType == Integer.TYPE
+ || otherType == Long.TYPE
+ || otherType == Float.TYPE
+ || otherType == Double.TYPE) {
+ return true;
+ }
+ } else if (type == Character.TYPE) {
+ if ( otherType == Character.TYPE
+ || otherType == Integer.TYPE
+ || otherType == Long.TYPE
+ || otherType == Float.TYPE
+ || otherType == Double.TYPE) {
+ return true;
+ }
+ } else if (type == Integer.TYPE) {
+ if ( otherType == Integer.TYPE
+ || otherType == Long.TYPE
+ || otherType == Float.TYPE
+ || otherType == Double.TYPE) {
+ return true;
+ }
+ } else if (type == Long.TYPE) {
+ if ( otherType == Long.TYPE
+ || otherType == Float.TYPE
+ || otherType == Double.TYPE) {
+ return true;
+ }
+ } else if (type == Float.TYPE) {
+ if ( otherType == Float.TYPE
+ || otherType == Double.TYPE) {
+ return true;
+ }
+ } else if (type == Double.TYPE) {
+ if (otherType == Double.TYPE) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /** Emits the widening bytecode for the given primitive conversion
+ (or none if the identity conversion). Requires that a primitive
+ conversion exists; i.e., canWidenTo must have already been
+ called and returned true. */
+ protected static void emitWideningBytecodeForPrimitiveConversion
+ (ClassFileAssembler cb,
+ Class<?> fromType,
+ Class<?> toType)
+ {
+ // Note that widening conversions for integral types (i.e., "b2s",
+ // "s2i") are no-ops since values on the Java stack are
+ // sign-extended.
+
+ // Widening conversions (from JVM spec):
+ // byte to short, int, long, float, or double
+ // short to int, long, float, or double
+ // char to int, long, float, or double
+ // int to long, float, or double
+ // long to float or double
+ // float to double
+
+ if ( fromType == Byte.TYPE
+ || fromType == Short.TYPE
+ || fromType == Character.TYPE
+ || fromType == Integer.TYPE) {
+ if (toType == Long.TYPE) {
+ cb.opc_i2l();
+ } else if (toType == Float.TYPE) {
+ cb.opc_i2f();
+ } else if (toType == Double.TYPE) {
+ cb.opc_i2d();
+ }
+ } else if (fromType == Long.TYPE) {
+ if (toType == Float.TYPE) {
+ cb.opc_l2f();
+ } else if (toType == Double.TYPE) {
+ cb.opc_l2d();
+ }
+ } else if (fromType == Float.TYPE) {
+ if (toType == Double.TYPE) {
+ cb.opc_f2d();
+ }
+ }
+
+ // Otherwise, was identity or no-op conversion. Fall through.
+ }
+
+ protected short unboxingMethodForPrimitiveType(Class<?> primType) {
+ if (primType == Boolean.TYPE) {
+ return booleanUnboxIdx;
+ } else if (primType == Byte.TYPE) {
+ return byteUnboxIdx;
+ } else if (primType == Character.TYPE) {
+ return characterUnboxIdx;
+ } else if (primType == Short.TYPE) {
+ return shortUnboxIdx;
+ } else if (primType == Integer.TYPE) {
+ return integerUnboxIdx;
+ } else if (primType == Long.TYPE) {
+ return longUnboxIdx;
+ } else if (primType == Float.TYPE) {
+ return floatUnboxIdx;
+ } else if (primType == Double.TYPE) {
+ return doubleUnboxIdx;
+ }
+ throw new InternalError("Illegal primitive type " + primType.getName());
+ }
+
+ protected static final Class<?>[] primitiveTypes = new Class<?>[] {
+ Boolean.TYPE,
+ Byte.TYPE,
+ Character.TYPE,
+ Short.TYPE,
+ Integer.TYPE,
+ Long.TYPE,
+ Float.TYPE,
+ Double.TYPE
+ };
+
+ /** We don't consider "Void" to be a primitive type */
+ protected static boolean isPrimitive(Class<?> c) {
+ return (c.isPrimitive() && c != Void.TYPE);
+ }
+
+ protected int typeSizeInStackSlots(Class<?> c) {
+ if (c == Void.TYPE) {
+ return 0;
+ }
+ if (c == Long.TYPE || c == Double.TYPE) {
+ return 2;
+ }
+ return 1;
+ }
+
+ private ClassFileAssembler illegalArgumentCodeBuffer;
+ protected ClassFileAssembler illegalArgumentCodeBuffer() {
+ if (illegalArgumentCodeBuffer == null) {
+ illegalArgumentCodeBuffer = new ClassFileAssembler();
+ illegalArgumentCodeBuffer.opc_new(illegalArgumentClass);
+ illegalArgumentCodeBuffer.opc_dup();
+ illegalArgumentCodeBuffer.opc_invokespecial(illegalArgumentCtorIdx, 0, 0);
+ illegalArgumentCodeBuffer.opc_athrow();
+ }
+
+ return illegalArgumentCodeBuffer;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/BootstrapConstructorAccessorImpl.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2001, 2011, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Constructor;
+
+/** Uses Unsafe.allocateObject() to instantiate classes; only used for
+ bootstrapping. */
+
+class BootstrapConstructorAccessorImpl extends ConstructorAccessorImpl {
+ private final Constructor<?> constructor;
+
+ BootstrapConstructorAccessorImpl(Constructor<?> c) {
+ this.constructor = c;
+ }
+
+ public Object newInstance(Object[] args)
+ throws IllegalArgumentException, InvocationTargetException
+ {
+ try {
+ return UnsafeFieldAccessorImpl.unsafe.
+ allocateInstance(constructor.getDeclaringClass());
+ } catch (InstantiationException e) {
+ throw new InvocationTargetException(e);
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/ByteVector.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2001, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+/** A growable array of bytes. */
+
+interface ByteVector {
+ public int getLength();
+ public byte get(int index);
+ public void put(int index, byte value);
+ public void add(byte value);
+ public void trim();
+ public byte[] getData();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/ByteVectorFactory.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2001, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+class ByteVectorFactory {
+ static ByteVector create() {
+ return new ByteVectorImpl();
+ }
+
+ static ByteVector create(int sz) {
+ return new ByteVectorImpl(sz);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/ByteVectorImpl.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2001, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+class ByteVectorImpl implements ByteVector {
+ private byte[] data;
+ private int pos;
+
+ public ByteVectorImpl() {
+ this(100);
+ }
+
+ public ByteVectorImpl(int sz) {
+ data = new byte[sz];
+ pos = -1;
+ }
+
+ public int getLength() {
+ return pos + 1;
+ }
+
+ public byte get(int index) {
+ if (index >= data.length) {
+ resize(index);
+ pos = index;
+ }
+ return data[index];
+ }
+
+ public void put(int index, byte value) {
+ if (index >= data.length) {
+ resize(index);
+ pos = index;
+ }
+ data[index] = value;
+ }
+
+ public void add(byte value) {
+ if (++pos >= data.length) {
+ resize(pos);
+ }
+ data[pos] = value;
+ }
+
+ public void trim() {
+ if (pos != data.length - 1) {
+ byte[] newData = new byte[pos + 1];
+ System.arraycopy(data, 0, newData, 0, pos + 1);
+ data = newData;
+ }
+ }
+
+ public byte[] getData() {
+ return data;
+ }
+
+ private void resize(int minSize) {
+ if (minSize <= 2 * data.length) {
+ minSize = 2 * data.length;
+ }
+ byte[] newData = new byte[minSize];
+ System.arraycopy(data, 0, newData, 0, data.length);
+ data = newData;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/CallerSensitive.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2013, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+import java.lang.annotation.*;
+import static java.lang.annotation.ElementType.*;
+
+/**
+ * A method annotated @CallerSensitive is sensitive to its calling class,
+ * via {@link jdk.internal.reflect.Reflection#getCallerClass Reflection.getCallerClass},
+ * or via some equivalent.
+ *
+ * @author John R. Rose
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target({METHOD})
+public @interface CallerSensitive {
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/ClassDefiner.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2001, 2011, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import jdk.internal.misc.Unsafe;
+
+/** Utility class which assists in calling Unsafe.defineClass() by
+ creating a new class loader which delegates to the one needed in
+ order for proper resolution of the given bytecodes to occur. */
+
+class ClassDefiner {
+ static final Unsafe unsafe = Unsafe.getUnsafe();
+
+ /** <P> We define generated code into a new class loader which
+ delegates to the defining loader of the target class. It is
+ necessary for the VM to be able to resolve references to the
+ target class from the generated bytecodes, which could not occur
+ if the generated code was loaded into the bootstrap class
+ loader. </P>
+
+ <P> There are two primary reasons for creating a new loader
+ instead of defining these bytecodes directly into the defining
+ loader of the target class: first, it avoids any possible
+ security risk of having these bytecodes in the same loader.
+ Second, it allows the generated bytecodes to be unloaded earlier
+ than would otherwise be possible, decreasing run-time
+ footprint. </P>
+ */
+ static Class<?> defineClass(String name, byte[] bytes, int off, int len,
+ final ClassLoader parentClassLoader)
+ {
+ ClassLoader newLoader = AccessController.doPrivileged(
+ new PrivilegedAction<ClassLoader>() {
+ public ClassLoader run() {
+ return new DelegatingClassLoader(parentClassLoader);
+ }
+ });
+ return unsafe.defineClass(name, bytes, off, len, newLoader, null);
+ }
+}
+
+
+// NOTE: this class's name and presence are known to the virtual
+// machine as of the fix for 4474172.
+class DelegatingClassLoader extends ClassLoader {
+ DelegatingClassLoader(ClassLoader parent) {
+ super(parent);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/ClassFileAssembler.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,671 @@
+/*
+ * Copyright (c) 2001, 2004, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+class ClassFileAssembler implements ClassFileConstants {
+ private ByteVector vec;
+ private short cpIdx = 0;
+
+ public ClassFileAssembler() {
+ this(ByteVectorFactory.create());
+ }
+
+ public ClassFileAssembler(ByteVector vec) {
+ this.vec = vec;
+ }
+
+ public ByteVector getData() {
+ return vec;
+ }
+
+ /** Length in bytes */
+ public short getLength() {
+ return (short) vec.getLength();
+ }
+
+ public void emitMagicAndVersion() {
+ emitInt(0xCAFEBABE);
+ emitShort((short) 0);
+ emitShort((short) 49);
+ }
+
+ public void emitInt(int val) {
+ emitByte((byte) (val >> 24));
+ emitByte((byte) ((val >> 16) & 0xFF));
+ emitByte((byte) ((val >> 8) & 0xFF));
+ emitByte((byte) (val & 0xFF));
+ }
+
+ public void emitShort(short val) {
+ emitByte((byte) ((val >> 8) & 0xFF));
+ emitByte((byte) (val & 0xFF));
+ }
+
+ // Support for labels; package-private
+ void emitShort(short bci, short val) {
+ vec.put(bci, (byte) ((val >> 8) & 0xFF));
+ vec.put(bci + 1, (byte) (val & 0xFF));
+ }
+
+ public void emitByte(byte val) {
+ vec.add(val);
+ }
+
+ public void append(ClassFileAssembler asm) {
+ append(asm.vec);
+ }
+
+ public void append(ByteVector vec) {
+ for (int i = 0; i < vec.getLength(); i++) {
+ emitByte(vec.get(i));
+ }
+ }
+
+ /** Keeps track of the current (one-based) constant pool index;
+ incremented after emitting one of the following constant pool
+ entries. Can fetch the current constant pool index for use in
+ later entries. Index points at the last valid constant pool
+ entry; initially invalid. It is illegal to fetch the constant
+ pool index before emitting at least one constant pool entry. */
+ public short cpi() {
+ if (cpIdx == 0) {
+ throw new RuntimeException("Illegal use of ClassFileAssembler");
+ }
+ return cpIdx;
+ }
+
+ public void emitConstantPoolUTF8(String str) {
+ // NOTE: can not use str.getBytes("UTF-8") here because of
+ // bootstrapping issues with the character set converters.
+ byte[] bytes = UTF8.encode(str);
+ emitByte(CONSTANT_Utf8);
+ emitShort((short) bytes.length);
+ for (int i = 0; i < bytes.length; i++) {
+ emitByte(bytes[i]);
+ }
+ cpIdx++;
+ }
+
+ public void emitConstantPoolClass(short index) {
+ emitByte(CONSTANT_Class);
+ emitShort(index);
+ cpIdx++;
+ }
+
+ public void emitConstantPoolNameAndType(short nameIndex, short typeIndex) {
+ emitByte(CONSTANT_NameAndType);
+ emitShort(nameIndex);
+ emitShort(typeIndex);
+ cpIdx++;
+ }
+
+ public void emitConstantPoolFieldref
+ (short classIndex, short nameAndTypeIndex)
+ {
+ emitByte(CONSTANT_Fieldref);
+ emitShort(classIndex);
+ emitShort(nameAndTypeIndex);
+ cpIdx++;
+ }
+
+ public void emitConstantPoolMethodref
+ (short classIndex, short nameAndTypeIndex)
+ {
+ emitByte(CONSTANT_Methodref);
+ emitShort(classIndex);
+ emitShort(nameAndTypeIndex);
+ cpIdx++;
+ }
+
+ public void emitConstantPoolInterfaceMethodref
+ (short classIndex, short nameAndTypeIndex)
+ {
+ emitByte(CONSTANT_InterfaceMethodref);
+ emitShort(classIndex);
+ emitShort(nameAndTypeIndex);
+ cpIdx++;
+ }
+
+ public void emitConstantPoolString(short utf8Index) {
+ emitByte(CONSTANT_String);
+ emitShort(utf8Index);
+ cpIdx++;
+ }
+
+ //----------------------------------------------------------------------
+ // Opcodes. Keeps track of maximum stack and locals. Make a new
+ // assembler for each piece of assembled code, then append the
+ // result to the previous assembler's class file.
+ //
+
+ private int stack = 0;
+ private int maxStack = 0;
+ private int maxLocals = 0;
+
+ private void incStack() {
+ setStack(stack + 1);
+ }
+
+ private void decStack() {
+ --stack;
+ }
+
+ public short getMaxStack() {
+ return (short) maxStack;
+ }
+
+ public short getMaxLocals() {
+ return (short) maxLocals;
+ }
+
+ /** It's necessary to be able to specify the number of arguments at
+ the beginning of the method (which translates to the initial
+ value of max locals) */
+ public void setMaxLocals(int maxLocals) {
+ this.maxLocals = maxLocals;
+ }
+
+ /** Needed to do flow control. Returns current stack depth. */
+ public int getStack() {
+ return stack;
+ }
+
+ /** Needed to do flow control. */
+ public void setStack(int value) {
+ stack = value;
+ if (stack > maxStack) {
+ maxStack = stack;
+ }
+ }
+
+ ///////////////
+ // Constants //
+ ///////////////
+
+ public void opc_aconst_null() {
+ emitByte(opc_aconst_null);
+ incStack();
+ }
+
+ public void opc_sipush(short constant) {
+ emitByte(opc_sipush);
+ emitShort(constant);
+ incStack();
+ }
+
+ public void opc_ldc(byte cpIdx) {
+ emitByte(opc_ldc);
+ emitByte(cpIdx);
+ incStack();
+ }
+
+ /////////////////////////////////////
+ // Local variable loads and stores //
+ /////////////////////////////////////
+
+ public void opc_iload_0() {
+ emitByte(opc_iload_0);
+ if (maxLocals < 1) maxLocals = 1;
+ incStack();
+ }
+
+ public void opc_iload_1() {
+ emitByte(opc_iload_1);
+ if (maxLocals < 2) maxLocals = 2;
+ incStack();
+ }
+
+ public void opc_iload_2() {
+ emitByte(opc_iload_2);
+ if (maxLocals < 3) maxLocals = 3;
+ incStack();
+ }
+
+ public void opc_iload_3() {
+ emitByte(opc_iload_3);
+ if (maxLocals < 4) maxLocals = 4;
+ incStack();
+ }
+
+ public void opc_lload_0() {
+ emitByte(opc_lload_0);
+ if (maxLocals < 2) maxLocals = 2;
+ incStack();
+ incStack();
+ }
+
+ public void opc_lload_1() {
+ emitByte(opc_lload_1);
+ if (maxLocals < 3) maxLocals = 3;
+ incStack();
+ incStack();
+ }
+
+ public void opc_lload_2() {
+ emitByte(opc_lload_2);
+ if (maxLocals < 4) maxLocals = 4;
+ incStack();
+ incStack();
+ }
+
+ public void opc_lload_3() {
+ emitByte(opc_lload_3);
+ if (maxLocals < 5) maxLocals = 5;
+ incStack();
+ incStack();
+ }
+
+ public void opc_fload_0() {
+ emitByte(opc_fload_0);
+ if (maxLocals < 1) maxLocals = 1;
+ incStack();
+ }
+
+ public void opc_fload_1() {
+ emitByte(opc_fload_1);
+ if (maxLocals < 2) maxLocals = 2;
+ incStack();
+ }
+
+ public void opc_fload_2() {
+ emitByte(opc_fload_2);
+ if (maxLocals < 3) maxLocals = 3;
+ incStack();
+ }
+
+ public void opc_fload_3() {
+ emitByte(opc_fload_3);
+ if (maxLocals < 4) maxLocals = 4;
+ incStack();
+ }
+
+ public void opc_dload_0() {
+ emitByte(opc_dload_0);
+ if (maxLocals < 2) maxLocals = 2;
+ incStack();
+ incStack();
+ }
+
+ public void opc_dload_1() {
+ emitByte(opc_dload_1);
+ if (maxLocals < 3) maxLocals = 3;
+ incStack();
+ incStack();
+ }
+
+ public void opc_dload_2() {
+ emitByte(opc_dload_2);
+ if (maxLocals < 4) maxLocals = 4;
+ incStack();
+ incStack();
+ }
+
+ public void opc_dload_3() {
+ emitByte(opc_dload_3);
+ if (maxLocals < 5) maxLocals = 5;
+ incStack();
+ incStack();
+ }
+
+ public void opc_aload_0() {
+ emitByte(opc_aload_0);
+ if (maxLocals < 1) maxLocals = 1;
+ incStack();
+ }
+
+ public void opc_aload_1() {
+ emitByte(opc_aload_1);
+ if (maxLocals < 2) maxLocals = 2;
+ incStack();
+ }
+
+ public void opc_aload_2() {
+ emitByte(opc_aload_2);
+ if (maxLocals < 3) maxLocals = 3;
+ incStack();
+ }
+
+ public void opc_aload_3() {
+ emitByte(opc_aload_3);
+ if (maxLocals < 4) maxLocals = 4;
+ incStack();
+ }
+
+ public void opc_aaload() {
+ emitByte(opc_aaload);
+ decStack();
+ }
+
+ public void opc_astore_0() {
+ emitByte(opc_astore_0);
+ if (maxLocals < 1) maxLocals = 1;
+ decStack();
+ }
+
+ public void opc_astore_1() {
+ emitByte(opc_astore_1);
+ if (maxLocals < 2) maxLocals = 2;
+ decStack();
+ }
+
+ public void opc_astore_2() {
+ emitByte(opc_astore_2);
+ if (maxLocals < 3) maxLocals = 3;
+ decStack();
+ }
+
+ public void opc_astore_3() {
+ emitByte(opc_astore_3);
+ if (maxLocals < 4) maxLocals = 4;
+ decStack();
+ }
+
+ ////////////////////////
+ // Stack manipulation //
+ ////////////////////////
+
+ public void opc_pop() {
+ emitByte(opc_pop);
+ decStack();
+ }
+
+ public void opc_dup() {
+ emitByte(opc_dup);
+ incStack();
+ }
+
+ public void opc_dup_x1() {
+ emitByte(opc_dup_x1);
+ incStack();
+ }
+
+ public void opc_swap() {
+ emitByte(opc_swap);
+ }
+
+ ///////////////////////////////
+ // Widening conversions only //
+ ///////////////////////////////
+
+ public void opc_i2l() {
+ emitByte(opc_i2l);
+ }
+
+ public void opc_i2f() {
+ emitByte(opc_i2f);
+ }
+
+ public void opc_i2d() {
+ emitByte(opc_i2d);
+ }
+
+ public void opc_l2f() {
+ emitByte(opc_l2f);
+ }
+
+ public void opc_l2d() {
+ emitByte(opc_l2d);
+ }
+
+ public void opc_f2d() {
+ emitByte(opc_f2d);
+ }
+
+ //////////////////
+ // Control flow //
+ //////////////////
+
+ public void opc_ifeq(short bciOffset) {
+ emitByte(opc_ifeq);
+ emitShort(bciOffset);
+ decStack();
+ }
+
+ /** Control flow with forward-reference BCI. Stack assumes
+ straight-through control flow. */
+ public void opc_ifeq(Label l) {
+ short instrBCI = getLength();
+ emitByte(opc_ifeq);
+ l.add(this, instrBCI, getLength(), getStack() - 1);
+ emitShort((short) -1); // Must be patched later
+ }
+
+ public void opc_if_icmpeq(short bciOffset) {
+ emitByte(opc_if_icmpeq);
+ emitShort(bciOffset);
+ setStack(getStack() - 2);
+ }
+
+ /** Control flow with forward-reference BCI. Stack assumes straight
+ control flow. */
+ public void opc_if_icmpeq(Label l) {
+ short instrBCI = getLength();
+ emitByte(opc_if_icmpeq);
+ l.add(this, instrBCI, getLength(), getStack() - 2);
+ emitShort((short) -1); // Must be patched later
+ }
+
+ public void opc_goto(short bciOffset) {
+ emitByte(opc_goto);
+ emitShort(bciOffset);
+ }
+
+ /** Control flow with forward-reference BCI. Stack assumes straight
+ control flow. */
+ public void opc_goto(Label l) {
+ short instrBCI = getLength();
+ emitByte(opc_goto);
+ l.add(this, instrBCI, getLength(), getStack());
+ emitShort((short) -1); // Must be patched later
+ }
+
+ public void opc_ifnull(short bciOffset) {
+ emitByte(opc_ifnull);
+ emitShort(bciOffset);
+ decStack();
+ }
+
+ /** Control flow with forward-reference BCI. Stack assumes straight
+ control flow. */
+ public void opc_ifnull(Label l) {
+ short instrBCI = getLength();
+ emitByte(opc_ifnull);
+ l.add(this, instrBCI, getLength(), getStack() - 1);
+ emitShort((short) -1); // Must be patched later
+ decStack();
+ }
+
+ public void opc_ifnonnull(short bciOffset) {
+ emitByte(opc_ifnonnull);
+ emitShort(bciOffset);
+ decStack();
+ }
+
+ /** Control flow with forward-reference BCI. Stack assumes straight
+ control flow. */
+ public void opc_ifnonnull(Label l) {
+ short instrBCI = getLength();
+ emitByte(opc_ifnonnull);
+ l.add(this, instrBCI, getLength(), getStack() - 1);
+ emitShort((short) -1); // Must be patched later
+ decStack();
+ }
+
+ /////////////////////////
+ // Return instructions //
+ /////////////////////////
+
+ public void opc_ireturn() {
+ emitByte(opc_ireturn);
+ setStack(0);
+ }
+
+ public void opc_lreturn() {
+ emitByte(opc_lreturn);
+ setStack(0);
+ }
+
+ public void opc_freturn() {
+ emitByte(opc_freturn);
+ setStack(0);
+ }
+
+ public void opc_dreturn() {
+ emitByte(opc_dreturn);
+ setStack(0);
+ }
+
+ public void opc_areturn() {
+ emitByte(opc_areturn);
+ setStack(0);
+ }
+
+ public void opc_return() {
+ emitByte(opc_return);
+ setStack(0);
+ }
+
+ //////////////////////
+ // Field operations //
+ //////////////////////
+
+ public void opc_getstatic(short fieldIndex, int fieldSizeInStackSlots) {
+ emitByte(opc_getstatic);
+ emitShort(fieldIndex);
+ setStack(getStack() + fieldSizeInStackSlots);
+ }
+
+ public void opc_putstatic(short fieldIndex, int fieldSizeInStackSlots) {
+ emitByte(opc_putstatic);
+ emitShort(fieldIndex);
+ setStack(getStack() - fieldSizeInStackSlots);
+ }
+
+ public void opc_getfield(short fieldIndex, int fieldSizeInStackSlots) {
+ emitByte(opc_getfield);
+ emitShort(fieldIndex);
+ setStack(getStack() + fieldSizeInStackSlots - 1);
+ }
+
+ public void opc_putfield(short fieldIndex, int fieldSizeInStackSlots) {
+ emitByte(opc_putfield);
+ emitShort(fieldIndex);
+ setStack(getStack() - fieldSizeInStackSlots - 1);
+ }
+
+ ////////////////////////
+ // Method invocations //
+ ////////////////////////
+
+ /** Long and double arguments and return types count as 2 arguments;
+ other values count as 1. */
+ public void opc_invokevirtual(short methodIndex,
+ int numArgs,
+ int numReturnValues)
+ {
+ emitByte(opc_invokevirtual);
+ emitShort(methodIndex);
+ setStack(getStack() - numArgs - 1 + numReturnValues);
+ }
+
+ /** Long and double arguments and return types count as 2 arguments;
+ other values count as 1. */
+ public void opc_invokespecial(short methodIndex,
+ int numArgs,
+ int numReturnValues)
+ {
+ emitByte(opc_invokespecial);
+ emitShort(methodIndex);
+ setStack(getStack() - numArgs - 1 + numReturnValues);
+ }
+
+ /** Long and double arguments and return types count as 2 arguments;
+ other values count as 1. */
+ public void opc_invokestatic(short methodIndex,
+ int numArgs,
+ int numReturnValues)
+ {
+ emitByte(opc_invokestatic);
+ emitShort(methodIndex);
+ setStack(getStack() - numArgs + numReturnValues);
+ }
+
+ /** Long and double arguments and return types count as 2 arguments;
+ other values count as 1. */
+ public void opc_invokeinterface(short methodIndex,
+ int numArgs,
+ byte count,
+ int numReturnValues)
+ {
+ emitByte(opc_invokeinterface);
+ emitShort(methodIndex);
+ emitByte(count);
+ emitByte((byte) 0);
+ setStack(getStack() - numArgs - 1 + numReturnValues);
+ }
+
+ //////////////////
+ // Array length //
+ //////////////////
+
+ public void opc_arraylength() {
+ emitByte(opc_arraylength);
+ }
+
+ /////////
+ // New //
+ /////////
+
+ public void opc_new(short classIndex) {
+ emitByte(opc_new);
+ emitShort(classIndex);
+ incStack();
+ }
+
+ ////////////
+ // Athrow //
+ ////////////
+
+ public void opc_athrow() {
+ emitByte(opc_athrow);
+ setStack(1);
+ }
+
+ //////////////////////////////
+ // Checkcast and instanceof //
+ //////////////////////////////
+
+ /** Assumes the checkcast succeeds */
+ public void opc_checkcast(short classIndex) {
+ emitByte(opc_checkcast);
+ emitShort(classIndex);
+ }
+
+ public void opc_instanceof(short classIndex) {
+ emitByte(opc_instanceof);
+ emitShort(classIndex);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/ClassFileConstants.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,140 @@
+/*
+ * Copyright (c) 2001, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+/** Minimal set of class file constants for assembly of field and
+ method accessors. */
+
+interface ClassFileConstants {
+ // Constants
+ public static final byte opc_aconst_null = (byte) 0x1;
+ public static final byte opc_sipush = (byte) 0x11;
+ public static final byte opc_ldc = (byte) 0x12;
+
+ // Local variable loads and stores
+ public static final byte opc_iload_0 = (byte) 0x1a;
+ public static final byte opc_iload_1 = (byte) 0x1b;
+ public static final byte opc_iload_2 = (byte) 0x1c;
+ public static final byte opc_iload_3 = (byte) 0x1d;
+ public static final byte opc_lload_0 = (byte) 0x1e;
+ public static final byte opc_lload_1 = (byte) 0x1f;
+ public static final byte opc_lload_2 = (byte) 0x20;
+ public static final byte opc_lload_3 = (byte) 0x21;
+ public static final byte opc_fload_0 = (byte) 0x22;
+ public static final byte opc_fload_1 = (byte) 0x23;
+ public static final byte opc_fload_2 = (byte) 0x24;
+ public static final byte opc_fload_3 = (byte) 0x25;
+ public static final byte opc_dload_0 = (byte) 0x26;
+ public static final byte opc_dload_1 = (byte) 0x27;
+ public static final byte opc_dload_2 = (byte) 0x28;
+ public static final byte opc_dload_3 = (byte) 0x29;
+ public static final byte opc_aload_0 = (byte) 0x2a;
+ public static final byte opc_aload_1 = (byte) 0x2b;
+ public static final byte opc_aload_2 = (byte) 0x2c;
+ public static final byte opc_aload_3 = (byte) 0x2d;
+ public static final byte opc_aaload = (byte) 0x32;
+ public static final byte opc_astore_0 = (byte) 0x4b;
+ public static final byte opc_astore_1 = (byte) 0x4c;
+ public static final byte opc_astore_2 = (byte) 0x4d;
+ public static final byte opc_astore_3 = (byte) 0x4e;
+
+ // Stack manipulation
+ public static final byte opc_pop = (byte) 0x57;
+ public static final byte opc_dup = (byte) 0x59;
+ public static final byte opc_dup_x1 = (byte) 0x5a;
+ public static final byte opc_swap = (byte) 0x5f;
+
+ // Conversions
+ public static final byte opc_i2l = (byte) 0x85;
+ public static final byte opc_i2f = (byte) 0x86;
+ public static final byte opc_i2d = (byte) 0x87;
+ public static final byte opc_l2i = (byte) 0x88;
+ public static final byte opc_l2f = (byte) 0x89;
+ public static final byte opc_l2d = (byte) 0x8a;
+ public static final byte opc_f2i = (byte) 0x8b;
+ public static final byte opc_f2l = (byte) 0x8c;
+ public static final byte opc_f2d = (byte) 0x8d;
+ public static final byte opc_d2i = (byte) 0x8e;
+ public static final byte opc_d2l = (byte) 0x8f;
+ public static final byte opc_d2f = (byte) 0x90;
+ public static final byte opc_i2b = (byte) 0x91;
+ public static final byte opc_i2c = (byte) 0x92;
+ public static final byte opc_i2s = (byte) 0x93;
+
+ // Control flow
+ public static final byte opc_ifeq = (byte) 0x99;
+ public static final byte opc_if_icmpeq = (byte) 0x9f;
+ public static final byte opc_goto = (byte) 0xa7;
+
+ // Return instructions
+ public static final byte opc_ireturn = (byte) 0xac;
+ public static final byte opc_lreturn = (byte) 0xad;
+ public static final byte opc_freturn = (byte) 0xae;
+ public static final byte opc_dreturn = (byte) 0xaf;
+ public static final byte opc_areturn = (byte) 0xb0;
+ public static final byte opc_return = (byte) 0xb1;
+
+ // Field operations
+ public static final byte opc_getstatic = (byte) 0xb2;
+ public static final byte opc_putstatic = (byte) 0xb3;
+ public static final byte opc_getfield = (byte) 0xb4;
+ public static final byte opc_putfield = (byte) 0xb5;
+
+ // Method invocations
+ public static final byte opc_invokevirtual = (byte) 0xb6;
+ public static final byte opc_invokespecial = (byte) 0xb7;
+ public static final byte opc_invokestatic = (byte) 0xb8;
+ public static final byte opc_invokeinterface = (byte) 0xb9;
+
+ // Array length
+ public static final byte opc_arraylength = (byte) 0xbe;
+
+ // New
+ public static final byte opc_new = (byte) 0xbb;
+
+ // Athrow
+ public static final byte opc_athrow = (byte) 0xbf;
+
+ // Checkcast and instanceof
+ public static final byte opc_checkcast = (byte) 0xc0;
+ public static final byte opc_instanceof = (byte) 0xc1;
+
+ // Ifnull and ifnonnull
+ public static final byte opc_ifnull = (byte) 0xc6;
+ public static final byte opc_ifnonnull = (byte) 0xc7;
+
+ // Constant pool tags
+ public static final byte CONSTANT_Class = (byte) 7;
+ public static final byte CONSTANT_Fieldref = (byte) 9;
+ public static final byte CONSTANT_Methodref = (byte) 10;
+ public static final byte CONSTANT_InterfaceMethodref = (byte) 11;
+ public static final byte CONSTANT_NameAndType = (byte) 12;
+ public static final byte CONSTANT_String = (byte) 8;
+ public static final byte CONSTANT_Utf8 = (byte) 1;
+
+ // Access flags
+ public static final short ACC_PUBLIC = (short) 0x0001;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/ConstantPool.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,131 @@
+/*
+ * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+import java.lang.reflect.*;
+
+/** Provides reflective access to the constant pools of classes.
+ Currently this is needed to provide reflective access to annotations
+ but may be used by other internal subsystems in the future. */
+
+public class ConstantPool {
+ // Number of entries in this constant pool (= maximum valid constant pool index)
+ public int getSize() { return getSize0 (constantPoolOop); }
+ public Class<?> getClassAt (int index) { return getClassAt0 (constantPoolOop, index); }
+ public Class<?> getClassAtIfLoaded (int index) { return getClassAtIfLoaded0 (constantPoolOop, index); }
+ // Returns a class reference index for a method or a field.
+ public int getClassRefIndexAt(int index) {
+ return getClassRefIndexAt0(constantPoolOop, index);
+ }
+ // Returns either a Method or Constructor.
+ // Static initializers are returned as Method objects.
+ public Member getMethodAt (int index) { return getMethodAt0 (constantPoolOop, index); }
+ public Member getMethodAtIfLoaded(int index) { return getMethodAtIfLoaded0(constantPoolOop, index); }
+ public Field getFieldAt (int index) { return getFieldAt0 (constantPoolOop, index); }
+ public Field getFieldAtIfLoaded (int index) { return getFieldAtIfLoaded0 (constantPoolOop, index); }
+ // Fetches the class name, member (field, method or interface
+ // method) name, and type descriptor as an array of three Strings
+ public String[] getMemberRefInfoAt (int index) { return getMemberRefInfoAt0 (constantPoolOop, index); }
+ // Returns a name and type reference index for a method, a field or an invokedynamic.
+ public int getNameAndTypeRefIndexAt(int index) {
+ return getNameAndTypeRefIndexAt0(constantPoolOop, index);
+ }
+ // Fetches the name and type from name_and_type index as an array of two Strings
+ public String[] getNameAndTypeRefInfoAt(int index) {
+ return getNameAndTypeRefInfoAt0(constantPoolOop, index);
+ }
+ public int getIntAt (int index) { return getIntAt0 (constantPoolOop, index); }
+ public long getLongAt (int index) { return getLongAt0 (constantPoolOop, index); }
+ public float getFloatAt (int index) { return getFloatAt0 (constantPoolOop, index); }
+ public double getDoubleAt (int index) { return getDoubleAt0 (constantPoolOop, index); }
+ public String getStringAt (int index) { return getStringAt0 (constantPoolOop, index); }
+ public String getUTF8At (int index) { return getUTF8At0 (constantPoolOop, index); }
+ public Tag getTagAt(int index) {
+ return Tag.valueOf(getTagAt0(constantPoolOop, index));
+ }
+
+ public static enum Tag {
+ UTF8(1),
+ INTEGER(3),
+ FLOAT(4),
+ LONG(5),
+ DOUBLE(6),
+ CLASS(7),
+ STRING(8),
+ FIELDREF(9),
+ METHODREF(10),
+ INTERFACEMETHODREF(11),
+ NAMEANDTYPE(12),
+ METHODHANDLE(15),
+ METHODTYPE(16),
+ INVOKEDYNAMIC(18),
+ INVALID(0);
+
+ private final int tagCode;
+
+ private Tag(int tagCode) {
+ this.tagCode = tagCode;
+ }
+
+ private static Tag valueOf(byte v) {
+ for (Tag tag : Tag.values()) {
+ if (tag.tagCode == v) {
+ return tag;
+ }
+ }
+ throw new IllegalArgumentException("Unknown constant pool tag code " + v);
+ }
+ }
+ //---------------------------------------------------------------------------
+ // Internals only below this point
+ //
+
+ static {
+ Reflection.registerFieldsToFilter(ConstantPool.class, new String[] { "constantPoolOop" });
+ }
+
+ // HotSpot-internal constant pool object (set by the VM, name known to the VM)
+ private Object constantPoolOop;
+
+ private native int getSize0 (Object constantPoolOop);
+ private native Class<?> getClassAt0 (Object constantPoolOop, int index);
+ private native Class<?> getClassAtIfLoaded0 (Object constantPoolOop, int index);
+ private native int getClassRefIndexAt0 (Object constantPoolOop, int index);
+ private native Member getMethodAt0 (Object constantPoolOop, int index);
+ private native Member getMethodAtIfLoaded0(Object constantPoolOop, int index);
+ private native Field getFieldAt0 (Object constantPoolOop, int index);
+ private native Field getFieldAtIfLoaded0 (Object constantPoolOop, int index);
+ private native String[] getMemberRefInfoAt0 (Object constantPoolOop, int index);
+ private native int getNameAndTypeRefIndexAt0(Object constantPoolOop, int index);
+ private native String[] getNameAndTypeRefInfoAt0(Object constantPoolOop, int index);
+ private native int getIntAt0 (Object constantPoolOop, int index);
+ private native long getLongAt0 (Object constantPoolOop, int index);
+ private native float getFloatAt0 (Object constantPoolOop, int index);
+ private native double getDoubleAt0 (Object constantPoolOop, int index);
+ private native String getStringAt0 (Object constantPoolOop, int index);
+ private native String getUTF8At0 (Object constantPoolOop, int index);
+ private native byte getTagAt0 (Object constantPoolOop, int index);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/ConstructorAccessor.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2001, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+import java.lang.reflect.InvocationTargetException;
+
+/** This interface provides the declaration for
+ java.lang.reflect.Constructor.invoke(). Each Constructor object is
+ configured with a (possibly dynamically-generated) class which
+ implements this interface. */
+
+public interface ConstructorAccessor {
+ /** Matches specification in {@link java.lang.reflect.Constructor} */
+ public Object newInstance(Object[] args)
+ throws InstantiationException,
+ IllegalArgumentException,
+ InvocationTargetException;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/ConstructorAccessorImpl.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2001, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+import java.lang.reflect.InvocationTargetException;
+
+/** Package-private implementation of the ConstructorAccessor
+ interface which has access to all classes and all fields,
+ regardless of language restrictions. See MagicAccessorImpl. */
+
+abstract class ConstructorAccessorImpl extends MagicAccessorImpl
+ implements ConstructorAccessor {
+ /** Matches specification in {@link java.lang.reflect.Constructor} */
+ public abstract Object newInstance(Object[] args)
+ throws InstantiationException,
+ IllegalArgumentException,
+ InvocationTargetException;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/DelegatingConstructorAccessorImpl.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2001, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+import java.lang.reflect.InvocationTargetException;
+
+/** Delegates its invocation to another ConstructorAccessorImpl and can
+ change its delegate at run time. */
+
+class DelegatingConstructorAccessorImpl extends ConstructorAccessorImpl {
+ private ConstructorAccessorImpl delegate;
+
+ DelegatingConstructorAccessorImpl(ConstructorAccessorImpl delegate) {
+ setDelegate(delegate);
+ }
+
+ public Object newInstance(Object[] args)
+ throws InstantiationException,
+ IllegalArgumentException,
+ InvocationTargetException
+ {
+ return delegate.newInstance(args);
+ }
+
+ void setDelegate(ConstructorAccessorImpl delegate) {
+ this.delegate = delegate;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/DelegatingMethodAccessorImpl.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2001, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+import java.lang.reflect.InvocationTargetException;
+
+/** Delegates its invocation to another MethodAccessorImpl and can
+ change its delegate at run time. */
+
+class DelegatingMethodAccessorImpl extends MethodAccessorImpl {
+ private MethodAccessorImpl delegate;
+
+ DelegatingMethodAccessorImpl(MethodAccessorImpl delegate) {
+ setDelegate(delegate);
+ }
+
+ public Object invoke(Object obj, Object[] args)
+ throws IllegalArgumentException, InvocationTargetException
+ {
+ return delegate.invoke(obj, args);
+ }
+
+ void setDelegate(MethodAccessorImpl delegate) {
+ this.delegate = delegate;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/FieldAccessor.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2001, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+/** This interface provides the declarations for the accessor methods
+ of java.lang.reflect.Field. Each Field object is configured with a
+ (possibly dynamically-generated) class which implements this
+ interface. */
+
+public interface FieldAccessor {
+ /** Matches specification in {@link java.lang.reflect.Field} */
+ public Object get(Object obj) throws IllegalArgumentException;
+
+ /** Matches specification in {@link java.lang.reflect.Field} */
+ public boolean getBoolean(Object obj) throws IllegalArgumentException;
+
+ /** Matches specification in {@link java.lang.reflect.Field} */
+ public byte getByte(Object obj) throws IllegalArgumentException;
+
+ /** Matches specification in {@link java.lang.reflect.Field} */
+ public char getChar(Object obj) throws IllegalArgumentException;
+
+ /** Matches specification in {@link java.lang.reflect.Field} */
+ public short getShort(Object obj) throws IllegalArgumentException;
+
+ /** Matches specification in {@link java.lang.reflect.Field} */
+ public int getInt(Object obj) throws IllegalArgumentException;
+
+ /** Matches specification in {@link java.lang.reflect.Field} */
+ public long getLong(Object obj) throws IllegalArgumentException;
+
+ /** Matches specification in {@link java.lang.reflect.Field} */
+ public float getFloat(Object obj) throws IllegalArgumentException;
+
+ /** Matches specification in {@link java.lang.reflect.Field} */
+ public double getDouble(Object obj) throws IllegalArgumentException;
+
+ /** Matches specification in {@link java.lang.reflect.Field} */
+ public void set(Object obj, Object value)
+ throws IllegalArgumentException, IllegalAccessException;
+
+ /** Matches specification in {@link java.lang.reflect.Field} */
+ public void setBoolean(Object obj, boolean z)
+ throws IllegalArgumentException, IllegalAccessException;
+
+ /** Matches specification in {@link java.lang.reflect.Field} */
+ public void setByte(Object obj, byte b)
+ throws IllegalArgumentException, IllegalAccessException;
+
+ /** Matches specification in {@link java.lang.reflect.Field} */
+ public void setChar(Object obj, char c)
+ throws IllegalArgumentException, IllegalAccessException;
+
+ /** Matches specification in {@link java.lang.reflect.Field} */
+ public void setShort(Object obj, short s)
+ throws IllegalArgumentException, IllegalAccessException;
+
+ /** Matches specification in {@link java.lang.reflect.Field} */
+ public void setInt(Object obj, int i)
+ throws IllegalArgumentException, IllegalAccessException;
+
+ /** Matches specification in {@link java.lang.reflect.Field} */
+ public void setLong(Object obj, long l)
+ throws IllegalArgumentException, IllegalAccessException;
+
+ /** Matches specification in {@link java.lang.reflect.Field} */
+ public void setFloat(Object obj, float f)
+ throws IllegalArgumentException, IllegalAccessException;
+
+ /** Matches specification in {@link java.lang.reflect.Field} */
+ public void setDouble(Object obj, double d)
+ throws IllegalArgumentException, IllegalAccessException;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/FieldAccessorImpl.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2001, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+/** Package-private implementation of the FieldAccessor interface
+ which has access to all classes and all fields, regardless of
+ language restrictions. See MagicAccessorImpl. */
+
+abstract class FieldAccessorImpl extends MagicAccessorImpl
+ implements FieldAccessor {
+ /** Matches specification in {@link java.lang.reflect.Field} */
+ public abstract Object get(Object obj)
+ throws IllegalArgumentException;
+
+ /** Matches specification in {@link java.lang.reflect.Field} */
+ public abstract boolean getBoolean(Object obj)
+ throws IllegalArgumentException;
+
+ /** Matches specification in {@link java.lang.reflect.Field} */
+ public abstract byte getByte(Object obj)
+ throws IllegalArgumentException;
+
+ /** Matches specification in {@link java.lang.reflect.Field} */
+ public abstract char getChar(Object obj)
+ throws IllegalArgumentException;
+
+ /** Matches specification in {@link java.lang.reflect.Field} */
+ public abstract short getShort(Object obj)
+ throws IllegalArgumentException;
+
+ /** Matches specification in {@link java.lang.reflect.Field} */
+ public abstract int getInt(Object obj)
+ throws IllegalArgumentException;
+
+ /** Matches specification in {@link java.lang.reflect.Field} */
+ public abstract long getLong(Object obj)
+ throws IllegalArgumentException;
+
+ /** Matches specification in {@link java.lang.reflect.Field} */
+ public abstract float getFloat(Object obj)
+ throws IllegalArgumentException;
+
+ /** Matches specification in {@link java.lang.reflect.Field} */
+ public abstract double getDouble(Object obj)
+ throws IllegalArgumentException;
+
+ /** Matches specification in {@link java.lang.reflect.Field} */
+ public abstract void set(Object obj, Object value)
+ throws IllegalArgumentException, IllegalAccessException;
+
+ /** Matches specification in {@link java.lang.reflect.Field} */
+ public abstract void setBoolean(Object obj, boolean z)
+ throws IllegalArgumentException, IllegalAccessException;
+
+ /** Matches specification in {@link java.lang.reflect.Field} */
+ public abstract void setByte(Object obj, byte b)
+ throws IllegalArgumentException, IllegalAccessException;
+
+ /** Matches specification in {@link java.lang.reflect.Field} */
+ public abstract void setChar(Object obj, char c)
+ throws IllegalArgumentException, IllegalAccessException;
+
+ /** Matches specification in {@link java.lang.reflect.Field} */
+ public abstract void setShort(Object obj, short s)
+ throws IllegalArgumentException, IllegalAccessException;
+
+ /** Matches specification in {@link java.lang.reflect.Field} */
+ public abstract void setInt(Object obj, int i)
+ throws IllegalArgumentException, IllegalAccessException;
+
+ /** Matches specification in {@link java.lang.reflect.Field} */
+ public abstract void setLong(Object obj, long l)
+ throws IllegalArgumentException, IllegalAccessException;
+
+ /** Matches specification in {@link java.lang.reflect.Field} */
+ public abstract void setFloat(Object obj, float f)
+ throws IllegalArgumentException, IllegalAccessException;
+
+ /** Matches specification in {@link java.lang.reflect.Field} */
+ public abstract void setDouble(Object obj, double d)
+ throws IllegalArgumentException, IllegalAccessException;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/InstantiationExceptionConstructorAccessorImpl.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2001, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+
+/** Throws an InstantiationException with given error message upon
+ newInstance() call */
+
+class InstantiationExceptionConstructorAccessorImpl
+ extends ConstructorAccessorImpl {
+ private final String message;
+
+ InstantiationExceptionConstructorAccessorImpl(String message) {
+ this.message = message;
+ }
+
+ public Object newInstance(Object[] args)
+ throws InstantiationException,
+ IllegalArgumentException,
+ InvocationTargetException
+ {
+ if (message == null) {
+ throw new InstantiationException();
+ }
+ throw new InstantiationException(message);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/Label.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2001, 2011, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+import java.util.List;
+import java.util.ArrayList;
+
+/** Allows forward references in bytecode streams emitted by
+ ClassFileAssembler. Assumes that the start of the method body is
+ the first byte in the assembler's buffer. May be used at more than
+ one branch site. */
+
+class Label {
+ static class PatchInfo {
+ PatchInfo(ClassFileAssembler asm,
+ short instrBCI,
+ short patchBCI,
+ int stackDepth)
+ {
+ this.asm = asm;
+ this.instrBCI = instrBCI;
+ this.patchBCI = patchBCI;
+ this.stackDepth = stackDepth;
+ }
+ // This won't work for more than one assembler anyway, so this is
+ // unnecessary
+ final ClassFileAssembler asm;
+ final short instrBCI;
+ final short patchBCI;
+ final int stackDepth;
+ }
+ private final List<PatchInfo> patches = new ArrayList<>();
+
+ public Label() {
+ }
+
+ void add(ClassFileAssembler asm,
+ short instrBCI,
+ short patchBCI,
+ int stackDepth)
+ {
+ patches.add(new PatchInfo(asm, instrBCI, patchBCI, stackDepth));
+ }
+
+ public void bind() {
+ for (PatchInfo patch : patches){
+ short curBCI = patch.asm.getLength();
+ short offset = (short) (curBCI - patch.instrBCI);
+ patch.asm.emitShort(patch.patchBCI, offset);
+ patch.asm.setStack(patch.stackDepth);
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/LangReflectAccess.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2001, 2013, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+import java.lang.reflect.*;
+
+/** An interface which gives privileged packages Java-level access to
+ internals of java.lang.reflect. */
+
+public interface LangReflectAccess {
+ /** Creates a new java.lang.reflect.Field. Access checks as per
+ java.lang.reflect.AccessibleObject are not overridden. */
+ public Field newField(Class<?> declaringClass,
+ String name,
+ Class<?> type,
+ int modifiers,
+ int slot,
+ String signature,
+ byte[] annotations);
+
+ /** Creates a new java.lang.reflect.Method. Access checks as per
+ java.lang.reflect.AccessibleObject are not overridden. */
+ public Method newMethod(Class<?> declaringClass,
+ String name,
+ Class<?>[] parameterTypes,
+ Class<?> returnType,
+ Class<?>[] checkedExceptions,
+ int modifiers,
+ int slot,
+ String signature,
+ byte[] annotations,
+ byte[] parameterAnnotations,
+ byte[] annotationDefault);
+
+ /** Creates a new java.lang.reflect.Constructor. Access checks as
+ per java.lang.reflect.AccessibleObject are not overridden. */
+ public <T> Constructor<T> newConstructor(Class<T> declaringClass,
+ Class<?>[] parameterTypes,
+ Class<?>[] checkedExceptions,
+ int modifiers,
+ int slot,
+ String signature,
+ byte[] annotations,
+ byte[] parameterAnnotations);
+
+ /** Gets the MethodAccessor object for a java.lang.reflect.Method */
+ public MethodAccessor getMethodAccessor(Method m);
+
+ /** Sets the MethodAccessor object for a java.lang.reflect.Method */
+ public void setMethodAccessor(Method m, MethodAccessor accessor);
+
+ /** Gets the ConstructorAccessor object for a
+ java.lang.reflect.Constructor */
+ public ConstructorAccessor getConstructorAccessor(Constructor<?> c);
+
+ /** Sets the ConstructorAccessor object for a
+ java.lang.reflect.Constructor */
+ public void setConstructorAccessor(Constructor<?> c,
+ ConstructorAccessor accessor);
+
+ /** Gets the byte[] that encodes TypeAnnotations on an Executable. */
+ public byte[] getExecutableTypeAnnotationBytes(Executable ex);
+
+ /** Gets the "slot" field from a Constructor (used for serialization) */
+ public int getConstructorSlot(Constructor<?> c);
+
+ /** Gets the "signature" field from a Constructor (used for serialization) */
+ public String getConstructorSignature(Constructor<?> c);
+
+ /** Gets the "annotations" field from a Constructor (used for serialization) */
+ public byte[] getConstructorAnnotations(Constructor<?> c);
+
+ /** Gets the "parameterAnnotations" field from a Constructor (used for serialization) */
+ public byte[] getConstructorParameterAnnotations(Constructor<?> c);
+
+ //
+ // Copying routines, needed to quickly fabricate new Field,
+ // Method, and Constructor objects from templates
+ //
+
+ /** Makes a "child" copy of a Method */
+ public Method copyMethod(Method arg);
+
+ /** Makes a copy of this non-root a Method */
+ public Method leafCopyMethod(Method arg);
+
+ /** Makes a "child" copy of a Field */
+ public Field copyField(Field arg);
+
+ /** Makes a "child" copy of a Constructor */
+ public <T> Constructor<T> copyConstructor(Constructor<T> arg);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/MagicAccessorImpl.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2001, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+/** <P> MagicAccessorImpl (named for parity with FieldAccessorImpl and
+ others, not because it actually implements an interface) is a
+ marker class in the hierarchy. All subclasses of this class are
+ "magically" granted access by the VM to otherwise inaccessible
+ fields and methods of other classes. It is used to hold the code
+ for dynamically-generated FieldAccessorImpl and MethodAccessorImpl
+ subclasses. (Use of the word "unsafe" was avoided in this class's
+ name to avoid confusion with {@link jdk.internal.misc.Unsafe}.) </P>
+
+ <P> The bug fix for 4486457 also necessitated disabling
+ verification for this class and all subclasses, as opposed to just
+ SerializationConstructorAccessorImpl and subclasses, to avoid
+ having to indicate to the VM which of these dynamically-generated
+ stub classes were known to be able to pass the verifier. </P>
+
+ <P> Do not change the name of this class without also changing the
+ VM's code. </P> */
+
+class MagicAccessorImpl {
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/MethodAccessor.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2001, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+import java.lang.reflect.InvocationTargetException;
+
+/** This interface provides the declaration for
+ java.lang.reflect.Method.invoke(). Each Method object is
+ configured with a (possibly dynamically-generated) class which
+ implements this interface.
+*/
+
+public interface MethodAccessor {
+ /** Matches specification in {@link java.lang.reflect.Method} */
+ public Object invoke(Object obj, Object[] args)
+ throws IllegalArgumentException, InvocationTargetException;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/MethodAccessorGenerator.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,780 @@
+/*
+ * Copyright (c) 2001, 2013, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+/** Generator for sun.reflect.MethodAccessor and
+ sun.reflect.ConstructorAccessor objects using bytecodes to
+ implement reflection. A java.lang.reflect.Method or
+ java.lang.reflect.Constructor object can delegate its invoke or
+ newInstance method to an accessor using native code or to one
+ generated by this class. (Methods and Constructors were merged
+ together in this class to ensure maximum code sharing.) */
+
+class MethodAccessorGenerator extends AccessorGenerator {
+
+ private static final short NUM_BASE_CPOOL_ENTRIES = (short) 12;
+ // One for invoke() plus one for constructor
+ private static final short NUM_METHODS = (short) 2;
+ // Only used if forSerialization is true
+ private static final short NUM_SERIALIZATION_CPOOL_ENTRIES = (short) 2;
+
+ private static volatile int methodSymnum;
+ private static volatile int constructorSymnum;
+ private static volatile int serializationConstructorSymnum;
+
+ private Class<?> declaringClass;
+ private Class<?>[] parameterTypes;
+ private Class<?> returnType;
+ private boolean isConstructor;
+ private boolean forSerialization;
+
+ private short targetMethodRef;
+ private short invokeIdx;
+ private short invokeDescriptorIdx;
+ // Constant pool index of CONSTANT_Class_info for first
+ // non-primitive parameter type. Should be incremented by 2.
+ private short nonPrimitiveParametersBaseIdx;
+
+ MethodAccessorGenerator() {
+ }
+
+ /** This routine is not thread-safe */
+ public MethodAccessor generateMethod(Class<?> declaringClass,
+ String name,
+ Class<?>[] parameterTypes,
+ Class<?> returnType,
+ Class<?>[] checkedExceptions,
+ int modifiers)
+ {
+ return (MethodAccessor) generate(declaringClass,
+ name,
+ parameterTypes,
+ returnType,
+ checkedExceptions,
+ modifiers,
+ false,
+ false,
+ null);
+ }
+
+ /** This routine is not thread-safe */
+ public ConstructorAccessor generateConstructor(Class<?> declaringClass,
+ Class<?>[] parameterTypes,
+ Class<?>[] checkedExceptions,
+ int modifiers)
+ {
+ return (ConstructorAccessor) generate(declaringClass,
+ "<init>",
+ parameterTypes,
+ Void.TYPE,
+ checkedExceptions,
+ modifiers,
+ true,
+ false,
+ null);
+ }
+
+ /** This routine is not thread-safe */
+ public SerializationConstructorAccessorImpl
+ generateSerializationConstructor(Class<?> declaringClass,
+ Class<?>[] parameterTypes,
+ Class<?>[] checkedExceptions,
+ int modifiers,
+ Class<?> targetConstructorClass)
+ {
+ return (SerializationConstructorAccessorImpl)
+ generate(declaringClass,
+ "<init>",
+ parameterTypes,
+ Void.TYPE,
+ checkedExceptions,
+ modifiers,
+ true,
+ true,
+ targetConstructorClass);
+ }
+
+ /** This routine is not thread-safe */
+ private MagicAccessorImpl generate(final Class<?> declaringClass,
+ String name,
+ Class<?>[] parameterTypes,
+ Class<?> returnType,
+ Class<?>[] checkedExceptions,
+ int modifiers,
+ boolean isConstructor,
+ boolean forSerialization,
+ Class<?> serializationTargetClass)
+ {
+ ByteVector vec = ByteVectorFactory.create();
+ asm = new ClassFileAssembler(vec);
+ this.declaringClass = declaringClass;
+ this.parameterTypes = parameterTypes;
+ this.returnType = returnType;
+ this.modifiers = modifiers;
+ this.isConstructor = isConstructor;
+ this.forSerialization = forSerialization;
+
+ asm.emitMagicAndVersion();
+
+ // Constant pool entries:
+ // ( * = Boxing information: optional)
+ // (+ = Shared entries provided by AccessorGenerator)
+ // (^ = Only present if generating SerializationConstructorAccessor)
+ // [UTF-8] [This class's name]
+ // [CONSTANT_Class_info] for above
+ // [UTF-8] "jdk/internal/reflect/{MethodAccessorImpl,ConstructorAccessorImpl,SerializationConstructorAccessorImpl}"
+ // [CONSTANT_Class_info] for above
+ // [UTF-8] [Target class's name]
+ // [CONSTANT_Class_info] for above
+ // ^ [UTF-8] [Serialization: Class's name in which to invoke constructor]
+ // ^ [CONSTANT_Class_info] for above
+ // [UTF-8] target method or constructor name
+ // [UTF-8] target method or constructor signature
+ // [CONSTANT_NameAndType_info] for above
+ // [CONSTANT_Methodref_info or CONSTANT_InterfaceMethodref_info] for target method
+ // [UTF-8] "invoke" or "newInstance"
+ // [UTF-8] invoke or newInstance descriptor
+ // [UTF-8] descriptor for type of non-primitive parameter 1
+ // [CONSTANT_Class_info] for type of non-primitive parameter 1
+ // ...
+ // [UTF-8] descriptor for type of non-primitive parameter n
+ // [CONSTANT_Class_info] for type of non-primitive parameter n
+ // + [UTF-8] "java/lang/Exception"
+ // + [CONSTANT_Class_info] for above
+ // + [UTF-8] "java/lang/ClassCastException"
+ // + [CONSTANT_Class_info] for above
+ // + [UTF-8] "java/lang/NullPointerException"
+ // + [CONSTANT_Class_info] for above
+ // + [UTF-8] "java/lang/IllegalArgumentException"
+ // + [CONSTANT_Class_info] for above
+ // + [UTF-8] "java/lang/InvocationTargetException"
+ // + [CONSTANT_Class_info] for above
+ // + [UTF-8] "<init>"
+ // + [UTF-8] "()V"
+ // + [CONSTANT_NameAndType_info] for above
+ // + [CONSTANT_Methodref_info] for NullPointerException's constructor
+ // + [CONSTANT_Methodref_info] for IllegalArgumentException's constructor
+ // + [UTF-8] "(Ljava/lang/String;)V"
+ // + [CONSTANT_NameAndType_info] for "<init>(Ljava/lang/String;)V"
+ // + [CONSTANT_Methodref_info] for IllegalArgumentException's constructor taking a String
+ // + [UTF-8] "(Ljava/lang/Throwable;)V"
+ // + [CONSTANT_NameAndType_info] for "<init>(Ljava/lang/Throwable;)V"
+ // + [CONSTANT_Methodref_info] for InvocationTargetException's constructor
+ // + [CONSTANT_Methodref_info] for "super()"
+ // + [UTF-8] "java/lang/Object"
+ // + [CONSTANT_Class_info] for above
+ // + [UTF-8] "toString"
+ // + [UTF-8] "()Ljava/lang/String;"
+ // + [CONSTANT_NameAndType_info] for "toString()Ljava/lang/String;"
+ // + [CONSTANT_Methodref_info] for Object's toString method
+ // + [UTF-8] "Code"
+ // + [UTF-8] "Exceptions"
+ // * [UTF-8] "java/lang/Boolean"
+ // * [CONSTANT_Class_info] for above
+ // * [UTF-8] "(Z)V"
+ // * [CONSTANT_NameAndType_info] for above
+ // * [CONSTANT_Methodref_info] for above
+ // * [UTF-8] "booleanValue"
+ // * [UTF-8] "()Z"
+ // * [CONSTANT_NameAndType_info] for above
+ // * [CONSTANT_Methodref_info] for above
+ // * [UTF-8] "java/lang/Byte"
+ // * [CONSTANT_Class_info] for above
+ // * [UTF-8] "(B)V"
+ // * [CONSTANT_NameAndType_info] for above
+ // * [CONSTANT_Methodref_info] for above
+ // * [UTF-8] "byteValue"
+ // * [UTF-8] "()B"
+ // * [CONSTANT_NameAndType_info] for above
+ // * [CONSTANT_Methodref_info] for above
+ // * [UTF-8] "java/lang/Character"
+ // * [CONSTANT_Class_info] for above
+ // * [UTF-8] "(C)V"
+ // * [CONSTANT_NameAndType_info] for above
+ // * [CONSTANT_Methodref_info] for above
+ // * [UTF-8] "charValue"
+ // * [UTF-8] "()C"
+ // * [CONSTANT_NameAndType_info] for above
+ // * [CONSTANT_Methodref_info] for above
+ // * [UTF-8] "java/lang/Double"
+ // * [CONSTANT_Class_info] for above
+ // * [UTF-8] "(D)V"
+ // * [CONSTANT_NameAndType_info] for above
+ // * [CONSTANT_Methodref_info] for above
+ // * [UTF-8] "doubleValue"
+ // * [UTF-8] "()D"
+ // * [CONSTANT_NameAndType_info] for above
+ // * [CONSTANT_Methodref_info] for above
+ // * [UTF-8] "java/lang/Float"
+ // * [CONSTANT_Class_info] for above
+ // * [UTF-8] "(F)V"
+ // * [CONSTANT_NameAndType_info] for above
+ // * [CONSTANT_Methodref_info] for above
+ // * [UTF-8] "floatValue"
+ // * [UTF-8] "()F"
+ // * [CONSTANT_NameAndType_info] for above
+ // * [CONSTANT_Methodref_info] for above
+ // * [UTF-8] "java/lang/Integer"
+ // * [CONSTANT_Class_info] for above
+ // * [UTF-8] "(I)V"
+ // * [CONSTANT_NameAndType_info] for above
+ // * [CONSTANT_Methodref_info] for above
+ // * [UTF-8] "intValue"
+ // * [UTF-8] "()I"
+ // * [CONSTANT_NameAndType_info] for above
+ // * [CONSTANT_Methodref_info] for above
+ // * [UTF-8] "java/lang/Long"
+ // * [CONSTANT_Class_info] for above
+ // * [UTF-8] "(J)V"
+ // * [CONSTANT_NameAndType_info] for above
+ // * [CONSTANT_Methodref_info] for above
+ // * [UTF-8] "longValue"
+ // * [UTF-8] "()J"
+ // * [CONSTANT_NameAndType_info] for above
+ // * [CONSTANT_Methodref_info] for above
+ // * [UTF-8] "java/lang/Short"
+ // * [CONSTANT_Class_info] for above
+ // * [UTF-8] "(S)V"
+ // * [CONSTANT_NameAndType_info] for above
+ // * [CONSTANT_Methodref_info] for above
+ // * [UTF-8] "shortValue"
+ // * [UTF-8] "()S"
+ // * [CONSTANT_NameAndType_info] for above
+ // * [CONSTANT_Methodref_info] for above
+
+ short numCPEntries = NUM_BASE_CPOOL_ENTRIES + NUM_COMMON_CPOOL_ENTRIES;
+ boolean usesPrimitives = usesPrimitiveTypes();
+ if (usesPrimitives) {
+ numCPEntries += NUM_BOXING_CPOOL_ENTRIES;
+ }
+ if (forSerialization) {
+ numCPEntries += NUM_SERIALIZATION_CPOOL_ENTRIES;
+ }
+
+ // Add in variable-length number of entries to be able to describe
+ // non-primitive parameter types and checked exceptions.
+ numCPEntries += (short) (2 * numNonPrimitiveParameterTypes());
+
+ asm.emitShort(add(numCPEntries, S1));
+
+ final String generatedName = generateName(isConstructor, forSerialization);
+ asm.emitConstantPoolUTF8(generatedName);
+ asm.emitConstantPoolClass(asm.cpi());
+ thisClass = asm.cpi();
+ if (isConstructor) {
+ if (forSerialization) {
+ asm.emitConstantPoolUTF8
+ ("jdk/internal/reflect/SerializationConstructorAccessorImpl");
+ } else {
+ asm.emitConstantPoolUTF8("jdk/internal/reflect/ConstructorAccessorImpl");
+ }
+ } else {
+ asm.emitConstantPoolUTF8("jdk/internal/reflect/MethodAccessorImpl");
+ }
+ asm.emitConstantPoolClass(asm.cpi());
+ superClass = asm.cpi();
+ asm.emitConstantPoolUTF8(getClassName(declaringClass, false));
+ asm.emitConstantPoolClass(asm.cpi());
+ targetClass = asm.cpi();
+ short serializationTargetClassIdx = (short) 0;
+ if (forSerialization) {
+ asm.emitConstantPoolUTF8(getClassName(serializationTargetClass, false));
+ asm.emitConstantPoolClass(asm.cpi());
+ serializationTargetClassIdx = asm.cpi();
+ }
+ asm.emitConstantPoolUTF8(name);
+ asm.emitConstantPoolUTF8(buildInternalSignature());
+ asm.emitConstantPoolNameAndType(sub(asm.cpi(), S1), asm.cpi());
+ if (isInterface()) {
+ asm.emitConstantPoolInterfaceMethodref(targetClass, asm.cpi());
+ } else {
+ if (forSerialization) {
+ asm.emitConstantPoolMethodref(serializationTargetClassIdx, asm.cpi());
+ } else {
+ asm.emitConstantPoolMethodref(targetClass, asm.cpi());
+ }
+ }
+ targetMethodRef = asm.cpi();
+ if (isConstructor) {
+ asm.emitConstantPoolUTF8("newInstance");
+ } else {
+ asm.emitConstantPoolUTF8("invoke");
+ }
+ invokeIdx = asm.cpi();
+ if (isConstructor) {
+ asm.emitConstantPoolUTF8("([Ljava/lang/Object;)Ljava/lang/Object;");
+ } else {
+ asm.emitConstantPoolUTF8
+ ("(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;");
+ }
+ invokeDescriptorIdx = asm.cpi();
+
+ // Output class information for non-primitive parameter types
+ nonPrimitiveParametersBaseIdx = add(asm.cpi(), S2);
+ for (int i = 0; i < parameterTypes.length; i++) {
+ Class<?> c = parameterTypes[i];
+ if (!isPrimitive(c)) {
+ asm.emitConstantPoolUTF8(getClassName(c, false));
+ asm.emitConstantPoolClass(asm.cpi());
+ }
+ }
+
+ // Entries common to FieldAccessor, MethodAccessor and ConstructorAccessor
+ emitCommonConstantPoolEntries();
+
+ // Boxing entries
+ if (usesPrimitives) {
+ emitBoxingContantPoolEntries();
+ }
+
+ if (asm.cpi() != numCPEntries) {
+ throw new InternalError("Adjust this code (cpi = " + asm.cpi() +
+ ", numCPEntries = " + numCPEntries + ")");
+ }
+
+ // Access flags
+ asm.emitShort(ACC_PUBLIC);
+
+ // This class
+ asm.emitShort(thisClass);
+
+ // Superclass
+ asm.emitShort(superClass);
+
+ // Interfaces count and interfaces
+ asm.emitShort(S0);
+
+ // Fields count and fields
+ asm.emitShort(S0);
+
+ // Methods count and methods
+ asm.emitShort(NUM_METHODS);
+
+ emitConstructor();
+ emitInvoke();
+
+ // Additional attributes (none)
+ asm.emitShort(S0);
+
+ // Load class
+ vec.trim();
+ final byte[] bytes = vec.getData();
+ // Note: the class loader is the only thing that really matters
+ // here -- it's important to get the generated code into the
+ // same namespace as the target class. Since the generated code
+ // is privileged anyway, the protection domain probably doesn't
+ // matter.
+ return AccessController.doPrivileged(
+ new PrivilegedAction<MagicAccessorImpl>() {
+ public MagicAccessorImpl run() {
+ try {
+ return (MagicAccessorImpl)
+ ClassDefiner.defineClass
+ (generatedName,
+ bytes,
+ 0,
+ bytes.length,
+ declaringClass.getClassLoader()).newInstance();
+ } catch (InstantiationException | IllegalAccessException e) {
+ throw new InternalError(e);
+ }
+ }
+ });
+ }
+
+ /** This emits the code for either invoke() or newInstance() */
+ private void emitInvoke() {
+ // NOTE that this code will only handle 65535 parameters since we
+ // use the sipush instruction to get the array index on the
+ // operand stack.
+ if (parameterTypes.length > 65535) {
+ throw new InternalError("Can't handle more than 65535 parameters");
+ }
+
+ // Generate code into fresh code buffer
+ ClassFileAssembler cb = new ClassFileAssembler();
+ if (isConstructor) {
+ // 1 incoming argument
+ cb.setMaxLocals(2);
+ } else {
+ // 2 incoming arguments
+ cb.setMaxLocals(3);
+ }
+
+ short illegalArgStartPC = 0;
+
+ if (isConstructor) {
+ // Instantiate target class before continuing
+ // new <target class type>
+ // dup
+ cb.opc_new(targetClass);
+ cb.opc_dup();
+ } else {
+ // Setup before iterating down argument list
+ if (isPrimitive(returnType)) {
+ // new <boxing type for primitive type>
+ // dup
+ // ... (see below:)
+ // invokespecial <constructor for boxing type for primitive type>
+ // areturn
+ cb.opc_new(indexForPrimitiveType(returnType));
+ cb.opc_dup();
+ }
+
+ // Get target object on operand stack if necessary.
+
+ // We need to do an explicit null check here; we won't see
+ // NullPointerExceptions from the invoke bytecode, since it's
+ // covered by an exception handler.
+ if (!isStatic()) {
+ // aload_1
+ // ifnonnull <checkcast label>
+ // new <NullPointerException>
+ // dup
+ // invokespecial <NullPointerException ctor>
+ // athrow
+ // <checkcast label:>
+ // aload_1
+ // checkcast <target class's type>
+ cb.opc_aload_1();
+ Label l = new Label();
+ cb.opc_ifnonnull(l);
+ cb.opc_new(nullPointerClass);
+ cb.opc_dup();
+ cb.opc_invokespecial(nullPointerCtorIdx, 0, 0);
+ cb.opc_athrow();
+ l.bind();
+ illegalArgStartPC = cb.getLength();
+ cb.opc_aload_1();
+ cb.opc_checkcast(targetClass);
+ }
+ }
+
+ // Have to check length of incoming array and throw
+ // IllegalArgumentException if not correct. A concession to the
+ // JCK (isn't clearly specified in the spec): we allow null in the
+ // case where the argument list is zero length.
+ // if no-arg:
+ // aload_2 | aload_1 (Method | Constructor)
+ // ifnull <success label>
+ // aload_2 | aload_1
+ // arraylength
+ // sipush <num parameter types>
+ // if_icmpeq <success label>
+ // new <IllegalArgumentException>
+ // dup
+ // invokespecial <IllegalArgumentException ctor>
+ // athrow
+ // <success label:>
+ Label successLabel = new Label();
+ if (parameterTypes.length == 0) {
+ if (isConstructor) {
+ cb.opc_aload_1();
+ } else {
+ cb.opc_aload_2();
+ }
+ cb.opc_ifnull(successLabel);
+ }
+ if (isConstructor) {
+ cb.opc_aload_1();
+ } else {
+ cb.opc_aload_2();
+ }
+ cb.opc_arraylength();
+ cb.opc_sipush((short) parameterTypes.length);
+ cb.opc_if_icmpeq(successLabel);
+ cb.opc_new(illegalArgumentClass);
+ cb.opc_dup();
+ cb.opc_invokespecial(illegalArgumentCtorIdx, 0, 0);
+ cb.opc_athrow();
+ successLabel.bind();
+
+ // Iterate through incoming actual parameters, ensuring that each
+ // is compatible with the formal parameter type, and pushing the
+ // actual on the operand stack (unboxing and widening if necessary).
+
+ short paramTypeCPIdx = nonPrimitiveParametersBaseIdx;
+ Label nextParamLabel = null;
+ byte count = 1; // both invokeinterface opcode's "count" as well as
+ // num args of other invoke bytecodes
+ for (int i = 0; i < parameterTypes.length; i++) {
+ Class<?> paramType = parameterTypes[i];
+ count += (byte) typeSizeInStackSlots(paramType);
+ if (nextParamLabel != null) {
+ nextParamLabel.bind();
+ nextParamLabel = null;
+ }
+ // aload_2 | aload_1
+ // sipush <index>
+ // aaload
+ if (isConstructor) {
+ cb.opc_aload_1();
+ } else {
+ cb.opc_aload_2();
+ }
+ cb.opc_sipush((short) i);
+ cb.opc_aaload();
+ if (isPrimitive(paramType)) {
+ // Unboxing code.
+ // Put parameter into temporary local variable
+ // astore_3 | astore_2
+ if (isConstructor) {
+ cb.opc_astore_2();
+ } else {
+ cb.opc_astore_3();
+ }
+
+ // repeat for all possible widening conversions:
+ // aload_3 | aload_2
+ // instanceof <primitive boxing type>
+ // ifeq <next unboxing label>
+ // aload_3 | aload_2
+ // checkcast <primitive boxing type> // Note: this is "redundant",
+ // // but necessary for the verifier
+ // invokevirtual <unboxing method>
+ // <widening conversion bytecode, if necessary>
+ // goto <next parameter label>
+ // <next unboxing label:> ...
+ // last unboxing label:
+ // new <IllegalArgumentException>
+ // dup
+ // invokespecial <IllegalArgumentException ctor>
+ // athrow
+
+ Label l = null; // unboxing label
+ nextParamLabel = new Label();
+
+ for (int j = 0; j < primitiveTypes.length; j++) {
+ Class<?> c = primitiveTypes[j];
+ if (canWidenTo(c, paramType)) {
+ if (l != null) {
+ l.bind();
+ }
+ // Emit checking and unboxing code for this type
+ if (isConstructor) {
+ cb.opc_aload_2();
+ } else {
+ cb.opc_aload_3();
+ }
+ cb.opc_instanceof(indexForPrimitiveType(c));
+ l = new Label();
+ cb.opc_ifeq(l);
+ if (isConstructor) {
+ cb.opc_aload_2();
+ } else {
+ cb.opc_aload_3();
+ }
+ cb.opc_checkcast(indexForPrimitiveType(c));
+ cb.opc_invokevirtual(unboxingMethodForPrimitiveType(c),
+ 0,
+ typeSizeInStackSlots(c));
+ emitWideningBytecodeForPrimitiveConversion(cb,
+ c,
+ paramType);
+ cb.opc_goto(nextParamLabel);
+ }
+ }
+
+ if (l == null) {
+ throw new InternalError
+ ("Must have found at least identity conversion");
+ }
+
+ // Fell through; given object is null or invalid. According to
+ // the spec, we can throw IllegalArgumentException for both of
+ // these cases.
+
+ l.bind();
+ cb.opc_new(illegalArgumentClass);
+ cb.opc_dup();
+ cb.opc_invokespecial(illegalArgumentCtorIdx, 0, 0);
+ cb.opc_athrow();
+ } else {
+ // Emit appropriate checkcast
+ cb.opc_checkcast(paramTypeCPIdx);
+ paramTypeCPIdx = add(paramTypeCPIdx, S2);
+ // Fall through to next argument
+ }
+ }
+ // Bind last goto if present
+ if (nextParamLabel != null) {
+ nextParamLabel.bind();
+ }
+
+ short invokeStartPC = cb.getLength();
+
+ // OK, ready to perform the invocation.
+ if (isConstructor) {
+ cb.opc_invokespecial(targetMethodRef, count, 0);
+ } else {
+ if (isStatic()) {
+ cb.opc_invokestatic(targetMethodRef,
+ count,
+ typeSizeInStackSlots(returnType));
+ } else {
+ if (isInterface()) {
+ if (isPrivate()) {
+ cb.opc_invokespecial(targetMethodRef, count, 0);
+ } else {
+ cb.opc_invokeinterface(targetMethodRef,
+ count,
+ count,
+ typeSizeInStackSlots(returnType));
+ }
+ } else {
+ cb.opc_invokevirtual(targetMethodRef,
+ count,
+ typeSizeInStackSlots(returnType));
+ }
+ }
+ }
+
+ short invokeEndPC = cb.getLength();
+
+ if (!isConstructor) {
+ // Box return value if necessary
+ if (isPrimitive(returnType)) {
+ cb.opc_invokestatic(boxingMethodForPrimitiveType(returnType),
+ typeSizeInStackSlots(returnType),
+ 0);
+ } else if (returnType == Void.TYPE) {
+ cb.opc_aconst_null();
+ }
+ }
+ cb.opc_areturn();
+
+ // We generate two exception handlers; one which is responsible
+ // for catching ClassCastException and NullPointerException and
+ // throwing IllegalArgumentException, and the other which catches
+ // all java/lang/Throwable objects thrown from the target method
+ // and wraps them in InvocationTargetExceptions.
+
+ short classCastHandler = cb.getLength();
+
+ // ClassCast, etc. exception handler
+ cb.setStack(1);
+ cb.opc_invokespecial(toStringIdx, 0, 1);
+ cb.opc_new(illegalArgumentClass);
+ cb.opc_dup_x1();
+ cb.opc_swap();
+ cb.opc_invokespecial(illegalArgumentStringCtorIdx, 1, 0);
+ cb.opc_athrow();
+
+ short invocationTargetHandler = cb.getLength();
+
+ // InvocationTargetException exception handler
+ cb.setStack(1);
+ cb.opc_new(invocationTargetClass);
+ cb.opc_dup_x1();
+ cb.opc_swap();
+ cb.opc_invokespecial(invocationTargetCtorIdx, 1, 0);
+ cb.opc_athrow();
+
+ // Generate exception table. We cover the entire code sequence
+ // with an exception handler which catches ClassCastException and
+ // converts it into an IllegalArgumentException.
+
+ ClassFileAssembler exc = new ClassFileAssembler();
+
+ exc.emitShort(illegalArgStartPC); // start PC
+ exc.emitShort(invokeStartPC); // end PC
+ exc.emitShort(classCastHandler); // handler PC
+ exc.emitShort(classCastClass); // catch type
+
+ exc.emitShort(illegalArgStartPC); // start PC
+ exc.emitShort(invokeStartPC); // end PC
+ exc.emitShort(classCastHandler); // handler PC
+ exc.emitShort(nullPointerClass); // catch type
+
+ exc.emitShort(invokeStartPC); // start PC
+ exc.emitShort(invokeEndPC); // end PC
+ exc.emitShort(invocationTargetHandler); // handler PC
+ exc.emitShort(throwableClass); // catch type
+
+ emitMethod(invokeIdx, cb.getMaxLocals(), cb, exc,
+ new short[] { invocationTargetClass });
+ }
+
+ private boolean usesPrimitiveTypes() {
+ // We need to emit boxing/unboxing constant pool information if
+ // the method takes a primitive type for any of its parameters or
+ // returns a primitive value (except void)
+ if (returnType.isPrimitive()) {
+ return true;
+ }
+ for (int i = 0; i < parameterTypes.length; i++) {
+ if (parameterTypes[i].isPrimitive()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private int numNonPrimitiveParameterTypes() {
+ int num = 0;
+ for (int i = 0; i < parameterTypes.length; i++) {
+ if (!parameterTypes[i].isPrimitive()) {
+ ++num;
+ }
+ }
+ return num;
+ }
+
+ private boolean isInterface() {
+ return declaringClass.isInterface();
+ }
+
+ private String buildInternalSignature() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("(");
+ for (int i = 0; i < parameterTypes.length; i++) {
+ sb.append(getClassName(parameterTypes[i], true));
+ }
+ sb.append(")");
+ sb.append(getClassName(returnType, true));
+ return sb.toString();
+ }
+
+ private static synchronized String generateName(boolean isConstructor,
+ boolean forSerialization)
+ {
+ if (isConstructor) {
+ if (forSerialization) {
+ int num = ++serializationConstructorSymnum;
+ return "jdk/internal/reflect/GeneratedSerializationConstructorAccessor" + num;
+ } else {
+ int num = ++constructorSymnum;
+ return "jdk/internal/reflect/GeneratedConstructorAccessor" + num;
+ }
+ } else {
+ int num = ++methodSymnum;
+ return "jdk/internal/reflect/GeneratedMethodAccessor" + num;
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/MethodAccessorImpl.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2001, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+import java.lang.reflect.InvocationTargetException;
+
+/** <P> Package-private implementation of the MethodAccessor interface
+ which has access to all classes and all fields, regardless of
+ language restrictions. See MagicAccessor. </P>
+
+ <P> This class is known to the VM; do not change its name without
+ also changing the VM's code. </P>
+
+ <P> NOTE: ALL methods of subclasses are skipped during security
+ walks up the stack. The assumption is that the only such methods
+ that will persistently show up on the stack are the implementing
+ methods for java.lang.reflect.Method.invoke(). </P>
+*/
+
+abstract class MethodAccessorImpl extends MagicAccessorImpl
+ implements MethodAccessor {
+ /** Matches specification in {@link java.lang.reflect.Method} */
+ public abstract Object invoke(Object obj, Object[] args)
+ throws IllegalArgumentException, InvocationTargetException;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/NativeConstructorAccessorImpl.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2001, 2013, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+import java.lang.reflect.*;
+import sun.reflect.misc.ReflectUtil;
+
+/** Used only for the first few invocations of a Constructor;
+ afterward, switches to bytecode-based implementation */
+
+class NativeConstructorAccessorImpl extends ConstructorAccessorImpl {
+ private final Constructor<?> c;
+ private DelegatingConstructorAccessorImpl parent;
+ private int numInvocations;
+
+ NativeConstructorAccessorImpl(Constructor<?> c) {
+ this.c = c;
+ }
+
+ public Object newInstance(Object[] args)
+ throws InstantiationException,
+ IllegalArgumentException,
+ InvocationTargetException
+ {
+ // We can't inflate a constructor belonging to a vm-anonymous class
+ // because that kind of class can't be referred to by name, hence can't
+ // be found from the generated bytecode.
+ if (++numInvocations > ReflectionFactory.inflationThreshold()
+ && !ReflectUtil.isVMAnonymousClass(c.getDeclaringClass())) {
+ ConstructorAccessorImpl acc = (ConstructorAccessorImpl)
+ new MethodAccessorGenerator().
+ generateConstructor(c.getDeclaringClass(),
+ c.getParameterTypes(),
+ c.getExceptionTypes(),
+ c.getModifiers());
+ parent.setDelegate(acc);
+ }
+
+ return newInstance0(c, args);
+ }
+
+ void setParent(DelegatingConstructorAccessorImpl parent) {
+ this.parent = parent;
+ }
+
+ private static native Object newInstance0(Constructor<?> c, Object[] args)
+ throws InstantiationException,
+ IllegalArgumentException,
+ InvocationTargetException;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/NativeMethodAccessorImpl.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2001, 2013, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+import java.lang.reflect.*;
+import sun.reflect.misc.ReflectUtil;
+
+/** Used only for the first few invocations of a Method; afterward,
+ switches to bytecode-based implementation */
+
+class NativeMethodAccessorImpl extends MethodAccessorImpl {
+ private final Method method;
+ private DelegatingMethodAccessorImpl parent;
+ private int numInvocations;
+
+ NativeMethodAccessorImpl(Method method) {
+ this.method = method;
+ }
+
+ public Object invoke(Object obj, Object[] args)
+ throws IllegalArgumentException, InvocationTargetException
+ {
+ // We can't inflate methods belonging to vm-anonymous classes because
+ // that kind of class can't be referred to by name, hence can't be
+ // found from the generated bytecode.
+ if (++numInvocations > ReflectionFactory.inflationThreshold()
+ && !ReflectUtil.isVMAnonymousClass(method.getDeclaringClass())) {
+ MethodAccessorImpl acc = (MethodAccessorImpl)
+ new MethodAccessorGenerator().
+ generateMethod(method.getDeclaringClass(),
+ method.getName(),
+ method.getParameterTypes(),
+ method.getReturnType(),
+ method.getExceptionTypes(),
+ method.getModifiers());
+ parent.setDelegate(acc);
+ }
+
+ return invoke0(method, obj, args);
+ }
+
+ void setParent(DelegatingMethodAccessorImpl parent) {
+ this.parent = parent;
+ }
+
+ private static native Object invoke0(Method m, Object obj, Object[] args);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/Reflection.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,425 @@
+/*
+ * Copyright (c) 2001, 2013, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+
+import java.lang.reflect.*;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+import jdk.internal.HotSpotIntrinsicCandidate;
+import jdk.internal.misc.VM;
+
+/** Common utility routines used by both java.lang and
+ java.lang.reflect */
+
+public class Reflection {
+
+ /** Used to filter out fields and methods from certain classes from public
+ view, where they are sensitive or they may contain VM-internal objects.
+ These Maps are updated very rarely. Rather than synchronize on
+ each access, we use copy-on-write */
+ private static volatile Map<Class<?>,String[]> fieldFilterMap;
+ private static volatile Map<Class<?>,String[]> methodFilterMap;
+
+ static {
+ Map<Class<?>,String[]> map = new HashMap<Class<?>,String[]>();
+ map.put(Reflection.class,
+ new String[] {"fieldFilterMap", "methodFilterMap"});
+ map.put(System.class, new String[] {"security"});
+ map.put(Class.class, new String[] {"classLoader"});
+ fieldFilterMap = map;
+
+ methodFilterMap = new HashMap<>();
+ }
+
+ /** Returns the class of the caller of the method calling this method,
+ ignoring frames associated with java.lang.reflect.Method.invoke()
+ and its implementation. */
+ @CallerSensitive
+ @HotSpotIntrinsicCandidate
+ public static native Class<?> getCallerClass();
+
+ /**
+ * @deprecated This method will be removed.
+ * This method is a private JDK API and retained temporarily to
+ * simplify the implementation of sun.misc.Reflection.getCallerClass.
+ */
+ @Deprecated(forRemoval=true)
+ public static native Class<?> getCallerClass(int depth);
+
+ /** Retrieves the access flags written to the class file. For
+ inner classes these flags may differ from those returned by
+ Class.getModifiers(), which searches the InnerClasses
+ attribute to find the source-level access flags. This is used
+ instead of Class.getModifiers() for run-time access checks due
+ to compatibility reasons; see 4471811. Only the values of the
+ low 13 bits (i.e., a mask of 0x1FFF) are guaranteed to be
+ valid. */
+ @HotSpotIntrinsicCandidate
+ public static native int getClassAccessFlags(Class<?> c);
+
+
+ public static void ensureMemberAccess(Class<?> currentClass,
+ Class<?> memberClass,
+ Object target,
+ int modifiers)
+ throws IllegalAccessException
+ {
+ if (currentClass == null || memberClass == null) {
+ throw new InternalError();
+ }
+
+ if (!verifyMemberAccess(currentClass, memberClass, target, modifiers)) {
+ throwIllegalAccessException(currentClass, memberClass, target, modifiers);
+ }
+ }
+
+ public static boolean verifyMemberAccess(Class<?> currentClass,
+ // Declaring class of field
+ // or method
+ Class<?> memberClass,
+ // May be NULL in case of statics
+ Object target,
+ int modifiers)
+ {
+ // Verify that currentClass can access a field, method, or
+ // constructor of memberClass, where that member's access bits are
+ // "modifiers".
+
+ boolean gotIsSameClassPackage = false;
+ boolean isSameClassPackage = false;
+
+ if (currentClass == memberClass) {
+ // Always succeeds
+ return true;
+ }
+
+ if (!verifyModuleAccess(currentClass, memberClass)) {
+ return false;
+ }
+
+ if (!Modifier.isPublic(getClassAccessFlags(memberClass))) {
+ isSameClassPackage = isSameClassPackage(currentClass, memberClass);
+ gotIsSameClassPackage = true;
+ if (!isSameClassPackage) {
+ return false;
+ }
+ }
+
+ // At this point we know that currentClass can access memberClass.
+
+ if (Modifier.isPublic(modifiers)) {
+ return true;
+ }
+
+ boolean successSoFar = false;
+
+ if (Modifier.isProtected(modifiers)) {
+ // See if currentClass is a subclass of memberClass
+ if (isSubclassOf(currentClass, memberClass)) {
+ successSoFar = true;
+ }
+ }
+
+ if (!successSoFar && !Modifier.isPrivate(modifiers)) {
+ if (!gotIsSameClassPackage) {
+ isSameClassPackage = isSameClassPackage(currentClass,
+ memberClass);
+ gotIsSameClassPackage = true;
+ }
+
+ if (isSameClassPackage) {
+ successSoFar = true;
+ }
+ }
+
+ if (!successSoFar) {
+ return false;
+ }
+
+ if (Modifier.isProtected(modifiers)) {
+ // Additional test for protected members: JLS 6.6.2
+ Class<?> targetClass = (target == null ? memberClass : target.getClass());
+ if (targetClass != currentClass) {
+ if (!gotIsSameClassPackage) {
+ isSameClassPackage = isSameClassPackage(currentClass, memberClass);
+ gotIsSameClassPackage = true;
+ }
+ if (!isSameClassPackage) {
+ if (!isSubclassOf(targetClass, currentClass)) {
+ return false;
+ }
+ }
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * Returns {@code true} if memberClass's's module exports memberClass's
+ * package to currentClass's module.
+ */
+ public static boolean verifyModuleAccess(Class<?> currentClass,
+ Class<?> memberClass) {
+ return verifyModuleAccess(currentClass.getModule(), memberClass);
+ }
+
+ public static boolean verifyModuleAccess(Module currentModule, Class<?> memberClass) {
+ Module memberModule = memberClass.getModule();
+
+ // module may be null during startup (initLevel 0)
+ if (currentModule == memberModule)
+ return true; // same module (named or unnamed)
+
+ // memberClass may be primitive or array class
+ Class<?> c = memberClass;
+ while (c.isArray()) {
+ c = c.getComponentType();
+ }
+ if (c.isPrimitive())
+ return true;
+
+ // check that memberModule exports the package to currentModule
+ return memberModule.isExported(c.getPackageName(), currentModule);
+ }
+
+ /**
+ * Returns true if two classes in the same package.
+ */
+ private static boolean isSameClassPackage(Class<?> c1, Class<?> c2) {
+ if (c1.getClassLoader() != c2.getClassLoader())
+ return false;
+ while (c1.isArray())
+ c1 = c1.getComponentType();
+ while (c2.isArray())
+ c2 = c2.getComponentType();
+ return Objects.equals(c1.getPackageName(), c2.getPackageName());
+ }
+
+ static boolean isSubclassOf(Class<?> queryClass,
+ Class<?> ofClass)
+ {
+ while (queryClass != null) {
+ if (queryClass == ofClass) {
+ return true;
+ }
+ queryClass = queryClass.getSuperclass();
+ }
+ return false;
+ }
+
+ // fieldNames must contain only interned Strings
+ public static synchronized void registerFieldsToFilter(Class<?> containingClass,
+ String ... fieldNames) {
+ fieldFilterMap =
+ registerFilter(fieldFilterMap, containingClass, fieldNames);
+ }
+
+ // methodNames must contain only interned Strings
+ public static synchronized void registerMethodsToFilter(Class<?> containingClass,
+ String ... methodNames) {
+ methodFilterMap =
+ registerFilter(methodFilterMap, containingClass, methodNames);
+ }
+
+ private static Map<Class<?>,String[]> registerFilter(Map<Class<?>,String[]> map,
+ Class<?> containingClass, String ... names) {
+ if (map.get(containingClass) != null) {
+ throw new IllegalArgumentException
+ ("Filter already registered: " + containingClass);
+ }
+ map = new HashMap<Class<?>,String[]>(map);
+ map.put(containingClass, names);
+ return map;
+ }
+
+ public static Field[] filterFields(Class<?> containingClass,
+ Field[] fields) {
+ if (fieldFilterMap == null) {
+ // Bootstrapping
+ return fields;
+ }
+ return (Field[])filter(fields, fieldFilterMap.get(containingClass));
+ }
+
+ public static Method[] filterMethods(Class<?> containingClass, Method[] methods) {
+ if (methodFilterMap == null) {
+ // Bootstrapping
+ return methods;
+ }
+ return (Method[])filter(methods, methodFilterMap.get(containingClass));
+ }
+
+ private static Member[] filter(Member[] members, String[] filteredNames) {
+ if ((filteredNames == null) || (members.length == 0)) {
+ return members;
+ }
+ int numNewMembers = 0;
+ for (Member member : members) {
+ boolean shouldSkip = false;
+ for (String filteredName : filteredNames) {
+ if (member.getName() == filteredName) {
+ shouldSkip = true;
+ break;
+ }
+ }
+ if (!shouldSkip) {
+ ++numNewMembers;
+ }
+ }
+ Member[] newMembers =
+ (Member[])Array.newInstance(members[0].getClass(), numNewMembers);
+ int destIdx = 0;
+ for (Member member : members) {
+ boolean shouldSkip = false;
+ for (String filteredName : filteredNames) {
+ if (member.getName() == filteredName) {
+ shouldSkip = true;
+ break;
+ }
+ }
+ if (!shouldSkip) {
+ newMembers[destIdx++] = member;
+ }
+ }
+ return newMembers;
+ }
+
+ /**
+ * Tests if the given method is caller-sensitive and the declaring class
+ * is defined by either the bootstrap class loader or platform class loader.
+ */
+ public static boolean isCallerSensitive(Method m) {
+ final ClassLoader loader = m.getDeclaringClass().getClassLoader();
+ if (VM.isSystemDomainLoader(loader) || isExtClassLoader(loader)) {
+ return m.isAnnotationPresent(CallerSensitive.class);
+ }
+ return false;
+ }
+
+ private static boolean isExtClassLoader(ClassLoader loader) {
+ ClassLoader cl = ClassLoader.getSystemClassLoader();
+ while (cl != null) {
+ if (cl.getParent() == null && cl == loader) {
+ return true;
+ }
+ cl = cl.getParent();
+ }
+ return false;
+ }
+
+
+ // true to print a stack trace when IAE is thrown
+ private static volatile boolean printStackWhenAccessFails;
+
+ // true if printStackWhenAccessFails has been initialized
+ private static volatile boolean printStackWhenAccessFailsSet;
+
+ private static void printStackTraceIfNeeded(Throwable e) {
+ if (!printStackWhenAccessFailsSet && VM.initLevel() >= 1) {
+ // can't use method reference here, might be too early in startup
+ PrivilegedAction<Boolean> pa = new PrivilegedAction<Boolean>() {
+ public Boolean run() {
+ String s;
+ s = System.getProperty("sun.reflect.debugModuleAccessChecks");
+ return (s != null && !s.equalsIgnoreCase("false"));
+ }
+ };
+ printStackWhenAccessFails = AccessController.doPrivileged(pa);
+ printStackWhenAccessFailsSet = true;
+ }
+ if (printStackWhenAccessFails) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Throws IllegalAccessException with the an exception message based on
+ * the access that is denied.
+ */
+ private static void throwIllegalAccessException(Class<?> currentClass,
+ Class<?> memberClass,
+ Object target,
+ int modifiers)
+ throws IllegalAccessException
+ {
+ String currentSuffix = "";
+ String memberSuffix = "";
+ Module m1 = currentClass.getModule();
+ if (m1.isNamed())
+ currentSuffix = " (in " + m1 + ")";
+ Module m2 = memberClass.getModule();
+ if (m2.isNamed())
+ memberSuffix = " (in " + m2 + ")";
+
+ Class<?> c = memberClass;
+ while (c.isArray()) {
+ c = c.getComponentType();
+ }
+ String memberPackageName = c.getPackageName();
+
+ String msg = currentClass + currentSuffix + " cannot access ";
+ if (m2.isExported(memberPackageName, m1)) {
+
+ // module access okay so include the modifiers in the message
+ msg += "a member of " + memberClass + memberSuffix +
+ " with modifiers \"" + Modifier.toString(modifiers) + "\"";
+
+ } else {
+ // module access failed
+ msg += memberClass + memberSuffix+ " because "
+ + m2 + " does not export " + memberPackageName;
+ if (m2.isNamed()) msg += " to " + m1;
+ }
+
+ throwIllegalAccessException(msg);
+ }
+
+ /**
+ * Throws IllegalAccessException with the given exception message.
+ */
+ public static void throwIllegalAccessException(String msg)
+ throws IllegalAccessException
+ {
+ IllegalAccessException e = new IllegalAccessException(msg);
+ printStackTraceIfNeeded(e);
+ throw e;
+ }
+
+ /**
+ * Throws InaccessibleObjectException with the given exception message.
+ */
+ public static void throwInaccessibleObjectException(String msg) {
+ InaccessibleObjectException e = new InaccessibleObjectException(msg);
+ printStackTraceIfNeeded(e);
+ throw e;
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/ReflectionFactory.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,432 @@
+/*
+ * Copyright (c) 2001, 2013, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Executable;
+import java.lang.reflect.Method;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Modifier;
+import java.security.AccessController;
+import java.security.Permission;
+import java.security.PrivilegedAction;
+import sun.reflect.misc.ReflectUtil;
+
+/** <P> The master factory for all reflective objects, both those in
+ java.lang.reflect (Fields, Methods, Constructors) as well as their
+ delegates (FieldAccessors, MethodAccessors, ConstructorAccessors).
+ </P>
+
+ <P> The methods in this class are extremely unsafe and can cause
+ subversion of both the language and the verifier. For this reason,
+ they are all instance methods, and access to the constructor of
+ this factory is guarded by a security check, in similar style to
+ {@link jdk.internal.misc.Unsafe}. </P>
+*/
+
+public class ReflectionFactory {
+
+ private static boolean initted = false;
+ private static final Permission reflectionFactoryAccessPerm
+ = new RuntimePermission("reflectionFactoryAccess");
+ private static final ReflectionFactory soleInstance = new ReflectionFactory();
+ // Provides access to package-private mechanisms in java.lang.reflect
+ private static volatile LangReflectAccess langReflectAccess;
+
+ //
+ // "Inflation" mechanism. Loading bytecodes to implement
+ // Method.invoke() and Constructor.newInstance() currently costs
+ // 3-4x more than an invocation via native code for the first
+ // invocation (though subsequent invocations have been benchmarked
+ // to be over 20x faster). Unfortunately this cost increases
+ // startup time for certain applications that use reflection
+ // intensively (but only once per class) to bootstrap themselves.
+ // To avoid this penalty we reuse the existing JVM entry points
+ // for the first few invocations of Methods and Constructors and
+ // then switch to the bytecode-based implementations.
+ //
+ // Package-private to be accessible to NativeMethodAccessorImpl
+ // and NativeConstructorAccessorImpl
+ private static boolean noInflation = false;
+ private static int inflationThreshold = 15;
+
+ private ReflectionFactory() {
+ }
+
+ /**
+ * A convenience class for acquiring the capability to instantiate
+ * reflective objects. Use this instead of a raw call to {@link
+ * #getReflectionFactory} in order to avoid being limited by the
+ * permissions of your callers.
+ *
+ * <p>An instance of this class can be used as the argument of
+ * <code>AccessController.doPrivileged</code>.
+ */
+ public static final class GetReflectionFactoryAction
+ implements PrivilegedAction<ReflectionFactory> {
+ public ReflectionFactory run() {
+ return getReflectionFactory();
+ }
+ }
+
+ /**
+ * Provides the caller with the capability to instantiate reflective
+ * objects.
+ *
+ * <p> First, if there is a security manager, its
+ * <code>checkPermission</code> method is called with a {@link
+ * java.lang.RuntimePermission} with target
+ * <code>"reflectionFactoryAccess"</code>. This may result in a
+ * security exception.
+ *
+ * <p> The returned <code>ReflectionFactory</code> object should be
+ * carefully guarded by the caller, since it can be used to read and
+ * write private data and invoke private methods, as well as to load
+ * unverified bytecodes. It must never be passed to untrusted code.
+ *
+ * @exception SecurityException if a security manager exists and its
+ * <code>checkPermission</code> method doesn't allow
+ * access to the RuntimePermission "reflectionFactoryAccess". */
+ public static ReflectionFactory getReflectionFactory() {
+ SecurityManager security = System.getSecurityManager();
+ if (security != null) {
+ // TO DO: security.checkReflectionFactoryAccess();
+ security.checkPermission(reflectionFactoryAccessPerm);
+ }
+ return soleInstance;
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Routines used by java.lang.reflect
+ //
+ //
+
+ /** Called only by java.lang.reflect.Modifier's static initializer */
+ public void setLangReflectAccess(LangReflectAccess access) {
+ langReflectAccess = access;
+ }
+
+ /**
+ * Note: this routine can cause the declaring class for the field
+ * be initialized and therefore must not be called until the
+ * first get/set of this field.
+ * @param field the field
+ * @param override true if caller has overridden accessibility
+ */
+ public FieldAccessor newFieldAccessor(Field field, boolean override) {
+ checkInitted();
+ return UnsafeFieldAccessorFactory.newFieldAccessor(field, override);
+ }
+
+ public MethodAccessor newMethodAccessor(Method method) {
+ checkInitted();
+
+ if (noInflation && !ReflectUtil.isVMAnonymousClass(method.getDeclaringClass())) {
+ return new MethodAccessorGenerator().
+ generateMethod(method.getDeclaringClass(),
+ method.getName(),
+ method.getParameterTypes(),
+ method.getReturnType(),
+ method.getExceptionTypes(),
+ method.getModifiers());
+ } else {
+ NativeMethodAccessorImpl acc =
+ new NativeMethodAccessorImpl(method);
+ DelegatingMethodAccessorImpl res =
+ new DelegatingMethodAccessorImpl(acc);
+ acc.setParent(res);
+ return res;
+ }
+ }
+
+ public ConstructorAccessor newConstructorAccessor(Constructor<?> c) {
+ checkInitted();
+
+ Class<?> declaringClass = c.getDeclaringClass();
+ if (Modifier.isAbstract(declaringClass.getModifiers())) {
+ return new InstantiationExceptionConstructorAccessorImpl(null);
+ }
+ if (declaringClass == Class.class) {
+ return new InstantiationExceptionConstructorAccessorImpl
+ ("Can not instantiate java.lang.Class");
+ }
+ // Bootstrapping issue: since we use Class.newInstance() in
+ // the ConstructorAccessor generation process, we have to
+ // break the cycle here.
+ if (Reflection.isSubclassOf(declaringClass,
+ ConstructorAccessorImpl.class)) {
+ return new BootstrapConstructorAccessorImpl(c);
+ }
+
+ if (noInflation && !ReflectUtil.isVMAnonymousClass(c.getDeclaringClass())) {
+ return new MethodAccessorGenerator().
+ generateConstructor(c.getDeclaringClass(),
+ c.getParameterTypes(),
+ c.getExceptionTypes(),
+ c.getModifiers());
+ } else {
+ NativeConstructorAccessorImpl acc =
+ new NativeConstructorAccessorImpl(c);
+ DelegatingConstructorAccessorImpl res =
+ new DelegatingConstructorAccessorImpl(acc);
+ acc.setParent(res);
+ return res;
+ }
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Routines used by java.lang
+ //
+ //
+
+ /** Creates a new java.lang.reflect.Field. Access checks as per
+ java.lang.reflect.AccessibleObject are not overridden. */
+ public Field newField(Class<?> declaringClass,
+ String name,
+ Class<?> type,
+ int modifiers,
+ int slot,
+ String signature,
+ byte[] annotations)
+ {
+ return langReflectAccess().newField(declaringClass,
+ name,
+ type,
+ modifiers,
+ slot,
+ signature,
+ annotations);
+ }
+
+ /** Creates a new java.lang.reflect.Method. Access checks as per
+ java.lang.reflect.AccessibleObject are not overridden. */
+ public Method newMethod(Class<?> declaringClass,
+ String name,
+ Class<?>[] parameterTypes,
+ Class<?> returnType,
+ Class<?>[] checkedExceptions,
+ int modifiers,
+ int slot,
+ String signature,
+ byte[] annotations,
+ byte[] parameterAnnotations,
+ byte[] annotationDefault)
+ {
+ return langReflectAccess().newMethod(declaringClass,
+ name,
+ parameterTypes,
+ returnType,
+ checkedExceptions,
+ modifiers,
+ slot,
+ signature,
+ annotations,
+ parameterAnnotations,
+ annotationDefault);
+ }
+
+ /** Creates a new java.lang.reflect.Constructor. Access checks as
+ per java.lang.reflect.AccessibleObject are not overridden. */
+ public Constructor<?> newConstructor(Class<?> declaringClass,
+ Class<?>[] parameterTypes,
+ Class<?>[] checkedExceptions,
+ int modifiers,
+ int slot,
+ String signature,
+ byte[] annotations,
+ byte[] parameterAnnotations)
+ {
+ return langReflectAccess().newConstructor(declaringClass,
+ parameterTypes,
+ checkedExceptions,
+ modifiers,
+ slot,
+ signature,
+ annotations,
+ parameterAnnotations);
+ }
+
+ /** Gets the MethodAccessor object for a java.lang.reflect.Method */
+ public MethodAccessor getMethodAccessor(Method m) {
+ return langReflectAccess().getMethodAccessor(m);
+ }
+
+ /** Sets the MethodAccessor object for a java.lang.reflect.Method */
+ public void setMethodAccessor(Method m, MethodAccessor accessor) {
+ langReflectAccess().setMethodAccessor(m, accessor);
+ }
+
+ /** Gets the ConstructorAccessor object for a
+ java.lang.reflect.Constructor */
+ public ConstructorAccessor getConstructorAccessor(Constructor<?> c) {
+ return langReflectAccess().getConstructorAccessor(c);
+ }
+
+ /** Sets the ConstructorAccessor object for a
+ java.lang.reflect.Constructor */
+ public void setConstructorAccessor(Constructor<?> c,
+ ConstructorAccessor accessor)
+ {
+ langReflectAccess().setConstructorAccessor(c, accessor);
+ }
+
+ /** Makes a copy of the passed method. The returned method is a
+ "child" of the passed one; see the comments in Method.java for
+ details. */
+ public Method copyMethod(Method arg) {
+ return langReflectAccess().copyMethod(arg);
+ }
+
+ /** Makes a copy of the passed method. The returned method is NOT
+ * a "child" but a "sibling" of the Method in arg. Should only be
+ * used on non-root methods. */
+ public Method leafCopyMethod(Method arg) {
+ return langReflectAccess().leafCopyMethod(arg);
+ }
+
+
+ /** Makes a copy of the passed field. The returned field is a
+ "child" of the passed one; see the comments in Field.java for
+ details. */
+ public Field copyField(Field arg) {
+ return langReflectAccess().copyField(arg);
+ }
+
+ /** Makes a copy of the passed constructor. The returned
+ constructor is a "child" of the passed one; see the comments
+ in Constructor.java for details. */
+ public <T> Constructor<T> copyConstructor(Constructor<T> arg) {
+ return langReflectAccess().copyConstructor(arg);
+ }
+
+ /** Gets the byte[] that encodes TypeAnnotations on an executable.
+ */
+ public byte[] getExecutableTypeAnnotationBytes(Executable ex) {
+ return langReflectAccess().getExecutableTypeAnnotationBytes(ex);
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Routines used by serialization
+ //
+ //
+
+ public Constructor<?> newConstructorForSerialization
+ (Class<?> classToInstantiate, Constructor<?> constructorToCall)
+ {
+ // Fast path
+ if (constructorToCall.getDeclaringClass() == classToInstantiate) {
+ return constructorToCall;
+ }
+
+ ConstructorAccessor acc = new MethodAccessorGenerator().
+ generateSerializationConstructor(classToInstantiate,
+ constructorToCall.getParameterTypes(),
+ constructorToCall.getExceptionTypes(),
+ constructorToCall.getModifiers(),
+ constructorToCall.getDeclaringClass());
+ Constructor<?> c = newConstructor(constructorToCall.getDeclaringClass(),
+ constructorToCall.getParameterTypes(),
+ constructorToCall.getExceptionTypes(),
+ constructorToCall.getModifiers(),
+ langReflectAccess().
+ getConstructorSlot(constructorToCall),
+ langReflectAccess().
+ getConstructorSignature(constructorToCall),
+ langReflectAccess().
+ getConstructorAnnotations(constructorToCall),
+ langReflectAccess().
+ getConstructorParameterAnnotations(constructorToCall));
+ setConstructorAccessor(c, acc);
+ return c;
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Internals only below this point
+ //
+
+ static int inflationThreshold() {
+ return inflationThreshold;
+ }
+
+ /** We have to defer full initialization of this class until after
+ the static initializer is run since java.lang.reflect.Method's
+ static initializer (more properly, that for
+ java.lang.reflect.AccessibleObject) causes this class's to be
+ run, before the system properties are set up. */
+ 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;
+ }
+
+ String val = System.getProperty("sun.reflect.noInflation");
+ if (val != null && val.equals("true")) {
+ noInflation = true;
+ }
+
+ val = System.getProperty("sun.reflect.inflationThreshold");
+ if (val != null) {
+ try {
+ inflationThreshold = Integer.parseInt(val);
+ } catch (NumberFormatException e) {
+ throw new RuntimeException("Unable to parse property sun.reflect.inflationThreshold", e);
+ }
+ }
+
+ initted = true;
+ return null;
+ }
+ });
+ }
+
+ private static LangReflectAccess langReflectAccess() {
+ if (langReflectAccess == null) {
+ // Call a static method to get class java.lang.reflect.Modifier
+ // initialized. Its static initializer will cause
+ // setLangReflectAccess() to be called from the context of the
+ // java.lang.reflect package.
+ Modifier.isPublic(Modifier.PUBLIC);
+ }
+ return langReflectAccess;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/SerializationConstructorAccessorImpl.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2001, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+/** <P> Java serialization (in java.io) expects to be able to
+ instantiate a class and invoke a no-arg constructor of that
+ class's first non-Serializable superclass. This is not a valid
+ operation according to the VM specification; one can not (for
+ classes A and B, where B is a subclass of A) write "new B;
+ invokespecial A()" without getting a verification error. </P>
+
+ <P> In all other respects, the bytecode-based reflection framework
+ can be reused for this purpose. This marker class was originally
+ known to the VM and verification disabled for it and all
+ subclasses, but the bug fix for 4486457 necessitated disabling
+ verification for all of the dynamically-generated bytecodes
+ associated with reflection. This class has been left in place to
+ make future debugging easier. </P> */
+
+abstract class SerializationConstructorAccessorImpl
+ extends ConstructorAccessorImpl {
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/SignatureIterator.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2001, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+/** Assists in iterating down a method's signature */
+
+class SignatureIterator {
+ private final String sig;
+ private int idx;
+
+ public SignatureIterator(String sig) {
+ this.sig = sig;
+ reset();
+ }
+
+ public void reset() {
+ idx = 1;
+ }
+
+ public boolean atEnd() {
+ return sig.charAt(idx) == ')';
+ }
+
+ public String next() {
+ if (atEnd()) return null;
+ char c = sig.charAt(idx);
+ if (c != '[' && c != 'L') {
+ ++idx;
+ return new String(new char[] { c });
+ }
+ // Walk forward to end of entry
+ int endIdx = idx;
+ if (c == '[') {
+ while ((c = sig.charAt(endIdx)) == '[') {
+ endIdx++;
+ }
+ }
+
+ if (c == 'L') {
+ while (sig.charAt(endIdx) != ';') {
+ endIdx++;
+ }
+ }
+
+ int beginIdx = idx;
+ idx = endIdx + 1;
+ return sig.substring(beginIdx, idx);
+ }
+
+ /** Should only be called when atEnd() is true. Does not change
+ state of iterator. */
+ public String returnType() {
+ if (!atEnd()) {
+ throw new InternalError("Illegal use of SignatureIterator");
+ }
+ return sig.substring(idx + 1, sig.length());
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/UTF8.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2001, 2011, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+/** It is necessary to use a "bootstrap" UTF-8 encoder for encoding
+ constant pool entries because the character set converters rely on
+ Class.newInstance(). */
+
+class UTF8 {
+ // This encoder is not quite correct. It does not handle surrogate pairs.
+ static byte[] encode(String str) {
+ int len = str.length();
+ byte[] res = new byte[utf8Length(str)];
+ int utf8Idx = 0;
+ try {
+ for (int i = 0; i < len; i++) {
+ int c = str.charAt(i) & 0xFFFF;
+ if (c >= 0x0001 && c <= 0x007F) {
+ res[utf8Idx++] = (byte) c;
+ } else if (c == 0x0000 ||
+ (c >= 0x0080 && c <= 0x07FF)) {
+ res[utf8Idx++] = (byte) (0xC0 + (c >> 6));
+ res[utf8Idx++] = (byte) (0x80 + (c & 0x3F));
+ } else {
+ res[utf8Idx++] = (byte) (0xE0 + (c >> 12));
+ res[utf8Idx++] = (byte) (0x80 + ((c >> 6) & 0x3F));
+ res[utf8Idx++] = (byte) (0x80 + (c & 0x3F));
+ }
+ }
+ } catch (ArrayIndexOutOfBoundsException e) {
+ throw new InternalError
+ ("Bug in sun.reflect bootstrap UTF-8 encoder", e);
+ }
+ return res;
+ }
+
+ private static int utf8Length(String str) {
+ int len = str.length();
+ int utf8Len = 0;
+ for (int i = 0; i < len; i++) {
+ int c = str.charAt(i) & 0xFFFF;
+ if (c >= 0x0001 && c <= 0x007F) {
+ utf8Len += 1;
+ } else if (c == 0x0000 ||
+ (c >= 0x0080 && c <= 0x07FF)) {
+ utf8Len += 2;
+ } else {
+ utf8Len += 3;
+ }
+ }
+ return utf8Len;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/UnsafeBooleanFieldAccessorImpl.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,140 @@
+/*
+ * Copyright (c) 2001, 2005, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+import java.lang.reflect.Field;
+
+class UnsafeBooleanFieldAccessorImpl extends UnsafeFieldAccessorImpl {
+ UnsafeBooleanFieldAccessorImpl(Field field) {
+ super(field);
+ }
+
+ public Object get(Object obj) throws IllegalArgumentException {
+ return Boolean.valueOf(getBoolean(obj));
+ }
+
+ public boolean getBoolean(Object obj) throws IllegalArgumentException {
+ ensureObj(obj);
+ return unsafe.getBoolean(obj, fieldOffset);
+ }
+
+ public byte getByte(Object obj) throws IllegalArgumentException {
+ throw newGetByteIllegalArgumentException();
+ }
+
+ public char getChar(Object obj) throws IllegalArgumentException {
+ throw newGetCharIllegalArgumentException();
+ }
+
+ public short getShort(Object obj) throws IllegalArgumentException {
+ throw newGetShortIllegalArgumentException();
+ }
+
+ public int getInt(Object obj) throws IllegalArgumentException {
+ throw newGetIntIllegalArgumentException();
+ }
+
+ public long getLong(Object obj) throws IllegalArgumentException {
+ throw newGetLongIllegalArgumentException();
+ }
+
+ public float getFloat(Object obj) throws IllegalArgumentException {
+ throw newGetFloatIllegalArgumentException();
+ }
+
+ public double getDouble(Object obj) throws IllegalArgumentException {
+ throw newGetDoubleIllegalArgumentException();
+ }
+
+ public void set(Object obj, Object value)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ ensureObj(obj);
+ if (isFinal) {
+ throwFinalFieldIllegalAccessException(value);
+ }
+ if (value == null) {
+ throwSetIllegalArgumentException(value);
+ }
+ if (value instanceof Boolean) {
+ unsafe.putBoolean(obj, fieldOffset, ((Boolean) value).booleanValue());
+ return;
+ }
+ throwSetIllegalArgumentException(value);
+ }
+
+ public void setBoolean(Object obj, boolean z)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ ensureObj(obj);
+ if (isFinal) {
+ throwFinalFieldIllegalAccessException(z);
+ }
+ unsafe.putBoolean(obj, fieldOffset, z);
+ }
+
+ public void setByte(Object obj, byte b)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(b);
+ }
+
+ public void setChar(Object obj, char c)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(c);
+ }
+
+ public void setShort(Object obj, short s)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(s);
+ }
+
+ public void setInt(Object obj, int i)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(i);
+ }
+
+ public void setLong(Object obj, long l)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(l);
+ }
+
+ public void setFloat(Object obj, float f)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(f);
+ }
+
+ public void setDouble(Object obj, double d)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(d);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/UnsafeByteFieldAccessorImpl.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,140 @@
+/*
+ * Copyright (c) 2001, 2005, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+import java.lang.reflect.Field;
+
+class UnsafeByteFieldAccessorImpl extends UnsafeFieldAccessorImpl {
+ UnsafeByteFieldAccessorImpl(Field field) {
+ super(field);
+ }
+
+ public Object get(Object obj) throws IllegalArgumentException {
+ return Byte.valueOf(getByte(obj));
+ }
+
+ public boolean getBoolean(Object obj) throws IllegalArgumentException {
+ throw newGetBooleanIllegalArgumentException();
+ }
+
+ public byte getByte(Object obj) throws IllegalArgumentException {
+ ensureObj(obj);
+ return unsafe.getByte(obj, fieldOffset);
+ }
+
+ public char getChar(Object obj) throws IllegalArgumentException {
+ throw newGetCharIllegalArgumentException();
+ }
+
+ public short getShort(Object obj) throws IllegalArgumentException {
+ return getByte(obj);
+ }
+
+ public int getInt(Object obj) throws IllegalArgumentException {
+ return getByte(obj);
+ }
+
+ public long getLong(Object obj) throws IllegalArgumentException {
+ return getByte(obj);
+ }
+
+ public float getFloat(Object obj) throws IllegalArgumentException {
+ return getByte(obj);
+ }
+
+ public double getDouble(Object obj) throws IllegalArgumentException {
+ return getByte(obj);
+ }
+
+ public void set(Object obj, Object value)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ ensureObj(obj);
+ if (isFinal) {
+ throwFinalFieldIllegalAccessException(value);
+ }
+ if (value == null) {
+ throwSetIllegalArgumentException(value);
+ }
+ if (value instanceof Byte) {
+ unsafe.putByte(obj, fieldOffset, ((Byte) value).byteValue());
+ return;
+ }
+ throwSetIllegalArgumentException(value);
+ }
+
+ public void setBoolean(Object obj, boolean z)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(z);
+ }
+
+ public void setByte(Object obj, byte b)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ ensureObj(obj);
+ if (isFinal) {
+ throwFinalFieldIllegalAccessException(b);
+ }
+ unsafe.putByte(obj, fieldOffset, b);
+ }
+
+ public void setChar(Object obj, char c)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(c);
+ }
+
+ public void setShort(Object obj, short s)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(s);
+ }
+
+ public void setInt(Object obj, int i)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(i);
+ }
+
+ public void setLong(Object obj, long l)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(l);
+ }
+
+ public void setFloat(Object obj, float f)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(f);
+ }
+
+ public void setDouble(Object obj, double d)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(d);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/UnsafeCharacterFieldAccessorImpl.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,140 @@
+/*
+ * Copyright (c) 2001, 2005, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+import java.lang.reflect.Field;
+
+class UnsafeCharacterFieldAccessorImpl extends UnsafeFieldAccessorImpl {
+ UnsafeCharacterFieldAccessorImpl(Field field) {
+ super(field);
+ }
+
+ public Object get(Object obj) throws IllegalArgumentException {
+ return Character.valueOf(getChar(obj));
+ }
+
+ public boolean getBoolean(Object obj) throws IllegalArgumentException {
+ throw newGetBooleanIllegalArgumentException();
+ }
+
+ public byte getByte(Object obj) throws IllegalArgumentException {
+ throw newGetByteIllegalArgumentException();
+ }
+
+ public char getChar(Object obj) throws IllegalArgumentException {
+ ensureObj(obj);
+ return unsafe.getChar(obj, fieldOffset);
+ }
+
+ public short getShort(Object obj) throws IllegalArgumentException {
+ throw newGetShortIllegalArgumentException();
+ }
+
+ public int getInt(Object obj) throws IllegalArgumentException {
+ return getChar(obj);
+ }
+
+ public long getLong(Object obj) throws IllegalArgumentException {
+ return getChar(obj);
+ }
+
+ public float getFloat(Object obj) throws IllegalArgumentException {
+ return getChar(obj);
+ }
+
+ public double getDouble(Object obj) throws IllegalArgumentException {
+ return getChar(obj);
+ }
+
+ public void set(Object obj, Object value)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ ensureObj(obj);
+ if (isFinal) {
+ throwFinalFieldIllegalAccessException(value);
+ }
+ if (value == null) {
+ throwSetIllegalArgumentException(value);
+ }
+ if (value instanceof Character) {
+ unsafe.putChar(obj, fieldOffset, ((Character) value).charValue());
+ return;
+ }
+ throwSetIllegalArgumentException(value);
+ }
+
+ public void setBoolean(Object obj, boolean z)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(z);
+ }
+
+ public void setByte(Object obj, byte b)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(b);
+ }
+
+ public void setChar(Object obj, char c)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ ensureObj(obj);
+ if (isFinal) {
+ throwFinalFieldIllegalAccessException(c);
+ }
+ unsafe.putChar(obj, fieldOffset, c);
+ }
+
+ public void setShort(Object obj, short s)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(s);
+ }
+
+ public void setInt(Object obj, int i)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(i);
+ }
+
+ public void setLong(Object obj, long l)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(l);
+ }
+
+ public void setFloat(Object obj, float f)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(f);
+ }
+
+ public void setDouble(Object obj, double d)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(d);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/UnsafeDoubleFieldAccessorImpl.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,164 @@
+/*
+ * Copyright (c) 2001, 2005, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+import java.lang.reflect.Field;
+
+class UnsafeDoubleFieldAccessorImpl extends UnsafeFieldAccessorImpl {
+ UnsafeDoubleFieldAccessorImpl(Field field) {
+ super(field);
+ }
+
+ public Object get(Object obj) throws IllegalArgumentException {
+ return Double.valueOf(getDouble(obj));
+ }
+
+ public boolean getBoolean(Object obj) throws IllegalArgumentException {
+ throw newGetBooleanIllegalArgumentException();
+ }
+
+ public byte getByte(Object obj) throws IllegalArgumentException {
+ throw newGetByteIllegalArgumentException();
+ }
+
+ public char getChar(Object obj) throws IllegalArgumentException {
+ throw newGetCharIllegalArgumentException();
+ }
+
+ public short getShort(Object obj) throws IllegalArgumentException {
+ throw newGetShortIllegalArgumentException();
+ }
+
+ public int getInt(Object obj) throws IllegalArgumentException {
+ throw newGetIntIllegalArgumentException();
+ }
+
+ public long getLong(Object obj) throws IllegalArgumentException {
+ throw newGetLongIllegalArgumentException();
+ }
+
+ public float getFloat(Object obj) throws IllegalArgumentException {
+ throw newGetFloatIllegalArgumentException();
+ }
+
+ public double getDouble(Object obj) throws IllegalArgumentException {
+ ensureObj(obj);
+ return unsafe.getDouble(obj, fieldOffset);
+ }
+
+ public void set(Object obj, Object value)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ ensureObj(obj);
+ if (isFinal) {
+ throwFinalFieldIllegalAccessException(value);
+ }
+ if (value == null) {
+ throwSetIllegalArgumentException(value);
+ }
+ if (value instanceof Byte) {
+ unsafe.putDouble(obj, fieldOffset, ((Byte) value).byteValue());
+ return;
+ }
+ if (value instanceof Short) {
+ unsafe.putDouble(obj, fieldOffset, ((Short) value).shortValue());
+ return;
+ }
+ if (value instanceof Character) {
+ unsafe.putDouble(obj, fieldOffset, ((Character) value).charValue());
+ return;
+ }
+ if (value instanceof Integer) {
+ unsafe.putDouble(obj, fieldOffset, ((Integer) value).intValue());
+ return;
+ }
+ if (value instanceof Long) {
+ unsafe.putDouble(obj, fieldOffset, ((Long) value).longValue());
+ return;
+ }
+ if (value instanceof Float) {
+ unsafe.putDouble(obj, fieldOffset, ((Float) value).floatValue());
+ return;
+ }
+ if (value instanceof Double) {
+ unsafe.putDouble(obj, fieldOffset, ((Double) value).doubleValue());
+ return;
+ }
+ throwSetIllegalArgumentException(value);
+ }
+
+ public void setBoolean(Object obj, boolean z)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(z);
+ }
+
+ public void setByte(Object obj, byte b)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setDouble(obj, b);
+ }
+
+ public void setChar(Object obj, char c)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setDouble(obj, c);
+ }
+
+ public void setShort(Object obj, short s)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setDouble(obj, s);
+ }
+
+ public void setInt(Object obj, int i)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setDouble(obj, i);
+ }
+
+ public void setLong(Object obj, long l)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setDouble(obj, l);
+ }
+
+ public void setFloat(Object obj, float f)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setDouble(obj, f);
+ }
+
+ public void setDouble(Object obj, double d)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ ensureObj(obj);
+ if (isFinal) {
+ throwFinalFieldIllegalAccessException(d);
+ }
+ unsafe.putDouble(obj, fieldOffset, d);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/UnsafeFieldAccessorFactory.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,130 @@
+/*
+ * Copyright (c) 2001, 2011, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+
+class UnsafeFieldAccessorFactory {
+ static FieldAccessor newFieldAccessor(Field field, boolean override) {
+ Class<?> type = field.getType();
+ boolean isStatic = Modifier.isStatic(field.getModifiers());
+ boolean isFinal = Modifier.isFinal(field.getModifiers());
+ boolean isVolatile = Modifier.isVolatile(field.getModifiers());
+ boolean isQualified = isFinal || isVolatile;
+ boolean isReadOnly = isFinal && (isStatic || !override);
+ if (isStatic) {
+ // This code path does not guarantee that the field's
+ // declaring class has been initialized, but it must be
+ // before performing reflective operations.
+ UnsafeFieldAccessorImpl.unsafe.ensureClassInitialized(field.getDeclaringClass());
+
+ if (!isQualified) {
+ if (type == Boolean.TYPE) {
+ return new UnsafeStaticBooleanFieldAccessorImpl(field);
+ } else if (type == Byte.TYPE) {
+ return new UnsafeStaticByteFieldAccessorImpl(field);
+ } else if (type == Short.TYPE) {
+ return new UnsafeStaticShortFieldAccessorImpl(field);
+ } else if (type == Character.TYPE) {
+ return new UnsafeStaticCharacterFieldAccessorImpl(field);
+ } else if (type == Integer.TYPE) {
+ return new UnsafeStaticIntegerFieldAccessorImpl(field);
+ } else if (type == Long.TYPE) {
+ return new UnsafeStaticLongFieldAccessorImpl(field);
+ } else if (type == Float.TYPE) {
+ return new UnsafeStaticFloatFieldAccessorImpl(field);
+ } else if (type == Double.TYPE) {
+ return new UnsafeStaticDoubleFieldAccessorImpl(field);
+ } else {
+ return new UnsafeStaticObjectFieldAccessorImpl(field);
+ }
+ } else {
+ if (type == Boolean.TYPE) {
+ return new UnsafeQualifiedStaticBooleanFieldAccessorImpl(field, isReadOnly);
+ } else if (type == Byte.TYPE) {
+ return new UnsafeQualifiedStaticByteFieldAccessorImpl(field, isReadOnly);
+ } else if (type == Short.TYPE) {
+ return new UnsafeQualifiedStaticShortFieldAccessorImpl(field, isReadOnly);
+ } else if (type == Character.TYPE) {
+ return new UnsafeQualifiedStaticCharacterFieldAccessorImpl(field, isReadOnly);
+ } else if (type == Integer.TYPE) {
+ return new UnsafeQualifiedStaticIntegerFieldAccessorImpl(field, isReadOnly);
+ } else if (type == Long.TYPE) {
+ return new UnsafeQualifiedStaticLongFieldAccessorImpl(field, isReadOnly);
+ } else if (type == Float.TYPE) {
+ return new UnsafeQualifiedStaticFloatFieldAccessorImpl(field, isReadOnly);
+ } else if (type == Double.TYPE) {
+ return new UnsafeQualifiedStaticDoubleFieldAccessorImpl(field, isReadOnly);
+ } else {
+ return new UnsafeQualifiedStaticObjectFieldAccessorImpl(field, isReadOnly);
+ }
+ }
+ } else {
+ if (!isQualified) {
+ if (type == Boolean.TYPE) {
+ return new UnsafeBooleanFieldAccessorImpl(field);
+ } else if (type == Byte.TYPE) {
+ return new UnsafeByteFieldAccessorImpl(field);
+ } else if (type == Short.TYPE) {
+ return new UnsafeShortFieldAccessorImpl(field);
+ } else if (type == Character.TYPE) {
+ return new UnsafeCharacterFieldAccessorImpl(field);
+ } else if (type == Integer.TYPE) {
+ return new UnsafeIntegerFieldAccessorImpl(field);
+ } else if (type == Long.TYPE) {
+ return new UnsafeLongFieldAccessorImpl(field);
+ } else if (type == Float.TYPE) {
+ return new UnsafeFloatFieldAccessorImpl(field);
+ } else if (type == Double.TYPE) {
+ return new UnsafeDoubleFieldAccessorImpl(field);
+ } else {
+ return new UnsafeObjectFieldAccessorImpl(field);
+ }
+ } else {
+ if (type == Boolean.TYPE) {
+ return new UnsafeQualifiedBooleanFieldAccessorImpl(field, isReadOnly);
+ } else if (type == Byte.TYPE) {
+ return new UnsafeQualifiedByteFieldAccessorImpl(field, isReadOnly);
+ } else if (type == Short.TYPE) {
+ return new UnsafeQualifiedShortFieldAccessorImpl(field, isReadOnly);
+ } else if (type == Character.TYPE) {
+ return new UnsafeQualifiedCharacterFieldAccessorImpl(field, isReadOnly);
+ } else if (type == Integer.TYPE) {
+ return new UnsafeQualifiedIntegerFieldAccessorImpl(field, isReadOnly);
+ } else if (type == Long.TYPE) {
+ return new UnsafeQualifiedLongFieldAccessorImpl(field, isReadOnly);
+ } else if (type == Float.TYPE) {
+ return new UnsafeQualifiedFloatFieldAccessorImpl(field, isReadOnly);
+ } else if (type == Double.TYPE) {
+ return new UnsafeQualifiedDoubleFieldAccessorImpl(field, isReadOnly);
+ } else {
+ return new UnsafeQualifiedObjectFieldAccessorImpl(field, isReadOnly);
+ }
+ }
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/UnsafeFieldAccessorImpl.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,206 @@
+/*
+ * Copyright (c) 2001, 2011, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+import jdk.internal.misc.Unsafe;
+
+/** Base class for jdk.internal.misc.Unsafe-based FieldAccessors. The
+ observation is that there are only nine types of fields from the
+ standpoint of reflection code: the eight primitive types and
+ Object. Using class Unsafe instead of generated bytecodes saves
+ memory and loading time for the dynamically-generated
+ FieldAccessors. */
+
+abstract class UnsafeFieldAccessorImpl extends FieldAccessorImpl {
+ static final Unsafe unsafe = Unsafe.getUnsafe();
+
+ protected final Field field;
+ protected final long fieldOffset;
+ protected final boolean isFinal;
+
+ UnsafeFieldAccessorImpl(Field field) {
+ this.field = field;
+ if (Modifier.isStatic(field.getModifiers()))
+ fieldOffset = unsafe.staticFieldOffset(field);
+ else
+ fieldOffset = unsafe.objectFieldOffset(field);
+ isFinal = Modifier.isFinal(field.getModifiers());
+ }
+
+ protected void ensureObj(Object o) {
+ // NOTE: will throw NullPointerException, as specified, if o is null
+ if (!field.getDeclaringClass().isAssignableFrom(o.getClass())) {
+ throwSetIllegalArgumentException(o);
+ }
+ }
+
+ private String getQualifiedFieldName() {
+ return field.getDeclaringClass().getName() + "." +field.getName();
+ }
+
+ protected IllegalArgumentException newGetIllegalArgumentException(String type) {
+ return new IllegalArgumentException(
+ "Attempt to get "+field.getType().getName()+" field \"" +
+ getQualifiedFieldName() + "\" with illegal data type conversion to "+type
+ );
+ }
+
+ protected void throwFinalFieldIllegalAccessException(String attemptedType,
+ String attemptedValue)
+ throws IllegalAccessException {
+ throw new IllegalAccessException(getSetMessage(attemptedType, attemptedValue));
+
+ }
+ protected void throwFinalFieldIllegalAccessException(Object o) throws IllegalAccessException {
+ throwFinalFieldIllegalAccessException(o != null ? o.getClass().getName() : "", "");
+ }
+
+ protected void throwFinalFieldIllegalAccessException(boolean z) throws IllegalAccessException {
+ throwFinalFieldIllegalAccessException("boolean", Boolean.toString(z));
+ }
+
+ protected void throwFinalFieldIllegalAccessException(char b) throws IllegalAccessException {
+ throwFinalFieldIllegalAccessException("char", Character.toString(b));
+ }
+
+ protected void throwFinalFieldIllegalAccessException(byte b) throws IllegalAccessException {
+ throwFinalFieldIllegalAccessException("byte", Byte.toString(b));
+ }
+
+ protected void throwFinalFieldIllegalAccessException(short b) throws IllegalAccessException {
+ throwFinalFieldIllegalAccessException("short", Short.toString(b));
+ }
+
+ protected void throwFinalFieldIllegalAccessException(int i) throws IllegalAccessException {
+ throwFinalFieldIllegalAccessException("int", Integer.toString(i));
+ }
+
+ protected void throwFinalFieldIllegalAccessException(long i) throws IllegalAccessException {
+ throwFinalFieldIllegalAccessException("long", Long.toString(i));
+ }
+
+ protected void throwFinalFieldIllegalAccessException(float f) throws IllegalAccessException {
+ throwFinalFieldIllegalAccessException("float", Float.toString(f));
+ }
+
+ protected void throwFinalFieldIllegalAccessException(double f) throws IllegalAccessException {
+ throwFinalFieldIllegalAccessException("double", Double.toString(f));
+ }
+
+ protected IllegalArgumentException newGetBooleanIllegalArgumentException() {
+ return newGetIllegalArgumentException("boolean");
+ }
+
+ protected IllegalArgumentException newGetByteIllegalArgumentException() {
+ return newGetIllegalArgumentException("byte");
+ }
+
+ protected IllegalArgumentException newGetCharIllegalArgumentException() {
+ return newGetIllegalArgumentException("char");
+ }
+
+ protected IllegalArgumentException newGetShortIllegalArgumentException() {
+ return newGetIllegalArgumentException("short");
+ }
+
+ protected IllegalArgumentException newGetIntIllegalArgumentException() {
+ return newGetIllegalArgumentException("int");
+ }
+
+ protected IllegalArgumentException newGetLongIllegalArgumentException() {
+ return newGetIllegalArgumentException("long");
+ }
+
+ protected IllegalArgumentException newGetFloatIllegalArgumentException() {
+ return newGetIllegalArgumentException("float");
+ }
+
+ protected IllegalArgumentException newGetDoubleIllegalArgumentException() {
+ return newGetIllegalArgumentException("double");
+ }
+
+ protected String getSetMessage(String attemptedType, String attemptedValue) {
+ String err = "Can not set";
+ if (Modifier.isStatic(field.getModifiers()))
+ err += " static";
+ if (isFinal)
+ err += " final";
+ err += " " + field.getType().getName() + " field " + getQualifiedFieldName() + " to ";
+ if (attemptedValue.length() > 0) {
+ err += "(" + attemptedType + ")" + attemptedValue;
+ } else {
+ if (attemptedType.length() > 0)
+ err += attemptedType;
+ else
+ err += "null value";
+ }
+ return err;
+ }
+
+ protected void throwSetIllegalArgumentException(String attemptedType,
+ String attemptedValue) {
+ throw new IllegalArgumentException(getSetMessage(attemptedType,attemptedValue));
+ }
+
+ protected void throwSetIllegalArgumentException(Object o) {
+ throwSetIllegalArgumentException(o != null ? o.getClass().getName() : "", "");
+ }
+
+ protected void throwSetIllegalArgumentException(boolean b) {
+ throwSetIllegalArgumentException("boolean", Boolean.toString(b));
+ }
+
+ protected void throwSetIllegalArgumentException(byte b) {
+ throwSetIllegalArgumentException("byte", Byte.toString(b));
+ }
+
+ protected void throwSetIllegalArgumentException(char c) {
+ throwSetIllegalArgumentException("char", Character.toString(c));
+ }
+
+ protected void throwSetIllegalArgumentException(short s) {
+ throwSetIllegalArgumentException("short", Short.toString(s));
+ }
+
+ protected void throwSetIllegalArgumentException(int i) {
+ throwSetIllegalArgumentException("int", Integer.toString(i));
+ }
+
+ protected void throwSetIllegalArgumentException(long l) {
+ throwSetIllegalArgumentException("long", Long.toString(l));
+ }
+
+ protected void throwSetIllegalArgumentException(float f) {
+ throwSetIllegalArgumentException("float", Float.toString(f));
+ }
+
+ protected void throwSetIllegalArgumentException(double d) {
+ throwSetIllegalArgumentException("double", Double.toString(d));
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/UnsafeFloatFieldAccessorImpl.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,160 @@
+/*
+ * Copyright (c) 2001, 2005, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+import java.lang.reflect.Field;
+
+class UnsafeFloatFieldAccessorImpl extends UnsafeFieldAccessorImpl {
+ UnsafeFloatFieldAccessorImpl(Field field) {
+ super(field);
+ }
+
+ public Object get(Object obj) throws IllegalArgumentException {
+ return Float.valueOf(getFloat(obj));
+ }
+
+ public boolean getBoolean(Object obj) throws IllegalArgumentException {
+ throw newGetBooleanIllegalArgumentException();
+ }
+
+ public byte getByte(Object obj) throws IllegalArgumentException {
+ throw newGetByteIllegalArgumentException();
+ }
+
+ public char getChar(Object obj) throws IllegalArgumentException {
+ throw newGetCharIllegalArgumentException();
+ }
+
+ public short getShort(Object obj) throws IllegalArgumentException {
+ throw newGetShortIllegalArgumentException();
+ }
+
+ public int getInt(Object obj) throws IllegalArgumentException {
+ throw newGetIntIllegalArgumentException();
+ }
+
+ public long getLong(Object obj) throws IllegalArgumentException {
+ throw newGetLongIllegalArgumentException();
+ }
+
+ public float getFloat(Object obj) throws IllegalArgumentException {
+ ensureObj(obj);
+ return unsafe.getFloat(obj, fieldOffset);
+ }
+
+ public double getDouble(Object obj) throws IllegalArgumentException {
+ return getFloat(obj);
+ }
+
+ public void set(Object obj, Object value)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ ensureObj(obj);
+ if (isFinal) {
+ throwFinalFieldIllegalAccessException(value);
+ }
+ if (value == null) {
+ throwSetIllegalArgumentException(value);
+ }
+ if (value instanceof Byte) {
+ unsafe.putFloat(obj, fieldOffset, ((Byte) value).byteValue());
+ return;
+ }
+ if (value instanceof Short) {
+ unsafe.putFloat(obj, fieldOffset, ((Short) value).shortValue());
+ return;
+ }
+ if (value instanceof Character) {
+ unsafe.putFloat(obj, fieldOffset, ((Character) value).charValue());
+ return;
+ }
+ if (value instanceof Integer) {
+ unsafe.putFloat(obj, fieldOffset, ((Integer) value).intValue());
+ return;
+ }
+ if (value instanceof Long) {
+ unsafe.putFloat(obj, fieldOffset, ((Long) value).longValue());
+ return;
+ }
+ if (value instanceof Float) {
+ unsafe.putFloat(obj, fieldOffset, ((Float) value).floatValue());
+ return;
+ }
+ throwSetIllegalArgumentException(value);
+ }
+
+ public void setBoolean(Object obj, boolean z)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(z);
+ }
+
+ public void setByte(Object obj, byte b)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setFloat(obj, b);
+ }
+
+ public void setChar(Object obj, char c)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setFloat(obj, c);
+ }
+
+ public void setShort(Object obj, short s)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setFloat(obj, s);
+ }
+
+ public void setInt(Object obj, int i)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setFloat(obj, i);
+ }
+
+ public void setLong(Object obj, long l)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setFloat(obj, l);
+ }
+
+ public void setFloat(Object obj, float f)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ ensureObj(obj);
+ if (isFinal) {
+ throwFinalFieldIllegalAccessException(f);
+ }
+ unsafe.putFloat(obj, fieldOffset, f);
+ }
+
+ public void setDouble(Object obj, double d)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(d);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/UnsafeIntegerFieldAccessorImpl.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,152 @@
+/*
+ * Copyright (c) 2001, 2005, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+import java.lang.reflect.Field;
+
+class UnsafeIntegerFieldAccessorImpl extends UnsafeFieldAccessorImpl {
+ UnsafeIntegerFieldAccessorImpl(Field field) {
+ super(field);
+ }
+
+ public Object get(Object obj) throws IllegalArgumentException {
+ return Integer.valueOf(getInt(obj));
+ }
+
+ public boolean getBoolean(Object obj) throws IllegalArgumentException {
+ throw newGetBooleanIllegalArgumentException();
+ }
+
+ public byte getByte(Object obj) throws IllegalArgumentException {
+ throw newGetByteIllegalArgumentException();
+ }
+
+ public char getChar(Object obj) throws IllegalArgumentException {
+ throw newGetCharIllegalArgumentException();
+ }
+
+ public short getShort(Object obj) throws IllegalArgumentException {
+ throw newGetShortIllegalArgumentException();
+ }
+
+ public int getInt(Object obj) throws IllegalArgumentException {
+ ensureObj(obj);
+ return unsafe.getInt(obj, fieldOffset);
+ }
+
+ public long getLong(Object obj) throws IllegalArgumentException {
+ return getInt(obj);
+ }
+
+ public float getFloat(Object obj) throws IllegalArgumentException {
+ return getInt(obj);
+ }
+
+ public double getDouble(Object obj) throws IllegalArgumentException {
+ return getInt(obj);
+ }
+
+ public void set(Object obj, Object value)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ ensureObj(obj);
+ if (isFinal) {
+ throwFinalFieldIllegalAccessException(value);
+ }
+ if (value == null) {
+ throwSetIllegalArgumentException(value);
+ }
+ if (value instanceof Byte) {
+ unsafe.putInt(obj, fieldOffset, ((Byte) value).byteValue());
+ return;
+ }
+ if (value instanceof Short) {
+ unsafe.putInt(obj, fieldOffset, ((Short) value).shortValue());
+ return;
+ }
+ if (value instanceof Character) {
+ unsafe.putInt(obj, fieldOffset, ((Character) value).charValue());
+ return;
+ }
+ if (value instanceof Integer) {
+ unsafe.putInt(obj, fieldOffset, ((Integer) value).intValue());
+ return;
+ }
+ throwSetIllegalArgumentException(value);
+ }
+
+ public void setBoolean(Object obj, boolean z)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(z);
+ }
+
+ public void setByte(Object obj, byte b)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setInt(obj, b);
+ }
+
+ public void setChar(Object obj, char c)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setInt(obj, c);
+ }
+
+ public void setShort(Object obj, short s)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setInt(obj, s);
+ }
+
+ public void setInt(Object obj, int i)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ ensureObj(obj);
+ if (isFinal) {
+ throwFinalFieldIllegalAccessException(i);
+ }
+ unsafe.putInt(obj, fieldOffset, i);
+ }
+
+ public void setLong(Object obj, long l)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(l);
+ }
+
+ public void setFloat(Object obj, float f)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(f);
+ }
+
+ public void setDouble(Object obj, double d)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(d);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/UnsafeLongFieldAccessorImpl.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,156 @@
+/*
+ * Copyright (c) 2001, 2005, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+import java.lang.reflect.Field;
+
+class UnsafeLongFieldAccessorImpl extends UnsafeFieldAccessorImpl {
+ UnsafeLongFieldAccessorImpl(Field field) {
+ super(field);
+ }
+
+ public Object get(Object obj) throws IllegalArgumentException {
+ return Long.valueOf(getLong(obj));
+ }
+
+ public boolean getBoolean(Object obj) throws IllegalArgumentException {
+ throw newGetBooleanIllegalArgumentException();
+ }
+
+ public byte getByte(Object obj) throws IllegalArgumentException {
+ throw newGetByteIllegalArgumentException();
+ }
+
+ public char getChar(Object obj) throws IllegalArgumentException {
+ throw newGetCharIllegalArgumentException();
+ }
+
+ public short getShort(Object obj) throws IllegalArgumentException {
+ throw newGetShortIllegalArgumentException();
+ }
+
+ public int getInt(Object obj) throws IllegalArgumentException {
+ throw newGetIntIllegalArgumentException();
+ }
+
+ public long getLong(Object obj) throws IllegalArgumentException {
+ ensureObj(obj);
+ return unsafe.getLong(obj, fieldOffset);
+ }
+
+ public float getFloat(Object obj) throws IllegalArgumentException {
+ return getLong(obj);
+ }
+
+ public double getDouble(Object obj) throws IllegalArgumentException {
+ return getLong(obj);
+ }
+
+ public void set(Object obj, Object value)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ ensureObj(obj);
+ if (isFinal) {
+ throwFinalFieldIllegalAccessException(value);
+ }
+ if (value == null) {
+ throwSetIllegalArgumentException(value);
+ }
+ if (value instanceof Byte) {
+ unsafe.putLong(obj, fieldOffset, ((Byte) value).byteValue());
+ return;
+ }
+ if (value instanceof Short) {
+ unsafe.putLong(obj, fieldOffset, ((Short) value).shortValue());
+ return;
+ }
+ if (value instanceof Character) {
+ unsafe.putLong(obj, fieldOffset, ((Character) value).charValue());
+ return;
+ }
+ if (value instanceof Integer) {
+ unsafe.putLong(obj, fieldOffset, ((Integer) value).intValue());
+ return;
+ }
+ if (value instanceof Long) {
+ unsafe.putLong(obj, fieldOffset, ((Long) value).longValue());
+ return;
+ }
+ throwSetIllegalArgumentException(value);
+ }
+
+ public void setBoolean(Object obj, boolean z)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(z);
+ }
+
+ public void setByte(Object obj, byte b)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setLong(obj, b);
+ }
+
+ public void setChar(Object obj, char c)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setLong(obj, c);
+ }
+
+ public void setShort(Object obj, short s)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setLong(obj, s);
+ }
+
+ public void setInt(Object obj, int i)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setLong(obj, i);
+ }
+
+ public void setLong(Object obj, long l)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ ensureObj(obj);
+ if (isFinal) {
+ throwFinalFieldIllegalAccessException(l);
+ }
+ unsafe.putLong(obj, fieldOffset, l);
+ }
+
+ public void setFloat(Object obj, float f)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(f);
+ }
+
+ public void setDouble(Object obj, double d)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(d);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/UnsafeObjectFieldAccessorImpl.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,134 @@
+/*
+ * Copyright (c) 2001, 2005, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+import java.lang.reflect.Field;
+
+class UnsafeObjectFieldAccessorImpl extends UnsafeFieldAccessorImpl {
+ UnsafeObjectFieldAccessorImpl(Field field) {
+ super(field);
+ }
+
+ public Object get(Object obj) throws IllegalArgumentException {
+ ensureObj(obj);
+ return unsafe.getObject(obj, fieldOffset);
+ }
+
+ public boolean getBoolean(Object obj) throws IllegalArgumentException {
+ throw newGetBooleanIllegalArgumentException();
+ }
+
+ public byte getByte(Object obj) throws IllegalArgumentException {
+ throw newGetByteIllegalArgumentException();
+ }
+
+ public char getChar(Object obj) throws IllegalArgumentException {
+ throw newGetCharIllegalArgumentException();
+ }
+
+ public short getShort(Object obj) throws IllegalArgumentException {
+ throw newGetShortIllegalArgumentException();
+ }
+
+ public int getInt(Object obj) throws IllegalArgumentException {
+ throw newGetIntIllegalArgumentException();
+ }
+
+ public long getLong(Object obj) throws IllegalArgumentException {
+ throw newGetLongIllegalArgumentException();
+ }
+
+ public float getFloat(Object obj) throws IllegalArgumentException {
+ throw newGetFloatIllegalArgumentException();
+ }
+
+ public double getDouble(Object obj) throws IllegalArgumentException {
+ throw newGetDoubleIllegalArgumentException();
+ }
+
+ public void set(Object obj, Object value)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ ensureObj(obj);
+ if (isFinal) {
+ throwFinalFieldIllegalAccessException(value);
+ }
+ if (value != null) {
+ if (!field.getType().isAssignableFrom(value.getClass())) {
+ throwSetIllegalArgumentException(value);
+ }
+ }
+ unsafe.putObject(obj, fieldOffset, value);
+ }
+
+ public void setBoolean(Object obj, boolean z)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(z);
+ }
+
+ public void setByte(Object obj, byte b)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(b);
+ }
+
+ public void setChar(Object obj, char c)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(c);
+ }
+
+ public void setShort(Object obj, short s)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(s);
+ }
+
+ public void setInt(Object obj, int i)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(i);
+ }
+
+ public void setLong(Object obj, long l)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(l);
+ }
+
+ public void setFloat(Object obj, float f)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(f);
+ }
+
+ public void setDouble(Object obj, double d)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(d);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/UnsafeQualifiedBooleanFieldAccessorImpl.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,142 @@
+/*
+ * Copyright (c) 2004, 2005, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+import java.lang.reflect.Field;
+
+class UnsafeQualifiedBooleanFieldAccessorImpl
+ extends UnsafeQualifiedFieldAccessorImpl
+{
+ UnsafeQualifiedBooleanFieldAccessorImpl(Field field, boolean isReadOnly) {
+ super(field, isReadOnly);
+ }
+
+ public Object get(Object obj) throws IllegalArgumentException {
+ return Boolean.valueOf(getBoolean(obj));
+ }
+
+ public boolean getBoolean(Object obj) throws IllegalArgumentException {
+ ensureObj(obj);
+ return unsafe.getBooleanVolatile(obj, fieldOffset);
+ }
+
+ public byte getByte(Object obj) throws IllegalArgumentException {
+ throw newGetByteIllegalArgumentException();
+ }
+
+ public char getChar(Object obj) throws IllegalArgumentException {
+ throw newGetCharIllegalArgumentException();
+ }
+
+ public short getShort(Object obj) throws IllegalArgumentException {
+ throw newGetShortIllegalArgumentException();
+ }
+
+ public int getInt(Object obj) throws IllegalArgumentException {
+ throw newGetIntIllegalArgumentException();
+ }
+
+ public long getLong(Object obj) throws IllegalArgumentException {
+ throw newGetLongIllegalArgumentException();
+ }
+
+ public float getFloat(Object obj) throws IllegalArgumentException {
+ throw newGetFloatIllegalArgumentException();
+ }
+
+ public double getDouble(Object obj) throws IllegalArgumentException {
+ throw newGetDoubleIllegalArgumentException();
+ }
+
+ public void set(Object obj, Object value)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ ensureObj(obj);
+ if (isReadOnly) {
+ throwFinalFieldIllegalAccessException(value);
+ }
+ if (value == null) {
+ throwSetIllegalArgumentException(value);
+ }
+ if (value instanceof Boolean) {
+ unsafe.putBooleanVolatile(obj, fieldOffset, ((Boolean) value).booleanValue());
+ return;
+ }
+ throwSetIllegalArgumentException(value);
+ }
+
+ public void setBoolean(Object obj, boolean z)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ ensureObj(obj);
+ if (isReadOnly) {
+ throwFinalFieldIllegalAccessException(z);
+ }
+ unsafe.putBooleanVolatile(obj, fieldOffset, z);
+ }
+
+ public void setByte(Object obj, byte b)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(b);
+ }
+
+ public void setChar(Object obj, char c)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(c);
+ }
+
+ public void setShort(Object obj, short s)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(s);
+ }
+
+ public void setInt(Object obj, int i)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(i);
+ }
+
+ public void setLong(Object obj, long l)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(l);
+ }
+
+ public void setFloat(Object obj, float f)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(f);
+ }
+
+ public void setDouble(Object obj, double d)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(d);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/UnsafeQualifiedByteFieldAccessorImpl.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,142 @@
+/*
+ * Copyright (c) 2004, 2005, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+import java.lang.reflect.Field;
+
+class UnsafeQualifiedByteFieldAccessorImpl
+ extends UnsafeQualifiedFieldAccessorImpl
+{
+ UnsafeQualifiedByteFieldAccessorImpl(Field field, boolean isReadOnly) {
+ super(field, isReadOnly);
+ }
+
+ public Object get(Object obj) throws IllegalArgumentException {
+ return Byte.valueOf(getByte(obj));
+ }
+
+ public boolean getBoolean(Object obj) throws IllegalArgumentException {
+ throw newGetBooleanIllegalArgumentException();
+ }
+
+ public byte getByte(Object obj) throws IllegalArgumentException {
+ ensureObj(obj);
+ return unsafe.getByteVolatile(obj, fieldOffset);
+ }
+
+ public char getChar(Object obj) throws IllegalArgumentException {
+ throw newGetCharIllegalArgumentException();
+ }
+
+ public short getShort(Object obj) throws IllegalArgumentException {
+ return getByte(obj);
+ }
+
+ public int getInt(Object obj) throws IllegalArgumentException {
+ return getByte(obj);
+ }
+
+ public long getLong(Object obj) throws IllegalArgumentException {
+ return getByte(obj);
+ }
+
+ public float getFloat(Object obj) throws IllegalArgumentException {
+ return getByte(obj);
+ }
+
+ public double getDouble(Object obj) throws IllegalArgumentException {
+ return getByte(obj);
+ }
+
+ public void set(Object obj, Object value)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ ensureObj(obj);
+ if (isReadOnly) {
+ throwFinalFieldIllegalAccessException(value);
+ }
+ if (value == null) {
+ throwSetIllegalArgumentException(value);
+ }
+ if (value instanceof Byte) {
+ unsafe.putByteVolatile(obj, fieldOffset, ((Byte) value).byteValue());
+ return;
+ }
+ throwSetIllegalArgumentException(value);
+ }
+
+ public void setBoolean(Object obj, boolean z)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(z);
+ }
+
+ public void setByte(Object obj, byte b)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ ensureObj(obj);
+ if (isReadOnly) {
+ throwFinalFieldIllegalAccessException(b);
+ }
+ unsafe.putByteVolatile(obj, fieldOffset, b);
+ }
+
+ public void setChar(Object obj, char c)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(c);
+ }
+
+ public void setShort(Object obj, short s)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(s);
+ }
+
+ public void setInt(Object obj, int i)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(i);
+ }
+
+ public void setLong(Object obj, long l)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(l);
+ }
+
+ public void setFloat(Object obj, float f)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(f);
+ }
+
+ public void setDouble(Object obj, double d)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(d);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/UnsafeQualifiedCharacterFieldAccessorImpl.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,142 @@
+/*
+ * Copyright (c) 2004, 2005, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+import java.lang.reflect.Field;
+
+class UnsafeQualifiedCharacterFieldAccessorImpl
+ extends UnsafeQualifiedFieldAccessorImpl
+{
+ UnsafeQualifiedCharacterFieldAccessorImpl(Field field, boolean isReadOnly) {
+ super(field, isReadOnly);
+ }
+
+ public Object get(Object obj) throws IllegalArgumentException {
+ return Character.valueOf(getChar(obj));
+ }
+
+ public boolean getBoolean(Object obj) throws IllegalArgumentException {
+ throw newGetBooleanIllegalArgumentException();
+ }
+
+ public byte getByte(Object obj) throws IllegalArgumentException {
+ throw newGetByteIllegalArgumentException();
+ }
+
+ public char getChar(Object obj) throws IllegalArgumentException {
+ ensureObj(obj);
+ return unsafe.getCharVolatile(obj, fieldOffset);
+ }
+
+ public short getShort(Object obj) throws IllegalArgumentException {
+ throw newGetShortIllegalArgumentException();
+ }
+
+ public int getInt(Object obj) throws IllegalArgumentException {
+ return getChar(obj);
+ }
+
+ public long getLong(Object obj) throws IllegalArgumentException {
+ return getChar(obj);
+ }
+
+ public float getFloat(Object obj) throws IllegalArgumentException {
+ return getChar(obj);
+ }
+
+ public double getDouble(Object obj) throws IllegalArgumentException {
+ return getChar(obj);
+ }
+
+ public void set(Object obj, Object value)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ ensureObj(obj);
+ if (isReadOnly) {
+ throwFinalFieldIllegalAccessException(value);
+ }
+ if (value == null) {
+ throwSetIllegalArgumentException(value);
+ }
+ if (value instanceof Character) {
+ unsafe.putCharVolatile(obj, fieldOffset, ((Character) value).charValue());
+ return;
+ }
+ throwSetIllegalArgumentException(value);
+ }
+
+ public void setBoolean(Object obj, boolean z)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(z);
+ }
+
+ public void setByte(Object obj, byte b)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(b);
+ }
+
+ public void setChar(Object obj, char c)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ ensureObj(obj);
+ if (isReadOnly) {
+ throwFinalFieldIllegalAccessException(c);
+ }
+ unsafe.putCharVolatile(obj, fieldOffset, c);
+ }
+
+ public void setShort(Object obj, short s)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(s);
+ }
+
+ public void setInt(Object obj, int i)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(i);
+ }
+
+ public void setLong(Object obj, long l)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(l);
+ }
+
+ public void setFloat(Object obj, float f)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(f);
+ }
+
+ public void setDouble(Object obj, double d)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(d);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/UnsafeQualifiedDoubleFieldAccessorImpl.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,166 @@
+/*
+ * Copyright (c) 2004, 2005, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+import java.lang.reflect.Field;
+
+class UnsafeQualifiedDoubleFieldAccessorImpl
+ extends UnsafeQualifiedFieldAccessorImpl
+{
+ UnsafeQualifiedDoubleFieldAccessorImpl(Field field, boolean isReadOnly) {
+ super(field, isReadOnly);
+ }
+
+ public Object get(Object obj) throws IllegalArgumentException {
+ return Double.valueOf(getDouble(obj));
+ }
+
+ public boolean getBoolean(Object obj) throws IllegalArgumentException {
+ throw newGetBooleanIllegalArgumentException();
+ }
+
+ public byte getByte(Object obj) throws IllegalArgumentException {
+ throw newGetByteIllegalArgumentException();
+ }
+
+ public char getChar(Object obj) throws IllegalArgumentException {
+ throw newGetCharIllegalArgumentException();
+ }
+
+ public short getShort(Object obj) throws IllegalArgumentException {
+ throw newGetShortIllegalArgumentException();
+ }
+
+ public int getInt(Object obj) throws IllegalArgumentException {
+ throw newGetIntIllegalArgumentException();
+ }
+
+ public long getLong(Object obj) throws IllegalArgumentException {
+ throw newGetLongIllegalArgumentException();
+ }
+
+ public float getFloat(Object obj) throws IllegalArgumentException {
+ throw newGetFloatIllegalArgumentException();
+ }
+
+ public double getDouble(Object obj) throws IllegalArgumentException {
+ ensureObj(obj);
+ return unsafe.getDoubleVolatile(obj, fieldOffset);
+ }
+
+ public void set(Object obj, Object value)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ ensureObj(obj);
+ if (isReadOnly) {
+ throwFinalFieldIllegalAccessException(value);
+ }
+ if (value == null) {
+ throwSetIllegalArgumentException(value);
+ }
+ if (value instanceof Byte) {
+ unsafe.putDoubleVolatile(obj, fieldOffset, ((Byte) value).byteValue());
+ return;
+ }
+ if (value instanceof Short) {
+ unsafe.putDoubleVolatile(obj, fieldOffset, ((Short) value).shortValue());
+ return;
+ }
+ if (value instanceof Character) {
+ unsafe.putDoubleVolatile(obj, fieldOffset, ((Character) value).charValue());
+ return;
+ }
+ if (value instanceof Integer) {
+ unsafe.putDoubleVolatile(obj, fieldOffset, ((Integer) value).intValue());
+ return;
+ }
+ if (value instanceof Long) {
+ unsafe.putDoubleVolatile(obj, fieldOffset, ((Long) value).longValue());
+ return;
+ }
+ if (value instanceof Float) {
+ unsafe.putDoubleVolatile(obj, fieldOffset, ((Float) value).floatValue());
+ return;
+ }
+ if (value instanceof Double) {
+ unsafe.putDoubleVolatile(obj, fieldOffset, ((Double) value).doubleValue());
+ return;
+ }
+ throwSetIllegalArgumentException(value);
+ }
+
+ public void setBoolean(Object obj, boolean z)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(z);
+ }
+
+ public void setByte(Object obj, byte b)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setDouble(obj, b);
+ }
+
+ public void setChar(Object obj, char c)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setDouble(obj, c);
+ }
+
+ public void setShort(Object obj, short s)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setDouble(obj, s);
+ }
+
+ public void setInt(Object obj, int i)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setDouble(obj, i);
+ }
+
+ public void setLong(Object obj, long l)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setDouble(obj, l);
+ }
+
+ public void setFloat(Object obj, float f)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setDouble(obj, f);
+ }
+
+ public void setDouble(Object obj, double d)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ ensureObj(obj);
+ if (isReadOnly) {
+ throwFinalFieldIllegalAccessException(d);
+ }
+ unsafe.putDoubleVolatile(obj, fieldOffset, d);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/UnsafeQualifiedFieldAccessorImpl.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2004, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+import jdk.internal.misc.Unsafe;
+
+/**
+ * Base class for jdk.internal.misc.Unsafe-based FieldAccessors for fields with
+ * final or volatile qualifiers. These differ from unqualified
+ * versions in that (1) they check for read-only status (2) they use
+ * the volatile forms of Unsafe get/put methods. (When accessed via
+ * reflection, finals act as slightly "lighter" forms of volatiles. So
+ * the volatile forms are heavier than necessary in terms of
+ * underlying reordering rules and memory barriers, but preserve
+ * correctness.)
+ */
+
+abstract class UnsafeQualifiedFieldAccessorImpl
+ extends UnsafeFieldAccessorImpl
+{
+ protected final boolean isReadOnly;
+
+ UnsafeQualifiedFieldAccessorImpl(Field field, boolean isReadOnly) {
+ super(field);
+ this.isReadOnly = isReadOnly;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/UnsafeQualifiedFloatFieldAccessorImpl.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,162 @@
+/*
+ * Copyright (c) 2004, 2005, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+import java.lang.reflect.Field;
+
+class UnsafeQualifiedFloatFieldAccessorImpl
+ extends UnsafeQualifiedFieldAccessorImpl
+{
+ UnsafeQualifiedFloatFieldAccessorImpl(Field field, boolean isReadOnly) {
+ super(field, isReadOnly);
+ }
+
+ public Object get(Object obj) throws IllegalArgumentException {
+ return Float.valueOf(getFloat(obj));
+ }
+
+ public boolean getBoolean(Object obj) throws IllegalArgumentException {
+ throw newGetBooleanIllegalArgumentException();
+ }
+
+ public byte getByte(Object obj) throws IllegalArgumentException {
+ throw newGetByteIllegalArgumentException();
+ }
+
+ public char getChar(Object obj) throws IllegalArgumentException {
+ throw newGetCharIllegalArgumentException();
+ }
+
+ public short getShort(Object obj) throws IllegalArgumentException {
+ throw newGetShortIllegalArgumentException();
+ }
+
+ public int getInt(Object obj) throws IllegalArgumentException {
+ throw newGetIntIllegalArgumentException();
+ }
+
+ public long getLong(Object obj) throws IllegalArgumentException {
+ throw newGetLongIllegalArgumentException();
+ }
+
+ public float getFloat(Object obj) throws IllegalArgumentException {
+ ensureObj(obj);
+ return unsafe.getFloatVolatile(obj, fieldOffset);
+ }
+
+ public double getDouble(Object obj) throws IllegalArgumentException {
+ return getFloat(obj);
+ }
+
+ public void set(Object obj, Object value)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ ensureObj(obj);
+ if (isReadOnly) {
+ throwFinalFieldIllegalAccessException(value);
+ }
+ if (value == null) {
+ throwSetIllegalArgumentException(value);
+ }
+ if (value instanceof Byte) {
+ unsafe.putFloatVolatile(obj, fieldOffset, ((Byte) value).byteValue());
+ return;
+ }
+ if (value instanceof Short) {
+ unsafe.putFloatVolatile(obj, fieldOffset, ((Short) value).shortValue());
+ return;
+ }
+ if (value instanceof Character) {
+ unsafe.putFloatVolatile(obj, fieldOffset, ((Character) value).charValue());
+ return;
+ }
+ if (value instanceof Integer) {
+ unsafe.putFloatVolatile(obj, fieldOffset, ((Integer) value).intValue());
+ return;
+ }
+ if (value instanceof Long) {
+ unsafe.putFloatVolatile(obj, fieldOffset, ((Long) value).longValue());
+ return;
+ }
+ if (value instanceof Float) {
+ unsafe.putFloatVolatile(obj, fieldOffset, ((Float) value).floatValue());
+ return;
+ }
+ throwSetIllegalArgumentException(value);
+ }
+
+ public void setBoolean(Object obj, boolean z)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(z);
+ }
+
+ public void setByte(Object obj, byte b)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setFloat(obj, b);
+ }
+
+ public void setChar(Object obj, char c)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setFloat(obj, c);
+ }
+
+ public void setShort(Object obj, short s)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setFloat(obj, s);
+ }
+
+ public void setInt(Object obj, int i)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setFloat(obj, i);
+ }
+
+ public void setLong(Object obj, long l)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setFloat(obj, l);
+ }
+
+ public void setFloat(Object obj, float f)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ ensureObj(obj);
+ if (isReadOnly) {
+ throwFinalFieldIllegalAccessException(f);
+ }
+ unsafe.putFloatVolatile(obj, fieldOffset, f);
+ }
+
+ public void setDouble(Object obj, double d)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(d);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/UnsafeQualifiedIntegerFieldAccessorImpl.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,154 @@
+/*
+ * Copyright (c) 2004, 2005, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+import java.lang.reflect.Field;
+
+class UnsafeQualifiedIntegerFieldAccessorImpl
+ extends UnsafeQualifiedFieldAccessorImpl
+{
+ UnsafeQualifiedIntegerFieldAccessorImpl(Field field, boolean isReadOnly) {
+ super(field, isReadOnly);
+ }
+
+ public Object get(Object obj) throws IllegalArgumentException {
+ return Integer.valueOf(getInt(obj));
+ }
+
+ public boolean getBoolean(Object obj) throws IllegalArgumentException {
+ throw newGetBooleanIllegalArgumentException();
+ }
+
+ public byte getByte(Object obj) throws IllegalArgumentException {
+ throw newGetByteIllegalArgumentException();
+ }
+
+ public char getChar(Object obj) throws IllegalArgumentException {
+ throw newGetCharIllegalArgumentException();
+ }
+
+ public short getShort(Object obj) throws IllegalArgumentException {
+ throw newGetShortIllegalArgumentException();
+ }
+
+ public int getInt(Object obj) throws IllegalArgumentException {
+ ensureObj(obj);
+ return unsafe.getIntVolatile(obj, fieldOffset);
+ }
+
+ public long getLong(Object obj) throws IllegalArgumentException {
+ return getInt(obj);
+ }
+
+ public float getFloat(Object obj) throws IllegalArgumentException {
+ return getInt(obj);
+ }
+
+ public double getDouble(Object obj) throws IllegalArgumentException {
+ return getInt(obj);
+ }
+
+ public void set(Object obj, Object value)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ ensureObj(obj);
+ if (isReadOnly) {
+ throwFinalFieldIllegalAccessException(value);
+ }
+ if (value == null) {
+ throwSetIllegalArgumentException(value);
+ }
+ if (value instanceof Byte) {
+ unsafe.putIntVolatile(obj, fieldOffset, ((Byte) value).byteValue());
+ return;
+ }
+ if (value instanceof Short) {
+ unsafe.putIntVolatile(obj, fieldOffset, ((Short) value).shortValue());
+ return;
+ }
+ if (value instanceof Character) {
+ unsafe.putIntVolatile(obj, fieldOffset, ((Character) value).charValue());
+ return;
+ }
+ if (value instanceof Integer) {
+ unsafe.putIntVolatile(obj, fieldOffset, ((Integer) value).intValue());
+ return;
+ }
+ throwSetIllegalArgumentException(value);
+ }
+
+ public void setBoolean(Object obj, boolean z)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(z);
+ }
+
+ public void setByte(Object obj, byte b)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setInt(obj, b);
+ }
+
+ public void setChar(Object obj, char c)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setInt(obj, c);
+ }
+
+ public void setShort(Object obj, short s)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setInt(obj, s);
+ }
+
+ public void setInt(Object obj, int i)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ ensureObj(obj);
+ if (isReadOnly) {
+ throwFinalFieldIllegalAccessException(i);
+ }
+ unsafe.putIntVolatile(obj, fieldOffset, i);
+ }
+
+ public void setLong(Object obj, long l)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(l);
+ }
+
+ public void setFloat(Object obj, float f)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(f);
+ }
+
+ public void setDouble(Object obj, double d)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(d);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/UnsafeQualifiedLongFieldAccessorImpl.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,158 @@
+/*
+ * Copyright (c) 2004, 2005, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+import java.lang.reflect.Field;
+
+class UnsafeQualifiedLongFieldAccessorImpl
+ extends UnsafeQualifiedFieldAccessorImpl
+{
+ UnsafeQualifiedLongFieldAccessorImpl(Field field, boolean isReadOnly) {
+ super(field, isReadOnly);
+ }
+
+ public Object get(Object obj) throws IllegalArgumentException {
+ return Long.valueOf(getLong(obj));
+ }
+
+ public boolean getBoolean(Object obj) throws IllegalArgumentException {
+ throw newGetBooleanIllegalArgumentException();
+ }
+
+ public byte getByte(Object obj) throws IllegalArgumentException {
+ throw newGetByteIllegalArgumentException();
+ }
+
+ public char getChar(Object obj) throws IllegalArgumentException {
+ throw newGetCharIllegalArgumentException();
+ }
+
+ public short getShort(Object obj) throws IllegalArgumentException {
+ throw newGetShortIllegalArgumentException();
+ }
+
+ public int getInt(Object obj) throws IllegalArgumentException {
+ throw newGetIntIllegalArgumentException();
+ }
+
+ public long getLong(Object obj) throws IllegalArgumentException {
+ ensureObj(obj);
+ return unsafe.getLongVolatile(obj, fieldOffset);
+ }
+
+ public float getFloat(Object obj) throws IllegalArgumentException {
+ return getLong(obj);
+ }
+
+ public double getDouble(Object obj) throws IllegalArgumentException {
+ return getLong(obj);
+ }
+
+ public void set(Object obj, Object value)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ ensureObj(obj);
+ if (isReadOnly) {
+ throwFinalFieldIllegalAccessException(value);
+ }
+ if (value == null) {
+ throwSetIllegalArgumentException(value);
+ }
+ if (value instanceof Byte) {
+ unsafe.putLongVolatile(obj, fieldOffset, ((Byte) value).byteValue());
+ return;
+ }
+ if (value instanceof Short) {
+ unsafe.putLongVolatile(obj, fieldOffset, ((Short) value).shortValue());
+ return;
+ }
+ if (value instanceof Character) {
+ unsafe.putLongVolatile(obj, fieldOffset, ((Character) value).charValue());
+ return;
+ }
+ if (value instanceof Integer) {
+ unsafe.putLongVolatile(obj, fieldOffset, ((Integer) value).intValue());
+ return;
+ }
+ if (value instanceof Long) {
+ unsafe.putLongVolatile(obj, fieldOffset, ((Long) value).longValue());
+ return;
+ }
+ throwSetIllegalArgumentException(value);
+ }
+
+ public void setBoolean(Object obj, boolean z)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(z);
+ }
+
+ public void setByte(Object obj, byte b)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setLong(obj, b);
+ }
+
+ public void setChar(Object obj, char c)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setLong(obj, c);
+ }
+
+ public void setShort(Object obj, short s)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setLong(obj, s);
+ }
+
+ public void setInt(Object obj, int i)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setLong(obj, i);
+ }
+
+ public void setLong(Object obj, long l)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ ensureObj(obj);
+ if (isReadOnly) {
+ throwFinalFieldIllegalAccessException(l);
+ }
+ unsafe.putLongVolatile(obj, fieldOffset, l);
+ }
+
+ public void setFloat(Object obj, float f)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(f);
+ }
+
+ public void setDouble(Object obj, double d)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(d);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/UnsafeQualifiedObjectFieldAccessorImpl.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 2004, 2005, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+import java.lang.reflect.Field;
+
+class UnsafeQualifiedObjectFieldAccessorImpl
+ extends UnsafeQualifiedFieldAccessorImpl
+{
+ UnsafeQualifiedObjectFieldAccessorImpl(Field field, boolean isReadOnly) {
+ super(field, isReadOnly);
+ }
+
+ public Object get(Object obj) throws IllegalArgumentException {
+ ensureObj(obj);
+ return unsafe.getObjectVolatile(obj, fieldOffset);
+ }
+
+ public boolean getBoolean(Object obj) throws IllegalArgumentException {
+ throw newGetBooleanIllegalArgumentException();
+ }
+
+ public byte getByte(Object obj) throws IllegalArgumentException {
+ throw newGetByteIllegalArgumentException();
+ }
+
+ public char getChar(Object obj) throws IllegalArgumentException {
+ throw newGetCharIllegalArgumentException();
+ }
+
+ public short getShort(Object obj) throws IllegalArgumentException {
+ throw newGetShortIllegalArgumentException();
+ }
+
+ public int getInt(Object obj) throws IllegalArgumentException {
+ throw newGetIntIllegalArgumentException();
+ }
+
+ public long getLong(Object obj) throws IllegalArgumentException {
+ throw newGetLongIllegalArgumentException();
+ }
+
+ public float getFloat(Object obj) throws IllegalArgumentException {
+ throw newGetFloatIllegalArgumentException();
+ }
+
+ public double getDouble(Object obj) throws IllegalArgumentException {
+ throw newGetDoubleIllegalArgumentException();
+ }
+
+ public void set(Object obj, Object value)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ ensureObj(obj);
+ if (isReadOnly) {
+ throwFinalFieldIllegalAccessException(value);
+ }
+ if (value != null) {
+ if (!field.getType().isAssignableFrom(value.getClass())) {
+ throwSetIllegalArgumentException(value);
+ }
+ }
+ unsafe.putObjectVolatile(obj, fieldOffset, value);
+ }
+
+ public void setBoolean(Object obj, boolean z)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(z);
+ }
+
+ public void setByte(Object obj, byte b)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(b);
+ }
+
+ public void setChar(Object obj, char c)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(c);
+ }
+
+ public void setShort(Object obj, short s)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(s);
+ }
+
+ public void setInt(Object obj, int i)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(i);
+ }
+
+ public void setLong(Object obj, long l)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(l);
+ }
+
+ public void setFloat(Object obj, float f)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(f);
+ }
+
+ public void setDouble(Object obj, double d)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(d);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/UnsafeQualifiedShortFieldAccessorImpl.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,146 @@
+/*
+ * Copyright (c) 2004, 2005, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+import java.lang.reflect.Field;
+
+class UnsafeQualifiedShortFieldAccessorImpl
+ extends UnsafeQualifiedFieldAccessorImpl
+{
+ UnsafeQualifiedShortFieldAccessorImpl(Field field, boolean isReadOnly) {
+ super(field, isReadOnly);
+ }
+
+ public Object get(Object obj) throws IllegalArgumentException {
+ return Short.valueOf(getShort(obj));
+ }
+
+ public boolean getBoolean(Object obj) throws IllegalArgumentException {
+ throw newGetBooleanIllegalArgumentException();
+ }
+
+ public byte getByte(Object obj) throws IllegalArgumentException {
+ throw newGetByteIllegalArgumentException();
+ }
+
+ public char getChar(Object obj) throws IllegalArgumentException {
+ throw newGetCharIllegalArgumentException();
+ }
+
+ public short getShort(Object obj) throws IllegalArgumentException {
+ ensureObj(obj);
+ return unsafe.getShortVolatile(obj, fieldOffset);
+ }
+
+ public int getInt(Object obj) throws IllegalArgumentException {
+ return getShort(obj);
+ }
+
+ public long getLong(Object obj) throws IllegalArgumentException {
+ return getShort(obj);
+ }
+
+ public float getFloat(Object obj) throws IllegalArgumentException {
+ return getShort(obj);
+ }
+
+ public double getDouble(Object obj) throws IllegalArgumentException {
+ return getShort(obj);
+ }
+
+ public void set(Object obj, Object value)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ ensureObj(obj);
+ if (isReadOnly) {
+ throwFinalFieldIllegalAccessException(value);
+ }
+ if (value == null) {
+ throwSetIllegalArgumentException(value);
+ }
+ if (value instanceof Byte) {
+ unsafe.putShortVolatile(obj, fieldOffset, ((Byte) value).byteValue());
+ return;
+ }
+ if (value instanceof Short) {
+ unsafe.putShortVolatile(obj, fieldOffset, ((Short) value).shortValue());
+ return;
+ }
+ throwSetIllegalArgumentException(value);
+ }
+
+ public void setBoolean(Object obj, boolean z)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(z);
+ }
+
+ public void setByte(Object obj, byte b)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setShort(obj, b);
+ }
+
+ public void setChar(Object obj, char c)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(c);
+ }
+
+ public void setShort(Object obj, short s)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ ensureObj(obj);
+ if (isReadOnly) {
+ throwFinalFieldIllegalAccessException(s);
+ }
+ unsafe.putShortVolatile(obj, fieldOffset, s);
+ }
+
+ public void setInt(Object obj, int i)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(i);
+ }
+
+ public void setLong(Object obj, long l)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(l);
+ }
+
+ public void setFloat(Object obj, float f)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(f);
+ }
+
+ public void setDouble(Object obj, double d)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(d);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/UnsafeQualifiedStaticBooleanFieldAccessorImpl.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,139 @@
+/*
+ * Copyright (c) 2004, 2005, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+import java.lang.reflect.Field;
+
+class UnsafeQualifiedStaticBooleanFieldAccessorImpl
+ extends UnsafeQualifiedStaticFieldAccessorImpl
+{
+ UnsafeQualifiedStaticBooleanFieldAccessorImpl(Field field, boolean isReadOnly) {
+ super(field, isReadOnly);
+ }
+
+ public Object get(Object obj) throws IllegalArgumentException {
+ return Boolean.valueOf(getBoolean(obj));
+ }
+
+ public boolean getBoolean(Object obj) throws IllegalArgumentException {
+ return unsafe.getBooleanVolatile(base, fieldOffset);
+ }
+
+ public byte getByte(Object obj) throws IllegalArgumentException {
+ throw newGetByteIllegalArgumentException();
+ }
+
+ public char getChar(Object obj) throws IllegalArgumentException {
+ throw newGetCharIllegalArgumentException();
+ }
+
+ public short getShort(Object obj) throws IllegalArgumentException {
+ throw newGetShortIllegalArgumentException();
+ }
+
+ public int getInt(Object obj) throws IllegalArgumentException {
+ throw newGetIntIllegalArgumentException();
+ }
+
+ public long getLong(Object obj) throws IllegalArgumentException {
+ throw newGetLongIllegalArgumentException();
+ }
+
+ public float getFloat(Object obj) throws IllegalArgumentException {
+ throw newGetFloatIllegalArgumentException();
+ }
+
+ public double getDouble(Object obj) throws IllegalArgumentException {
+ throw newGetDoubleIllegalArgumentException();
+ }
+
+ public void set(Object obj, Object value)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ if (isReadOnly) {
+ throwFinalFieldIllegalAccessException(value);
+ }
+ if (value == null) {
+ throwSetIllegalArgumentException(value);
+ }
+ if (value instanceof Boolean) {
+ unsafe.putBooleanVolatile(base, fieldOffset, ((Boolean) value).booleanValue());
+ return;
+ }
+ throwSetIllegalArgumentException(value);
+ }
+
+ public void setBoolean(Object obj, boolean z)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ if (isReadOnly) {
+ throwFinalFieldIllegalAccessException(z);
+ }
+ unsafe.putBooleanVolatile(base, fieldOffset, z);
+ }
+
+ public void setByte(Object obj, byte b)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(b);
+ }
+
+ public void setChar(Object obj, char c)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(c);
+ }
+
+ public void setShort(Object obj, short s)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(s);
+ }
+
+ public void setInt(Object obj, int i)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(i);
+ }
+
+ public void setLong(Object obj, long l)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(l);
+ }
+
+ public void setFloat(Object obj, float f)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(f);
+ }
+
+ public void setDouble(Object obj, double d)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(d);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/UnsafeQualifiedStaticByteFieldAccessorImpl.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,139 @@
+/*
+ * Copyright (c) 2004, 2005, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+import java.lang.reflect.Field;
+
+class UnsafeQualifiedStaticByteFieldAccessorImpl
+ extends UnsafeQualifiedStaticFieldAccessorImpl
+{
+ UnsafeQualifiedStaticByteFieldAccessorImpl(Field field, boolean isReadOnly) {
+ super(field, isReadOnly);
+ }
+
+ public Object get(Object obj) throws IllegalArgumentException {
+ return Byte.valueOf(getByte(obj));
+ }
+
+ public boolean getBoolean(Object obj) throws IllegalArgumentException {
+ throw newGetBooleanIllegalArgumentException();
+ }
+
+ public byte getByte(Object obj) throws IllegalArgumentException {
+ return unsafe.getByteVolatile(base, fieldOffset);
+ }
+
+ public char getChar(Object obj) throws IllegalArgumentException {
+ throw newGetCharIllegalArgumentException();
+ }
+
+ public short getShort(Object obj) throws IllegalArgumentException {
+ return getByte(obj);
+ }
+
+ public int getInt(Object obj) throws IllegalArgumentException {
+ return getByte(obj);
+ }
+
+ public long getLong(Object obj) throws IllegalArgumentException {
+ return getByte(obj);
+ }
+
+ public float getFloat(Object obj) throws IllegalArgumentException {
+ return getByte(obj);
+ }
+
+ public double getDouble(Object obj) throws IllegalArgumentException {
+ return getByte(obj);
+ }
+
+ public void set(Object obj, Object value)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ if (isReadOnly) {
+ throwFinalFieldIllegalAccessException(value);
+ }
+ if (value == null) {
+ throwSetIllegalArgumentException(value);
+ }
+ if (value instanceof Byte) {
+ unsafe.putByteVolatile(base, fieldOffset, ((Byte) value).byteValue());
+ return;
+ }
+ throwSetIllegalArgumentException(value);
+ }
+
+ public void setBoolean(Object obj, boolean z)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(z);
+ }
+
+ public void setByte(Object obj, byte b)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ if (isReadOnly) {
+ throwFinalFieldIllegalAccessException(b);
+ }
+ unsafe.putByteVolatile(base, fieldOffset, b);
+ }
+
+ public void setChar(Object obj, char c)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(c);
+ }
+
+ public void setShort(Object obj, short s)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(s);
+ }
+
+ public void setInt(Object obj, int i)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(i);
+ }
+
+ public void setLong(Object obj, long l)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(l);
+ }
+
+ public void setFloat(Object obj, float f)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(f);
+ }
+
+ public void setDouble(Object obj, double d)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(d);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/UnsafeQualifiedStaticCharacterFieldAccessorImpl.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,139 @@
+/*
+ * Copyright (c) 2004, 2005, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+import java.lang.reflect.Field;
+
+class UnsafeQualifiedStaticCharacterFieldAccessorImpl
+ extends UnsafeQualifiedStaticFieldAccessorImpl
+{
+ UnsafeQualifiedStaticCharacterFieldAccessorImpl(Field field, boolean isReadOnly) {
+ super(field, isReadOnly);
+ }
+
+ public Object get(Object obj) throws IllegalArgumentException {
+ return Character.valueOf(getChar(obj));
+ }
+
+ public boolean getBoolean(Object obj) throws IllegalArgumentException {
+ throw newGetBooleanIllegalArgumentException();
+ }
+
+ public byte getByte(Object obj) throws IllegalArgumentException {
+ throw newGetByteIllegalArgumentException();
+ }
+
+ public char getChar(Object obj) throws IllegalArgumentException {
+ return unsafe.getCharVolatile(base, fieldOffset);
+ }
+
+ public short getShort(Object obj) throws IllegalArgumentException {
+ throw newGetShortIllegalArgumentException();
+ }
+
+ public int getInt(Object obj) throws IllegalArgumentException {
+ return getChar(obj);
+ }
+
+ public long getLong(Object obj) throws IllegalArgumentException {
+ return getChar(obj);
+ }
+
+ public float getFloat(Object obj) throws IllegalArgumentException {
+ return getChar(obj);
+ }
+
+ public double getDouble(Object obj) throws IllegalArgumentException {
+ return getChar(obj);
+ }
+
+ public void set(Object obj, Object value)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ if (isReadOnly) {
+ throwFinalFieldIllegalAccessException(value);
+ }
+ if (value == null) {
+ throwSetIllegalArgumentException(value);
+ }
+ if (value instanceof Character) {
+ unsafe.putCharVolatile(base, fieldOffset, ((Character) value).charValue());
+ return;
+ }
+ throwSetIllegalArgumentException(value);
+ }
+
+ public void setBoolean(Object obj, boolean z)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(z);
+ }
+
+ public void setByte(Object obj, byte b)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(b);
+ }
+
+ public void setChar(Object obj, char c)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ if (isReadOnly) {
+ throwFinalFieldIllegalAccessException(c);
+ }
+ unsafe.putCharVolatile(base, fieldOffset, c);
+ }
+
+ public void setShort(Object obj, short s)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(s);
+ }
+
+ public void setInt(Object obj, int i)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(i);
+ }
+
+ public void setLong(Object obj, long l)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(l);
+ }
+
+ public void setFloat(Object obj, float f)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(f);
+ }
+
+ public void setDouble(Object obj, double d)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(d);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/UnsafeQualifiedStaticDoubleFieldAccessorImpl.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,163 @@
+/*
+ * Copyright (c) 2004, 2005, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+import java.lang.reflect.Field;
+
+class UnsafeQualifiedStaticDoubleFieldAccessorImpl
+ extends UnsafeQualifiedStaticFieldAccessorImpl
+{
+ UnsafeQualifiedStaticDoubleFieldAccessorImpl(Field field, boolean isReadOnly) {
+ super(field, isReadOnly);
+ }
+
+ public Object get(Object obj) throws IllegalArgumentException {
+ return Double.valueOf(getDouble(obj));
+ }
+
+ public boolean getBoolean(Object obj) throws IllegalArgumentException {
+ throw newGetBooleanIllegalArgumentException();
+ }
+
+ public byte getByte(Object obj) throws IllegalArgumentException {
+ throw newGetByteIllegalArgumentException();
+ }
+
+ public char getChar(Object obj) throws IllegalArgumentException {
+ throw newGetCharIllegalArgumentException();
+ }
+
+ public short getShort(Object obj) throws IllegalArgumentException {
+ throw newGetShortIllegalArgumentException();
+ }
+
+ public int getInt(Object obj) throws IllegalArgumentException {
+ throw newGetIntIllegalArgumentException();
+ }
+
+ public long getLong(Object obj) throws IllegalArgumentException {
+ throw newGetLongIllegalArgumentException();
+ }
+
+ public float getFloat(Object obj) throws IllegalArgumentException {
+ throw newGetFloatIllegalArgumentException();
+ }
+
+ public double getDouble(Object obj) throws IllegalArgumentException {
+ return unsafe.getDoubleVolatile(base, fieldOffset);
+ }
+
+ public void set(Object obj, Object value)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ if (isReadOnly) {
+ throwFinalFieldIllegalAccessException(value);
+ }
+ if (value == null) {
+ throwSetIllegalArgumentException(value);
+ }
+ if (value instanceof Byte) {
+ unsafe.putDoubleVolatile(base, fieldOffset, ((Byte) value).byteValue());
+ return;
+ }
+ if (value instanceof Short) {
+ unsafe.putDoubleVolatile(base, fieldOffset, ((Short) value).shortValue());
+ return;
+ }
+ if (value instanceof Character) {
+ unsafe.putDoubleVolatile(base, fieldOffset, ((Character) value).charValue());
+ return;
+ }
+ if (value instanceof Integer) {
+ unsafe.putDoubleVolatile(base, fieldOffset, ((Integer) value).intValue());
+ return;
+ }
+ if (value instanceof Long) {
+ unsafe.putDoubleVolatile(base, fieldOffset, ((Long) value).longValue());
+ return;
+ }
+ if (value instanceof Float) {
+ unsafe.putDoubleVolatile(base, fieldOffset, ((Float) value).floatValue());
+ return;
+ }
+ if (value instanceof Double) {
+ unsafe.putDoubleVolatile(base, fieldOffset, ((Double) value).doubleValue());
+ return;
+ }
+ throwSetIllegalArgumentException(value);
+ }
+
+ public void setBoolean(Object obj, boolean z)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(z);
+ }
+
+ public void setByte(Object obj, byte b)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setDouble(obj, b);
+ }
+
+ public void setChar(Object obj, char c)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setDouble(obj, c);
+ }
+
+ public void setShort(Object obj, short s)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setDouble(obj, s);
+ }
+
+ public void setInt(Object obj, int i)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setDouble(obj, i);
+ }
+
+ public void setLong(Object obj, long l)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setDouble(obj, l);
+ }
+
+ public void setFloat(Object obj, float f)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setDouble(obj, f);
+ }
+
+ public void setDouble(Object obj, double d)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ if (isReadOnly) {
+ throwFinalFieldIllegalAccessException(d);
+ }
+ unsafe.putDoubleVolatile(base, fieldOffset, d);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/UnsafeQualifiedStaticFieldAccessorImpl.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2004, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+import java.security.AccessController;
+import jdk.internal.misc.Unsafe;
+
+/** Base class for jdk.internal.misc.Unsafe-based FieldAccessors for final or
+ static volatile fields. */
+
+abstract class UnsafeQualifiedStaticFieldAccessorImpl
+ extends UnsafeStaticFieldAccessorImpl
+{
+ protected final boolean isReadOnly;
+
+ UnsafeQualifiedStaticFieldAccessorImpl(Field field, boolean isReadOnly) {
+ super(field);
+ this.isReadOnly = isReadOnly;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/UnsafeQualifiedStaticFloatFieldAccessorImpl.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,159 @@
+/*
+ * Copyright (c) 2004, 2005, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+import java.lang.reflect.Field;
+
+class UnsafeQualifiedStaticFloatFieldAccessorImpl
+ extends UnsafeQualifiedStaticFieldAccessorImpl
+{
+ UnsafeQualifiedStaticFloatFieldAccessorImpl(Field field, boolean isReadOnly) {
+ super(field, isReadOnly);
+ }
+
+ public Object get(Object obj) throws IllegalArgumentException {
+ return Float.valueOf(getFloat(obj));
+ }
+
+ public boolean getBoolean(Object obj) throws IllegalArgumentException {
+ throw newGetBooleanIllegalArgumentException();
+ }
+
+ public byte getByte(Object obj) throws IllegalArgumentException {
+ throw newGetByteIllegalArgumentException();
+ }
+
+ public char getChar(Object obj) throws IllegalArgumentException {
+ throw newGetCharIllegalArgumentException();
+ }
+
+ public short getShort(Object obj) throws IllegalArgumentException {
+ throw newGetShortIllegalArgumentException();
+ }
+
+ public int getInt(Object obj) throws IllegalArgumentException {
+ throw newGetIntIllegalArgumentException();
+ }
+
+ public long getLong(Object obj) throws IllegalArgumentException {
+ throw newGetLongIllegalArgumentException();
+ }
+
+ public float getFloat(Object obj) throws IllegalArgumentException {
+ return unsafe.getFloatVolatile(base, fieldOffset);
+ }
+
+ public double getDouble(Object obj) throws IllegalArgumentException {
+ return getFloat(obj);
+ }
+
+ public void set(Object obj, Object value)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ if (isReadOnly) {
+ throwFinalFieldIllegalAccessException(value);
+ }
+ if (value == null) {
+ throwSetIllegalArgumentException(value);
+ }
+ if (value instanceof Byte) {
+ unsafe.putFloatVolatile(base, fieldOffset, ((Byte) value).byteValue());
+ return;
+ }
+ if (value instanceof Short) {
+ unsafe.putFloatVolatile(base, fieldOffset, ((Short) value).shortValue());
+ return;
+ }
+ if (value instanceof Character) {
+ unsafe.putFloatVolatile(base, fieldOffset, ((Character) value).charValue());
+ return;
+ }
+ if (value instanceof Integer) {
+ unsafe.putFloatVolatile(base, fieldOffset, ((Integer) value).intValue());
+ return;
+ }
+ if (value instanceof Long) {
+ unsafe.putFloatVolatile(base, fieldOffset, ((Long) value).longValue());
+ return;
+ }
+ if (value instanceof Float) {
+ unsafe.putFloatVolatile(base, fieldOffset, ((Float) value).floatValue());
+ return;
+ }
+ throwSetIllegalArgumentException(value);
+ }
+
+ public void setBoolean(Object obj, boolean z)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(z);
+ }
+
+ public void setByte(Object obj, byte b)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setFloat(obj, b);
+ }
+
+ public void setChar(Object obj, char c)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setFloat(obj, c);
+ }
+
+ public void setShort(Object obj, short s)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setFloat(obj, s);
+ }
+
+ public void setInt(Object obj, int i)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setFloat(obj, i);
+ }
+
+ public void setLong(Object obj, long l)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setFloat(obj, l);
+ }
+
+ public void setFloat(Object obj, float f)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ if (isReadOnly) {
+ throwFinalFieldIllegalAccessException(f);
+ }
+ unsafe.putFloatVolatile(base, fieldOffset, f);
+ }
+
+ public void setDouble(Object obj, double d)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(d);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/UnsafeQualifiedStaticIntegerFieldAccessorImpl.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,151 @@
+/*
+ * Copyright (c) 2004, 2005, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+import java.lang.reflect.Field;
+
+class UnsafeQualifiedStaticIntegerFieldAccessorImpl
+ extends UnsafeQualifiedStaticFieldAccessorImpl
+{
+ UnsafeQualifiedStaticIntegerFieldAccessorImpl(Field field, boolean isReadOnly) {
+ super(field, isReadOnly);
+ }
+
+ public Object get(Object obj) throws IllegalArgumentException {
+ return Integer.valueOf(getInt(obj));
+ }
+
+ public boolean getBoolean(Object obj) throws IllegalArgumentException {
+ throw newGetBooleanIllegalArgumentException();
+ }
+
+ public byte getByte(Object obj) throws IllegalArgumentException {
+ throw newGetByteIllegalArgumentException();
+ }
+
+ public char getChar(Object obj) throws IllegalArgumentException {
+ throw newGetCharIllegalArgumentException();
+ }
+
+ public short getShort(Object obj) throws IllegalArgumentException {
+ throw newGetShortIllegalArgumentException();
+ }
+
+ public int getInt(Object obj) throws IllegalArgumentException {
+ return unsafe.getIntVolatile(base, fieldOffset);
+ }
+
+ public long getLong(Object obj) throws IllegalArgumentException {
+ return getInt(obj);
+ }
+
+ public float getFloat(Object obj) throws IllegalArgumentException {
+ return getInt(obj);
+ }
+
+ public double getDouble(Object obj) throws IllegalArgumentException {
+ return getInt(obj);
+ }
+
+ public void set(Object obj, Object value)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ if (isReadOnly) {
+ throwFinalFieldIllegalAccessException(value);
+ }
+ if (value == null) {
+ throwSetIllegalArgumentException(value);
+ }
+ if (value instanceof Byte) {
+ unsafe.putIntVolatile(base, fieldOffset, ((Byte) value).byteValue());
+ return;
+ }
+ if (value instanceof Short) {
+ unsafe.putIntVolatile(base, fieldOffset, ((Short) value).shortValue());
+ return;
+ }
+ if (value instanceof Character) {
+ unsafe.putIntVolatile(base, fieldOffset, ((Character) value).charValue());
+ return;
+ }
+ if (value instanceof Integer) {
+ unsafe.putIntVolatile(base, fieldOffset, ((Integer) value).intValue());
+ return;
+ }
+ throwSetIllegalArgumentException(value);
+ }
+
+ public void setBoolean(Object obj, boolean z)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(z);
+ }
+
+ public void setByte(Object obj, byte b)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setInt(obj, b);
+ }
+
+ public void setChar(Object obj, char c)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setInt(obj, c);
+ }
+
+ public void setShort(Object obj, short s)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setInt(obj, s);
+ }
+
+ public void setInt(Object obj, int i)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ if (isReadOnly) {
+ throwFinalFieldIllegalAccessException(i);
+ }
+ unsafe.putIntVolatile(base, fieldOffset, i);
+ }
+
+ public void setLong(Object obj, long l)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(l);
+ }
+
+ public void setFloat(Object obj, float f)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(f);
+ }
+
+ public void setDouble(Object obj, double d)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(d);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/UnsafeQualifiedStaticLongFieldAccessorImpl.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,155 @@
+/*
+ * Copyright (c) 2004, 2005, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+import java.lang.reflect.Field;
+
+class UnsafeQualifiedStaticLongFieldAccessorImpl
+ extends UnsafeQualifiedStaticFieldAccessorImpl
+{
+ UnsafeQualifiedStaticLongFieldAccessorImpl(Field field, boolean isReadOnly) {
+ super(field, isReadOnly);
+ }
+
+ public Object get(Object obj) throws IllegalArgumentException {
+ return Long.valueOf(getLong(obj));
+ }
+
+ public boolean getBoolean(Object obj) throws IllegalArgumentException {
+ throw newGetBooleanIllegalArgumentException();
+ }
+
+ public byte getByte(Object obj) throws IllegalArgumentException {
+ throw newGetByteIllegalArgumentException();
+ }
+
+ public char getChar(Object obj) throws IllegalArgumentException {
+ throw newGetCharIllegalArgumentException();
+ }
+
+ public short getShort(Object obj) throws IllegalArgumentException {
+ throw newGetShortIllegalArgumentException();
+ }
+
+ public int getInt(Object obj) throws IllegalArgumentException {
+ throw newGetIntIllegalArgumentException();
+ }
+
+ public long getLong(Object obj) throws IllegalArgumentException {
+ return unsafe.getLongVolatile(base, fieldOffset);
+ }
+
+ public float getFloat(Object obj) throws IllegalArgumentException {
+ return getLong(obj);
+ }
+
+ public double getDouble(Object obj) throws IllegalArgumentException {
+ return getLong(obj);
+ }
+
+ public void set(Object obj, Object value)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ if (isReadOnly) {
+ throwFinalFieldIllegalAccessException(value);
+ }
+ if (value == null) {
+ throwSetIllegalArgumentException(value);
+ }
+ if (value instanceof Byte) {
+ unsafe.putLongVolatile(base, fieldOffset, ((Byte) value).byteValue());
+ return;
+ }
+ if (value instanceof Short) {
+ unsafe.putLongVolatile(base, fieldOffset, ((Short) value).shortValue());
+ return;
+ }
+ if (value instanceof Character) {
+ unsafe.putLongVolatile(base, fieldOffset, ((Character) value).charValue());
+ return;
+ }
+ if (value instanceof Integer) {
+ unsafe.putLongVolatile(base, fieldOffset, ((Integer) value).intValue());
+ return;
+ }
+ if (value instanceof Long) {
+ unsafe.putLongVolatile(base, fieldOffset, ((Long) value).longValue());
+ return;
+ }
+ throwSetIllegalArgumentException(value);
+ }
+
+ public void setBoolean(Object obj, boolean z)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(z);
+ }
+
+ public void setByte(Object obj, byte b)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setLong(obj, b);
+ }
+
+ public void setChar(Object obj, char c)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setLong(obj, c);
+ }
+
+ public void setShort(Object obj, short s)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setLong(obj, s);
+ }
+
+ public void setInt(Object obj, int i)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setLong(obj, i);
+ }
+
+ public void setLong(Object obj, long l)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ if (isReadOnly) {
+ throwFinalFieldIllegalAccessException(l);
+ }
+ unsafe.putLongVolatile(base, fieldOffset, l);
+ }
+
+ public void setFloat(Object obj, float f)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(f);
+ }
+
+ public void setDouble(Object obj, double d)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(d);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/UnsafeQualifiedStaticObjectFieldAccessorImpl.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,134 @@
+/*
+ * Copyright (c) 2004, 2005, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+import java.lang.reflect.Field;
+
+class UnsafeQualifiedStaticObjectFieldAccessorImpl
+ extends UnsafeQualifiedStaticFieldAccessorImpl
+{
+ UnsafeQualifiedStaticObjectFieldAccessorImpl(Field field, boolean isReadOnly) {
+ super(field, isReadOnly);
+ }
+
+ public Object get(Object obj) throws IllegalArgumentException {
+ return unsafe.getObjectVolatile(base, fieldOffset);
+ }
+
+ public boolean getBoolean(Object obj) throws IllegalArgumentException {
+ throw newGetBooleanIllegalArgumentException();
+ }
+
+ public byte getByte(Object obj) throws IllegalArgumentException {
+ throw newGetByteIllegalArgumentException();
+ }
+
+ public char getChar(Object obj) throws IllegalArgumentException {
+ throw newGetCharIllegalArgumentException();
+ }
+
+ public short getShort(Object obj) throws IllegalArgumentException {
+ throw newGetShortIllegalArgumentException();
+ }
+
+ public int getInt(Object obj) throws IllegalArgumentException {
+ throw newGetIntIllegalArgumentException();
+ }
+
+ public long getLong(Object obj) throws IllegalArgumentException {
+ throw newGetLongIllegalArgumentException();
+ }
+
+ public float getFloat(Object obj) throws IllegalArgumentException {
+ throw newGetFloatIllegalArgumentException();
+ }
+
+ public double getDouble(Object obj) throws IllegalArgumentException {
+ throw newGetDoubleIllegalArgumentException();
+ }
+
+ public void set(Object obj, Object value)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ if (isReadOnly) {
+ throwFinalFieldIllegalAccessException(value);
+ }
+ if (value != null) {
+ if (!field.getType().isAssignableFrom(value.getClass())) {
+ throwSetIllegalArgumentException(value);
+ }
+ }
+ unsafe.putObjectVolatile(base, fieldOffset, value);
+ }
+
+ public void setBoolean(Object obj, boolean z)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(z);
+ }
+
+ public void setByte(Object obj, byte b)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(b);
+ }
+
+ public void setChar(Object obj, char c)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(c);
+ }
+
+ public void setShort(Object obj, short s)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(s);
+ }
+
+ public void setInt(Object obj, int i)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(i);
+ }
+
+ public void setLong(Object obj, long l)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(l);
+ }
+
+ public void setFloat(Object obj, float f)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(f);
+ }
+
+ public void setDouble(Object obj, double d)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(d);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/UnsafeQualifiedStaticShortFieldAccessorImpl.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) 2004, 2005, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+import java.lang.reflect.Field;
+
+class UnsafeQualifiedStaticShortFieldAccessorImpl
+ extends UnsafeQualifiedStaticFieldAccessorImpl
+{
+ UnsafeQualifiedStaticShortFieldAccessorImpl(Field field, boolean isReadOnly) {
+ super(field, isReadOnly);
+ }
+
+ public Object get(Object obj) throws IllegalArgumentException {
+ return Short.valueOf(getShort(obj));
+ }
+
+ public boolean getBoolean(Object obj) throws IllegalArgumentException {
+ throw newGetBooleanIllegalArgumentException();
+ }
+
+ public byte getByte(Object obj) throws IllegalArgumentException {
+ throw newGetByteIllegalArgumentException();
+ }
+
+ public char getChar(Object obj) throws IllegalArgumentException {
+ throw newGetCharIllegalArgumentException();
+ }
+
+ public short getShort(Object obj) throws IllegalArgumentException {
+ return unsafe.getShortVolatile(base, fieldOffset);
+ }
+
+ public int getInt(Object obj) throws IllegalArgumentException {
+ return getShort(obj);
+ }
+
+ public long getLong(Object obj) throws IllegalArgumentException {
+ return getShort(obj);
+ }
+
+ public float getFloat(Object obj) throws IllegalArgumentException {
+ return getShort(obj);
+ }
+
+ public double getDouble(Object obj) throws IllegalArgumentException {
+ return getShort(obj);
+ }
+
+ public void set(Object obj, Object value)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ if (isReadOnly) {
+ throwFinalFieldIllegalAccessException(value);
+ }
+ if (value == null) {
+ throwSetIllegalArgumentException(value);
+ }
+ if (value instanceof Byte) {
+ unsafe.putShortVolatile(base, fieldOffset, ((Byte) value).byteValue());
+ return;
+ }
+ if (value instanceof Short) {
+ unsafe.putShortVolatile(base, fieldOffset, ((Short) value).shortValue());
+ return;
+ }
+ throwSetIllegalArgumentException(value);
+ }
+
+ public void setBoolean(Object obj, boolean z)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(z);
+ }
+
+ public void setByte(Object obj, byte b)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setShort(obj, b);
+ }
+
+ public void setChar(Object obj, char c)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(c);
+ }
+
+ public void setShort(Object obj, short s)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ if (isReadOnly) {
+ throwFinalFieldIllegalAccessException(s);
+ }
+ unsafe.putShortVolatile(base, fieldOffset, s);
+ }
+
+ public void setInt(Object obj, int i)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(i);
+ }
+
+ public void setLong(Object obj, long l)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(l);
+ }
+
+ public void setFloat(Object obj, float f)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(f);
+ }
+
+ public void setDouble(Object obj, double d)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(d);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/UnsafeShortFieldAccessorImpl.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,144 @@
+/*
+ * Copyright (c) 2001, 2005, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+import java.lang.reflect.Field;
+
+class UnsafeShortFieldAccessorImpl extends UnsafeFieldAccessorImpl {
+ UnsafeShortFieldAccessorImpl(Field field) {
+ super(field);
+ }
+
+ public Object get(Object obj) throws IllegalArgumentException {
+ return Short.valueOf(getShort(obj));
+ }
+
+ public boolean getBoolean(Object obj) throws IllegalArgumentException {
+ throw newGetBooleanIllegalArgumentException();
+ }
+
+ public byte getByte(Object obj) throws IllegalArgumentException {
+ throw newGetByteIllegalArgumentException();
+ }
+
+ public char getChar(Object obj) throws IllegalArgumentException {
+ throw newGetCharIllegalArgumentException();
+ }
+
+ public short getShort(Object obj) throws IllegalArgumentException {
+ ensureObj(obj);
+ return unsafe.getShort(obj, fieldOffset);
+ }
+
+ public int getInt(Object obj) throws IllegalArgumentException {
+ return getShort(obj);
+ }
+
+ public long getLong(Object obj) throws IllegalArgumentException {
+ return getShort(obj);
+ }
+
+ public float getFloat(Object obj) throws IllegalArgumentException {
+ return getShort(obj);
+ }
+
+ public double getDouble(Object obj) throws IllegalArgumentException {
+ return getShort(obj);
+ }
+
+ public void set(Object obj, Object value)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ ensureObj(obj);
+ if (isFinal) {
+ throwFinalFieldIllegalAccessException(value);
+ }
+ if (value == null) {
+ throwSetIllegalArgumentException(value);
+ }
+ if (value instanceof Byte) {
+ unsafe.putShort(obj, fieldOffset, ((Byte) value).byteValue());
+ return;
+ }
+ if (value instanceof Short) {
+ unsafe.putShort(obj, fieldOffset, ((Short) value).shortValue());
+ return;
+ }
+ throwSetIllegalArgumentException(value);
+ }
+
+ public void setBoolean(Object obj, boolean z)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(z);
+ }
+
+ public void setByte(Object obj, byte b)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setShort(obj, b);
+ }
+
+ public void setChar(Object obj, char c)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(c);
+ }
+
+ public void setShort(Object obj, short s)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ ensureObj(obj);
+ if (isFinal) {
+ throwFinalFieldIllegalAccessException(s);
+ }
+ unsafe.putShort(obj, fieldOffset, s);
+ }
+
+ public void setInt(Object obj, int i)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(i);
+ }
+
+ public void setLong(Object obj, long l)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(l);
+ }
+
+ public void setFloat(Object obj, float f)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(f);
+ }
+
+ public void setDouble(Object obj, double d)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(d);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/UnsafeStaticBooleanFieldAccessorImpl.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,137 @@
+/*
+ * Copyright (c) 2001, 2005, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+import java.lang.reflect.Field;
+
+class UnsafeStaticBooleanFieldAccessorImpl extends UnsafeStaticFieldAccessorImpl {
+ UnsafeStaticBooleanFieldAccessorImpl(Field field) {
+ super(field);
+ }
+
+ public Object get(Object obj) throws IllegalArgumentException {
+ return Boolean.valueOf(getBoolean(obj));
+ }
+
+ public boolean getBoolean(Object obj) throws IllegalArgumentException {
+ return unsafe.getBoolean(base, fieldOffset);
+ }
+
+ public byte getByte(Object obj) throws IllegalArgumentException {
+ throw newGetByteIllegalArgumentException();
+ }
+
+ public char getChar(Object obj) throws IllegalArgumentException {
+ throw newGetCharIllegalArgumentException();
+ }
+
+ public short getShort(Object obj) throws IllegalArgumentException {
+ throw newGetShortIllegalArgumentException();
+ }
+
+ public int getInt(Object obj) throws IllegalArgumentException {
+ throw newGetIntIllegalArgumentException();
+ }
+
+ public long getLong(Object obj) throws IllegalArgumentException {
+ throw newGetLongIllegalArgumentException();
+ }
+
+ public float getFloat(Object obj) throws IllegalArgumentException {
+ throw newGetFloatIllegalArgumentException();
+ }
+
+ public double getDouble(Object obj) throws IllegalArgumentException {
+ throw newGetDoubleIllegalArgumentException();
+ }
+
+ public void set(Object obj, Object value)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ if (isFinal) {
+ throwFinalFieldIllegalAccessException(value);
+ }
+ if (value == null) {
+ throwSetIllegalArgumentException(value);
+ }
+ if (value instanceof Boolean) {
+ unsafe.putBoolean(base, fieldOffset, ((Boolean) value).booleanValue());
+ return;
+ }
+ throwSetIllegalArgumentException(value);
+ }
+
+ public void setBoolean(Object obj, boolean z)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ if (isFinal) {
+ throwFinalFieldIllegalAccessException(z);
+ }
+ unsafe.putBoolean(base, fieldOffset, z);
+ }
+
+ public void setByte(Object obj, byte b)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(b);
+ }
+
+ public void setChar(Object obj, char c)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(c);
+ }
+
+ public void setShort(Object obj, short s)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(s);
+ }
+
+ public void setInt(Object obj, int i)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(i);
+ }
+
+ public void setLong(Object obj, long l)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(l);
+ }
+
+ public void setFloat(Object obj, float f)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(f);
+ }
+
+ public void setDouble(Object obj, double d)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(d);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/UnsafeStaticByteFieldAccessorImpl.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,137 @@
+/*
+ * Copyright (c) 2001, 2005, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+import java.lang.reflect.Field;
+
+class UnsafeStaticByteFieldAccessorImpl extends UnsafeStaticFieldAccessorImpl {
+ UnsafeStaticByteFieldAccessorImpl(Field field) {
+ super(field);
+ }
+
+ public Object get(Object obj) throws IllegalArgumentException {
+ return Byte.valueOf(getByte(obj));
+ }
+
+ public boolean getBoolean(Object obj) throws IllegalArgumentException {
+ throw newGetBooleanIllegalArgumentException();
+ }
+
+ public byte getByte(Object obj) throws IllegalArgumentException {
+ return unsafe.getByte(base, fieldOffset);
+ }
+
+ public char getChar(Object obj) throws IllegalArgumentException {
+ throw newGetCharIllegalArgumentException();
+ }
+
+ public short getShort(Object obj) throws IllegalArgumentException {
+ return getByte(obj);
+ }
+
+ public int getInt(Object obj) throws IllegalArgumentException {
+ return getByte(obj);
+ }
+
+ public long getLong(Object obj) throws IllegalArgumentException {
+ return getByte(obj);
+ }
+
+ public float getFloat(Object obj) throws IllegalArgumentException {
+ return getByte(obj);
+ }
+
+ public double getDouble(Object obj) throws IllegalArgumentException {
+ return getByte(obj);
+ }
+
+ public void set(Object obj, Object value)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ if (isFinal) {
+ throwFinalFieldIllegalAccessException(value);
+ }
+ if (value == null) {
+ throwSetIllegalArgumentException(value);
+ }
+ if (value instanceof Byte) {
+ unsafe.putByte(base, fieldOffset, ((Byte) value).byteValue());
+ return;
+ }
+ throwSetIllegalArgumentException(value);
+ }
+
+ public void setBoolean(Object obj, boolean z)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(z);
+ }
+
+ public void setByte(Object obj, byte b)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ if (isFinal) {
+ throwFinalFieldIllegalAccessException(b);
+ }
+ unsafe.putByte(base, fieldOffset, b);
+ }
+
+ public void setChar(Object obj, char c)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(c);
+ }
+
+ public void setShort(Object obj, short s)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(s);
+ }
+
+ public void setInt(Object obj, int i)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(i);
+ }
+
+ public void setLong(Object obj, long l)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(l);
+ }
+
+ public void setFloat(Object obj, float f)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(f);
+ }
+
+ public void setDouble(Object obj, double d)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(d);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/UnsafeStaticCharacterFieldAccessorImpl.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,137 @@
+/*
+ * Copyright (c) 2001, 2005, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+import java.lang.reflect.Field;
+
+class UnsafeStaticCharacterFieldAccessorImpl extends UnsafeStaticFieldAccessorImpl {
+ UnsafeStaticCharacterFieldAccessorImpl(Field field) {
+ super(field);
+ }
+
+ public Object get(Object obj) throws IllegalArgumentException {
+ return Character.valueOf(getChar(obj));
+ }
+
+ public boolean getBoolean(Object obj) throws IllegalArgumentException {
+ throw newGetBooleanIllegalArgumentException();
+ }
+
+ public byte getByte(Object obj) throws IllegalArgumentException {
+ throw newGetByteIllegalArgumentException();
+ }
+
+ public char getChar(Object obj) throws IllegalArgumentException {
+ return unsafe.getChar(base, fieldOffset);
+ }
+
+ public short getShort(Object obj) throws IllegalArgumentException {
+ throw newGetShortIllegalArgumentException();
+ }
+
+ public int getInt(Object obj) throws IllegalArgumentException {
+ return getChar(obj);
+ }
+
+ public long getLong(Object obj) throws IllegalArgumentException {
+ return getChar(obj);
+ }
+
+ public float getFloat(Object obj) throws IllegalArgumentException {
+ return getChar(obj);
+ }
+
+ public double getDouble(Object obj) throws IllegalArgumentException {
+ return getChar(obj);
+ }
+
+ public void set(Object obj, Object value)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ if (isFinal) {
+ throwFinalFieldIllegalAccessException(value);
+ }
+ if (value == null) {
+ throwSetIllegalArgumentException(value);
+ }
+ if (value instanceof Character) {
+ unsafe.putChar(base, fieldOffset, ((Character) value).charValue());
+ return;
+ }
+ throwSetIllegalArgumentException(value);
+ }
+
+ public void setBoolean(Object obj, boolean z)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(z);
+ }
+
+ public void setByte(Object obj, byte b)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(b);
+ }
+
+ public void setChar(Object obj, char c)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ if (isFinal) {
+ throwFinalFieldIllegalAccessException(c);
+ }
+ unsafe.putChar(base, fieldOffset, c);
+ }
+
+ public void setShort(Object obj, short s)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(s);
+ }
+
+ public void setInt(Object obj, int i)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(i);
+ }
+
+ public void setLong(Object obj, long l)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(l);
+ }
+
+ public void setFloat(Object obj, float f)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(f);
+ }
+
+ public void setDouble(Object obj, double d)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(d);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/UnsafeStaticDoubleFieldAccessorImpl.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,161 @@
+/*
+ * Copyright (c) 2001, 2005, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+import java.lang.reflect.Field;
+
+class UnsafeStaticDoubleFieldAccessorImpl extends UnsafeStaticFieldAccessorImpl {
+ UnsafeStaticDoubleFieldAccessorImpl(Field field) {
+ super(field);
+ }
+
+ public Object get(Object obj) throws IllegalArgumentException {
+ return Double.valueOf(getDouble(obj));
+ }
+
+ public boolean getBoolean(Object obj) throws IllegalArgumentException {
+ throw newGetBooleanIllegalArgumentException();
+ }
+
+ public byte getByte(Object obj) throws IllegalArgumentException {
+ throw newGetByteIllegalArgumentException();
+ }
+
+ public char getChar(Object obj) throws IllegalArgumentException {
+ throw newGetCharIllegalArgumentException();
+ }
+
+ public short getShort(Object obj) throws IllegalArgumentException {
+ throw newGetShortIllegalArgumentException();
+ }
+
+ public int getInt(Object obj) throws IllegalArgumentException {
+ throw newGetIntIllegalArgumentException();
+ }
+
+ public long getLong(Object obj) throws IllegalArgumentException {
+ throw newGetLongIllegalArgumentException();
+ }
+
+ public float getFloat(Object obj) throws IllegalArgumentException {
+ throw newGetFloatIllegalArgumentException();
+ }
+
+ public double getDouble(Object obj) throws IllegalArgumentException {
+ return unsafe.getDouble(base, fieldOffset);
+ }
+
+ public void set(Object obj, Object value)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ if (isFinal) {
+ throwFinalFieldIllegalAccessException(value);
+ }
+ if (value == null) {
+ throwSetIllegalArgumentException(value);
+ }
+ if (value instanceof Byte) {
+ unsafe.putDouble(base, fieldOffset, ((Byte) value).byteValue());
+ return;
+ }
+ if (value instanceof Short) {
+ unsafe.putDouble(base, fieldOffset, ((Short) value).shortValue());
+ return;
+ }
+ if (value instanceof Character) {
+ unsafe.putDouble(base, fieldOffset, ((Character) value).charValue());
+ return;
+ }
+ if (value instanceof Integer) {
+ unsafe.putDouble(base, fieldOffset, ((Integer) value).intValue());
+ return;
+ }
+ if (value instanceof Long) {
+ unsafe.putDouble(base, fieldOffset, ((Long) value).longValue());
+ return;
+ }
+ if (value instanceof Float) {
+ unsafe.putDouble(base, fieldOffset, ((Float) value).floatValue());
+ return;
+ }
+ if (value instanceof Double) {
+ unsafe.putDouble(base, fieldOffset, ((Double) value).doubleValue());
+ return;
+ }
+ throwSetIllegalArgumentException(value);
+ }
+
+ public void setBoolean(Object obj, boolean z)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(z);
+ }
+
+ public void setByte(Object obj, byte b)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setDouble(obj, b);
+ }
+
+ public void setChar(Object obj, char c)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setDouble(obj, c);
+ }
+
+ public void setShort(Object obj, short s)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setDouble(obj, s);
+ }
+
+ public void setInt(Object obj, int i)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setDouble(obj, i);
+ }
+
+ public void setLong(Object obj, long l)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setDouble(obj, l);
+ }
+
+ public void setFloat(Object obj, float f)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setDouble(obj, f);
+ }
+
+ public void setDouble(Object obj, double d)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ if (isFinal) {
+ throwFinalFieldIllegalAccessException(d);
+ }
+ unsafe.putDouble(base, fieldOffset, d);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/UnsafeStaticFieldAccessorImpl.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2001, 2012, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+import java.security.AccessController;
+import jdk.internal.misc.Unsafe;
+
+/** Base class for jdk.internal.misc.Unsafe-based FieldAccessors for static
+ fields. The observation is that there are only nine types of
+ fields from the standpoint of reflection code: the eight primitive
+ types and Object. Using class Unsafe instead of generated
+ bytecodes saves memory and loading time for the
+ dynamically-generated FieldAccessors. */
+
+abstract class UnsafeStaticFieldAccessorImpl extends UnsafeFieldAccessorImpl {
+ static {
+ Reflection.registerFieldsToFilter(UnsafeStaticFieldAccessorImpl.class,
+ new String[] { "base" });
+ }
+
+ protected final Object base; // base
+
+ UnsafeStaticFieldAccessorImpl(Field field) {
+ super(field);
+ base = unsafe.staticFieldBase(field);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/UnsafeStaticFloatFieldAccessorImpl.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,157 @@
+/*
+ * Copyright (c) 2001, 2005, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+import java.lang.reflect.Field;
+
+class UnsafeStaticFloatFieldAccessorImpl extends UnsafeStaticFieldAccessorImpl {
+ UnsafeStaticFloatFieldAccessorImpl(Field field) {
+ super(field);
+ }
+
+ public Object get(Object obj) throws IllegalArgumentException {
+ return Float.valueOf(getFloat(obj));
+ }
+
+ public boolean getBoolean(Object obj) throws IllegalArgumentException {
+ throw newGetBooleanIllegalArgumentException();
+ }
+
+ public byte getByte(Object obj) throws IllegalArgumentException {
+ throw newGetByteIllegalArgumentException();
+ }
+
+ public char getChar(Object obj) throws IllegalArgumentException {
+ throw newGetCharIllegalArgumentException();
+ }
+
+ public short getShort(Object obj) throws IllegalArgumentException {
+ throw newGetShortIllegalArgumentException();
+ }
+
+ public int getInt(Object obj) throws IllegalArgumentException {
+ throw newGetIntIllegalArgumentException();
+ }
+
+ public long getLong(Object obj) throws IllegalArgumentException {
+ throw newGetLongIllegalArgumentException();
+ }
+
+ public float getFloat(Object obj) throws IllegalArgumentException {
+ return unsafe.getFloat(base, fieldOffset);
+ }
+
+ public double getDouble(Object obj) throws IllegalArgumentException {
+ return getFloat(obj);
+ }
+
+ public void set(Object obj, Object value)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ if (isFinal) {
+ throwFinalFieldIllegalAccessException(value);
+ }
+ if (value == null) {
+ throwSetIllegalArgumentException(value);
+ }
+ if (value instanceof Byte) {
+ unsafe.putFloat(base, fieldOffset, ((Byte) value).byteValue());
+ return;
+ }
+ if (value instanceof Short) {
+ unsafe.putFloat(base, fieldOffset, ((Short) value).shortValue());
+ return;
+ }
+ if (value instanceof Character) {
+ unsafe.putFloat(base, fieldOffset, ((Character) value).charValue());
+ return;
+ }
+ if (value instanceof Integer) {
+ unsafe.putFloat(base, fieldOffset, ((Integer) value).intValue());
+ return;
+ }
+ if (value instanceof Long) {
+ unsafe.putFloat(base, fieldOffset, ((Long) value).longValue());
+ return;
+ }
+ if (value instanceof Float) {
+ unsafe.putFloat(base, fieldOffset, ((Float) value).floatValue());
+ return;
+ }
+ throwSetIllegalArgumentException(value);
+ }
+
+ public void setBoolean(Object obj, boolean z)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(z);
+ }
+
+ public void setByte(Object obj, byte b)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setFloat(obj, b);
+ }
+
+ public void setChar(Object obj, char c)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setFloat(obj, c);
+ }
+
+ public void setShort(Object obj, short s)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setFloat(obj, s);
+ }
+
+ public void setInt(Object obj, int i)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setFloat(obj, i);
+ }
+
+ public void setLong(Object obj, long l)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setFloat(obj, l);
+ }
+
+ public void setFloat(Object obj, float f)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ if (isFinal) {
+ throwFinalFieldIllegalAccessException(f);
+ }
+ unsafe.putFloat(base, fieldOffset, f);
+ }
+
+ public void setDouble(Object obj, double d)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(d);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/UnsafeStaticIntegerFieldAccessorImpl.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,149 @@
+/*
+ * Copyright (c) 2001, 2005, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+import java.lang.reflect.Field;
+
+class UnsafeStaticIntegerFieldAccessorImpl extends UnsafeStaticFieldAccessorImpl {
+ UnsafeStaticIntegerFieldAccessorImpl(Field field) {
+ super(field);
+ }
+
+ public Object get(Object obj) throws IllegalArgumentException {
+ return Integer.valueOf(getInt(obj));
+ }
+
+ public boolean getBoolean(Object obj) throws IllegalArgumentException {
+ throw newGetBooleanIllegalArgumentException();
+ }
+
+ public byte getByte(Object obj) throws IllegalArgumentException {
+ throw newGetByteIllegalArgumentException();
+ }
+
+ public char getChar(Object obj) throws IllegalArgumentException {
+ throw newGetCharIllegalArgumentException();
+ }
+
+ public short getShort(Object obj) throws IllegalArgumentException {
+ throw newGetShortIllegalArgumentException();
+ }
+
+ public int getInt(Object obj) throws IllegalArgumentException {
+ return unsafe.getInt(base, fieldOffset);
+ }
+
+ public long getLong(Object obj) throws IllegalArgumentException {
+ return getInt(obj);
+ }
+
+ public float getFloat(Object obj) throws IllegalArgumentException {
+ return getInt(obj);
+ }
+
+ public double getDouble(Object obj) throws IllegalArgumentException {
+ return getInt(obj);
+ }
+
+ public void set(Object obj, Object value)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ if (isFinal) {
+ throwFinalFieldIllegalAccessException(value);
+ }
+ if (value == null) {
+ throwSetIllegalArgumentException(value);
+ }
+ if (value instanceof Byte) {
+ unsafe.putInt(base, fieldOffset, ((Byte) value).byteValue());
+ return;
+ }
+ if (value instanceof Short) {
+ unsafe.putInt(base, fieldOffset, ((Short) value).shortValue());
+ return;
+ }
+ if (value instanceof Character) {
+ unsafe.putInt(base, fieldOffset, ((Character) value).charValue());
+ return;
+ }
+ if (value instanceof Integer) {
+ unsafe.putInt(base, fieldOffset, ((Integer) value).intValue());
+ return;
+ }
+ throwSetIllegalArgumentException(value);
+ }
+
+ public void setBoolean(Object obj, boolean z)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(z);
+ }
+
+ public void setByte(Object obj, byte b)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setInt(obj, b);
+ }
+
+ public void setChar(Object obj, char c)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setInt(obj, c);
+ }
+
+ public void setShort(Object obj, short s)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setInt(obj, s);
+ }
+
+ public void setInt(Object obj, int i)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ if (isFinal) {
+ throwFinalFieldIllegalAccessException(i);
+ }
+ unsafe.putInt(base, fieldOffset, i);
+ }
+
+ public void setLong(Object obj, long l)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(l);
+ }
+
+ public void setFloat(Object obj, float f)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(f);
+ }
+
+ public void setDouble(Object obj, double d)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(d);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/UnsafeStaticLongFieldAccessorImpl.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,153 @@
+/*
+ * Copyright (c) 2001, 2005, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+import java.lang.reflect.Field;
+
+class UnsafeStaticLongFieldAccessorImpl extends UnsafeStaticFieldAccessorImpl {
+ UnsafeStaticLongFieldAccessorImpl(Field field) {
+ super(field);
+ }
+
+ public Object get(Object obj) throws IllegalArgumentException {
+ return Long.valueOf(getLong(obj));
+ }
+
+ public boolean getBoolean(Object obj) throws IllegalArgumentException {
+ throw newGetBooleanIllegalArgumentException();
+ }
+
+ public byte getByte(Object obj) throws IllegalArgumentException {
+ throw newGetByteIllegalArgumentException();
+ }
+
+ public char getChar(Object obj) throws IllegalArgumentException {
+ throw newGetCharIllegalArgumentException();
+ }
+
+ public short getShort(Object obj) throws IllegalArgumentException {
+ throw newGetShortIllegalArgumentException();
+ }
+
+ public int getInt(Object obj) throws IllegalArgumentException {
+ throw newGetIntIllegalArgumentException();
+ }
+
+ public long getLong(Object obj) throws IllegalArgumentException {
+ return unsafe.getLong(base, fieldOffset);
+ }
+
+ public float getFloat(Object obj) throws IllegalArgumentException {
+ return getLong(obj);
+ }
+
+ public double getDouble(Object obj) throws IllegalArgumentException {
+ return getLong(obj);
+ }
+
+ public void set(Object obj, Object value)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ if (isFinal) {
+ throwFinalFieldIllegalAccessException(value);
+ }
+ if (value == null) {
+ throwSetIllegalArgumentException(value);
+ }
+ if (value instanceof Byte) {
+ unsafe.putLong(base, fieldOffset, ((Byte) value).byteValue());
+ return;
+ }
+ if (value instanceof Short) {
+ unsafe.putLong(base, fieldOffset, ((Short) value).shortValue());
+ return;
+ }
+ if (value instanceof Character) {
+ unsafe.putLong(base, fieldOffset, ((Character) value).charValue());
+ return;
+ }
+ if (value instanceof Integer) {
+ unsafe.putLong(base, fieldOffset, ((Integer) value).intValue());
+ return;
+ }
+ if (value instanceof Long) {
+ unsafe.putLong(base, fieldOffset, ((Long) value).longValue());
+ return;
+ }
+ throwSetIllegalArgumentException(value);
+ }
+
+ public void setBoolean(Object obj, boolean z)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(z);
+ }
+
+ public void setByte(Object obj, byte b)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setLong(obj, b);
+ }
+
+ public void setChar(Object obj, char c)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setLong(obj, c);
+ }
+
+ public void setShort(Object obj, short s)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setLong(obj, s);
+ }
+
+ public void setInt(Object obj, int i)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setLong(obj, i);
+ }
+
+ public void setLong(Object obj, long l)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ if (isFinal) {
+ throwFinalFieldIllegalAccessException(l);
+ }
+ unsafe.putLong(base, fieldOffset, l);
+ }
+
+ public void setFloat(Object obj, float f)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(f);
+ }
+
+ public void setDouble(Object obj, double d)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(d);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/UnsafeStaticObjectFieldAccessorImpl.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,132 @@
+/*
+ * Copyright (c) 2001, 2005, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+import java.lang.reflect.Field;
+
+class UnsafeStaticObjectFieldAccessorImpl extends UnsafeStaticFieldAccessorImpl {
+ UnsafeStaticObjectFieldAccessorImpl(Field field) {
+ super(field);
+ }
+
+ public Object get(Object obj) throws IllegalArgumentException {
+ return unsafe.getObject(base, fieldOffset);
+ }
+
+ public boolean getBoolean(Object obj) throws IllegalArgumentException {
+ throw newGetBooleanIllegalArgumentException();
+ }
+
+ public byte getByte(Object obj) throws IllegalArgumentException {
+ throw newGetByteIllegalArgumentException();
+ }
+
+ public char getChar(Object obj) throws IllegalArgumentException {
+ throw newGetCharIllegalArgumentException();
+ }
+
+ public short getShort(Object obj) throws IllegalArgumentException {
+ throw newGetShortIllegalArgumentException();
+ }
+
+ public int getInt(Object obj) throws IllegalArgumentException {
+ throw newGetIntIllegalArgumentException();
+ }
+
+ public long getLong(Object obj) throws IllegalArgumentException {
+ throw newGetLongIllegalArgumentException();
+ }
+
+ public float getFloat(Object obj) throws IllegalArgumentException {
+ throw newGetFloatIllegalArgumentException();
+ }
+
+ public double getDouble(Object obj) throws IllegalArgumentException {
+ throw newGetDoubleIllegalArgumentException();
+ }
+
+ public void set(Object obj, Object value)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ if (isFinal) {
+ throwFinalFieldIllegalAccessException(value);
+ }
+ if (value != null) {
+ if (!field.getType().isAssignableFrom(value.getClass())) {
+ throwSetIllegalArgumentException(value);
+ }
+ }
+ unsafe.putObject(base, fieldOffset, value);
+ }
+
+ public void setBoolean(Object obj, boolean z)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(z);
+ }
+
+ public void setByte(Object obj, byte b)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(b);
+ }
+
+ public void setChar(Object obj, char c)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(c);
+ }
+
+ public void setShort(Object obj, short s)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(s);
+ }
+
+ public void setInt(Object obj, int i)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(i);
+ }
+
+ public void setLong(Object obj, long l)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(l);
+ }
+
+ public void setFloat(Object obj, float f)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(f);
+ }
+
+ public void setDouble(Object obj, double d)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(d);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/UnsafeStaticShortFieldAccessorImpl.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 2001, 2005, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.internal.reflect;
+
+import java.lang.reflect.Field;
+
+class UnsafeStaticShortFieldAccessorImpl extends UnsafeStaticFieldAccessorImpl {
+ UnsafeStaticShortFieldAccessorImpl(Field field) {
+ super(field);
+ }
+
+ public Object get(Object obj) throws IllegalArgumentException {
+ return Short.valueOf(getShort(obj));
+ }
+
+ public boolean getBoolean(Object obj) throws IllegalArgumentException {
+ throw newGetBooleanIllegalArgumentException();
+ }
+
+ public byte getByte(Object obj) throws IllegalArgumentException {
+ throw newGetByteIllegalArgumentException();
+ }
+
+ public char getChar(Object obj) throws IllegalArgumentException {
+ throw newGetCharIllegalArgumentException();
+ }
+
+ public short getShort(Object obj) throws IllegalArgumentException {
+ return unsafe.getShort(base, fieldOffset);
+ }
+
+ public int getInt(Object obj) throws IllegalArgumentException {
+ return getShort(obj);
+ }
+
+ public long getLong(Object obj) throws IllegalArgumentException {
+ return getShort(obj);
+ }
+
+ public float getFloat(Object obj) throws IllegalArgumentException {
+ return getShort(obj);
+ }
+
+ public double getDouble(Object obj) throws IllegalArgumentException {
+ return getShort(obj);
+ }
+
+ public void set(Object obj, Object value)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ if (isFinal) {
+ throwFinalFieldIllegalAccessException(value);
+ }
+ if (value == null) {
+ throwSetIllegalArgumentException(value);
+ }
+ if (value instanceof Byte) {
+ unsafe.putShort(base, fieldOffset, ((Byte) value).byteValue());
+ return;
+ }
+ if (value instanceof Short) {
+ unsafe.putShort(base, fieldOffset, ((Short) value).shortValue());
+ return;
+ }
+ throwSetIllegalArgumentException(value);
+ }
+
+ public void setBoolean(Object obj, boolean z)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(z);
+ }
+
+ public void setByte(Object obj, byte b)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ setShort(obj, b);
+ }
+
+ public void setChar(Object obj, char c)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(c);
+ }
+
+ public void setShort(Object obj, short s)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ if (isFinal) {
+ throwFinalFieldIllegalAccessException(s);
+ }
+ unsafe.putShort(base, fieldOffset, s);
+ }
+
+ public void setInt(Object obj, int i)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(i);
+ }
+
+ public void setLong(Object obj, long l)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(l);
+ }
+
+ public void setFloat(Object obj, float f)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(f);
+ }
+
+ public void setDouble(Object obj, double d)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ throwSetIllegalArgumentException(d);
+ }
+}
--- a/jdk/src/java.base/share/classes/module-info.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/module-info.java Wed Jul 05 21:35:27 2017 +0200
@@ -86,9 +86,6 @@
// see JDK-8044773
exports jdk.net;
- // This will move to a jdk.internal module via JEP-260
- exports sun.reflect;
-
// the service types defined by the APIs in this module
@@ -180,6 +177,14 @@
jdk.jvmstat;
exports jdk.internal.ref to
java.desktop;
+ exports jdk.internal.reflect to
+ java.corba,
+ java.logging,
+ java.sql,
+ java.sql.rowset,
+ jdk.dynalink,
+ jdk.scripting.nashorn,
+ jdk.unsupported;
exports jdk.internal.vm.annotation to
jdk.unsupported;
exports jdk.internal.util.jar to
--- a/jdk/src/java.base/share/classes/sun/invoke/util/VerifyAccess.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/sun/invoke/util/VerifyAccess.java Wed Jul 05 21:35:27 2017 +0200
@@ -28,7 +28,7 @@
import java.lang.reflect.Modifier;
import static java.lang.reflect.Modifier.*;
import java.lang.reflect.Module;
-import sun.reflect.Reflection;
+import jdk.internal.reflect.Reflection;
/**
* This class centralizes information about the JVM's linkage access control.
--- a/jdk/src/java.base/share/classes/sun/nio/fs/AbstractFileSystemProvider.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/sun/nio/fs/AbstractFileSystemProvider.java Wed Jul 05 21:35:27 2017 +0200
@@ -25,7 +25,9 @@
package sun.nio.fs;
-import java.nio.file.*;
+import java.nio.file.Path;
+import java.nio.file.LinkOption;
+import java.nio.file.attribute.BasicFileAttributes;
import java.nio.file.spi.FileSystemProvider;
import java.io.IOException;
import java.util.Map;
@@ -34,7 +36,7 @@
* Base implementation class of FileSystemProvider
*/
-abstract class AbstractFileSystemProvider extends FileSystemProvider {
+public abstract class AbstractFileSystemProvider extends FileSystemProvider {
protected AbstractFileSystemProvider() { }
/**
@@ -107,4 +109,49 @@
public final boolean deleteIfExists(Path file) throws IOException {
return implDelete(file, false);
}
+
+ /**
+ * Tests whether a file is a directory.
+ *
+ * @return {@code true} if the file is a directory; {@code false} if
+ * the file does not exist, is not a directory, or it cannot
+ * be determined if the file is a directory or not.
+ */
+ public boolean isDirectory(Path file) {
+ try {
+ return readAttributes(file, BasicFileAttributes.class).isDirectory();
+ } catch (IOException ioe) {
+ return false;
+ }
+ }
+
+ /**
+ * Tests whether a file is a regular file with opaque content.
+ *
+ * @return {@code true} if the file is a regular file; {@code false} if
+ * the file does not exist, is not a regular file, or it
+ * cannot be determined if the file is a regular file or not.
+ */
+ public boolean isRegularFile(Path file) {
+ try {
+ return readAttributes(file, BasicFileAttributes.class).isRegularFile();
+ } catch (IOException ioe) {
+ return false;
+ }
+ }
+
+ /**
+ * Checks the existence of a file.
+ *
+ * @return {@code true} if the file exists; {@code false} if the file does
+ * not exist or its existence cannot be determined.
+ */
+ public boolean exists(Path file) {
+ try {
+ checkAccess(file);
+ return true;
+ } catch (IOException ioe) {
+ return false;
+ }
+ }
}
--- a/jdk/src/java.base/share/classes/sun/reflect/AccessorGenerator.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,723 +0,0 @@
-/*
- * Copyright (c) 2001, 2013, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-import java.lang.reflect.*;
-import jdk.internal.misc.Unsafe;
-
-/** Shared functionality for all accessor generators */
-
-class AccessorGenerator implements ClassFileConstants {
- static final Unsafe unsafe = Unsafe.getUnsafe();
-
- // Constants because there's no way to say "short integer constant",
- // i.e., "1S"
- protected static final short S0 = (short) 0;
- protected static final short S1 = (short) 1;
- protected static final short S2 = (short) 2;
- protected static final short S3 = (short) 3;
- protected static final short S4 = (short) 4;
- protected static final short S5 = (short) 5;
- protected static final short S6 = (short) 6;
-
- // Instance variables for shared functionality between
- // FieldAccessorGenerator and MethodAccessorGenerator
- protected ClassFileAssembler asm;
- protected int modifiers;
- protected short thisClass;
- protected short superClass;
- protected short targetClass;
- // Common constant pool entries to FieldAccessor and MethodAccessor
- protected short throwableClass;
- protected short classCastClass;
- protected short nullPointerClass;
- protected short illegalArgumentClass;
- protected short invocationTargetClass;
- protected short initIdx;
- protected short initNameAndTypeIdx;
- protected short initStringNameAndTypeIdx;
- protected short nullPointerCtorIdx;
- protected short illegalArgumentCtorIdx;
- protected short illegalArgumentStringCtorIdx;
- protected short invocationTargetCtorIdx;
- protected short superCtorIdx;
- protected short objectClass;
- protected short toStringIdx;
- protected short codeIdx;
- protected short exceptionsIdx;
- // Boxing
- protected short valueOfIdx;
- protected short booleanIdx;
- protected short booleanBoxIdx;
- protected short booleanUnboxIdx;
- protected short byteIdx;
- protected short byteBoxIdx;
- protected short byteUnboxIdx;
- protected short characterIdx;
- protected short characterBoxIdx;
- protected short characterUnboxIdx;
- protected short doubleIdx;
- protected short doubleBoxIdx;
- protected short doubleUnboxIdx;
- protected short floatIdx;
- protected short floatBoxIdx;
- protected short floatUnboxIdx;
- protected short integerIdx;
- protected short integerBoxIdx;
- protected short integerUnboxIdx;
- protected short longIdx;
- protected short longBoxIdx;
- protected short longUnboxIdx;
- protected short shortIdx;
- protected short shortBoxIdx;
- protected short shortUnboxIdx;
-
- protected final short NUM_COMMON_CPOOL_ENTRIES = (short) 30;
- protected final short NUM_BOXING_CPOOL_ENTRIES = (short) 73;
-
- // Requires that superClass has been set up
- protected void emitCommonConstantPoolEntries() {
- // + [UTF-8] "java/lang/Throwable"
- // + [CONSTANT_Class_info] for above
- // + [UTF-8] "java/lang/ClassCastException"
- // + [CONSTANT_Class_info] for above
- // + [UTF-8] "java/lang/NullPointerException"
- // + [CONSTANT_Class_info] for above
- // + [UTF-8] "java/lang/IllegalArgumentException"
- // + [CONSTANT_Class_info] for above
- // + [UTF-8] "java/lang/InvocationTargetException"
- // + [CONSTANT_Class_info] for above
- // + [UTF-8] "<init>"
- // + [UTF-8] "()V"
- // + [CONSTANT_NameAndType_info] for above
- // + [CONSTANT_Methodref_info] for NullPointerException's constructor
- // + [CONSTANT_Methodref_info] for IllegalArgumentException's constructor
- // + [UTF-8] "(Ljava/lang/String;)V"
- // + [CONSTANT_NameAndType_info] for "<init>(Ljava/lang/String;)V"
- // + [CONSTANT_Methodref_info] for IllegalArgumentException's constructor taking a String
- // + [UTF-8] "(Ljava/lang/Throwable;)V"
- // + [CONSTANT_NameAndType_info] for "<init>(Ljava/lang/Throwable;)V"
- // + [CONSTANT_Methodref_info] for InvocationTargetException's constructor
- // + [CONSTANT_Methodref_info] for "super()"
- // + [UTF-8] "java/lang/Object"
- // + [CONSTANT_Class_info] for above
- // + [UTF-8] "toString"
- // + [UTF-8] "()Ljava/lang/String;"
- // + [CONSTANT_NameAndType_info] for "toString()Ljava/lang/String;"
- // + [CONSTANT_Methodref_info] for Object's toString method
- // + [UTF-8] "Code"
- // + [UTF-8] "Exceptions"
- asm.emitConstantPoolUTF8("java/lang/Throwable");
- asm.emitConstantPoolClass(asm.cpi());
- throwableClass = asm.cpi();
- asm.emitConstantPoolUTF8("java/lang/ClassCastException");
- asm.emitConstantPoolClass(asm.cpi());
- classCastClass = asm.cpi();
- asm.emitConstantPoolUTF8("java/lang/NullPointerException");
- asm.emitConstantPoolClass(asm.cpi());
- nullPointerClass = asm.cpi();
- asm.emitConstantPoolUTF8("java/lang/IllegalArgumentException");
- asm.emitConstantPoolClass(asm.cpi());
- illegalArgumentClass = asm.cpi();
- asm.emitConstantPoolUTF8("java/lang/reflect/InvocationTargetException");
- asm.emitConstantPoolClass(asm.cpi());
- invocationTargetClass = asm.cpi();
- asm.emitConstantPoolUTF8("<init>");
- initIdx = asm.cpi();
- asm.emitConstantPoolUTF8("()V");
- asm.emitConstantPoolNameAndType(initIdx, asm.cpi());
- initNameAndTypeIdx = asm.cpi();
- asm.emitConstantPoolMethodref(nullPointerClass, initNameAndTypeIdx);
- nullPointerCtorIdx = asm.cpi();
- asm.emitConstantPoolMethodref(illegalArgumentClass, initNameAndTypeIdx);
- illegalArgumentCtorIdx = asm.cpi();
- asm.emitConstantPoolUTF8("(Ljava/lang/String;)V");
- asm.emitConstantPoolNameAndType(initIdx, asm.cpi());
- initStringNameAndTypeIdx = asm.cpi();
- asm.emitConstantPoolMethodref(illegalArgumentClass, initStringNameAndTypeIdx);
- illegalArgumentStringCtorIdx = asm.cpi();
- asm.emitConstantPoolUTF8("(Ljava/lang/Throwable;)V");
- asm.emitConstantPoolNameAndType(initIdx, asm.cpi());
- asm.emitConstantPoolMethodref(invocationTargetClass, asm.cpi());
- invocationTargetCtorIdx = asm.cpi();
- asm.emitConstantPoolMethodref(superClass, initNameAndTypeIdx);
- superCtorIdx = asm.cpi();
- asm.emitConstantPoolUTF8("java/lang/Object");
- asm.emitConstantPoolClass(asm.cpi());
- objectClass = asm.cpi();
- asm.emitConstantPoolUTF8("toString");
- asm.emitConstantPoolUTF8("()Ljava/lang/String;");
- asm.emitConstantPoolNameAndType(sub(asm.cpi(), S1), asm.cpi());
- asm.emitConstantPoolMethodref(objectClass, asm.cpi());
- toStringIdx = asm.cpi();
- asm.emitConstantPoolUTF8("Code");
- codeIdx = asm.cpi();
- asm.emitConstantPoolUTF8("Exceptions");
- exceptionsIdx = asm.cpi();
- }
-
- /** Constant pool entries required to be able to box/unbox primitive
- types. Note that we don't emit these if we don't need them. */
- protected void emitBoxingContantPoolEntries() {
- // * [UTF-8] "valueOf"
- // * [UTF-8] "java/lang/Boolean"
- // * [CONSTANT_Class_info] for above
- // * [UTF-8] "(Z)Ljava/lang/Boolean;"
- // * [CONSTANT_NameAndType_info] for above
- // * [CONSTANT_Methodref_info] for above
- // * [UTF-8] "booleanValue"
- // * [UTF-8] "()Z"
- // * [CONSTANT_NameAndType_info] for above
- // * [CONSTANT_Methodref_info] for above
- // * [UTF-8] "java/lang/Byte"
- // * [CONSTANT_Class_info] for above
- // * [UTF-8] "(B)Ljava/lang/Byte;"
- // * [CONSTANT_NameAndType_info] for above
- // * [CONSTANT_Methodref_info] for above
- // * [UTF-8] "byteValue"
- // * [UTF-8] "()B"
- // * [CONSTANT_NameAndType_info] for above
- // * [CONSTANT_Methodref_info] for above
- // * [UTF-8] "java/lang/Character"
- // * [CONSTANT_Class_info] for above
- // * [UTF-8] "(C)Ljava/lang/Character;"
- // * [CONSTANT_NameAndType_info] for above
- // * [CONSTANT_Methodref_info] for above
- // * [UTF-8] "charValue"
- // * [UTF-8] "()C"
- // * [CONSTANT_NameAndType_info] for above
- // * [CONSTANT_Methodref_info] for above
- // * [UTF-8] "java/lang/Double"
- // * [CONSTANT_Class_info] for above
- // * [UTF-8] "(D)Ljava/lang/Double;"
- // * [CONSTANT_NameAndType_info] for above
- // * [CONSTANT_Methodref_info] for above
- // * [UTF-8] "doubleValue"
- // * [UTF-8] "()D"
- // * [CONSTANT_NameAndType_info] for above
- // * [CONSTANT_Methodref_info] for above
- // * [UTF-8] "java/lang/Float"
- // * [CONSTANT_Class_info] for above
- // * [UTF-8] "(F)Ljava/lang/Float;"
- // * [CONSTANT_NameAndType_info] for above
- // * [CONSTANT_Methodref_info] for above
- // * [UTF-8] "floatValue"
- // * [UTF-8] "()F"
- // * [CONSTANT_NameAndType_info] for above
- // * [CONSTANT_Methodref_info] for above
- // * [UTF-8] "java/lang/Integer"
- // * [CONSTANT_Class_info] for above
- // * [UTF-8] "(I)Ljava/lang/Integer;"
- // * [CONSTANT_NameAndType_info] for above
- // * [CONSTANT_Methodref_info] for above
- // * [UTF-8] "intValue"
- // * [UTF-8] "()I"
- // * [CONSTANT_NameAndType_info] for above
- // * [CONSTANT_Methodref_info] for above
- // * [UTF-8] "java/lang/Long"
- // * [CONSTANT_Class_info] for above
- // * [UTF-8] "(J)Ljava/lang/Long;"
- // * [CONSTANT_NameAndType_info] for above
- // * [CONSTANT_Methodref_info] for above
- // * [UTF-8] "longValue"
- // * [UTF-8] "()J"
- // * [CONSTANT_NameAndType_info] for above
- // * [CONSTANT_Methodref_info] for above
- // * [UTF-8] "java/lang/Short"
- // * [CONSTANT_Class_info] for above
- // * [UTF-8] "(S)Ljava/lang/Short;"
- // * [CONSTANT_NameAndType_info] for above
- // * [CONSTANT_Methodref_info] for above
- // * [UTF-8] "shortValue"
- // * [UTF-8] "()S"
- // * [CONSTANT_NameAndType_info] for above
- // * [CONSTANT_Methodref_info] for above
-
- // valueOf-method name
- asm.emitConstantPoolUTF8("valueOf");
- valueOfIdx = asm.cpi();
-
- // Boolean
- asm.emitConstantPoolUTF8("java/lang/Boolean");
- asm.emitConstantPoolClass(asm.cpi());
- booleanIdx = asm.cpi();
- asm.emitConstantPoolUTF8("(Z)Ljava/lang/Boolean;");
- asm.emitConstantPoolNameAndType(valueOfIdx, asm.cpi());
- asm.emitConstantPoolMethodref(sub(asm.cpi(), S2), asm.cpi());
- booleanBoxIdx = asm.cpi();
- asm.emitConstantPoolUTF8("booleanValue");
- asm.emitConstantPoolUTF8("()Z");
- asm.emitConstantPoolNameAndType(sub(asm.cpi(), S1), asm.cpi());
- asm.emitConstantPoolMethodref(sub(asm.cpi(), S6), asm.cpi());
- booleanUnboxIdx = asm.cpi();
-
- // Byte
- asm.emitConstantPoolUTF8("java/lang/Byte");
- asm.emitConstantPoolClass(asm.cpi());
- byteIdx = asm.cpi();
- asm.emitConstantPoolUTF8("(B)Ljava/lang/Byte;");
- asm.emitConstantPoolNameAndType(valueOfIdx, asm.cpi());
- asm.emitConstantPoolMethodref(sub(asm.cpi(), S2), asm.cpi());
- byteBoxIdx = asm.cpi();
- asm.emitConstantPoolUTF8("byteValue");
- asm.emitConstantPoolUTF8("()B");
- asm.emitConstantPoolNameAndType(sub(asm.cpi(), S1), asm.cpi());
- asm.emitConstantPoolMethodref(sub(asm.cpi(), S6), asm.cpi());
- byteUnboxIdx = asm.cpi();
-
- // Character
- asm.emitConstantPoolUTF8("java/lang/Character");
- asm.emitConstantPoolClass(asm.cpi());
- characterIdx = asm.cpi();
- asm.emitConstantPoolUTF8("(C)Ljava/lang/Character;");
- asm.emitConstantPoolNameAndType(valueOfIdx, asm.cpi());
- asm.emitConstantPoolMethodref(sub(asm.cpi(), S2), asm.cpi());
- characterBoxIdx = asm.cpi();
- asm.emitConstantPoolUTF8("charValue");
- asm.emitConstantPoolUTF8("()C");
- asm.emitConstantPoolNameAndType(sub(asm.cpi(), S1), asm.cpi());
- asm.emitConstantPoolMethodref(sub(asm.cpi(), S6), asm.cpi());
- characterUnboxIdx = asm.cpi();
-
- // Double
- asm.emitConstantPoolUTF8("java/lang/Double");
- asm.emitConstantPoolClass(asm.cpi());
- doubleIdx = asm.cpi();
- asm.emitConstantPoolUTF8("(D)Ljava/lang/Double;");
- asm.emitConstantPoolNameAndType(valueOfIdx, asm.cpi());
- asm.emitConstantPoolMethodref(sub(asm.cpi(), S2), asm.cpi());
- doubleBoxIdx = asm.cpi();
- asm.emitConstantPoolUTF8("doubleValue");
- asm.emitConstantPoolUTF8("()D");
- asm.emitConstantPoolNameAndType(sub(asm.cpi(), S1), asm.cpi());
- asm.emitConstantPoolMethodref(sub(asm.cpi(), S6), asm.cpi());
- doubleUnboxIdx = asm.cpi();
-
- // Float
- asm.emitConstantPoolUTF8("java/lang/Float");
- asm.emitConstantPoolClass(asm.cpi());
- floatIdx = asm.cpi();
- asm.emitConstantPoolUTF8("(F)Ljava/lang/Float;");
- asm.emitConstantPoolNameAndType(valueOfIdx, asm.cpi());
- asm.emitConstantPoolMethodref(sub(asm.cpi(), S2), asm.cpi());
- floatBoxIdx = asm.cpi();
- asm.emitConstantPoolUTF8("floatValue");
- asm.emitConstantPoolUTF8("()F");
- asm.emitConstantPoolNameAndType(sub(asm.cpi(), S1), asm.cpi());
- asm.emitConstantPoolMethodref(sub(asm.cpi(), S6), asm.cpi());
- floatUnboxIdx = asm.cpi();
-
- // Integer
- asm.emitConstantPoolUTF8("java/lang/Integer");
- asm.emitConstantPoolClass(asm.cpi());
- integerIdx = asm.cpi();
- asm.emitConstantPoolUTF8("(I)Ljava/lang/Integer;");
- asm.emitConstantPoolNameAndType(valueOfIdx, asm.cpi());
- asm.emitConstantPoolMethodref(sub(asm.cpi(), S2), asm.cpi());
- integerBoxIdx = asm.cpi();
- asm.emitConstantPoolUTF8("intValue");
- asm.emitConstantPoolUTF8("()I");
- asm.emitConstantPoolNameAndType(sub(asm.cpi(), S1), asm.cpi());
- asm.emitConstantPoolMethodref(sub(asm.cpi(), S6), asm.cpi());
- integerUnboxIdx = asm.cpi();
-
- // Long
- asm.emitConstantPoolUTF8("java/lang/Long");
- asm.emitConstantPoolClass(asm.cpi());
- longIdx = asm.cpi();
- asm.emitConstantPoolUTF8("(J)Ljava/lang/Long;");
- asm.emitConstantPoolNameAndType(valueOfIdx, asm.cpi());
- asm.emitConstantPoolMethodref(sub(asm.cpi(), S2), asm.cpi());
- longBoxIdx = asm.cpi();
- asm.emitConstantPoolUTF8("longValue");
- asm.emitConstantPoolUTF8("()J");
- asm.emitConstantPoolNameAndType(sub(asm.cpi(), S1), asm.cpi());
- asm.emitConstantPoolMethodref(sub(asm.cpi(), S6), asm.cpi());
- longUnboxIdx = asm.cpi();
-
- // Short
- asm.emitConstantPoolUTF8("java/lang/Short");
- asm.emitConstantPoolClass(asm.cpi());
- shortIdx = asm.cpi();
- asm.emitConstantPoolUTF8("(S)Ljava/lang/Short;");
- asm.emitConstantPoolNameAndType(valueOfIdx, asm.cpi());
- asm.emitConstantPoolMethodref(sub(asm.cpi(), S2), asm.cpi());
- shortBoxIdx = asm.cpi();
- asm.emitConstantPoolUTF8("shortValue");
- asm.emitConstantPoolUTF8("()S");
- asm.emitConstantPoolNameAndType(sub(asm.cpi(), S1), asm.cpi());
- asm.emitConstantPoolMethodref(sub(asm.cpi(), S6), asm.cpi());
- shortUnboxIdx = asm.cpi();
- }
-
- // Necessary because of Java's annoying promotion rules
- protected static short add(short s1, short s2) {
- return (short) (s1 + s2);
- }
-
- protected static short sub(short s1, short s2) {
- return (short) (s1 - s2);
- }
-
- protected boolean isStatic() {
- return Modifier.isStatic(modifiers);
- }
-
- protected boolean isPrivate() {
- return Modifier.isPrivate(modifiers);
- }
-
- /** Returns class name in "internal" form (i.e., '/' separators
- instead of '.') */
- protected static String getClassName
- (Class<?> c, boolean addPrefixAndSuffixForNonPrimitiveTypes)
- {
- if (c.isPrimitive()) {
- if (c == Boolean.TYPE) {
- return "Z";
- } else if (c == Byte.TYPE) {
- return "B";
- } else if (c == Character.TYPE) {
- return "C";
- } else if (c == Double.TYPE) {
- return "D";
- } else if (c == Float.TYPE) {
- return "F";
- } else if (c == Integer.TYPE) {
- return "I";
- } else if (c == Long.TYPE) {
- return "J";
- } else if (c == Short.TYPE) {
- return "S";
- } else if (c == Void.TYPE) {
- return "V";
- }
- throw new InternalError("Should have found primitive type");
- } else if (c.isArray()) {
- return "[" + getClassName(c.getComponentType(), true);
- } else {
- if (addPrefixAndSuffixForNonPrimitiveTypes) {
- return internalize("L" + c.getName() + ";");
- } else {
- return internalize(c.getName());
- }
- }
- }
-
- private static String internalize(String className) {
- return className.replace('.', '/');
- }
-
- protected void emitConstructor() {
- // Generate code into fresh code buffer
- ClassFileAssembler cb = new ClassFileAssembler();
- // 0 incoming arguments
- cb.setMaxLocals(1);
- cb.opc_aload_0();
- cb.opc_invokespecial(superCtorIdx, 0, 0);
- cb.opc_return();
-
- // Emit method
- emitMethod(initIdx, cb.getMaxLocals(), cb, null, null);
- }
-
- // The descriptor's index in the constant pool must be (1 +
- // nameIdx). "numArgs" must indicate ALL arguments, including the
- // implicit "this" argument; double and long arguments each count
- // as 2 in this count. The code buffer must NOT contain the code
- // length. The exception table may be null, but if non-null must
- // NOT contain the exception table's length. The checked exception
- // indices may be null.
- protected void emitMethod(short nameIdx,
- int numArgs,
- ClassFileAssembler code,
- ClassFileAssembler exceptionTable,
- short[] checkedExceptionIndices)
- {
- int codeLen = code.getLength();
- int excLen = 0;
- if (exceptionTable != null) {
- excLen = exceptionTable.getLength();
- if ((excLen % 8) != 0) {
- throw new IllegalArgumentException("Illegal exception table");
- }
- }
- int attrLen = 12 + codeLen + excLen;
- excLen = excLen / 8; // No-op if no exception table
-
- asm.emitShort(ACC_PUBLIC);
- asm.emitShort(nameIdx);
- asm.emitShort(add(nameIdx, S1));
- if (checkedExceptionIndices == null) {
- // Code attribute only
- asm.emitShort(S1);
- } else {
- // Code and Exceptions attributes
- asm.emitShort(S2);
- }
- // Code attribute
- asm.emitShort(codeIdx);
- asm.emitInt(attrLen);
- asm.emitShort(code.getMaxStack());
- asm.emitShort((short) Math.max(numArgs, code.getMaxLocals()));
- asm.emitInt(codeLen);
- asm.append(code);
- asm.emitShort((short) excLen);
- if (exceptionTable != null) {
- asm.append(exceptionTable);
- }
- asm.emitShort(S0); // No additional attributes for Code attribute
- if (checkedExceptionIndices != null) {
- // Exceptions attribute
- asm.emitShort(exceptionsIdx);
- asm.emitInt(2 + 2 * checkedExceptionIndices.length);
- asm.emitShort((short) checkedExceptionIndices.length);
- for (int i = 0; i < checkedExceptionIndices.length; i++) {
- asm.emitShort(checkedExceptionIndices[i]);
- }
- }
- }
-
- protected short indexForPrimitiveType(Class<?> type) {
- if (type == Boolean.TYPE) {
- return booleanIdx;
- } else if (type == Byte.TYPE) {
- return byteIdx;
- } else if (type == Character.TYPE) {
- return characterIdx;
- } else if (type == Double.TYPE) {
- return doubleIdx;
- } else if (type == Float.TYPE) {
- return floatIdx;
- } else if (type == Integer.TYPE) {
- return integerIdx;
- } else if (type == Long.TYPE) {
- return longIdx;
- } else if (type == Short.TYPE) {
- return shortIdx;
- }
- throw new InternalError("Should have found primitive type");
- }
-
- protected short boxingMethodForPrimitiveType(Class<?> type) {
- if (type == Boolean.TYPE) {
- return booleanBoxIdx;
- } else if (type == Byte.TYPE) {
- return byteBoxIdx;
- } else if (type == Character.TYPE) {
- return characterBoxIdx;
- } else if (type == Double.TYPE) {
- return doubleBoxIdx;
- } else if (type == Float.TYPE) {
- return floatBoxIdx;
- } else if (type == Integer.TYPE) {
- return integerBoxIdx;
- } else if (type == Long.TYPE) {
- return longBoxIdx;
- } else if (type == Short.TYPE) {
- return shortBoxIdx;
- }
- throw new InternalError("Should have found primitive type");
- }
-
- /** Returns true for widening or identity conversions for primitive
- types only */
- protected static boolean canWidenTo(Class<?> type, Class<?> otherType) {
- if (!type.isPrimitive()) {
- return false;
- }
-
- // Widening conversions (from JVM spec):
- // byte to short, int, long, float, or double
- // short to int, long, float, or double
- // char to int, long, float, or double
- // int to long, float, or double
- // long to float or double
- // float to double
-
- if (type == Boolean.TYPE) {
- if (otherType == Boolean.TYPE) {
- return true;
- }
- } else if (type == Byte.TYPE) {
- if ( otherType == Byte.TYPE
- || otherType == Short.TYPE
- || otherType == Integer.TYPE
- || otherType == Long.TYPE
- || otherType == Float.TYPE
- || otherType == Double.TYPE) {
- return true;
- }
- } else if (type == Short.TYPE) {
- if ( otherType == Short.TYPE
- || otherType == Integer.TYPE
- || otherType == Long.TYPE
- || otherType == Float.TYPE
- || otherType == Double.TYPE) {
- return true;
- }
- } else if (type == Character.TYPE) {
- if ( otherType == Character.TYPE
- || otherType == Integer.TYPE
- || otherType == Long.TYPE
- || otherType == Float.TYPE
- || otherType == Double.TYPE) {
- return true;
- }
- } else if (type == Integer.TYPE) {
- if ( otherType == Integer.TYPE
- || otherType == Long.TYPE
- || otherType == Float.TYPE
- || otherType == Double.TYPE) {
- return true;
- }
- } else if (type == Long.TYPE) {
- if ( otherType == Long.TYPE
- || otherType == Float.TYPE
- || otherType == Double.TYPE) {
- return true;
- }
- } else if (type == Float.TYPE) {
- if ( otherType == Float.TYPE
- || otherType == Double.TYPE) {
- return true;
- }
- } else if (type == Double.TYPE) {
- if (otherType == Double.TYPE) {
- return true;
- }
- }
-
- return false;
- }
-
- /** Emits the widening bytecode for the given primitive conversion
- (or none if the identity conversion). Requires that a primitive
- conversion exists; i.e., canWidenTo must have already been
- called and returned true. */
- protected static void emitWideningBytecodeForPrimitiveConversion
- (ClassFileAssembler cb,
- Class<?> fromType,
- Class<?> toType)
- {
- // Note that widening conversions for integral types (i.e., "b2s",
- // "s2i") are no-ops since values on the Java stack are
- // sign-extended.
-
- // Widening conversions (from JVM spec):
- // byte to short, int, long, float, or double
- // short to int, long, float, or double
- // char to int, long, float, or double
- // int to long, float, or double
- // long to float or double
- // float to double
-
- if ( fromType == Byte.TYPE
- || fromType == Short.TYPE
- || fromType == Character.TYPE
- || fromType == Integer.TYPE) {
- if (toType == Long.TYPE) {
- cb.opc_i2l();
- } else if (toType == Float.TYPE) {
- cb.opc_i2f();
- } else if (toType == Double.TYPE) {
- cb.opc_i2d();
- }
- } else if (fromType == Long.TYPE) {
- if (toType == Float.TYPE) {
- cb.opc_l2f();
- } else if (toType == Double.TYPE) {
- cb.opc_l2d();
- }
- } else if (fromType == Float.TYPE) {
- if (toType == Double.TYPE) {
- cb.opc_f2d();
- }
- }
-
- // Otherwise, was identity or no-op conversion. Fall through.
- }
-
- protected short unboxingMethodForPrimitiveType(Class<?> primType) {
- if (primType == Boolean.TYPE) {
- return booleanUnboxIdx;
- } else if (primType == Byte.TYPE) {
- return byteUnboxIdx;
- } else if (primType == Character.TYPE) {
- return characterUnboxIdx;
- } else if (primType == Short.TYPE) {
- return shortUnboxIdx;
- } else if (primType == Integer.TYPE) {
- return integerUnboxIdx;
- } else if (primType == Long.TYPE) {
- return longUnboxIdx;
- } else if (primType == Float.TYPE) {
- return floatUnboxIdx;
- } else if (primType == Double.TYPE) {
- return doubleUnboxIdx;
- }
- throw new InternalError("Illegal primitive type " + primType.getName());
- }
-
- protected static final Class<?>[] primitiveTypes = new Class<?>[] {
- Boolean.TYPE,
- Byte.TYPE,
- Character.TYPE,
- Short.TYPE,
- Integer.TYPE,
- Long.TYPE,
- Float.TYPE,
- Double.TYPE
- };
-
- /** We don't consider "Void" to be a primitive type */
- protected static boolean isPrimitive(Class<?> c) {
- return (c.isPrimitive() && c != Void.TYPE);
- }
-
- protected int typeSizeInStackSlots(Class<?> c) {
- if (c == Void.TYPE) {
- return 0;
- }
- if (c == Long.TYPE || c == Double.TYPE) {
- return 2;
- }
- return 1;
- }
-
- private ClassFileAssembler illegalArgumentCodeBuffer;
- protected ClassFileAssembler illegalArgumentCodeBuffer() {
- if (illegalArgumentCodeBuffer == null) {
- illegalArgumentCodeBuffer = new ClassFileAssembler();
- illegalArgumentCodeBuffer.opc_new(illegalArgumentClass);
- illegalArgumentCodeBuffer.opc_dup();
- illegalArgumentCodeBuffer.opc_invokespecial(illegalArgumentCtorIdx, 0, 0);
- illegalArgumentCodeBuffer.opc_athrow();
- }
-
- return illegalArgumentCodeBuffer;
- }
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/BootstrapConstructorAccessorImpl.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 2001, 2011, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Constructor;
-
-/** Uses Unsafe.allocateObject() to instantiate classes; only used for
- bootstrapping. */
-
-class BootstrapConstructorAccessorImpl extends ConstructorAccessorImpl {
- private final Constructor<?> constructor;
-
- BootstrapConstructorAccessorImpl(Constructor<?> c) {
- this.constructor = c;
- }
-
- public Object newInstance(Object[] args)
- throws IllegalArgumentException, InvocationTargetException
- {
- try {
- return UnsafeFieldAccessorImpl.unsafe.
- allocateInstance(constructor.getDeclaringClass());
- } catch (InstantiationException e) {
- throw new InvocationTargetException(e);
- }
- }
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/ByteVector.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2001, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-/** A growable array of bytes. */
-
-interface ByteVector {
- public int getLength();
- public byte get(int index);
- public void put(int index, byte value);
- public void add(byte value);
- public void trim();
- public byte[] getData();
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/ByteVectorFactory.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2001, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-class ByteVectorFactory {
- static ByteVector create() {
- return new ByteVectorImpl();
- }
-
- static ByteVector create(int sz) {
- return new ByteVectorImpl(sz);
- }
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/ByteVectorImpl.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,88 +0,0 @@
-/*
- * Copyright (c) 2001, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-class ByteVectorImpl implements ByteVector {
- private byte[] data;
- private int pos;
-
- public ByteVectorImpl() {
- this(100);
- }
-
- public ByteVectorImpl(int sz) {
- data = new byte[sz];
- pos = -1;
- }
-
- public int getLength() {
- return pos + 1;
- }
-
- public byte get(int index) {
- if (index >= data.length) {
- resize(index);
- pos = index;
- }
- return data[index];
- }
-
- public void put(int index, byte value) {
- if (index >= data.length) {
- resize(index);
- pos = index;
- }
- data[index] = value;
- }
-
- public void add(byte value) {
- if (++pos >= data.length) {
- resize(pos);
- }
- data[pos] = value;
- }
-
- public void trim() {
- if (pos != data.length - 1) {
- byte[] newData = new byte[pos + 1];
- System.arraycopy(data, 0, newData, 0, pos + 1);
- data = newData;
- }
- }
-
- public byte[] getData() {
- return data;
- }
-
- private void resize(int minSize) {
- if (minSize <= 2 * data.length) {
- minSize = 2 * data.length;
- }
- byte[] newData = new byte[minSize];
- System.arraycopy(data, 0, newData, 0, data.length);
- data = newData;
- }
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/CallerSensitive.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2013, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-import java.lang.annotation.*;
-import static java.lang.annotation.ElementType.*;
-
-/**
- * A method annotated @CallerSensitive is sensitive to its calling class,
- * via {@link sun.reflect.Reflection#getCallerClass Reflection.getCallerClass},
- * or via some equivalent.
- *
- * @author John R. Rose
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target({METHOD})
-public @interface CallerSensitive {
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/ClassDefiner.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,74 +0,0 @@
-/*
- * Copyright (c) 2001, 2011, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import jdk.internal.misc.Unsafe;
-
-/** Utility class which assists in calling Unsafe.defineClass() by
- creating a new class loader which delegates to the one needed in
- order for proper resolution of the given bytecodes to occur. */
-
-class ClassDefiner {
- static final Unsafe unsafe = Unsafe.getUnsafe();
-
- /** <P> We define generated code into a new class loader which
- delegates to the defining loader of the target class. It is
- necessary for the VM to be able to resolve references to the
- target class from the generated bytecodes, which could not occur
- if the generated code was loaded into the bootstrap class
- loader. </P>
-
- <P> There are two primary reasons for creating a new loader
- instead of defining these bytecodes directly into the defining
- loader of the target class: first, it avoids any possible
- security risk of having these bytecodes in the same loader.
- Second, it allows the generated bytecodes to be unloaded earlier
- than would otherwise be possible, decreasing run-time
- footprint. </P>
- */
- static Class<?> defineClass(String name, byte[] bytes, int off, int len,
- final ClassLoader parentClassLoader)
- {
- ClassLoader newLoader = AccessController.doPrivileged(
- new PrivilegedAction<ClassLoader>() {
- public ClassLoader run() {
- return new DelegatingClassLoader(parentClassLoader);
- }
- });
- return unsafe.defineClass(name, bytes, off, len, newLoader, null);
- }
-}
-
-
-// NOTE: this class's name and presence are known to the virtual
-// machine as of the fix for 4474172.
-class DelegatingClassLoader extends ClassLoader {
- DelegatingClassLoader(ClassLoader parent) {
- super(parent);
- }
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/ClassFileAssembler.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,671 +0,0 @@
-/*
- * Copyright (c) 2001, 2004, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-class ClassFileAssembler implements ClassFileConstants {
- private ByteVector vec;
- private short cpIdx = 0;
-
- public ClassFileAssembler() {
- this(ByteVectorFactory.create());
- }
-
- public ClassFileAssembler(ByteVector vec) {
- this.vec = vec;
- }
-
- public ByteVector getData() {
- return vec;
- }
-
- /** Length in bytes */
- public short getLength() {
- return (short) vec.getLength();
- }
-
- public void emitMagicAndVersion() {
- emitInt(0xCAFEBABE);
- emitShort((short) 0);
- emitShort((short) 49);
- }
-
- public void emitInt(int val) {
- emitByte((byte) (val >> 24));
- emitByte((byte) ((val >> 16) & 0xFF));
- emitByte((byte) ((val >> 8) & 0xFF));
- emitByte((byte) (val & 0xFF));
- }
-
- public void emitShort(short val) {
- emitByte((byte) ((val >> 8) & 0xFF));
- emitByte((byte) (val & 0xFF));
- }
-
- // Support for labels; package-private
- void emitShort(short bci, short val) {
- vec.put(bci, (byte) ((val >> 8) & 0xFF));
- vec.put(bci + 1, (byte) (val & 0xFF));
- }
-
- public void emitByte(byte val) {
- vec.add(val);
- }
-
- public void append(ClassFileAssembler asm) {
- append(asm.vec);
- }
-
- public void append(ByteVector vec) {
- for (int i = 0; i < vec.getLength(); i++) {
- emitByte(vec.get(i));
- }
- }
-
- /** Keeps track of the current (one-based) constant pool index;
- incremented after emitting one of the following constant pool
- entries. Can fetch the current constant pool index for use in
- later entries. Index points at the last valid constant pool
- entry; initially invalid. It is illegal to fetch the constant
- pool index before emitting at least one constant pool entry. */
- public short cpi() {
- if (cpIdx == 0) {
- throw new RuntimeException("Illegal use of ClassFileAssembler");
- }
- return cpIdx;
- }
-
- public void emitConstantPoolUTF8(String str) {
- // NOTE: can not use str.getBytes("UTF-8") here because of
- // bootstrapping issues with the character set converters.
- byte[] bytes = UTF8.encode(str);
- emitByte(CONSTANT_Utf8);
- emitShort((short) bytes.length);
- for (int i = 0; i < bytes.length; i++) {
- emitByte(bytes[i]);
- }
- cpIdx++;
- }
-
- public void emitConstantPoolClass(short index) {
- emitByte(CONSTANT_Class);
- emitShort(index);
- cpIdx++;
- }
-
- public void emitConstantPoolNameAndType(short nameIndex, short typeIndex) {
- emitByte(CONSTANT_NameAndType);
- emitShort(nameIndex);
- emitShort(typeIndex);
- cpIdx++;
- }
-
- public void emitConstantPoolFieldref
- (short classIndex, short nameAndTypeIndex)
- {
- emitByte(CONSTANT_Fieldref);
- emitShort(classIndex);
- emitShort(nameAndTypeIndex);
- cpIdx++;
- }
-
- public void emitConstantPoolMethodref
- (short classIndex, short nameAndTypeIndex)
- {
- emitByte(CONSTANT_Methodref);
- emitShort(classIndex);
- emitShort(nameAndTypeIndex);
- cpIdx++;
- }
-
- public void emitConstantPoolInterfaceMethodref
- (short classIndex, short nameAndTypeIndex)
- {
- emitByte(CONSTANT_InterfaceMethodref);
- emitShort(classIndex);
- emitShort(nameAndTypeIndex);
- cpIdx++;
- }
-
- public void emitConstantPoolString(short utf8Index) {
- emitByte(CONSTANT_String);
- emitShort(utf8Index);
- cpIdx++;
- }
-
- //----------------------------------------------------------------------
- // Opcodes. Keeps track of maximum stack and locals. Make a new
- // assembler for each piece of assembled code, then append the
- // result to the previous assembler's class file.
- //
-
- private int stack = 0;
- private int maxStack = 0;
- private int maxLocals = 0;
-
- private void incStack() {
- setStack(stack + 1);
- }
-
- private void decStack() {
- --stack;
- }
-
- public short getMaxStack() {
- return (short) maxStack;
- }
-
- public short getMaxLocals() {
- return (short) maxLocals;
- }
-
- /** It's necessary to be able to specify the number of arguments at
- the beginning of the method (which translates to the initial
- value of max locals) */
- public void setMaxLocals(int maxLocals) {
- this.maxLocals = maxLocals;
- }
-
- /** Needed to do flow control. Returns current stack depth. */
- public int getStack() {
- return stack;
- }
-
- /** Needed to do flow control. */
- public void setStack(int value) {
- stack = value;
- if (stack > maxStack) {
- maxStack = stack;
- }
- }
-
- ///////////////
- // Constants //
- ///////////////
-
- public void opc_aconst_null() {
- emitByte(opc_aconst_null);
- incStack();
- }
-
- public void opc_sipush(short constant) {
- emitByte(opc_sipush);
- emitShort(constant);
- incStack();
- }
-
- public void opc_ldc(byte cpIdx) {
- emitByte(opc_ldc);
- emitByte(cpIdx);
- incStack();
- }
-
- /////////////////////////////////////
- // Local variable loads and stores //
- /////////////////////////////////////
-
- public void opc_iload_0() {
- emitByte(opc_iload_0);
- if (maxLocals < 1) maxLocals = 1;
- incStack();
- }
-
- public void opc_iload_1() {
- emitByte(opc_iload_1);
- if (maxLocals < 2) maxLocals = 2;
- incStack();
- }
-
- public void opc_iload_2() {
- emitByte(opc_iload_2);
- if (maxLocals < 3) maxLocals = 3;
- incStack();
- }
-
- public void opc_iload_3() {
- emitByte(opc_iload_3);
- if (maxLocals < 4) maxLocals = 4;
- incStack();
- }
-
- public void opc_lload_0() {
- emitByte(opc_lload_0);
- if (maxLocals < 2) maxLocals = 2;
- incStack();
- incStack();
- }
-
- public void opc_lload_1() {
- emitByte(opc_lload_1);
- if (maxLocals < 3) maxLocals = 3;
- incStack();
- incStack();
- }
-
- public void opc_lload_2() {
- emitByte(opc_lload_2);
- if (maxLocals < 4) maxLocals = 4;
- incStack();
- incStack();
- }
-
- public void opc_lload_3() {
- emitByte(opc_lload_3);
- if (maxLocals < 5) maxLocals = 5;
- incStack();
- incStack();
- }
-
- public void opc_fload_0() {
- emitByte(opc_fload_0);
- if (maxLocals < 1) maxLocals = 1;
- incStack();
- }
-
- public void opc_fload_1() {
- emitByte(opc_fload_1);
- if (maxLocals < 2) maxLocals = 2;
- incStack();
- }
-
- public void opc_fload_2() {
- emitByte(opc_fload_2);
- if (maxLocals < 3) maxLocals = 3;
- incStack();
- }
-
- public void opc_fload_3() {
- emitByte(opc_fload_3);
- if (maxLocals < 4) maxLocals = 4;
- incStack();
- }
-
- public void opc_dload_0() {
- emitByte(opc_dload_0);
- if (maxLocals < 2) maxLocals = 2;
- incStack();
- incStack();
- }
-
- public void opc_dload_1() {
- emitByte(opc_dload_1);
- if (maxLocals < 3) maxLocals = 3;
- incStack();
- incStack();
- }
-
- public void opc_dload_2() {
- emitByte(opc_dload_2);
- if (maxLocals < 4) maxLocals = 4;
- incStack();
- incStack();
- }
-
- public void opc_dload_3() {
- emitByte(opc_dload_3);
- if (maxLocals < 5) maxLocals = 5;
- incStack();
- incStack();
- }
-
- public void opc_aload_0() {
- emitByte(opc_aload_0);
- if (maxLocals < 1) maxLocals = 1;
- incStack();
- }
-
- public void opc_aload_1() {
- emitByte(opc_aload_1);
- if (maxLocals < 2) maxLocals = 2;
- incStack();
- }
-
- public void opc_aload_2() {
- emitByte(opc_aload_2);
- if (maxLocals < 3) maxLocals = 3;
- incStack();
- }
-
- public void opc_aload_3() {
- emitByte(opc_aload_3);
- if (maxLocals < 4) maxLocals = 4;
- incStack();
- }
-
- public void opc_aaload() {
- emitByte(opc_aaload);
- decStack();
- }
-
- public void opc_astore_0() {
- emitByte(opc_astore_0);
- if (maxLocals < 1) maxLocals = 1;
- decStack();
- }
-
- public void opc_astore_1() {
- emitByte(opc_astore_1);
- if (maxLocals < 2) maxLocals = 2;
- decStack();
- }
-
- public void opc_astore_2() {
- emitByte(opc_astore_2);
- if (maxLocals < 3) maxLocals = 3;
- decStack();
- }
-
- public void opc_astore_3() {
- emitByte(opc_astore_3);
- if (maxLocals < 4) maxLocals = 4;
- decStack();
- }
-
- ////////////////////////
- // Stack manipulation //
- ////////////////////////
-
- public void opc_pop() {
- emitByte(opc_pop);
- decStack();
- }
-
- public void opc_dup() {
- emitByte(opc_dup);
- incStack();
- }
-
- public void opc_dup_x1() {
- emitByte(opc_dup_x1);
- incStack();
- }
-
- public void opc_swap() {
- emitByte(opc_swap);
- }
-
- ///////////////////////////////
- // Widening conversions only //
- ///////////////////////////////
-
- public void opc_i2l() {
- emitByte(opc_i2l);
- }
-
- public void opc_i2f() {
- emitByte(opc_i2f);
- }
-
- public void opc_i2d() {
- emitByte(opc_i2d);
- }
-
- public void opc_l2f() {
- emitByte(opc_l2f);
- }
-
- public void opc_l2d() {
- emitByte(opc_l2d);
- }
-
- public void opc_f2d() {
- emitByte(opc_f2d);
- }
-
- //////////////////
- // Control flow //
- //////////////////
-
- public void opc_ifeq(short bciOffset) {
- emitByte(opc_ifeq);
- emitShort(bciOffset);
- decStack();
- }
-
- /** Control flow with forward-reference BCI. Stack assumes
- straight-through control flow. */
- public void opc_ifeq(Label l) {
- short instrBCI = getLength();
- emitByte(opc_ifeq);
- l.add(this, instrBCI, getLength(), getStack() - 1);
- emitShort((short) -1); // Must be patched later
- }
-
- public void opc_if_icmpeq(short bciOffset) {
- emitByte(opc_if_icmpeq);
- emitShort(bciOffset);
- setStack(getStack() - 2);
- }
-
- /** Control flow with forward-reference BCI. Stack assumes straight
- control flow. */
- public void opc_if_icmpeq(Label l) {
- short instrBCI = getLength();
- emitByte(opc_if_icmpeq);
- l.add(this, instrBCI, getLength(), getStack() - 2);
- emitShort((short) -1); // Must be patched later
- }
-
- public void opc_goto(short bciOffset) {
- emitByte(opc_goto);
- emitShort(bciOffset);
- }
-
- /** Control flow with forward-reference BCI. Stack assumes straight
- control flow. */
- public void opc_goto(Label l) {
- short instrBCI = getLength();
- emitByte(opc_goto);
- l.add(this, instrBCI, getLength(), getStack());
- emitShort((short) -1); // Must be patched later
- }
-
- public void opc_ifnull(short bciOffset) {
- emitByte(opc_ifnull);
- emitShort(bciOffset);
- decStack();
- }
-
- /** Control flow with forward-reference BCI. Stack assumes straight
- control flow. */
- public void opc_ifnull(Label l) {
- short instrBCI = getLength();
- emitByte(opc_ifnull);
- l.add(this, instrBCI, getLength(), getStack() - 1);
- emitShort((short) -1); // Must be patched later
- decStack();
- }
-
- public void opc_ifnonnull(short bciOffset) {
- emitByte(opc_ifnonnull);
- emitShort(bciOffset);
- decStack();
- }
-
- /** Control flow with forward-reference BCI. Stack assumes straight
- control flow. */
- public void opc_ifnonnull(Label l) {
- short instrBCI = getLength();
- emitByte(opc_ifnonnull);
- l.add(this, instrBCI, getLength(), getStack() - 1);
- emitShort((short) -1); // Must be patched later
- decStack();
- }
-
- /////////////////////////
- // Return instructions //
- /////////////////////////
-
- public void opc_ireturn() {
- emitByte(opc_ireturn);
- setStack(0);
- }
-
- public void opc_lreturn() {
- emitByte(opc_lreturn);
- setStack(0);
- }
-
- public void opc_freturn() {
- emitByte(opc_freturn);
- setStack(0);
- }
-
- public void opc_dreturn() {
- emitByte(opc_dreturn);
- setStack(0);
- }
-
- public void opc_areturn() {
- emitByte(opc_areturn);
- setStack(0);
- }
-
- public void opc_return() {
- emitByte(opc_return);
- setStack(0);
- }
-
- //////////////////////
- // Field operations //
- //////////////////////
-
- public void opc_getstatic(short fieldIndex, int fieldSizeInStackSlots) {
- emitByte(opc_getstatic);
- emitShort(fieldIndex);
- setStack(getStack() + fieldSizeInStackSlots);
- }
-
- public void opc_putstatic(short fieldIndex, int fieldSizeInStackSlots) {
- emitByte(opc_putstatic);
- emitShort(fieldIndex);
- setStack(getStack() - fieldSizeInStackSlots);
- }
-
- public void opc_getfield(short fieldIndex, int fieldSizeInStackSlots) {
- emitByte(opc_getfield);
- emitShort(fieldIndex);
- setStack(getStack() + fieldSizeInStackSlots - 1);
- }
-
- public void opc_putfield(short fieldIndex, int fieldSizeInStackSlots) {
- emitByte(opc_putfield);
- emitShort(fieldIndex);
- setStack(getStack() - fieldSizeInStackSlots - 1);
- }
-
- ////////////////////////
- // Method invocations //
- ////////////////////////
-
- /** Long and double arguments and return types count as 2 arguments;
- other values count as 1. */
- public void opc_invokevirtual(short methodIndex,
- int numArgs,
- int numReturnValues)
- {
- emitByte(opc_invokevirtual);
- emitShort(methodIndex);
- setStack(getStack() - numArgs - 1 + numReturnValues);
- }
-
- /** Long and double arguments and return types count as 2 arguments;
- other values count as 1. */
- public void opc_invokespecial(short methodIndex,
- int numArgs,
- int numReturnValues)
- {
- emitByte(opc_invokespecial);
- emitShort(methodIndex);
- setStack(getStack() - numArgs - 1 + numReturnValues);
- }
-
- /** Long and double arguments and return types count as 2 arguments;
- other values count as 1. */
- public void opc_invokestatic(short methodIndex,
- int numArgs,
- int numReturnValues)
- {
- emitByte(opc_invokestatic);
- emitShort(methodIndex);
- setStack(getStack() - numArgs + numReturnValues);
- }
-
- /** Long and double arguments and return types count as 2 arguments;
- other values count as 1. */
- public void opc_invokeinterface(short methodIndex,
- int numArgs,
- byte count,
- int numReturnValues)
- {
- emitByte(opc_invokeinterface);
- emitShort(methodIndex);
- emitByte(count);
- emitByte((byte) 0);
- setStack(getStack() - numArgs - 1 + numReturnValues);
- }
-
- //////////////////
- // Array length //
- //////////////////
-
- public void opc_arraylength() {
- emitByte(opc_arraylength);
- }
-
- /////////
- // New //
- /////////
-
- public void opc_new(short classIndex) {
- emitByte(opc_new);
- emitShort(classIndex);
- incStack();
- }
-
- ////////////
- // Athrow //
- ////////////
-
- public void opc_athrow() {
- emitByte(opc_athrow);
- setStack(1);
- }
-
- //////////////////////////////
- // Checkcast and instanceof //
- //////////////////////////////
-
- /** Assumes the checkcast succeeds */
- public void opc_checkcast(short classIndex) {
- emitByte(opc_checkcast);
- emitShort(classIndex);
- }
-
- public void opc_instanceof(short classIndex) {
- emitByte(opc_instanceof);
- emitShort(classIndex);
- }
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/ClassFileConstants.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,140 +0,0 @@
-/*
- * Copyright (c) 2001, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-/** Minimal set of class file constants for assembly of field and
- method accessors. */
-
-interface ClassFileConstants {
- // Constants
- public static final byte opc_aconst_null = (byte) 0x1;
- public static final byte opc_sipush = (byte) 0x11;
- public static final byte opc_ldc = (byte) 0x12;
-
- // Local variable loads and stores
- public static final byte opc_iload_0 = (byte) 0x1a;
- public static final byte opc_iload_1 = (byte) 0x1b;
- public static final byte opc_iload_2 = (byte) 0x1c;
- public static final byte opc_iload_3 = (byte) 0x1d;
- public static final byte opc_lload_0 = (byte) 0x1e;
- public static final byte opc_lload_1 = (byte) 0x1f;
- public static final byte opc_lload_2 = (byte) 0x20;
- public static final byte opc_lload_3 = (byte) 0x21;
- public static final byte opc_fload_0 = (byte) 0x22;
- public static final byte opc_fload_1 = (byte) 0x23;
- public static final byte opc_fload_2 = (byte) 0x24;
- public static final byte opc_fload_3 = (byte) 0x25;
- public static final byte opc_dload_0 = (byte) 0x26;
- public static final byte opc_dload_1 = (byte) 0x27;
- public static final byte opc_dload_2 = (byte) 0x28;
- public static final byte opc_dload_3 = (byte) 0x29;
- public static final byte opc_aload_0 = (byte) 0x2a;
- public static final byte opc_aload_1 = (byte) 0x2b;
- public static final byte opc_aload_2 = (byte) 0x2c;
- public static final byte opc_aload_3 = (byte) 0x2d;
- public static final byte opc_aaload = (byte) 0x32;
- public static final byte opc_astore_0 = (byte) 0x4b;
- public static final byte opc_astore_1 = (byte) 0x4c;
- public static final byte opc_astore_2 = (byte) 0x4d;
- public static final byte opc_astore_3 = (byte) 0x4e;
-
- // Stack manipulation
- public static final byte opc_pop = (byte) 0x57;
- public static final byte opc_dup = (byte) 0x59;
- public static final byte opc_dup_x1 = (byte) 0x5a;
- public static final byte opc_swap = (byte) 0x5f;
-
- // Conversions
- public static final byte opc_i2l = (byte) 0x85;
- public static final byte opc_i2f = (byte) 0x86;
- public static final byte opc_i2d = (byte) 0x87;
- public static final byte opc_l2i = (byte) 0x88;
- public static final byte opc_l2f = (byte) 0x89;
- public static final byte opc_l2d = (byte) 0x8a;
- public static final byte opc_f2i = (byte) 0x8b;
- public static final byte opc_f2l = (byte) 0x8c;
- public static final byte opc_f2d = (byte) 0x8d;
- public static final byte opc_d2i = (byte) 0x8e;
- public static final byte opc_d2l = (byte) 0x8f;
- public static final byte opc_d2f = (byte) 0x90;
- public static final byte opc_i2b = (byte) 0x91;
- public static final byte opc_i2c = (byte) 0x92;
- public static final byte opc_i2s = (byte) 0x93;
-
- // Control flow
- public static final byte opc_ifeq = (byte) 0x99;
- public static final byte opc_if_icmpeq = (byte) 0x9f;
- public static final byte opc_goto = (byte) 0xa7;
-
- // Return instructions
- public static final byte opc_ireturn = (byte) 0xac;
- public static final byte opc_lreturn = (byte) 0xad;
- public static final byte opc_freturn = (byte) 0xae;
- public static final byte opc_dreturn = (byte) 0xaf;
- public static final byte opc_areturn = (byte) 0xb0;
- public static final byte opc_return = (byte) 0xb1;
-
- // Field operations
- public static final byte opc_getstatic = (byte) 0xb2;
- public static final byte opc_putstatic = (byte) 0xb3;
- public static final byte opc_getfield = (byte) 0xb4;
- public static final byte opc_putfield = (byte) 0xb5;
-
- // Method invocations
- public static final byte opc_invokevirtual = (byte) 0xb6;
- public static final byte opc_invokespecial = (byte) 0xb7;
- public static final byte opc_invokestatic = (byte) 0xb8;
- public static final byte opc_invokeinterface = (byte) 0xb9;
-
- // Array length
- public static final byte opc_arraylength = (byte) 0xbe;
-
- // New
- public static final byte opc_new = (byte) 0xbb;
-
- // Athrow
- public static final byte opc_athrow = (byte) 0xbf;
-
- // Checkcast and instanceof
- public static final byte opc_checkcast = (byte) 0xc0;
- public static final byte opc_instanceof = (byte) 0xc1;
-
- // Ifnull and ifnonnull
- public static final byte opc_ifnull = (byte) 0xc6;
- public static final byte opc_ifnonnull = (byte) 0xc7;
-
- // Constant pool tags
- public static final byte CONSTANT_Class = (byte) 7;
- public static final byte CONSTANT_Fieldref = (byte) 9;
- public static final byte CONSTANT_Methodref = (byte) 10;
- public static final byte CONSTANT_InterfaceMethodref = (byte) 11;
- public static final byte CONSTANT_NameAndType = (byte) 12;
- public static final byte CONSTANT_String = (byte) 8;
- public static final byte CONSTANT_Utf8 = (byte) 1;
-
- // Access flags
- public static final short ACC_PUBLIC = (short) 0x0001;
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/ConstantPool.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,131 +0,0 @@
-/*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-import java.lang.reflect.*;
-
-/** Provides reflective access to the constant pools of classes.
- Currently this is needed to provide reflective access to annotations
- but may be used by other internal subsystems in the future. */
-
-public class ConstantPool {
- // Number of entries in this constant pool (= maximum valid constant pool index)
- public int getSize() { return getSize0 (constantPoolOop); }
- public Class<?> getClassAt (int index) { return getClassAt0 (constantPoolOop, index); }
- public Class<?> getClassAtIfLoaded (int index) { return getClassAtIfLoaded0 (constantPoolOop, index); }
- // Returns a class reference index for a method or a field.
- public int getClassRefIndexAt(int index) {
- return getClassRefIndexAt0(constantPoolOop, index);
- }
- // Returns either a Method or Constructor.
- // Static initializers are returned as Method objects.
- public Member getMethodAt (int index) { return getMethodAt0 (constantPoolOop, index); }
- public Member getMethodAtIfLoaded(int index) { return getMethodAtIfLoaded0(constantPoolOop, index); }
- public Field getFieldAt (int index) { return getFieldAt0 (constantPoolOop, index); }
- public Field getFieldAtIfLoaded (int index) { return getFieldAtIfLoaded0 (constantPoolOop, index); }
- // Fetches the class name, member (field, method or interface
- // method) name, and type descriptor as an array of three Strings
- public String[] getMemberRefInfoAt (int index) { return getMemberRefInfoAt0 (constantPoolOop, index); }
- // Returns a name and type reference index for a method, a field or an invokedynamic.
- public int getNameAndTypeRefIndexAt(int index) {
- return getNameAndTypeRefIndexAt0(constantPoolOop, index);
- }
- // Fetches the name and type from name_and_type index as an array of two Strings
- public String[] getNameAndTypeRefInfoAt(int index) {
- return getNameAndTypeRefInfoAt0(constantPoolOop, index);
- }
- public int getIntAt (int index) { return getIntAt0 (constantPoolOop, index); }
- public long getLongAt (int index) { return getLongAt0 (constantPoolOop, index); }
- public float getFloatAt (int index) { return getFloatAt0 (constantPoolOop, index); }
- public double getDoubleAt (int index) { return getDoubleAt0 (constantPoolOop, index); }
- public String getStringAt (int index) { return getStringAt0 (constantPoolOop, index); }
- public String getUTF8At (int index) { return getUTF8At0 (constantPoolOop, index); }
- public Tag getTagAt(int index) {
- return Tag.valueOf(getTagAt0(constantPoolOop, index));
- }
-
- public static enum Tag {
- UTF8(1),
- INTEGER(3),
- FLOAT(4),
- LONG(5),
- DOUBLE(6),
- CLASS(7),
- STRING(8),
- FIELDREF(9),
- METHODREF(10),
- INTERFACEMETHODREF(11),
- NAMEANDTYPE(12),
- METHODHANDLE(15),
- METHODTYPE(16),
- INVOKEDYNAMIC(18),
- INVALID(0);
-
- private final int tagCode;
-
- private Tag(int tagCode) {
- this.tagCode = tagCode;
- }
-
- private static Tag valueOf(byte v) {
- for (Tag tag : Tag.values()) {
- if (tag.tagCode == v) {
- return tag;
- }
- }
- throw new IllegalArgumentException("Unknown constant pool tag code " + v);
- }
- }
- //---------------------------------------------------------------------------
- // Internals only below this point
- //
-
- static {
- Reflection.registerFieldsToFilter(ConstantPool.class, new String[] { "constantPoolOop" });
- }
-
- // HotSpot-internal constant pool object (set by the VM, name known to the VM)
- private Object constantPoolOop;
-
- private native int getSize0 (Object constantPoolOop);
- private native Class<?> getClassAt0 (Object constantPoolOop, int index);
- private native Class<?> getClassAtIfLoaded0 (Object constantPoolOop, int index);
- private native int getClassRefIndexAt0 (Object constantPoolOop, int index);
- private native Member getMethodAt0 (Object constantPoolOop, int index);
- private native Member getMethodAtIfLoaded0(Object constantPoolOop, int index);
- private native Field getFieldAt0 (Object constantPoolOop, int index);
- private native Field getFieldAtIfLoaded0 (Object constantPoolOop, int index);
- private native String[] getMemberRefInfoAt0 (Object constantPoolOop, int index);
- private native int getNameAndTypeRefIndexAt0(Object constantPoolOop, int index);
- private native String[] getNameAndTypeRefInfoAt0(Object constantPoolOop, int index);
- private native int getIntAt0 (Object constantPoolOop, int index);
- private native long getLongAt0 (Object constantPoolOop, int index);
- private native float getFloatAt0 (Object constantPoolOop, int index);
- private native double getDoubleAt0 (Object constantPoolOop, int index);
- private native String getStringAt0 (Object constantPoolOop, int index);
- private native String getUTF8At0 (Object constantPoolOop, int index);
- private native byte getTagAt0 (Object constantPoolOop, int index);
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/ConstructorAccessor.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2001, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-import java.lang.reflect.InvocationTargetException;
-
-/** This interface provides the declaration for
- java.lang.reflect.Constructor.invoke(). Each Constructor object is
- configured with a (possibly dynamically-generated) class which
- implements this interface. */
-
-public interface ConstructorAccessor {
- /** Matches specification in {@link java.lang.reflect.Constructor} */
- public Object newInstance(Object[] args)
- throws InstantiationException,
- IllegalArgumentException,
- InvocationTargetException;
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/ConstructorAccessorImpl.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2001, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-import java.lang.reflect.InvocationTargetException;
-
-/** Package-private implementation of the ConstructorAccessor
- interface which has access to all classes and all fields,
- regardless of language restrictions. See MagicAccessorImpl. */
-
-abstract class ConstructorAccessorImpl extends MagicAccessorImpl
- implements ConstructorAccessor {
- /** Matches specification in {@link java.lang.reflect.Constructor} */
- public abstract Object newInstance(Object[] args)
- throws InstantiationException,
- IllegalArgumentException,
- InvocationTargetException;
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/DelegatingConstructorAccessorImpl.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 2001, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-import java.lang.reflect.InvocationTargetException;
-
-/** Delegates its invocation to another ConstructorAccessorImpl and can
- change its delegate at run time. */
-
-class DelegatingConstructorAccessorImpl extends ConstructorAccessorImpl {
- private ConstructorAccessorImpl delegate;
-
- DelegatingConstructorAccessorImpl(ConstructorAccessorImpl delegate) {
- setDelegate(delegate);
- }
-
- public Object newInstance(Object[] args)
- throws InstantiationException,
- IllegalArgumentException,
- InvocationTargetException
- {
- return delegate.newInstance(args);
- }
-
- void setDelegate(ConstructorAccessorImpl delegate) {
- this.delegate = delegate;
- }
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/DelegatingMethodAccessorImpl.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2001, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-import java.lang.reflect.InvocationTargetException;
-
-/** Delegates its invocation to another MethodAccessorImpl and can
- change its delegate at run time. */
-
-class DelegatingMethodAccessorImpl extends MethodAccessorImpl {
- private MethodAccessorImpl delegate;
-
- DelegatingMethodAccessorImpl(MethodAccessorImpl delegate) {
- setDelegate(delegate);
- }
-
- public Object invoke(Object obj, Object[] args)
- throws IllegalArgumentException, InvocationTargetException
- {
- return delegate.invoke(obj, args);
- }
-
- void setDelegate(MethodAccessorImpl delegate) {
- this.delegate = delegate;
- }
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/FieldAccessor.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,96 +0,0 @@
-/*
- * Copyright (c) 2001, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-/** This interface provides the declarations for the accessor methods
- of java.lang.reflect.Field. Each Field object is configured with a
- (possibly dynamically-generated) class which implements this
- interface. */
-
-public interface FieldAccessor {
- /** Matches specification in {@link java.lang.reflect.Field} */
- public Object get(Object obj) throws IllegalArgumentException;
-
- /** Matches specification in {@link java.lang.reflect.Field} */
- public boolean getBoolean(Object obj) throws IllegalArgumentException;
-
- /** Matches specification in {@link java.lang.reflect.Field} */
- public byte getByte(Object obj) throws IllegalArgumentException;
-
- /** Matches specification in {@link java.lang.reflect.Field} */
- public char getChar(Object obj) throws IllegalArgumentException;
-
- /** Matches specification in {@link java.lang.reflect.Field} */
- public short getShort(Object obj) throws IllegalArgumentException;
-
- /** Matches specification in {@link java.lang.reflect.Field} */
- public int getInt(Object obj) throws IllegalArgumentException;
-
- /** Matches specification in {@link java.lang.reflect.Field} */
- public long getLong(Object obj) throws IllegalArgumentException;
-
- /** Matches specification in {@link java.lang.reflect.Field} */
- public float getFloat(Object obj) throws IllegalArgumentException;
-
- /** Matches specification in {@link java.lang.reflect.Field} */
- public double getDouble(Object obj) throws IllegalArgumentException;
-
- /** Matches specification in {@link java.lang.reflect.Field} */
- public void set(Object obj, Object value)
- throws IllegalArgumentException, IllegalAccessException;
-
- /** Matches specification in {@link java.lang.reflect.Field} */
- public void setBoolean(Object obj, boolean z)
- throws IllegalArgumentException, IllegalAccessException;
-
- /** Matches specification in {@link java.lang.reflect.Field} */
- public void setByte(Object obj, byte b)
- throws IllegalArgumentException, IllegalAccessException;
-
- /** Matches specification in {@link java.lang.reflect.Field} */
- public void setChar(Object obj, char c)
- throws IllegalArgumentException, IllegalAccessException;
-
- /** Matches specification in {@link java.lang.reflect.Field} */
- public void setShort(Object obj, short s)
- throws IllegalArgumentException, IllegalAccessException;
-
- /** Matches specification in {@link java.lang.reflect.Field} */
- public void setInt(Object obj, int i)
- throws IllegalArgumentException, IllegalAccessException;
-
- /** Matches specification in {@link java.lang.reflect.Field} */
- public void setLong(Object obj, long l)
- throws IllegalArgumentException, IllegalAccessException;
-
- /** Matches specification in {@link java.lang.reflect.Field} */
- public void setFloat(Object obj, float f)
- throws IllegalArgumentException, IllegalAccessException;
-
- /** Matches specification in {@link java.lang.reflect.Field} */
- public void setDouble(Object obj, double d)
- throws IllegalArgumentException, IllegalAccessException;
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/FieldAccessorImpl.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,105 +0,0 @@
-/*
- * Copyright (c) 2001, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-/** Package-private implementation of the FieldAccessor interface
- which has access to all classes and all fields, regardless of
- language restrictions. See MagicAccessorImpl. */
-
-abstract class FieldAccessorImpl extends MagicAccessorImpl
- implements FieldAccessor {
- /** Matches specification in {@link java.lang.reflect.Field} */
- public abstract Object get(Object obj)
- throws IllegalArgumentException;
-
- /** Matches specification in {@link java.lang.reflect.Field} */
- public abstract boolean getBoolean(Object obj)
- throws IllegalArgumentException;
-
- /** Matches specification in {@link java.lang.reflect.Field} */
- public abstract byte getByte(Object obj)
- throws IllegalArgumentException;
-
- /** Matches specification in {@link java.lang.reflect.Field} */
- public abstract char getChar(Object obj)
- throws IllegalArgumentException;
-
- /** Matches specification in {@link java.lang.reflect.Field} */
- public abstract short getShort(Object obj)
- throws IllegalArgumentException;
-
- /** Matches specification in {@link java.lang.reflect.Field} */
- public abstract int getInt(Object obj)
- throws IllegalArgumentException;
-
- /** Matches specification in {@link java.lang.reflect.Field} */
- public abstract long getLong(Object obj)
- throws IllegalArgumentException;
-
- /** Matches specification in {@link java.lang.reflect.Field} */
- public abstract float getFloat(Object obj)
- throws IllegalArgumentException;
-
- /** Matches specification in {@link java.lang.reflect.Field} */
- public abstract double getDouble(Object obj)
- throws IllegalArgumentException;
-
- /** Matches specification in {@link java.lang.reflect.Field} */
- public abstract void set(Object obj, Object value)
- throws IllegalArgumentException, IllegalAccessException;
-
- /** Matches specification in {@link java.lang.reflect.Field} */
- public abstract void setBoolean(Object obj, boolean z)
- throws IllegalArgumentException, IllegalAccessException;
-
- /** Matches specification in {@link java.lang.reflect.Field} */
- public abstract void setByte(Object obj, byte b)
- throws IllegalArgumentException, IllegalAccessException;
-
- /** Matches specification in {@link java.lang.reflect.Field} */
- public abstract void setChar(Object obj, char c)
- throws IllegalArgumentException, IllegalAccessException;
-
- /** Matches specification in {@link java.lang.reflect.Field} */
- public abstract void setShort(Object obj, short s)
- throws IllegalArgumentException, IllegalAccessException;
-
- /** Matches specification in {@link java.lang.reflect.Field} */
- public abstract void setInt(Object obj, int i)
- throws IllegalArgumentException, IllegalAccessException;
-
- /** Matches specification in {@link java.lang.reflect.Field} */
- public abstract void setLong(Object obj, long l)
- throws IllegalArgumentException, IllegalAccessException;
-
- /** Matches specification in {@link java.lang.reflect.Field} */
- public abstract void setFloat(Object obj, float f)
- throws IllegalArgumentException, IllegalAccessException;
-
- /** Matches specification in {@link java.lang.reflect.Field} */
- public abstract void setDouble(Object obj, double d)
- throws IllegalArgumentException, IllegalAccessException;
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/FieldInfo.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,71 +0,0 @@
-/*
- * Copyright (c) 2001, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
-
-/** NOTE: obsolete as of JDK 1.4 B75 and should be removed from the
- workspace (FIXME) */
-
-public class FieldInfo {
- // Set by the VM directly. Do not move these fields around or add
- // others before (or after) them without also modifying the VM's code.
- private String name;
- private String signature;
- private int modifiers;
- // This is compatible with the old reflection implementation's
- // "slot" value to allow jdk.internal.misc.Unsafe to work
- private int slot;
-
- // Not really necessary to provide a constructor since the VM
- // creates these directly
- FieldInfo() {
- }
-
- public String name() {
- return name;
- }
-
- /** This is in "external" format, i.e. having '.' as separator
- rather than '/' */
- public String signature() {
- return signature;
- }
-
- public int modifiers() {
- return modifiers;
- }
-
- public int slot() {
- return slot;
- }
-
- /** Convenience routine */
- public boolean isPublic() {
- return (Modifier.isPublic(modifiers()));
- }
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/InstantiationExceptionConstructorAccessorImpl.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 2001, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-
-/** Throws an InstantiationException with given error message upon
- newInstance() call */
-
-class InstantiationExceptionConstructorAccessorImpl
- extends ConstructorAccessorImpl {
- private final String message;
-
- InstantiationExceptionConstructorAccessorImpl(String message) {
- this.message = message;
- }
-
- public Object newInstance(Object[] args)
- throws InstantiationException,
- IllegalArgumentException,
- InvocationTargetException
- {
- if (message == null) {
- throw new InstantiationException();
- }
- throw new InstantiationException(message);
- }
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/Label.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,76 +0,0 @@
-/*
- * Copyright (c) 2001, 2011, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-import java.util.List;
-import java.util.ArrayList;
-
-/** Allows forward references in bytecode streams emitted by
- ClassFileAssembler. Assumes that the start of the method body is
- the first byte in the assembler's buffer. May be used at more than
- one branch site. */
-
-class Label {
- static class PatchInfo {
- PatchInfo(ClassFileAssembler asm,
- short instrBCI,
- short patchBCI,
- int stackDepth)
- {
- this.asm = asm;
- this.instrBCI = instrBCI;
- this.patchBCI = patchBCI;
- this.stackDepth = stackDepth;
- }
- // This won't work for more than one assembler anyway, so this is
- // unnecessary
- final ClassFileAssembler asm;
- final short instrBCI;
- final short patchBCI;
- final int stackDepth;
- }
- private final List<PatchInfo> patches = new ArrayList<>();
-
- public Label() {
- }
-
- void add(ClassFileAssembler asm,
- short instrBCI,
- short patchBCI,
- int stackDepth)
- {
- patches.add(new PatchInfo(asm, instrBCI, patchBCI, stackDepth));
- }
-
- public void bind() {
- for (PatchInfo patch : patches){
- short curBCI = patch.asm.getLength();
- short offset = (short) (curBCI - patch.instrBCI);
- patch.asm.emitShort(patch.patchBCI, offset);
- patch.asm.setStack(patch.stackDepth);
- }
- }
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/LangReflectAccess.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,115 +0,0 @@
-/*
- * Copyright (c) 2001, 2013, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-import java.lang.reflect.*;
-
-/** An interface which gives privileged packages Java-level access to
- internals of java.lang.reflect. */
-
-public interface LangReflectAccess {
- /** Creates a new java.lang.reflect.Field. Access checks as per
- java.lang.reflect.AccessibleObject are not overridden. */
- public Field newField(Class<?> declaringClass,
- String name,
- Class<?> type,
- int modifiers,
- int slot,
- String signature,
- byte[] annotations);
-
- /** Creates a new java.lang.reflect.Method. Access checks as per
- java.lang.reflect.AccessibleObject are not overridden. */
- public Method newMethod(Class<?> declaringClass,
- String name,
- Class<?>[] parameterTypes,
- Class<?> returnType,
- Class<?>[] checkedExceptions,
- int modifiers,
- int slot,
- String signature,
- byte[] annotations,
- byte[] parameterAnnotations,
- byte[] annotationDefault);
-
- /** Creates a new java.lang.reflect.Constructor. Access checks as
- per java.lang.reflect.AccessibleObject are not overridden. */
- public <T> Constructor<T> newConstructor(Class<T> declaringClass,
- Class<?>[] parameterTypes,
- Class<?>[] checkedExceptions,
- int modifiers,
- int slot,
- String signature,
- byte[] annotations,
- byte[] parameterAnnotations);
-
- /** Gets the MethodAccessor object for a java.lang.reflect.Method */
- public MethodAccessor getMethodAccessor(Method m);
-
- /** Sets the MethodAccessor object for a java.lang.reflect.Method */
- public void setMethodAccessor(Method m, MethodAccessor accessor);
-
- /** Gets the ConstructorAccessor object for a
- java.lang.reflect.Constructor */
- public ConstructorAccessor getConstructorAccessor(Constructor<?> c);
-
- /** Sets the ConstructorAccessor object for a
- java.lang.reflect.Constructor */
- public void setConstructorAccessor(Constructor<?> c,
- ConstructorAccessor accessor);
-
- /** Gets the byte[] that encodes TypeAnnotations on an Executable. */
- public byte[] getExecutableTypeAnnotationBytes(Executable ex);
-
- /** Gets the "slot" field from a Constructor (used for serialization) */
- public int getConstructorSlot(Constructor<?> c);
-
- /** Gets the "signature" field from a Constructor (used for serialization) */
- public String getConstructorSignature(Constructor<?> c);
-
- /** Gets the "annotations" field from a Constructor (used for serialization) */
- public byte[] getConstructorAnnotations(Constructor<?> c);
-
- /** Gets the "parameterAnnotations" field from a Constructor (used for serialization) */
- public byte[] getConstructorParameterAnnotations(Constructor<?> c);
-
- //
- // Copying routines, needed to quickly fabricate new Field,
- // Method, and Constructor objects from templates
- //
-
- /** Makes a "child" copy of a Method */
- public Method copyMethod(Method arg);
-
- /** Makes a copy of this non-root a Method */
- public Method leafCopyMethod(Method arg);
-
- /** Makes a "child" copy of a Field */
- public Field copyField(Field arg);
-
- /** Makes a "child" copy of a Constructor */
- public <T> Constructor<T> copyConstructor(Constructor<T> arg);
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/MagicAccessorImpl.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2001, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-/** <P> MagicAccessorImpl (named for parity with FieldAccessorImpl and
- others, not because it actually implements an interface) is a
- marker class in the hierarchy. All subclasses of this class are
- "magically" granted access by the VM to otherwise inaccessible
- fields and methods of other classes. It is used to hold the code
- for dynamically-generated FieldAccessorImpl and MethodAccessorImpl
- subclasses. (Use of the word "unsafe" was avoided in this class's
- name to avoid confusion with {@link jdk.internal.misc.Unsafe}.) </P>
-
- <P> The bug fix for 4486457 also necessitated disabling
- verification for this class and all subclasses, as opposed to just
- SerializationConstructorAccessorImpl and subclasses, to avoid
- having to indicate to the VM which of these dynamically-generated
- stub classes were known to be able to pass the verifier. </P>
-
- <P> Do not change the name of this class without also changing the
- VM's code. </P> */
-
-class MagicAccessorImpl {
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/MethodAccessor.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2001, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-import java.lang.reflect.InvocationTargetException;
-
-/** This interface provides the declaration for
- java.lang.reflect.Method.invoke(). Each Method object is
- configured with a (possibly dynamically-generated) class which
- implements this interface.
-*/
-
-public interface MethodAccessor {
- /** Matches specification in {@link java.lang.reflect.Method} */
- public Object invoke(Object obj, Object[] args)
- throws IllegalArgumentException, InvocationTargetException;
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/MethodAccessorGenerator.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,780 +0,0 @@
-/*
- * Copyright (c) 2001, 2013, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-
-/** Generator for sun.reflect.MethodAccessor and
- sun.reflect.ConstructorAccessor objects using bytecodes to
- implement reflection. A java.lang.reflect.Method or
- java.lang.reflect.Constructor object can delegate its invoke or
- newInstance method to an accessor using native code or to one
- generated by this class. (Methods and Constructors were merged
- together in this class to ensure maximum code sharing.) */
-
-class MethodAccessorGenerator extends AccessorGenerator {
-
- private static final short NUM_BASE_CPOOL_ENTRIES = (short) 12;
- // One for invoke() plus one for constructor
- private static final short NUM_METHODS = (short) 2;
- // Only used if forSerialization is true
- private static final short NUM_SERIALIZATION_CPOOL_ENTRIES = (short) 2;
-
- private static volatile int methodSymnum;
- private static volatile int constructorSymnum;
- private static volatile int serializationConstructorSymnum;
-
- private Class<?> declaringClass;
- private Class<?>[] parameterTypes;
- private Class<?> returnType;
- private boolean isConstructor;
- private boolean forSerialization;
-
- private short targetMethodRef;
- private short invokeIdx;
- private short invokeDescriptorIdx;
- // Constant pool index of CONSTANT_Class_info for first
- // non-primitive parameter type. Should be incremented by 2.
- private short nonPrimitiveParametersBaseIdx;
-
- MethodAccessorGenerator() {
- }
-
- /** This routine is not thread-safe */
- public MethodAccessor generateMethod(Class<?> declaringClass,
- String name,
- Class<?>[] parameterTypes,
- Class<?> returnType,
- Class<?>[] checkedExceptions,
- int modifiers)
- {
- return (MethodAccessor) generate(declaringClass,
- name,
- parameterTypes,
- returnType,
- checkedExceptions,
- modifiers,
- false,
- false,
- null);
- }
-
- /** This routine is not thread-safe */
- public ConstructorAccessor generateConstructor(Class<?> declaringClass,
- Class<?>[] parameterTypes,
- Class<?>[] checkedExceptions,
- int modifiers)
- {
- return (ConstructorAccessor) generate(declaringClass,
- "<init>",
- parameterTypes,
- Void.TYPE,
- checkedExceptions,
- modifiers,
- true,
- false,
- null);
- }
-
- /** This routine is not thread-safe */
- public SerializationConstructorAccessorImpl
- generateSerializationConstructor(Class<?> declaringClass,
- Class<?>[] parameterTypes,
- Class<?>[] checkedExceptions,
- int modifiers,
- Class<?> targetConstructorClass)
- {
- return (SerializationConstructorAccessorImpl)
- generate(declaringClass,
- "<init>",
- parameterTypes,
- Void.TYPE,
- checkedExceptions,
- modifiers,
- true,
- true,
- targetConstructorClass);
- }
-
- /** This routine is not thread-safe */
- private MagicAccessorImpl generate(final Class<?> declaringClass,
- String name,
- Class<?>[] parameterTypes,
- Class<?> returnType,
- Class<?>[] checkedExceptions,
- int modifiers,
- boolean isConstructor,
- boolean forSerialization,
- Class<?> serializationTargetClass)
- {
- ByteVector vec = ByteVectorFactory.create();
- asm = new ClassFileAssembler(vec);
- this.declaringClass = declaringClass;
- this.parameterTypes = parameterTypes;
- this.returnType = returnType;
- this.modifiers = modifiers;
- this.isConstructor = isConstructor;
- this.forSerialization = forSerialization;
-
- asm.emitMagicAndVersion();
-
- // Constant pool entries:
- // ( * = Boxing information: optional)
- // (+ = Shared entries provided by AccessorGenerator)
- // (^ = Only present if generating SerializationConstructorAccessor)
- // [UTF-8] [This class's name]
- // [CONSTANT_Class_info] for above
- // [UTF-8] "sun/reflect/{MethodAccessorImpl,ConstructorAccessorImpl,SerializationConstructorAccessorImpl}"
- // [CONSTANT_Class_info] for above
- // [UTF-8] [Target class's name]
- // [CONSTANT_Class_info] for above
- // ^ [UTF-8] [Serialization: Class's name in which to invoke constructor]
- // ^ [CONSTANT_Class_info] for above
- // [UTF-8] target method or constructor name
- // [UTF-8] target method or constructor signature
- // [CONSTANT_NameAndType_info] for above
- // [CONSTANT_Methodref_info or CONSTANT_InterfaceMethodref_info] for target method
- // [UTF-8] "invoke" or "newInstance"
- // [UTF-8] invoke or newInstance descriptor
- // [UTF-8] descriptor for type of non-primitive parameter 1
- // [CONSTANT_Class_info] for type of non-primitive parameter 1
- // ...
- // [UTF-8] descriptor for type of non-primitive parameter n
- // [CONSTANT_Class_info] for type of non-primitive parameter n
- // + [UTF-8] "java/lang/Exception"
- // + [CONSTANT_Class_info] for above
- // + [UTF-8] "java/lang/ClassCastException"
- // + [CONSTANT_Class_info] for above
- // + [UTF-8] "java/lang/NullPointerException"
- // + [CONSTANT_Class_info] for above
- // + [UTF-8] "java/lang/IllegalArgumentException"
- // + [CONSTANT_Class_info] for above
- // + [UTF-8] "java/lang/InvocationTargetException"
- // + [CONSTANT_Class_info] for above
- // + [UTF-8] "<init>"
- // + [UTF-8] "()V"
- // + [CONSTANT_NameAndType_info] for above
- // + [CONSTANT_Methodref_info] for NullPointerException's constructor
- // + [CONSTANT_Methodref_info] for IllegalArgumentException's constructor
- // + [UTF-8] "(Ljava/lang/String;)V"
- // + [CONSTANT_NameAndType_info] for "<init>(Ljava/lang/String;)V"
- // + [CONSTANT_Methodref_info] for IllegalArgumentException's constructor taking a String
- // + [UTF-8] "(Ljava/lang/Throwable;)V"
- // + [CONSTANT_NameAndType_info] for "<init>(Ljava/lang/Throwable;)V"
- // + [CONSTANT_Methodref_info] for InvocationTargetException's constructor
- // + [CONSTANT_Methodref_info] for "super()"
- // + [UTF-8] "java/lang/Object"
- // + [CONSTANT_Class_info] for above
- // + [UTF-8] "toString"
- // + [UTF-8] "()Ljava/lang/String;"
- // + [CONSTANT_NameAndType_info] for "toString()Ljava/lang/String;"
- // + [CONSTANT_Methodref_info] for Object's toString method
- // + [UTF-8] "Code"
- // + [UTF-8] "Exceptions"
- // * [UTF-8] "java/lang/Boolean"
- // * [CONSTANT_Class_info] for above
- // * [UTF-8] "(Z)V"
- // * [CONSTANT_NameAndType_info] for above
- // * [CONSTANT_Methodref_info] for above
- // * [UTF-8] "booleanValue"
- // * [UTF-8] "()Z"
- // * [CONSTANT_NameAndType_info] for above
- // * [CONSTANT_Methodref_info] for above
- // * [UTF-8] "java/lang/Byte"
- // * [CONSTANT_Class_info] for above
- // * [UTF-8] "(B)V"
- // * [CONSTANT_NameAndType_info] for above
- // * [CONSTANT_Methodref_info] for above
- // * [UTF-8] "byteValue"
- // * [UTF-8] "()B"
- // * [CONSTANT_NameAndType_info] for above
- // * [CONSTANT_Methodref_info] for above
- // * [UTF-8] "java/lang/Character"
- // * [CONSTANT_Class_info] for above
- // * [UTF-8] "(C)V"
- // * [CONSTANT_NameAndType_info] for above
- // * [CONSTANT_Methodref_info] for above
- // * [UTF-8] "charValue"
- // * [UTF-8] "()C"
- // * [CONSTANT_NameAndType_info] for above
- // * [CONSTANT_Methodref_info] for above
- // * [UTF-8] "java/lang/Double"
- // * [CONSTANT_Class_info] for above
- // * [UTF-8] "(D)V"
- // * [CONSTANT_NameAndType_info] for above
- // * [CONSTANT_Methodref_info] for above
- // * [UTF-8] "doubleValue"
- // * [UTF-8] "()D"
- // * [CONSTANT_NameAndType_info] for above
- // * [CONSTANT_Methodref_info] for above
- // * [UTF-8] "java/lang/Float"
- // * [CONSTANT_Class_info] for above
- // * [UTF-8] "(F)V"
- // * [CONSTANT_NameAndType_info] for above
- // * [CONSTANT_Methodref_info] for above
- // * [UTF-8] "floatValue"
- // * [UTF-8] "()F"
- // * [CONSTANT_NameAndType_info] for above
- // * [CONSTANT_Methodref_info] for above
- // * [UTF-8] "java/lang/Integer"
- // * [CONSTANT_Class_info] for above
- // * [UTF-8] "(I)V"
- // * [CONSTANT_NameAndType_info] for above
- // * [CONSTANT_Methodref_info] for above
- // * [UTF-8] "intValue"
- // * [UTF-8] "()I"
- // * [CONSTANT_NameAndType_info] for above
- // * [CONSTANT_Methodref_info] for above
- // * [UTF-8] "java/lang/Long"
- // * [CONSTANT_Class_info] for above
- // * [UTF-8] "(J)V"
- // * [CONSTANT_NameAndType_info] for above
- // * [CONSTANT_Methodref_info] for above
- // * [UTF-8] "longValue"
- // * [UTF-8] "()J"
- // * [CONSTANT_NameAndType_info] for above
- // * [CONSTANT_Methodref_info] for above
- // * [UTF-8] "java/lang/Short"
- // * [CONSTANT_Class_info] for above
- // * [UTF-8] "(S)V"
- // * [CONSTANT_NameAndType_info] for above
- // * [CONSTANT_Methodref_info] for above
- // * [UTF-8] "shortValue"
- // * [UTF-8] "()S"
- // * [CONSTANT_NameAndType_info] for above
- // * [CONSTANT_Methodref_info] for above
-
- short numCPEntries = NUM_BASE_CPOOL_ENTRIES + NUM_COMMON_CPOOL_ENTRIES;
- boolean usesPrimitives = usesPrimitiveTypes();
- if (usesPrimitives) {
- numCPEntries += NUM_BOXING_CPOOL_ENTRIES;
- }
- if (forSerialization) {
- numCPEntries += NUM_SERIALIZATION_CPOOL_ENTRIES;
- }
-
- // Add in variable-length number of entries to be able to describe
- // non-primitive parameter types and checked exceptions.
- numCPEntries += (short) (2 * numNonPrimitiveParameterTypes());
-
- asm.emitShort(add(numCPEntries, S1));
-
- final String generatedName = generateName(isConstructor, forSerialization);
- asm.emitConstantPoolUTF8(generatedName);
- asm.emitConstantPoolClass(asm.cpi());
- thisClass = asm.cpi();
- if (isConstructor) {
- if (forSerialization) {
- asm.emitConstantPoolUTF8
- ("sun/reflect/SerializationConstructorAccessorImpl");
- } else {
- asm.emitConstantPoolUTF8("sun/reflect/ConstructorAccessorImpl");
- }
- } else {
- asm.emitConstantPoolUTF8("sun/reflect/MethodAccessorImpl");
- }
- asm.emitConstantPoolClass(asm.cpi());
- superClass = asm.cpi();
- asm.emitConstantPoolUTF8(getClassName(declaringClass, false));
- asm.emitConstantPoolClass(asm.cpi());
- targetClass = asm.cpi();
- short serializationTargetClassIdx = (short) 0;
- if (forSerialization) {
- asm.emitConstantPoolUTF8(getClassName(serializationTargetClass, false));
- asm.emitConstantPoolClass(asm.cpi());
- serializationTargetClassIdx = asm.cpi();
- }
- asm.emitConstantPoolUTF8(name);
- asm.emitConstantPoolUTF8(buildInternalSignature());
- asm.emitConstantPoolNameAndType(sub(asm.cpi(), S1), asm.cpi());
- if (isInterface()) {
- asm.emitConstantPoolInterfaceMethodref(targetClass, asm.cpi());
- } else {
- if (forSerialization) {
- asm.emitConstantPoolMethodref(serializationTargetClassIdx, asm.cpi());
- } else {
- asm.emitConstantPoolMethodref(targetClass, asm.cpi());
- }
- }
- targetMethodRef = asm.cpi();
- if (isConstructor) {
- asm.emitConstantPoolUTF8("newInstance");
- } else {
- asm.emitConstantPoolUTF8("invoke");
- }
- invokeIdx = asm.cpi();
- if (isConstructor) {
- asm.emitConstantPoolUTF8("([Ljava/lang/Object;)Ljava/lang/Object;");
- } else {
- asm.emitConstantPoolUTF8
- ("(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;");
- }
- invokeDescriptorIdx = asm.cpi();
-
- // Output class information for non-primitive parameter types
- nonPrimitiveParametersBaseIdx = add(asm.cpi(), S2);
- for (int i = 0; i < parameterTypes.length; i++) {
- Class<?> c = parameterTypes[i];
- if (!isPrimitive(c)) {
- asm.emitConstantPoolUTF8(getClassName(c, false));
- asm.emitConstantPoolClass(asm.cpi());
- }
- }
-
- // Entries common to FieldAccessor, MethodAccessor and ConstructorAccessor
- emitCommonConstantPoolEntries();
-
- // Boxing entries
- if (usesPrimitives) {
- emitBoxingContantPoolEntries();
- }
-
- if (asm.cpi() != numCPEntries) {
- throw new InternalError("Adjust this code (cpi = " + asm.cpi() +
- ", numCPEntries = " + numCPEntries + ")");
- }
-
- // Access flags
- asm.emitShort(ACC_PUBLIC);
-
- // This class
- asm.emitShort(thisClass);
-
- // Superclass
- asm.emitShort(superClass);
-
- // Interfaces count and interfaces
- asm.emitShort(S0);
-
- // Fields count and fields
- asm.emitShort(S0);
-
- // Methods count and methods
- asm.emitShort(NUM_METHODS);
-
- emitConstructor();
- emitInvoke();
-
- // Additional attributes (none)
- asm.emitShort(S0);
-
- // Load class
- vec.trim();
- final byte[] bytes = vec.getData();
- // Note: the class loader is the only thing that really matters
- // here -- it's important to get the generated code into the
- // same namespace as the target class. Since the generated code
- // is privileged anyway, the protection domain probably doesn't
- // matter.
- return AccessController.doPrivileged(
- new PrivilegedAction<MagicAccessorImpl>() {
- public MagicAccessorImpl run() {
- try {
- return (MagicAccessorImpl)
- ClassDefiner.defineClass
- (generatedName,
- bytes,
- 0,
- bytes.length,
- declaringClass.getClassLoader()).newInstance();
- } catch (InstantiationException | IllegalAccessException e) {
- throw new InternalError(e);
- }
- }
- });
- }
-
- /** This emits the code for either invoke() or newInstance() */
- private void emitInvoke() {
- // NOTE that this code will only handle 65535 parameters since we
- // use the sipush instruction to get the array index on the
- // operand stack.
- if (parameterTypes.length > 65535) {
- throw new InternalError("Can't handle more than 65535 parameters");
- }
-
- // Generate code into fresh code buffer
- ClassFileAssembler cb = new ClassFileAssembler();
- if (isConstructor) {
- // 1 incoming argument
- cb.setMaxLocals(2);
- } else {
- // 2 incoming arguments
- cb.setMaxLocals(3);
- }
-
- short illegalArgStartPC = 0;
-
- if (isConstructor) {
- // Instantiate target class before continuing
- // new <target class type>
- // dup
- cb.opc_new(targetClass);
- cb.opc_dup();
- } else {
- // Setup before iterating down argument list
- if (isPrimitive(returnType)) {
- // new <boxing type for primitive type>
- // dup
- // ... (see below:)
- // invokespecial <constructor for boxing type for primitive type>
- // areturn
- cb.opc_new(indexForPrimitiveType(returnType));
- cb.opc_dup();
- }
-
- // Get target object on operand stack if necessary.
-
- // We need to do an explicit null check here; we won't see
- // NullPointerExceptions from the invoke bytecode, since it's
- // covered by an exception handler.
- if (!isStatic()) {
- // aload_1
- // ifnonnull <checkcast label>
- // new <NullPointerException>
- // dup
- // invokespecial <NullPointerException ctor>
- // athrow
- // <checkcast label:>
- // aload_1
- // checkcast <target class's type>
- cb.opc_aload_1();
- Label l = new Label();
- cb.opc_ifnonnull(l);
- cb.opc_new(nullPointerClass);
- cb.opc_dup();
- cb.opc_invokespecial(nullPointerCtorIdx, 0, 0);
- cb.opc_athrow();
- l.bind();
- illegalArgStartPC = cb.getLength();
- cb.opc_aload_1();
- cb.opc_checkcast(targetClass);
- }
- }
-
- // Have to check length of incoming array and throw
- // IllegalArgumentException if not correct. A concession to the
- // JCK (isn't clearly specified in the spec): we allow null in the
- // case where the argument list is zero length.
- // if no-arg:
- // aload_2 | aload_1 (Method | Constructor)
- // ifnull <success label>
- // aload_2 | aload_1
- // arraylength
- // sipush <num parameter types>
- // if_icmpeq <success label>
- // new <IllegalArgumentException>
- // dup
- // invokespecial <IllegalArgumentException ctor>
- // athrow
- // <success label:>
- Label successLabel = new Label();
- if (parameterTypes.length == 0) {
- if (isConstructor) {
- cb.opc_aload_1();
- } else {
- cb.opc_aload_2();
- }
- cb.opc_ifnull(successLabel);
- }
- if (isConstructor) {
- cb.opc_aload_1();
- } else {
- cb.opc_aload_2();
- }
- cb.opc_arraylength();
- cb.opc_sipush((short) parameterTypes.length);
- cb.opc_if_icmpeq(successLabel);
- cb.opc_new(illegalArgumentClass);
- cb.opc_dup();
- cb.opc_invokespecial(illegalArgumentCtorIdx, 0, 0);
- cb.opc_athrow();
- successLabel.bind();
-
- // Iterate through incoming actual parameters, ensuring that each
- // is compatible with the formal parameter type, and pushing the
- // actual on the operand stack (unboxing and widening if necessary).
-
- short paramTypeCPIdx = nonPrimitiveParametersBaseIdx;
- Label nextParamLabel = null;
- byte count = 1; // both invokeinterface opcode's "count" as well as
- // num args of other invoke bytecodes
- for (int i = 0; i < parameterTypes.length; i++) {
- Class<?> paramType = parameterTypes[i];
- count += (byte) typeSizeInStackSlots(paramType);
- if (nextParamLabel != null) {
- nextParamLabel.bind();
- nextParamLabel = null;
- }
- // aload_2 | aload_1
- // sipush <index>
- // aaload
- if (isConstructor) {
- cb.opc_aload_1();
- } else {
- cb.opc_aload_2();
- }
- cb.opc_sipush((short) i);
- cb.opc_aaload();
- if (isPrimitive(paramType)) {
- // Unboxing code.
- // Put parameter into temporary local variable
- // astore_3 | astore_2
- if (isConstructor) {
- cb.opc_astore_2();
- } else {
- cb.opc_astore_3();
- }
-
- // repeat for all possible widening conversions:
- // aload_3 | aload_2
- // instanceof <primitive boxing type>
- // ifeq <next unboxing label>
- // aload_3 | aload_2
- // checkcast <primitive boxing type> // Note: this is "redundant",
- // // but necessary for the verifier
- // invokevirtual <unboxing method>
- // <widening conversion bytecode, if necessary>
- // goto <next parameter label>
- // <next unboxing label:> ...
- // last unboxing label:
- // new <IllegalArgumentException>
- // dup
- // invokespecial <IllegalArgumentException ctor>
- // athrow
-
- Label l = null; // unboxing label
- nextParamLabel = new Label();
-
- for (int j = 0; j < primitiveTypes.length; j++) {
- Class<?> c = primitiveTypes[j];
- if (canWidenTo(c, paramType)) {
- if (l != null) {
- l.bind();
- }
- // Emit checking and unboxing code for this type
- if (isConstructor) {
- cb.opc_aload_2();
- } else {
- cb.opc_aload_3();
- }
- cb.opc_instanceof(indexForPrimitiveType(c));
- l = new Label();
- cb.opc_ifeq(l);
- if (isConstructor) {
- cb.opc_aload_2();
- } else {
- cb.opc_aload_3();
- }
- cb.opc_checkcast(indexForPrimitiveType(c));
- cb.opc_invokevirtual(unboxingMethodForPrimitiveType(c),
- 0,
- typeSizeInStackSlots(c));
- emitWideningBytecodeForPrimitiveConversion(cb,
- c,
- paramType);
- cb.opc_goto(nextParamLabel);
- }
- }
-
- if (l == null) {
- throw new InternalError
- ("Must have found at least identity conversion");
- }
-
- // Fell through; given object is null or invalid. According to
- // the spec, we can throw IllegalArgumentException for both of
- // these cases.
-
- l.bind();
- cb.opc_new(illegalArgumentClass);
- cb.opc_dup();
- cb.opc_invokespecial(illegalArgumentCtorIdx, 0, 0);
- cb.opc_athrow();
- } else {
- // Emit appropriate checkcast
- cb.opc_checkcast(paramTypeCPIdx);
- paramTypeCPIdx = add(paramTypeCPIdx, S2);
- // Fall through to next argument
- }
- }
- // Bind last goto if present
- if (nextParamLabel != null) {
- nextParamLabel.bind();
- }
-
- short invokeStartPC = cb.getLength();
-
- // OK, ready to perform the invocation.
- if (isConstructor) {
- cb.opc_invokespecial(targetMethodRef, count, 0);
- } else {
- if (isStatic()) {
- cb.opc_invokestatic(targetMethodRef,
- count,
- typeSizeInStackSlots(returnType));
- } else {
- if (isInterface()) {
- if (isPrivate()) {
- cb.opc_invokespecial(targetMethodRef, count, 0);
- } else {
- cb.opc_invokeinterface(targetMethodRef,
- count,
- count,
- typeSizeInStackSlots(returnType));
- }
- } else {
- cb.opc_invokevirtual(targetMethodRef,
- count,
- typeSizeInStackSlots(returnType));
- }
- }
- }
-
- short invokeEndPC = cb.getLength();
-
- if (!isConstructor) {
- // Box return value if necessary
- if (isPrimitive(returnType)) {
- cb.opc_invokestatic(boxingMethodForPrimitiveType(returnType),
- typeSizeInStackSlots(returnType),
- 0);
- } else if (returnType == Void.TYPE) {
- cb.opc_aconst_null();
- }
- }
- cb.opc_areturn();
-
- // We generate two exception handlers; one which is responsible
- // for catching ClassCastException and NullPointerException and
- // throwing IllegalArgumentException, and the other which catches
- // all java/lang/Throwable objects thrown from the target method
- // and wraps them in InvocationTargetExceptions.
-
- short classCastHandler = cb.getLength();
-
- // ClassCast, etc. exception handler
- cb.setStack(1);
- cb.opc_invokespecial(toStringIdx, 0, 1);
- cb.opc_new(illegalArgumentClass);
- cb.opc_dup_x1();
- cb.opc_swap();
- cb.opc_invokespecial(illegalArgumentStringCtorIdx, 1, 0);
- cb.opc_athrow();
-
- short invocationTargetHandler = cb.getLength();
-
- // InvocationTargetException exception handler
- cb.setStack(1);
- cb.opc_new(invocationTargetClass);
- cb.opc_dup_x1();
- cb.opc_swap();
- cb.opc_invokespecial(invocationTargetCtorIdx, 1, 0);
- cb.opc_athrow();
-
- // Generate exception table. We cover the entire code sequence
- // with an exception handler which catches ClassCastException and
- // converts it into an IllegalArgumentException.
-
- ClassFileAssembler exc = new ClassFileAssembler();
-
- exc.emitShort(illegalArgStartPC); // start PC
- exc.emitShort(invokeStartPC); // end PC
- exc.emitShort(classCastHandler); // handler PC
- exc.emitShort(classCastClass); // catch type
-
- exc.emitShort(illegalArgStartPC); // start PC
- exc.emitShort(invokeStartPC); // end PC
- exc.emitShort(classCastHandler); // handler PC
- exc.emitShort(nullPointerClass); // catch type
-
- exc.emitShort(invokeStartPC); // start PC
- exc.emitShort(invokeEndPC); // end PC
- exc.emitShort(invocationTargetHandler); // handler PC
- exc.emitShort(throwableClass); // catch type
-
- emitMethod(invokeIdx, cb.getMaxLocals(), cb, exc,
- new short[] { invocationTargetClass });
- }
-
- private boolean usesPrimitiveTypes() {
- // We need to emit boxing/unboxing constant pool information if
- // the method takes a primitive type for any of its parameters or
- // returns a primitive value (except void)
- if (returnType.isPrimitive()) {
- return true;
- }
- for (int i = 0; i < parameterTypes.length; i++) {
- if (parameterTypes[i].isPrimitive()) {
- return true;
- }
- }
- return false;
- }
-
- private int numNonPrimitiveParameterTypes() {
- int num = 0;
- for (int i = 0; i < parameterTypes.length; i++) {
- if (!parameterTypes[i].isPrimitive()) {
- ++num;
- }
- }
- return num;
- }
-
- private boolean isInterface() {
- return declaringClass.isInterface();
- }
-
- private String buildInternalSignature() {
- StringBuilder sb = new StringBuilder();
- sb.append("(");
- for (int i = 0; i < parameterTypes.length; i++) {
- sb.append(getClassName(parameterTypes[i], true));
- }
- sb.append(")");
- sb.append(getClassName(returnType, true));
- return sb.toString();
- }
-
- private static synchronized String generateName(boolean isConstructor,
- boolean forSerialization)
- {
- if (isConstructor) {
- if (forSerialization) {
- int num = ++serializationConstructorSymnum;
- return "sun/reflect/GeneratedSerializationConstructorAccessor" + num;
- } else {
- int num = ++constructorSymnum;
- return "sun/reflect/GeneratedConstructorAccessor" + num;
- }
- } else {
- int num = ++methodSymnum;
- return "sun/reflect/GeneratedMethodAccessor" + num;
- }
- }
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/MethodAccessorImpl.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2001, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-import java.lang.reflect.InvocationTargetException;
-
-/** <P> Package-private implementation of the MethodAccessor interface
- which has access to all classes and all fields, regardless of
- language restrictions. See MagicAccessor. </P>
-
- <P> This class is known to the VM; do not change its name without
- also changing the VM's code. </P>
-
- <P> NOTE: ALL methods of subclasses are skipped during security
- walks up the stack. The assumption is that the only such methods
- that will persistently show up on the stack are the implementing
- methods for java.lang.reflect.Method.invoke(). </P>
-*/
-
-abstract class MethodAccessorImpl extends MagicAccessorImpl
- implements MethodAccessor {
- /** Matches specification in {@link java.lang.reflect.Method} */
- public abstract Object invoke(Object obj, Object[] args)
- throws IllegalArgumentException, InvocationTargetException;
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/NativeConstructorAccessorImpl.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,73 +0,0 @@
-/*
- * Copyright (c) 2001, 2013, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-import java.lang.reflect.*;
-import sun.reflect.misc.ReflectUtil;
-
-/** Used only for the first few invocations of a Constructor;
- afterward, switches to bytecode-based implementation */
-
-class NativeConstructorAccessorImpl extends ConstructorAccessorImpl {
- private final Constructor<?> c;
- private DelegatingConstructorAccessorImpl parent;
- private int numInvocations;
-
- NativeConstructorAccessorImpl(Constructor<?> c) {
- this.c = c;
- }
-
- public Object newInstance(Object[] args)
- throws InstantiationException,
- IllegalArgumentException,
- InvocationTargetException
- {
- // We can't inflate a constructor belonging to a vm-anonymous class
- // because that kind of class can't be referred to by name, hence can't
- // be found from the generated bytecode.
- if (++numInvocations > ReflectionFactory.inflationThreshold()
- && !ReflectUtil.isVMAnonymousClass(c.getDeclaringClass())) {
- ConstructorAccessorImpl acc = (ConstructorAccessorImpl)
- new MethodAccessorGenerator().
- generateConstructor(c.getDeclaringClass(),
- c.getParameterTypes(),
- c.getExceptionTypes(),
- c.getModifiers());
- parent.setDelegate(acc);
- }
-
- return newInstance0(c, args);
- }
-
- void setParent(DelegatingConstructorAccessorImpl parent) {
- this.parent = parent;
- }
-
- private static native Object newInstance0(Constructor<?> c, Object[] args)
- throws InstantiationException,
- IllegalArgumentException,
- InvocationTargetException;
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/NativeMethodAccessorImpl.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,70 +0,0 @@
-/*
- * Copyright (c) 2001, 2013, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-import java.lang.reflect.*;
-import sun.reflect.misc.ReflectUtil;
-
-/** Used only for the first few invocations of a Method; afterward,
- switches to bytecode-based implementation */
-
-class NativeMethodAccessorImpl extends MethodAccessorImpl {
- private final Method method;
- private DelegatingMethodAccessorImpl parent;
- private int numInvocations;
-
- NativeMethodAccessorImpl(Method method) {
- this.method = method;
- }
-
- public Object invoke(Object obj, Object[] args)
- throws IllegalArgumentException, InvocationTargetException
- {
- // We can't inflate methods belonging to vm-anonymous classes because
- // that kind of class can't be referred to by name, hence can't be
- // found from the generated bytecode.
- if (++numInvocations > ReflectionFactory.inflationThreshold()
- && !ReflectUtil.isVMAnonymousClass(method.getDeclaringClass())) {
- MethodAccessorImpl acc = (MethodAccessorImpl)
- new MethodAccessorGenerator().
- generateMethod(method.getDeclaringClass(),
- method.getName(),
- method.getParameterTypes(),
- method.getReturnType(),
- method.getExceptionTypes(),
- method.getModifiers());
- parent.setDelegate(acc);
- }
-
- return invoke0(method, obj, args);
- }
-
- void setParent(DelegatingMethodAccessorImpl parent) {
- this.parent = parent;
- }
-
- private static native Object invoke0(Method m, Object obj, Object[] args);
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/Reflection.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,425 +0,0 @@
-/*
- * Copyright (c) 2001, 2013, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-
-import java.lang.reflect.*;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Objects;
-import jdk.internal.HotSpotIntrinsicCandidate;
-import jdk.internal.misc.VM;
-
-/** Common utility routines used by both java.lang and
- java.lang.reflect */
-
-public class Reflection {
-
- /** Used to filter out fields and methods from certain classes from public
- view, where they are sensitive or they may contain VM-internal objects.
- These Maps are updated very rarely. Rather than synchronize on
- each access, we use copy-on-write */
- private static volatile Map<Class<?>,String[]> fieldFilterMap;
- private static volatile Map<Class<?>,String[]> methodFilterMap;
-
- static {
- Map<Class<?>,String[]> map = new HashMap<Class<?>,String[]>();
- map.put(Reflection.class,
- new String[] {"fieldFilterMap", "methodFilterMap"});
- map.put(System.class, new String[] {"security"});
- map.put(Class.class, new String[] {"classLoader"});
- fieldFilterMap = map;
-
- methodFilterMap = new HashMap<>();
- }
-
- /** Returns the class of the caller of the method calling this method,
- ignoring frames associated with java.lang.reflect.Method.invoke()
- and its implementation. */
- @CallerSensitive
- @HotSpotIntrinsicCandidate
- public static native Class<?> getCallerClass();
-
- /**
- * @deprecated This method will be removed in JDK 9.
- * This method is a private JDK API and retained temporarily for
- * existing code to run until a replacement API is defined.
- */
- @Deprecated
- public static native Class<?> getCallerClass(int depth);
-
- /** Retrieves the access flags written to the class file. For
- inner classes these flags may differ from those returned by
- Class.getModifiers(), which searches the InnerClasses
- attribute to find the source-level access flags. This is used
- instead of Class.getModifiers() for run-time access checks due
- to compatibility reasons; see 4471811. Only the values of the
- low 13 bits (i.e., a mask of 0x1FFF) are guaranteed to be
- valid. */
- @HotSpotIntrinsicCandidate
- public static native int getClassAccessFlags(Class<?> c);
-
-
- public static void ensureMemberAccess(Class<?> currentClass,
- Class<?> memberClass,
- Object target,
- int modifiers)
- throws IllegalAccessException
- {
- if (currentClass == null || memberClass == null) {
- throw new InternalError();
- }
-
- if (!verifyMemberAccess(currentClass, memberClass, target, modifiers)) {
- throwIllegalAccessException(currentClass, memberClass, target, modifiers);
- }
- }
-
- public static boolean verifyMemberAccess(Class<?> currentClass,
- // Declaring class of field
- // or method
- Class<?> memberClass,
- // May be NULL in case of statics
- Object target,
- int modifiers)
- {
- // Verify that currentClass can access a field, method, or
- // constructor of memberClass, where that member's access bits are
- // "modifiers".
-
- boolean gotIsSameClassPackage = false;
- boolean isSameClassPackage = false;
-
- if (currentClass == memberClass) {
- // Always succeeds
- return true;
- }
-
- if (!verifyModuleAccess(currentClass, memberClass)) {
- return false;
- }
-
- if (!Modifier.isPublic(getClassAccessFlags(memberClass))) {
- isSameClassPackage = isSameClassPackage(currentClass, memberClass);
- gotIsSameClassPackage = true;
- if (!isSameClassPackage) {
- return false;
- }
- }
-
- // At this point we know that currentClass can access memberClass.
-
- if (Modifier.isPublic(modifiers)) {
- return true;
- }
-
- boolean successSoFar = false;
-
- if (Modifier.isProtected(modifiers)) {
- // See if currentClass is a subclass of memberClass
- if (isSubclassOf(currentClass, memberClass)) {
- successSoFar = true;
- }
- }
-
- if (!successSoFar && !Modifier.isPrivate(modifiers)) {
- if (!gotIsSameClassPackage) {
- isSameClassPackage = isSameClassPackage(currentClass,
- memberClass);
- gotIsSameClassPackage = true;
- }
-
- if (isSameClassPackage) {
- successSoFar = true;
- }
- }
-
- if (!successSoFar) {
- return false;
- }
-
- if (Modifier.isProtected(modifiers)) {
- // Additional test for protected members: JLS 6.6.2
- Class<?> targetClass = (target == null ? memberClass : target.getClass());
- if (targetClass != currentClass) {
- if (!gotIsSameClassPackage) {
- isSameClassPackage = isSameClassPackage(currentClass, memberClass);
- gotIsSameClassPackage = true;
- }
- if (!isSameClassPackage) {
- if (!isSubclassOf(targetClass, currentClass)) {
- return false;
- }
- }
- }
- }
-
- return true;
- }
-
- /**
- * Returns {@code true} if memberClass's's module exports memberClass's
- * package to currentClass's module.
- */
- public static boolean verifyModuleAccess(Class<?> currentClass,
- Class<?> memberClass) {
- return verifyModuleAccess(currentClass.getModule(), memberClass);
- }
-
- public static boolean verifyModuleAccess(Module currentModule, Class<?> memberClass) {
- Module memberModule = memberClass.getModule();
-
- // module may be null during startup (initLevel 0)
- if (currentModule == memberModule)
- return true; // same module (named or unnamed)
-
- // memberClass may be primitive or array class
- Class<?> c = memberClass;
- while (c.isArray()) {
- c = c.getComponentType();
- }
- if (c.isPrimitive())
- return true;
-
- // check that memberModule exports the package to currentModule
- return memberModule.isExported(c.getPackageName(), currentModule);
- }
-
- /**
- * Returns true if two classes in the same package.
- */
- private static boolean isSameClassPackage(Class<?> c1, Class<?> c2) {
- if (c1.getClassLoader() != c2.getClassLoader())
- return false;
- while (c1.isArray())
- c1 = c1.getComponentType();
- while (c2.isArray())
- c2 = c2.getComponentType();
- return Objects.equals(c1.getPackageName(), c2.getPackageName());
- }
-
- static boolean isSubclassOf(Class<?> queryClass,
- Class<?> ofClass)
- {
- while (queryClass != null) {
- if (queryClass == ofClass) {
- return true;
- }
- queryClass = queryClass.getSuperclass();
- }
- return false;
- }
-
- // fieldNames must contain only interned Strings
- public static synchronized void registerFieldsToFilter(Class<?> containingClass,
- String ... fieldNames) {
- fieldFilterMap =
- registerFilter(fieldFilterMap, containingClass, fieldNames);
- }
-
- // methodNames must contain only interned Strings
- public static synchronized void registerMethodsToFilter(Class<?> containingClass,
- String ... methodNames) {
- methodFilterMap =
- registerFilter(methodFilterMap, containingClass, methodNames);
- }
-
- private static Map<Class<?>,String[]> registerFilter(Map<Class<?>,String[]> map,
- Class<?> containingClass, String ... names) {
- if (map.get(containingClass) != null) {
- throw new IllegalArgumentException
- ("Filter already registered: " + containingClass);
- }
- map = new HashMap<Class<?>,String[]>(map);
- map.put(containingClass, names);
- return map;
- }
-
- public static Field[] filterFields(Class<?> containingClass,
- Field[] fields) {
- if (fieldFilterMap == null) {
- // Bootstrapping
- return fields;
- }
- return (Field[])filter(fields, fieldFilterMap.get(containingClass));
- }
-
- public static Method[] filterMethods(Class<?> containingClass, Method[] methods) {
- if (methodFilterMap == null) {
- // Bootstrapping
- return methods;
- }
- return (Method[])filter(methods, methodFilterMap.get(containingClass));
- }
-
- private static Member[] filter(Member[] members, String[] filteredNames) {
- if ((filteredNames == null) || (members.length == 0)) {
- return members;
- }
- int numNewMembers = 0;
- for (Member member : members) {
- boolean shouldSkip = false;
- for (String filteredName : filteredNames) {
- if (member.getName() == filteredName) {
- shouldSkip = true;
- break;
- }
- }
- if (!shouldSkip) {
- ++numNewMembers;
- }
- }
- Member[] newMembers =
- (Member[])Array.newInstance(members[0].getClass(), numNewMembers);
- int destIdx = 0;
- for (Member member : members) {
- boolean shouldSkip = false;
- for (String filteredName : filteredNames) {
- if (member.getName() == filteredName) {
- shouldSkip = true;
- break;
- }
- }
- if (!shouldSkip) {
- newMembers[destIdx++] = member;
- }
- }
- return newMembers;
- }
-
- /**
- * Tests if the given method is caller-sensitive and the declaring class
- * is defined by either the bootstrap class loader or platform class loader.
- */
- public static boolean isCallerSensitive(Method m) {
- final ClassLoader loader = m.getDeclaringClass().getClassLoader();
- if (VM.isSystemDomainLoader(loader) || isExtClassLoader(loader)) {
- return m.isAnnotationPresent(CallerSensitive.class);
- }
- return false;
- }
-
- private static boolean isExtClassLoader(ClassLoader loader) {
- ClassLoader cl = ClassLoader.getSystemClassLoader();
- while (cl != null) {
- if (cl.getParent() == null && cl == loader) {
- return true;
- }
- cl = cl.getParent();
- }
- return false;
- }
-
-
- // true to print a stack trace when IAE is thrown
- private static volatile boolean printStackWhenAccessFails;
-
- // true if printStackWhenAccessFails has been initialized
- private static volatile boolean printStackWhenAccessFailsSet;
-
- private static void printStackTraceIfNeeded(Throwable e) {
- if (!printStackWhenAccessFailsSet && VM.initLevel() >= 1) {
- // can't use method reference here, might be too early in startup
- PrivilegedAction<Boolean> pa = new PrivilegedAction<Boolean>() {
- public Boolean run() {
- String s;
- s = System.getProperty("sun.reflect.debugModuleAccessChecks");
- return (s != null && !s.equalsIgnoreCase("false"));
- }
- };
- printStackWhenAccessFails = AccessController.doPrivileged(pa);
- printStackWhenAccessFailsSet = true;
- }
- if (printStackWhenAccessFails) {
- e.printStackTrace();
- }
- }
-
- /**
- * Throws IllegalAccessException with the an exception message based on
- * the access that is denied.
- */
- private static void throwIllegalAccessException(Class<?> currentClass,
- Class<?> memberClass,
- Object target,
- int modifiers)
- throws IllegalAccessException
- {
- String currentSuffix = "";
- String memberSuffix = "";
- Module m1 = currentClass.getModule();
- if (m1.isNamed())
- currentSuffix = " (in " + m1 + ")";
- Module m2 = memberClass.getModule();
- if (m2.isNamed())
- memberSuffix = " (in " + m2 + ")";
-
- Class<?> c = memberClass;
- while (c.isArray()) {
- c = c.getComponentType();
- }
- String memberPackageName = c.getPackageName();
-
- String msg = currentClass + currentSuffix + " cannot access ";
- if (m2.isExported(memberPackageName, m1)) {
-
- // module access okay so include the modifiers in the message
- msg += "a member of " + memberClass + memberSuffix +
- " with modifiers \"" + Modifier.toString(modifiers) + "\"";
-
- } else {
- // module access failed
- msg += memberClass + memberSuffix+ " because "
- + m2 + " does not export " + memberPackageName;
- if (m2.isNamed()) msg += " to " + m1;
- }
-
- throwIllegalAccessException(msg);
- }
-
- /**
- * Throws IllegalAccessException with the given exception message.
- */
- public static void throwIllegalAccessException(String msg)
- throws IllegalAccessException
- {
- IllegalAccessException e = new IllegalAccessException(msg);
- printStackTraceIfNeeded(e);
- throw e;
- }
-
- /**
- * Throws InaccessibleObjectException with the given exception message.
- */
- public static void throwInaccessibleObjectException(String msg) {
- InaccessibleObjectException e = new InaccessibleObjectException(msg);
- printStackTraceIfNeeded(e);
- throw e;
- }
-
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/ReflectionFactory.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,432 +0,0 @@
-/*
- * Copyright (c) 2001, 2013, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Executable;
-import java.lang.reflect.Method;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Modifier;
-import java.security.AccessController;
-import java.security.Permission;
-import java.security.PrivilegedAction;
-import sun.reflect.misc.ReflectUtil;
-
-/** <P> The master factory for all reflective objects, both those in
- java.lang.reflect (Fields, Methods, Constructors) as well as their
- delegates (FieldAccessors, MethodAccessors, ConstructorAccessors).
- </P>
-
- <P> The methods in this class are extremely unsafe and can cause
- subversion of both the language and the verifier. For this reason,
- they are all instance methods, and access to the constructor of
- this factory is guarded by a security check, in similar style to
- {@link jdk.internal.misc.Unsafe}. </P>
-*/
-
-public class ReflectionFactory {
-
- private static boolean initted = false;
- private static final Permission reflectionFactoryAccessPerm
- = new RuntimePermission("reflectionFactoryAccess");
- private static final ReflectionFactory soleInstance = new ReflectionFactory();
- // Provides access to package-private mechanisms in java.lang.reflect
- private static volatile LangReflectAccess langReflectAccess;
-
- //
- // "Inflation" mechanism. Loading bytecodes to implement
- // Method.invoke() and Constructor.newInstance() currently costs
- // 3-4x more than an invocation via native code for the first
- // invocation (though subsequent invocations have been benchmarked
- // to be over 20x faster). Unfortunately this cost increases
- // startup time for certain applications that use reflection
- // intensively (but only once per class) to bootstrap themselves.
- // To avoid this penalty we reuse the existing JVM entry points
- // for the first few invocations of Methods and Constructors and
- // then switch to the bytecode-based implementations.
- //
- // Package-private to be accessible to NativeMethodAccessorImpl
- // and NativeConstructorAccessorImpl
- private static boolean noInflation = false;
- private static int inflationThreshold = 15;
-
- private ReflectionFactory() {
- }
-
- /**
- * A convenience class for acquiring the capability to instantiate
- * reflective objects. Use this instead of a raw call to {@link
- * #getReflectionFactory} in order to avoid being limited by the
- * permissions of your callers.
- *
- * <p>An instance of this class can be used as the argument of
- * <code>AccessController.doPrivileged</code>.
- */
- public static final class GetReflectionFactoryAction
- implements PrivilegedAction<ReflectionFactory> {
- public ReflectionFactory run() {
- return getReflectionFactory();
- }
- }
-
- /**
- * Provides the caller with the capability to instantiate reflective
- * objects.
- *
- * <p> First, if there is a security manager, its
- * <code>checkPermission</code> method is called with a {@link
- * java.lang.RuntimePermission} with target
- * <code>"reflectionFactoryAccess"</code>. This may result in a
- * security exception.
- *
- * <p> The returned <code>ReflectionFactory</code> object should be
- * carefully guarded by the caller, since it can be used to read and
- * write private data and invoke private methods, as well as to load
- * unverified bytecodes. It must never be passed to untrusted code.
- *
- * @exception SecurityException if a security manager exists and its
- * <code>checkPermission</code> method doesn't allow
- * access to the RuntimePermission "reflectionFactoryAccess". */
- public static ReflectionFactory getReflectionFactory() {
- SecurityManager security = System.getSecurityManager();
- if (security != null) {
- // TO DO: security.checkReflectionFactoryAccess();
- security.checkPermission(reflectionFactoryAccessPerm);
- }
- return soleInstance;
- }
-
- //--------------------------------------------------------------------------
- //
- // Routines used by java.lang.reflect
- //
- //
-
- /** Called only by java.lang.reflect.Modifier's static initializer */
- public void setLangReflectAccess(LangReflectAccess access) {
- langReflectAccess = access;
- }
-
- /**
- * Note: this routine can cause the declaring class for the field
- * be initialized and therefore must not be called until the
- * first get/set of this field.
- * @param field the field
- * @param override true if caller has overridden accessibility
- */
- public FieldAccessor newFieldAccessor(Field field, boolean override) {
- checkInitted();
- return UnsafeFieldAccessorFactory.newFieldAccessor(field, override);
- }
-
- public MethodAccessor newMethodAccessor(Method method) {
- checkInitted();
-
- if (noInflation && !ReflectUtil.isVMAnonymousClass(method.getDeclaringClass())) {
- return new MethodAccessorGenerator().
- generateMethod(method.getDeclaringClass(),
- method.getName(),
- method.getParameterTypes(),
- method.getReturnType(),
- method.getExceptionTypes(),
- method.getModifiers());
- } else {
- NativeMethodAccessorImpl acc =
- new NativeMethodAccessorImpl(method);
- DelegatingMethodAccessorImpl res =
- new DelegatingMethodAccessorImpl(acc);
- acc.setParent(res);
- return res;
- }
- }
-
- public ConstructorAccessor newConstructorAccessor(Constructor<?> c) {
- checkInitted();
-
- Class<?> declaringClass = c.getDeclaringClass();
- if (Modifier.isAbstract(declaringClass.getModifiers())) {
- return new InstantiationExceptionConstructorAccessorImpl(null);
- }
- if (declaringClass == Class.class) {
- return new InstantiationExceptionConstructorAccessorImpl
- ("Can not instantiate java.lang.Class");
- }
- // Bootstrapping issue: since we use Class.newInstance() in
- // the ConstructorAccessor generation process, we have to
- // break the cycle here.
- if (Reflection.isSubclassOf(declaringClass,
- ConstructorAccessorImpl.class)) {
- return new BootstrapConstructorAccessorImpl(c);
- }
-
- if (noInflation && !ReflectUtil.isVMAnonymousClass(c.getDeclaringClass())) {
- return new MethodAccessorGenerator().
- generateConstructor(c.getDeclaringClass(),
- c.getParameterTypes(),
- c.getExceptionTypes(),
- c.getModifiers());
- } else {
- NativeConstructorAccessorImpl acc =
- new NativeConstructorAccessorImpl(c);
- DelegatingConstructorAccessorImpl res =
- new DelegatingConstructorAccessorImpl(acc);
- acc.setParent(res);
- return res;
- }
- }
-
- //--------------------------------------------------------------------------
- //
- // Routines used by java.lang
- //
- //
-
- /** Creates a new java.lang.reflect.Field. Access checks as per
- java.lang.reflect.AccessibleObject are not overridden. */
- public Field newField(Class<?> declaringClass,
- String name,
- Class<?> type,
- int modifiers,
- int slot,
- String signature,
- byte[] annotations)
- {
- return langReflectAccess().newField(declaringClass,
- name,
- type,
- modifiers,
- slot,
- signature,
- annotations);
- }
-
- /** Creates a new java.lang.reflect.Method. Access checks as per
- java.lang.reflect.AccessibleObject are not overridden. */
- public Method newMethod(Class<?> declaringClass,
- String name,
- Class<?>[] parameterTypes,
- Class<?> returnType,
- Class<?>[] checkedExceptions,
- int modifiers,
- int slot,
- String signature,
- byte[] annotations,
- byte[] parameterAnnotations,
- byte[] annotationDefault)
- {
- return langReflectAccess().newMethod(declaringClass,
- name,
- parameterTypes,
- returnType,
- checkedExceptions,
- modifiers,
- slot,
- signature,
- annotations,
- parameterAnnotations,
- annotationDefault);
- }
-
- /** Creates a new java.lang.reflect.Constructor. Access checks as
- per java.lang.reflect.AccessibleObject are not overridden. */
- public Constructor<?> newConstructor(Class<?> declaringClass,
- Class<?>[] parameterTypes,
- Class<?>[] checkedExceptions,
- int modifiers,
- int slot,
- String signature,
- byte[] annotations,
- byte[] parameterAnnotations)
- {
- return langReflectAccess().newConstructor(declaringClass,
- parameterTypes,
- checkedExceptions,
- modifiers,
- slot,
- signature,
- annotations,
- parameterAnnotations);
- }
-
- /** Gets the MethodAccessor object for a java.lang.reflect.Method */
- public MethodAccessor getMethodAccessor(Method m) {
- return langReflectAccess().getMethodAccessor(m);
- }
-
- /** Sets the MethodAccessor object for a java.lang.reflect.Method */
- public void setMethodAccessor(Method m, MethodAccessor accessor) {
- langReflectAccess().setMethodAccessor(m, accessor);
- }
-
- /** Gets the ConstructorAccessor object for a
- java.lang.reflect.Constructor */
- public ConstructorAccessor getConstructorAccessor(Constructor<?> c) {
- return langReflectAccess().getConstructorAccessor(c);
- }
-
- /** Sets the ConstructorAccessor object for a
- java.lang.reflect.Constructor */
- public void setConstructorAccessor(Constructor<?> c,
- ConstructorAccessor accessor)
- {
- langReflectAccess().setConstructorAccessor(c, accessor);
- }
-
- /** Makes a copy of the passed method. The returned method is a
- "child" of the passed one; see the comments in Method.java for
- details. */
- public Method copyMethod(Method arg) {
- return langReflectAccess().copyMethod(arg);
- }
-
- /** Makes a copy of the passed method. The returned method is NOT
- * a "child" but a "sibling" of the Method in arg. Should only be
- * used on non-root methods. */
- public Method leafCopyMethod(Method arg) {
- return langReflectAccess().leafCopyMethod(arg);
- }
-
-
- /** Makes a copy of the passed field. The returned field is a
- "child" of the passed one; see the comments in Field.java for
- details. */
- public Field copyField(Field arg) {
- return langReflectAccess().copyField(arg);
- }
-
- /** Makes a copy of the passed constructor. The returned
- constructor is a "child" of the passed one; see the comments
- in Constructor.java for details. */
- public <T> Constructor<T> copyConstructor(Constructor<T> arg) {
- return langReflectAccess().copyConstructor(arg);
- }
-
- /** Gets the byte[] that encodes TypeAnnotations on an executable.
- */
- public byte[] getExecutableTypeAnnotationBytes(Executable ex) {
- return langReflectAccess().getExecutableTypeAnnotationBytes(ex);
- }
-
- //--------------------------------------------------------------------------
- //
- // Routines used by serialization
- //
- //
-
- public Constructor<?> newConstructorForSerialization
- (Class<?> classToInstantiate, Constructor<?> constructorToCall)
- {
- // Fast path
- if (constructorToCall.getDeclaringClass() == classToInstantiate) {
- return constructorToCall;
- }
-
- ConstructorAccessor acc = new MethodAccessorGenerator().
- generateSerializationConstructor(classToInstantiate,
- constructorToCall.getParameterTypes(),
- constructorToCall.getExceptionTypes(),
- constructorToCall.getModifiers(),
- constructorToCall.getDeclaringClass());
- Constructor<?> c = newConstructor(constructorToCall.getDeclaringClass(),
- constructorToCall.getParameterTypes(),
- constructorToCall.getExceptionTypes(),
- constructorToCall.getModifiers(),
- langReflectAccess().
- getConstructorSlot(constructorToCall),
- langReflectAccess().
- getConstructorSignature(constructorToCall),
- langReflectAccess().
- getConstructorAnnotations(constructorToCall),
- langReflectAccess().
- getConstructorParameterAnnotations(constructorToCall));
- setConstructorAccessor(c, acc);
- return c;
- }
-
- //--------------------------------------------------------------------------
- //
- // Internals only below this point
- //
-
- static int inflationThreshold() {
- return inflationThreshold;
- }
-
- /** We have to defer full initialization of this class until after
- the static initializer is run since java.lang.reflect.Method's
- static initializer (more properly, that for
- java.lang.reflect.AccessibleObject) causes this class's to be
- run, before the system properties are set up. */
- 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;
- }
-
- String val = System.getProperty("sun.reflect.noInflation");
- if (val != null && val.equals("true")) {
- noInflation = true;
- }
-
- val = System.getProperty("sun.reflect.inflationThreshold");
- if (val != null) {
- try {
- inflationThreshold = Integer.parseInt(val);
- } catch (NumberFormatException e) {
- throw new RuntimeException("Unable to parse property sun.reflect.inflationThreshold", e);
- }
- }
-
- initted = true;
- return null;
- }
- });
- }
-
- private static LangReflectAccess langReflectAccess() {
- if (langReflectAccess == null) {
- // Call a static method to get class java.lang.reflect.Modifier
- // initialized. Its static initializer will cause
- // setLangReflectAccess() to be called from the context of the
- // java.lang.reflect package.
- Modifier.isPublic(Modifier.PUBLIC);
- }
- return langReflectAccess;
- }
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/SerializationConstructorAccessorImpl.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2001, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-/** <P> Java serialization (in java.io) expects to be able to
- instantiate a class and invoke a no-arg constructor of that
- class's first non-Serializable superclass. This is not a valid
- operation according to the VM specification; one can not (for
- classes A and B, where B is a subclass of A) write "new B;
- invokespecial A()" without getting a verification error. </P>
-
- <P> In all other respects, the bytecode-based reflection framework
- can be reused for this purpose. This marker class was originally
- known to the VM and verification disabled for it and all
- subclasses, but the bug fix for 4486457 necessitated disabling
- verification for all of the dynamically-generated bytecodes
- associated with reflection. This class has been left in place to
- make future debugging easier. </P> */
-
-abstract class SerializationConstructorAccessorImpl
- extends ConstructorAccessorImpl {
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/SignatureIterator.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,81 +0,0 @@
-/*
- * Copyright (c) 2001, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-/** Assists in iterating down a method's signature */
-
-public class SignatureIterator {
- private final String sig;
- private int idx;
-
- public SignatureIterator(String sig) {
- this.sig = sig;
- reset();
- }
-
- public void reset() {
- idx = 1;
- }
-
- public boolean atEnd() {
- return sig.charAt(idx) == ')';
- }
-
- public String next() {
- if (atEnd()) return null;
- char c = sig.charAt(idx);
- if (c != '[' && c != 'L') {
- ++idx;
- return new String(new char[] { c });
- }
- // Walk forward to end of entry
- int endIdx = idx;
- if (c == '[') {
- while ((c = sig.charAt(endIdx)) == '[') {
- endIdx++;
- }
- }
-
- if (c == 'L') {
- while (sig.charAt(endIdx) != ';') {
- endIdx++;
- }
- }
-
- int beginIdx = idx;
- idx = endIdx + 1;
- return sig.substring(beginIdx, idx);
- }
-
- /** Should only be called when atEnd() is true. Does not change
- state of iterator. */
- public String returnType() {
- if (!atEnd()) {
- throw new InternalError("Illegal use of SignatureIterator");
- }
- return sig.substring(idx + 1, sig.length());
- }
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/UTF8.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,76 +0,0 @@
-/*
- * Copyright (c) 2001, 2011, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-/** It is necessary to use a "bootstrap" UTF-8 encoder for encoding
- constant pool entries because the character set converters rely on
- Class.newInstance(). */
-
-class UTF8 {
- // This encoder is not quite correct. It does not handle surrogate pairs.
- static byte[] encode(String str) {
- int len = str.length();
- byte[] res = new byte[utf8Length(str)];
- int utf8Idx = 0;
- try {
- for (int i = 0; i < len; i++) {
- int c = str.charAt(i) & 0xFFFF;
- if (c >= 0x0001 && c <= 0x007F) {
- res[utf8Idx++] = (byte) c;
- } else if (c == 0x0000 ||
- (c >= 0x0080 && c <= 0x07FF)) {
- res[utf8Idx++] = (byte) (0xC0 + (c >> 6));
- res[utf8Idx++] = (byte) (0x80 + (c & 0x3F));
- } else {
- res[utf8Idx++] = (byte) (0xE0 + (c >> 12));
- res[utf8Idx++] = (byte) (0x80 + ((c >> 6) & 0x3F));
- res[utf8Idx++] = (byte) (0x80 + (c & 0x3F));
- }
- }
- } catch (ArrayIndexOutOfBoundsException e) {
- throw new InternalError
- ("Bug in sun.reflect bootstrap UTF-8 encoder", e);
- }
- return res;
- }
-
- private static int utf8Length(String str) {
- int len = str.length();
- int utf8Len = 0;
- for (int i = 0; i < len; i++) {
- int c = str.charAt(i) & 0xFFFF;
- if (c >= 0x0001 && c <= 0x007F) {
- utf8Len += 1;
- } else if (c == 0x0000 ||
- (c >= 0x0080 && c <= 0x07FF)) {
- utf8Len += 2;
- } else {
- utf8Len += 3;
- }
- }
- return utf8Len;
- }
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/UnsafeBooleanFieldAccessorImpl.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,140 +0,0 @@
-/*
- * Copyright (c) 2001, 2005, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-import java.lang.reflect.Field;
-
-class UnsafeBooleanFieldAccessorImpl extends UnsafeFieldAccessorImpl {
- UnsafeBooleanFieldAccessorImpl(Field field) {
- super(field);
- }
-
- public Object get(Object obj) throws IllegalArgumentException {
- return Boolean.valueOf(getBoolean(obj));
- }
-
- public boolean getBoolean(Object obj) throws IllegalArgumentException {
- ensureObj(obj);
- return unsafe.getBoolean(obj, fieldOffset);
- }
-
- public byte getByte(Object obj) throws IllegalArgumentException {
- throw newGetByteIllegalArgumentException();
- }
-
- public char getChar(Object obj) throws IllegalArgumentException {
- throw newGetCharIllegalArgumentException();
- }
-
- public short getShort(Object obj) throws IllegalArgumentException {
- throw newGetShortIllegalArgumentException();
- }
-
- public int getInt(Object obj) throws IllegalArgumentException {
- throw newGetIntIllegalArgumentException();
- }
-
- public long getLong(Object obj) throws IllegalArgumentException {
- throw newGetLongIllegalArgumentException();
- }
-
- public float getFloat(Object obj) throws IllegalArgumentException {
- throw newGetFloatIllegalArgumentException();
- }
-
- public double getDouble(Object obj) throws IllegalArgumentException {
- throw newGetDoubleIllegalArgumentException();
- }
-
- public void set(Object obj, Object value)
- throws IllegalArgumentException, IllegalAccessException
- {
- ensureObj(obj);
- if (isFinal) {
- throwFinalFieldIllegalAccessException(value);
- }
- if (value == null) {
- throwSetIllegalArgumentException(value);
- }
- if (value instanceof Boolean) {
- unsafe.putBoolean(obj, fieldOffset, ((Boolean) value).booleanValue());
- return;
- }
- throwSetIllegalArgumentException(value);
- }
-
- public void setBoolean(Object obj, boolean z)
- throws IllegalArgumentException, IllegalAccessException
- {
- ensureObj(obj);
- if (isFinal) {
- throwFinalFieldIllegalAccessException(z);
- }
- unsafe.putBoolean(obj, fieldOffset, z);
- }
-
- public void setByte(Object obj, byte b)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(b);
- }
-
- public void setChar(Object obj, char c)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(c);
- }
-
- public void setShort(Object obj, short s)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(s);
- }
-
- public void setInt(Object obj, int i)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(i);
- }
-
- public void setLong(Object obj, long l)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(l);
- }
-
- public void setFloat(Object obj, float f)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(f);
- }
-
- public void setDouble(Object obj, double d)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(d);
- }
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/UnsafeByteFieldAccessorImpl.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,140 +0,0 @@
-/*
- * Copyright (c) 2001, 2005, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-import java.lang.reflect.Field;
-
-class UnsafeByteFieldAccessorImpl extends UnsafeFieldAccessorImpl {
- UnsafeByteFieldAccessorImpl(Field field) {
- super(field);
- }
-
- public Object get(Object obj) throws IllegalArgumentException {
- return Byte.valueOf(getByte(obj));
- }
-
- public boolean getBoolean(Object obj) throws IllegalArgumentException {
- throw newGetBooleanIllegalArgumentException();
- }
-
- public byte getByte(Object obj) throws IllegalArgumentException {
- ensureObj(obj);
- return unsafe.getByte(obj, fieldOffset);
- }
-
- public char getChar(Object obj) throws IllegalArgumentException {
- throw newGetCharIllegalArgumentException();
- }
-
- public short getShort(Object obj) throws IllegalArgumentException {
- return getByte(obj);
- }
-
- public int getInt(Object obj) throws IllegalArgumentException {
- return getByte(obj);
- }
-
- public long getLong(Object obj) throws IllegalArgumentException {
- return getByte(obj);
- }
-
- public float getFloat(Object obj) throws IllegalArgumentException {
- return getByte(obj);
- }
-
- public double getDouble(Object obj) throws IllegalArgumentException {
- return getByte(obj);
- }
-
- public void set(Object obj, Object value)
- throws IllegalArgumentException, IllegalAccessException
- {
- ensureObj(obj);
- if (isFinal) {
- throwFinalFieldIllegalAccessException(value);
- }
- if (value == null) {
- throwSetIllegalArgumentException(value);
- }
- if (value instanceof Byte) {
- unsafe.putByte(obj, fieldOffset, ((Byte) value).byteValue());
- return;
- }
- throwSetIllegalArgumentException(value);
- }
-
- public void setBoolean(Object obj, boolean z)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(z);
- }
-
- public void setByte(Object obj, byte b)
- throws IllegalArgumentException, IllegalAccessException
- {
- ensureObj(obj);
- if (isFinal) {
- throwFinalFieldIllegalAccessException(b);
- }
- unsafe.putByte(obj, fieldOffset, b);
- }
-
- public void setChar(Object obj, char c)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(c);
- }
-
- public void setShort(Object obj, short s)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(s);
- }
-
- public void setInt(Object obj, int i)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(i);
- }
-
- public void setLong(Object obj, long l)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(l);
- }
-
- public void setFloat(Object obj, float f)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(f);
- }
-
- public void setDouble(Object obj, double d)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(d);
- }
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/UnsafeCharacterFieldAccessorImpl.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,140 +0,0 @@
-/*
- * Copyright (c) 2001, 2005, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-import java.lang.reflect.Field;
-
-class UnsafeCharacterFieldAccessorImpl extends UnsafeFieldAccessorImpl {
- UnsafeCharacterFieldAccessorImpl(Field field) {
- super(field);
- }
-
- public Object get(Object obj) throws IllegalArgumentException {
- return Character.valueOf(getChar(obj));
- }
-
- public boolean getBoolean(Object obj) throws IllegalArgumentException {
- throw newGetBooleanIllegalArgumentException();
- }
-
- public byte getByte(Object obj) throws IllegalArgumentException {
- throw newGetByteIllegalArgumentException();
- }
-
- public char getChar(Object obj) throws IllegalArgumentException {
- ensureObj(obj);
- return unsafe.getChar(obj, fieldOffset);
- }
-
- public short getShort(Object obj) throws IllegalArgumentException {
- throw newGetShortIllegalArgumentException();
- }
-
- public int getInt(Object obj) throws IllegalArgumentException {
- return getChar(obj);
- }
-
- public long getLong(Object obj) throws IllegalArgumentException {
- return getChar(obj);
- }
-
- public float getFloat(Object obj) throws IllegalArgumentException {
- return getChar(obj);
- }
-
- public double getDouble(Object obj) throws IllegalArgumentException {
- return getChar(obj);
- }
-
- public void set(Object obj, Object value)
- throws IllegalArgumentException, IllegalAccessException
- {
- ensureObj(obj);
- if (isFinal) {
- throwFinalFieldIllegalAccessException(value);
- }
- if (value == null) {
- throwSetIllegalArgumentException(value);
- }
- if (value instanceof Character) {
- unsafe.putChar(obj, fieldOffset, ((Character) value).charValue());
- return;
- }
- throwSetIllegalArgumentException(value);
- }
-
- public void setBoolean(Object obj, boolean z)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(z);
- }
-
- public void setByte(Object obj, byte b)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(b);
- }
-
- public void setChar(Object obj, char c)
- throws IllegalArgumentException, IllegalAccessException
- {
- ensureObj(obj);
- if (isFinal) {
- throwFinalFieldIllegalAccessException(c);
- }
- unsafe.putChar(obj, fieldOffset, c);
- }
-
- public void setShort(Object obj, short s)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(s);
- }
-
- public void setInt(Object obj, int i)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(i);
- }
-
- public void setLong(Object obj, long l)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(l);
- }
-
- public void setFloat(Object obj, float f)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(f);
- }
-
- public void setDouble(Object obj, double d)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(d);
- }
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/UnsafeDoubleFieldAccessorImpl.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,164 +0,0 @@
-/*
- * Copyright (c) 2001, 2005, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-import java.lang.reflect.Field;
-
-class UnsafeDoubleFieldAccessorImpl extends UnsafeFieldAccessorImpl {
- UnsafeDoubleFieldAccessorImpl(Field field) {
- super(field);
- }
-
- public Object get(Object obj) throws IllegalArgumentException {
- return Double.valueOf(getDouble(obj));
- }
-
- public boolean getBoolean(Object obj) throws IllegalArgumentException {
- throw newGetBooleanIllegalArgumentException();
- }
-
- public byte getByte(Object obj) throws IllegalArgumentException {
- throw newGetByteIllegalArgumentException();
- }
-
- public char getChar(Object obj) throws IllegalArgumentException {
- throw newGetCharIllegalArgumentException();
- }
-
- public short getShort(Object obj) throws IllegalArgumentException {
- throw newGetShortIllegalArgumentException();
- }
-
- public int getInt(Object obj) throws IllegalArgumentException {
- throw newGetIntIllegalArgumentException();
- }
-
- public long getLong(Object obj) throws IllegalArgumentException {
- throw newGetLongIllegalArgumentException();
- }
-
- public float getFloat(Object obj) throws IllegalArgumentException {
- throw newGetFloatIllegalArgumentException();
- }
-
- public double getDouble(Object obj) throws IllegalArgumentException {
- ensureObj(obj);
- return unsafe.getDouble(obj, fieldOffset);
- }
-
- public void set(Object obj, Object value)
- throws IllegalArgumentException, IllegalAccessException
- {
- ensureObj(obj);
- if (isFinal) {
- throwFinalFieldIllegalAccessException(value);
- }
- if (value == null) {
- throwSetIllegalArgumentException(value);
- }
- if (value instanceof Byte) {
- unsafe.putDouble(obj, fieldOffset, ((Byte) value).byteValue());
- return;
- }
- if (value instanceof Short) {
- unsafe.putDouble(obj, fieldOffset, ((Short) value).shortValue());
- return;
- }
- if (value instanceof Character) {
- unsafe.putDouble(obj, fieldOffset, ((Character) value).charValue());
- return;
- }
- if (value instanceof Integer) {
- unsafe.putDouble(obj, fieldOffset, ((Integer) value).intValue());
- return;
- }
- if (value instanceof Long) {
- unsafe.putDouble(obj, fieldOffset, ((Long) value).longValue());
- return;
- }
- if (value instanceof Float) {
- unsafe.putDouble(obj, fieldOffset, ((Float) value).floatValue());
- return;
- }
- if (value instanceof Double) {
- unsafe.putDouble(obj, fieldOffset, ((Double) value).doubleValue());
- return;
- }
- throwSetIllegalArgumentException(value);
- }
-
- public void setBoolean(Object obj, boolean z)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(z);
- }
-
- public void setByte(Object obj, byte b)
- throws IllegalArgumentException, IllegalAccessException
- {
- setDouble(obj, b);
- }
-
- public void setChar(Object obj, char c)
- throws IllegalArgumentException, IllegalAccessException
- {
- setDouble(obj, c);
- }
-
- public void setShort(Object obj, short s)
- throws IllegalArgumentException, IllegalAccessException
- {
- setDouble(obj, s);
- }
-
- public void setInt(Object obj, int i)
- throws IllegalArgumentException, IllegalAccessException
- {
- setDouble(obj, i);
- }
-
- public void setLong(Object obj, long l)
- throws IllegalArgumentException, IllegalAccessException
- {
- setDouble(obj, l);
- }
-
- public void setFloat(Object obj, float f)
- throws IllegalArgumentException, IllegalAccessException
- {
- setDouble(obj, f);
- }
-
- public void setDouble(Object obj, double d)
- throws IllegalArgumentException, IllegalAccessException
- {
- ensureObj(obj);
- if (isFinal) {
- throwFinalFieldIllegalAccessException(d);
- }
- unsafe.putDouble(obj, fieldOffset, d);
- }
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/UnsafeFieldAccessorFactory.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,130 +0,0 @@
-/*
- * Copyright (c) 2001, 2011, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
-
-class UnsafeFieldAccessorFactory {
- static FieldAccessor newFieldAccessor(Field field, boolean override) {
- Class<?> type = field.getType();
- boolean isStatic = Modifier.isStatic(field.getModifiers());
- boolean isFinal = Modifier.isFinal(field.getModifiers());
- boolean isVolatile = Modifier.isVolatile(field.getModifiers());
- boolean isQualified = isFinal || isVolatile;
- boolean isReadOnly = isFinal && (isStatic || !override);
- if (isStatic) {
- // This code path does not guarantee that the field's
- // declaring class has been initialized, but it must be
- // before performing reflective operations.
- UnsafeFieldAccessorImpl.unsafe.ensureClassInitialized(field.getDeclaringClass());
-
- if (!isQualified) {
- if (type == Boolean.TYPE) {
- return new UnsafeStaticBooleanFieldAccessorImpl(field);
- } else if (type == Byte.TYPE) {
- return new UnsafeStaticByteFieldAccessorImpl(field);
- } else if (type == Short.TYPE) {
- return new UnsafeStaticShortFieldAccessorImpl(field);
- } else if (type == Character.TYPE) {
- return new UnsafeStaticCharacterFieldAccessorImpl(field);
- } else if (type == Integer.TYPE) {
- return new UnsafeStaticIntegerFieldAccessorImpl(field);
- } else if (type == Long.TYPE) {
- return new UnsafeStaticLongFieldAccessorImpl(field);
- } else if (type == Float.TYPE) {
- return new UnsafeStaticFloatFieldAccessorImpl(field);
- } else if (type == Double.TYPE) {
- return new UnsafeStaticDoubleFieldAccessorImpl(field);
- } else {
- return new UnsafeStaticObjectFieldAccessorImpl(field);
- }
- } else {
- if (type == Boolean.TYPE) {
- return new UnsafeQualifiedStaticBooleanFieldAccessorImpl(field, isReadOnly);
- } else if (type == Byte.TYPE) {
- return new UnsafeQualifiedStaticByteFieldAccessorImpl(field, isReadOnly);
- } else if (type == Short.TYPE) {
- return new UnsafeQualifiedStaticShortFieldAccessorImpl(field, isReadOnly);
- } else if (type == Character.TYPE) {
- return new UnsafeQualifiedStaticCharacterFieldAccessorImpl(field, isReadOnly);
- } else if (type == Integer.TYPE) {
- return new UnsafeQualifiedStaticIntegerFieldAccessorImpl(field, isReadOnly);
- } else if (type == Long.TYPE) {
- return new UnsafeQualifiedStaticLongFieldAccessorImpl(field, isReadOnly);
- } else if (type == Float.TYPE) {
- return new UnsafeQualifiedStaticFloatFieldAccessorImpl(field, isReadOnly);
- } else if (type == Double.TYPE) {
- return new UnsafeQualifiedStaticDoubleFieldAccessorImpl(field, isReadOnly);
- } else {
- return new UnsafeQualifiedStaticObjectFieldAccessorImpl(field, isReadOnly);
- }
- }
- } else {
- if (!isQualified) {
- if (type == Boolean.TYPE) {
- return new UnsafeBooleanFieldAccessorImpl(field);
- } else if (type == Byte.TYPE) {
- return new UnsafeByteFieldAccessorImpl(field);
- } else if (type == Short.TYPE) {
- return new UnsafeShortFieldAccessorImpl(field);
- } else if (type == Character.TYPE) {
- return new UnsafeCharacterFieldAccessorImpl(field);
- } else if (type == Integer.TYPE) {
- return new UnsafeIntegerFieldAccessorImpl(field);
- } else if (type == Long.TYPE) {
- return new UnsafeLongFieldAccessorImpl(field);
- } else if (type == Float.TYPE) {
- return new UnsafeFloatFieldAccessorImpl(field);
- } else if (type == Double.TYPE) {
- return new UnsafeDoubleFieldAccessorImpl(field);
- } else {
- return new UnsafeObjectFieldAccessorImpl(field);
- }
- } else {
- if (type == Boolean.TYPE) {
- return new UnsafeQualifiedBooleanFieldAccessorImpl(field, isReadOnly);
- } else if (type == Byte.TYPE) {
- return new UnsafeQualifiedByteFieldAccessorImpl(field, isReadOnly);
- } else if (type == Short.TYPE) {
- return new UnsafeQualifiedShortFieldAccessorImpl(field, isReadOnly);
- } else if (type == Character.TYPE) {
- return new UnsafeQualifiedCharacterFieldAccessorImpl(field, isReadOnly);
- } else if (type == Integer.TYPE) {
- return new UnsafeQualifiedIntegerFieldAccessorImpl(field, isReadOnly);
- } else if (type == Long.TYPE) {
- return new UnsafeQualifiedLongFieldAccessorImpl(field, isReadOnly);
- } else if (type == Float.TYPE) {
- return new UnsafeQualifiedFloatFieldAccessorImpl(field, isReadOnly);
- } else if (type == Double.TYPE) {
- return new UnsafeQualifiedDoubleFieldAccessorImpl(field, isReadOnly);
- } else {
- return new UnsafeQualifiedObjectFieldAccessorImpl(field, isReadOnly);
- }
- }
- }
- }
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/UnsafeFieldAccessorImpl.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,206 +0,0 @@
-/*
- * Copyright (c) 2001, 2011, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
-import jdk.internal.misc.Unsafe;
-
-/** Base class for jdk.internal.misc.Unsafe-based FieldAccessors. The
- observation is that there are only nine types of fields from the
- standpoint of reflection code: the eight primitive types and
- Object. Using class Unsafe instead of generated bytecodes saves
- memory and loading time for the dynamically-generated
- FieldAccessors. */
-
-abstract class UnsafeFieldAccessorImpl extends FieldAccessorImpl {
- static final Unsafe unsafe = Unsafe.getUnsafe();
-
- protected final Field field;
- protected final long fieldOffset;
- protected final boolean isFinal;
-
- UnsafeFieldAccessorImpl(Field field) {
- this.field = field;
- if (Modifier.isStatic(field.getModifiers()))
- fieldOffset = unsafe.staticFieldOffset(field);
- else
- fieldOffset = unsafe.objectFieldOffset(field);
- isFinal = Modifier.isFinal(field.getModifiers());
- }
-
- protected void ensureObj(Object o) {
- // NOTE: will throw NullPointerException, as specified, if o is null
- if (!field.getDeclaringClass().isAssignableFrom(o.getClass())) {
- throwSetIllegalArgumentException(o);
- }
- }
-
- private String getQualifiedFieldName() {
- return field.getDeclaringClass().getName() + "." +field.getName();
- }
-
- protected IllegalArgumentException newGetIllegalArgumentException(String type) {
- return new IllegalArgumentException(
- "Attempt to get "+field.getType().getName()+" field \"" +
- getQualifiedFieldName() + "\" with illegal data type conversion to "+type
- );
- }
-
- protected void throwFinalFieldIllegalAccessException(String attemptedType,
- String attemptedValue)
- throws IllegalAccessException {
- throw new IllegalAccessException(getSetMessage(attemptedType, attemptedValue));
-
- }
- protected void throwFinalFieldIllegalAccessException(Object o) throws IllegalAccessException {
- throwFinalFieldIllegalAccessException(o != null ? o.getClass().getName() : "", "");
- }
-
- protected void throwFinalFieldIllegalAccessException(boolean z) throws IllegalAccessException {
- throwFinalFieldIllegalAccessException("boolean", Boolean.toString(z));
- }
-
- protected void throwFinalFieldIllegalAccessException(char b) throws IllegalAccessException {
- throwFinalFieldIllegalAccessException("char", Character.toString(b));
- }
-
- protected void throwFinalFieldIllegalAccessException(byte b) throws IllegalAccessException {
- throwFinalFieldIllegalAccessException("byte", Byte.toString(b));
- }
-
- protected void throwFinalFieldIllegalAccessException(short b) throws IllegalAccessException {
- throwFinalFieldIllegalAccessException("short", Short.toString(b));
- }
-
- protected void throwFinalFieldIllegalAccessException(int i) throws IllegalAccessException {
- throwFinalFieldIllegalAccessException("int", Integer.toString(i));
- }
-
- protected void throwFinalFieldIllegalAccessException(long i) throws IllegalAccessException {
- throwFinalFieldIllegalAccessException("long", Long.toString(i));
- }
-
- protected void throwFinalFieldIllegalAccessException(float f) throws IllegalAccessException {
- throwFinalFieldIllegalAccessException("float", Float.toString(f));
- }
-
- protected void throwFinalFieldIllegalAccessException(double f) throws IllegalAccessException {
- throwFinalFieldIllegalAccessException("double", Double.toString(f));
- }
-
- protected IllegalArgumentException newGetBooleanIllegalArgumentException() {
- return newGetIllegalArgumentException("boolean");
- }
-
- protected IllegalArgumentException newGetByteIllegalArgumentException() {
- return newGetIllegalArgumentException("byte");
- }
-
- protected IllegalArgumentException newGetCharIllegalArgumentException() {
- return newGetIllegalArgumentException("char");
- }
-
- protected IllegalArgumentException newGetShortIllegalArgumentException() {
- return newGetIllegalArgumentException("short");
- }
-
- protected IllegalArgumentException newGetIntIllegalArgumentException() {
- return newGetIllegalArgumentException("int");
- }
-
- protected IllegalArgumentException newGetLongIllegalArgumentException() {
- return newGetIllegalArgumentException("long");
- }
-
- protected IllegalArgumentException newGetFloatIllegalArgumentException() {
- return newGetIllegalArgumentException("float");
- }
-
- protected IllegalArgumentException newGetDoubleIllegalArgumentException() {
- return newGetIllegalArgumentException("double");
- }
-
- protected String getSetMessage(String attemptedType, String attemptedValue) {
- String err = "Can not set";
- if (Modifier.isStatic(field.getModifiers()))
- err += " static";
- if (isFinal)
- err += " final";
- err += " " + field.getType().getName() + " field " + getQualifiedFieldName() + " to ";
- if (attemptedValue.length() > 0) {
- err += "(" + attemptedType + ")" + attemptedValue;
- } else {
- if (attemptedType.length() > 0)
- err += attemptedType;
- else
- err += "null value";
- }
- return err;
- }
-
- protected void throwSetIllegalArgumentException(String attemptedType,
- String attemptedValue) {
- throw new IllegalArgumentException(getSetMessage(attemptedType,attemptedValue));
- }
-
- protected void throwSetIllegalArgumentException(Object o) {
- throwSetIllegalArgumentException(o != null ? o.getClass().getName() : "", "");
- }
-
- protected void throwSetIllegalArgumentException(boolean b) {
- throwSetIllegalArgumentException("boolean", Boolean.toString(b));
- }
-
- protected void throwSetIllegalArgumentException(byte b) {
- throwSetIllegalArgumentException("byte", Byte.toString(b));
- }
-
- protected void throwSetIllegalArgumentException(char c) {
- throwSetIllegalArgumentException("char", Character.toString(c));
- }
-
- protected void throwSetIllegalArgumentException(short s) {
- throwSetIllegalArgumentException("short", Short.toString(s));
- }
-
- protected void throwSetIllegalArgumentException(int i) {
- throwSetIllegalArgumentException("int", Integer.toString(i));
- }
-
- protected void throwSetIllegalArgumentException(long l) {
- throwSetIllegalArgumentException("long", Long.toString(l));
- }
-
- protected void throwSetIllegalArgumentException(float f) {
- throwSetIllegalArgumentException("float", Float.toString(f));
- }
-
- protected void throwSetIllegalArgumentException(double d) {
- throwSetIllegalArgumentException("double", Double.toString(d));
- }
-
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/UnsafeFloatFieldAccessorImpl.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,160 +0,0 @@
-/*
- * Copyright (c) 2001, 2005, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-import java.lang.reflect.Field;
-
-class UnsafeFloatFieldAccessorImpl extends UnsafeFieldAccessorImpl {
- UnsafeFloatFieldAccessorImpl(Field field) {
- super(field);
- }
-
- public Object get(Object obj) throws IllegalArgumentException {
- return Float.valueOf(getFloat(obj));
- }
-
- public boolean getBoolean(Object obj) throws IllegalArgumentException {
- throw newGetBooleanIllegalArgumentException();
- }
-
- public byte getByte(Object obj) throws IllegalArgumentException {
- throw newGetByteIllegalArgumentException();
- }
-
- public char getChar(Object obj) throws IllegalArgumentException {
- throw newGetCharIllegalArgumentException();
- }
-
- public short getShort(Object obj) throws IllegalArgumentException {
- throw newGetShortIllegalArgumentException();
- }
-
- public int getInt(Object obj) throws IllegalArgumentException {
- throw newGetIntIllegalArgumentException();
- }
-
- public long getLong(Object obj) throws IllegalArgumentException {
- throw newGetLongIllegalArgumentException();
- }
-
- public float getFloat(Object obj) throws IllegalArgumentException {
- ensureObj(obj);
- return unsafe.getFloat(obj, fieldOffset);
- }
-
- public double getDouble(Object obj) throws IllegalArgumentException {
- return getFloat(obj);
- }
-
- public void set(Object obj, Object value)
- throws IllegalArgumentException, IllegalAccessException
- {
- ensureObj(obj);
- if (isFinal) {
- throwFinalFieldIllegalAccessException(value);
- }
- if (value == null) {
- throwSetIllegalArgumentException(value);
- }
- if (value instanceof Byte) {
- unsafe.putFloat(obj, fieldOffset, ((Byte) value).byteValue());
- return;
- }
- if (value instanceof Short) {
- unsafe.putFloat(obj, fieldOffset, ((Short) value).shortValue());
- return;
- }
- if (value instanceof Character) {
- unsafe.putFloat(obj, fieldOffset, ((Character) value).charValue());
- return;
- }
- if (value instanceof Integer) {
- unsafe.putFloat(obj, fieldOffset, ((Integer) value).intValue());
- return;
- }
- if (value instanceof Long) {
- unsafe.putFloat(obj, fieldOffset, ((Long) value).longValue());
- return;
- }
- if (value instanceof Float) {
- unsafe.putFloat(obj, fieldOffset, ((Float) value).floatValue());
- return;
- }
- throwSetIllegalArgumentException(value);
- }
-
- public void setBoolean(Object obj, boolean z)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(z);
- }
-
- public void setByte(Object obj, byte b)
- throws IllegalArgumentException, IllegalAccessException
- {
- setFloat(obj, b);
- }
-
- public void setChar(Object obj, char c)
- throws IllegalArgumentException, IllegalAccessException
- {
- setFloat(obj, c);
- }
-
- public void setShort(Object obj, short s)
- throws IllegalArgumentException, IllegalAccessException
- {
- setFloat(obj, s);
- }
-
- public void setInt(Object obj, int i)
- throws IllegalArgumentException, IllegalAccessException
- {
- setFloat(obj, i);
- }
-
- public void setLong(Object obj, long l)
- throws IllegalArgumentException, IllegalAccessException
- {
- setFloat(obj, l);
- }
-
- public void setFloat(Object obj, float f)
- throws IllegalArgumentException, IllegalAccessException
- {
- ensureObj(obj);
- if (isFinal) {
- throwFinalFieldIllegalAccessException(f);
- }
- unsafe.putFloat(obj, fieldOffset, f);
- }
-
- public void setDouble(Object obj, double d)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(d);
- }
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/UnsafeIntegerFieldAccessorImpl.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,152 +0,0 @@
-/*
- * Copyright (c) 2001, 2005, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-import java.lang.reflect.Field;
-
-class UnsafeIntegerFieldAccessorImpl extends UnsafeFieldAccessorImpl {
- UnsafeIntegerFieldAccessorImpl(Field field) {
- super(field);
- }
-
- public Object get(Object obj) throws IllegalArgumentException {
- return Integer.valueOf(getInt(obj));
- }
-
- public boolean getBoolean(Object obj) throws IllegalArgumentException {
- throw newGetBooleanIllegalArgumentException();
- }
-
- public byte getByte(Object obj) throws IllegalArgumentException {
- throw newGetByteIllegalArgumentException();
- }
-
- public char getChar(Object obj) throws IllegalArgumentException {
- throw newGetCharIllegalArgumentException();
- }
-
- public short getShort(Object obj) throws IllegalArgumentException {
- throw newGetShortIllegalArgumentException();
- }
-
- public int getInt(Object obj) throws IllegalArgumentException {
- ensureObj(obj);
- return unsafe.getInt(obj, fieldOffset);
- }
-
- public long getLong(Object obj) throws IllegalArgumentException {
- return getInt(obj);
- }
-
- public float getFloat(Object obj) throws IllegalArgumentException {
- return getInt(obj);
- }
-
- public double getDouble(Object obj) throws IllegalArgumentException {
- return getInt(obj);
- }
-
- public void set(Object obj, Object value)
- throws IllegalArgumentException, IllegalAccessException
- {
- ensureObj(obj);
- if (isFinal) {
- throwFinalFieldIllegalAccessException(value);
- }
- if (value == null) {
- throwSetIllegalArgumentException(value);
- }
- if (value instanceof Byte) {
- unsafe.putInt(obj, fieldOffset, ((Byte) value).byteValue());
- return;
- }
- if (value instanceof Short) {
- unsafe.putInt(obj, fieldOffset, ((Short) value).shortValue());
- return;
- }
- if (value instanceof Character) {
- unsafe.putInt(obj, fieldOffset, ((Character) value).charValue());
- return;
- }
- if (value instanceof Integer) {
- unsafe.putInt(obj, fieldOffset, ((Integer) value).intValue());
- return;
- }
- throwSetIllegalArgumentException(value);
- }
-
- public void setBoolean(Object obj, boolean z)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(z);
- }
-
- public void setByte(Object obj, byte b)
- throws IllegalArgumentException, IllegalAccessException
- {
- setInt(obj, b);
- }
-
- public void setChar(Object obj, char c)
- throws IllegalArgumentException, IllegalAccessException
- {
- setInt(obj, c);
- }
-
- public void setShort(Object obj, short s)
- throws IllegalArgumentException, IllegalAccessException
- {
- setInt(obj, s);
- }
-
- public void setInt(Object obj, int i)
- throws IllegalArgumentException, IllegalAccessException
- {
- ensureObj(obj);
- if (isFinal) {
- throwFinalFieldIllegalAccessException(i);
- }
- unsafe.putInt(obj, fieldOffset, i);
- }
-
- public void setLong(Object obj, long l)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(l);
- }
-
- public void setFloat(Object obj, float f)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(f);
- }
-
- public void setDouble(Object obj, double d)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(d);
- }
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/UnsafeLongFieldAccessorImpl.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,156 +0,0 @@
-/*
- * Copyright (c) 2001, 2005, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-import java.lang.reflect.Field;
-
-class UnsafeLongFieldAccessorImpl extends UnsafeFieldAccessorImpl {
- UnsafeLongFieldAccessorImpl(Field field) {
- super(field);
- }
-
- public Object get(Object obj) throws IllegalArgumentException {
- return Long.valueOf(getLong(obj));
- }
-
- public boolean getBoolean(Object obj) throws IllegalArgumentException {
- throw newGetBooleanIllegalArgumentException();
- }
-
- public byte getByte(Object obj) throws IllegalArgumentException {
- throw newGetByteIllegalArgumentException();
- }
-
- public char getChar(Object obj) throws IllegalArgumentException {
- throw newGetCharIllegalArgumentException();
- }
-
- public short getShort(Object obj) throws IllegalArgumentException {
- throw newGetShortIllegalArgumentException();
- }
-
- public int getInt(Object obj) throws IllegalArgumentException {
- throw newGetIntIllegalArgumentException();
- }
-
- public long getLong(Object obj) throws IllegalArgumentException {
- ensureObj(obj);
- return unsafe.getLong(obj, fieldOffset);
- }
-
- public float getFloat(Object obj) throws IllegalArgumentException {
- return getLong(obj);
- }
-
- public double getDouble(Object obj) throws IllegalArgumentException {
- return getLong(obj);
- }
-
- public void set(Object obj, Object value)
- throws IllegalArgumentException, IllegalAccessException
- {
- ensureObj(obj);
- if (isFinal) {
- throwFinalFieldIllegalAccessException(value);
- }
- if (value == null) {
- throwSetIllegalArgumentException(value);
- }
- if (value instanceof Byte) {
- unsafe.putLong(obj, fieldOffset, ((Byte) value).byteValue());
- return;
- }
- if (value instanceof Short) {
- unsafe.putLong(obj, fieldOffset, ((Short) value).shortValue());
- return;
- }
- if (value instanceof Character) {
- unsafe.putLong(obj, fieldOffset, ((Character) value).charValue());
- return;
- }
- if (value instanceof Integer) {
- unsafe.putLong(obj, fieldOffset, ((Integer) value).intValue());
- return;
- }
- if (value instanceof Long) {
- unsafe.putLong(obj, fieldOffset, ((Long) value).longValue());
- return;
- }
- throwSetIllegalArgumentException(value);
- }
-
- public void setBoolean(Object obj, boolean z)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(z);
- }
-
- public void setByte(Object obj, byte b)
- throws IllegalArgumentException, IllegalAccessException
- {
- setLong(obj, b);
- }
-
- public void setChar(Object obj, char c)
- throws IllegalArgumentException, IllegalAccessException
- {
- setLong(obj, c);
- }
-
- public void setShort(Object obj, short s)
- throws IllegalArgumentException, IllegalAccessException
- {
- setLong(obj, s);
- }
-
- public void setInt(Object obj, int i)
- throws IllegalArgumentException, IllegalAccessException
- {
- setLong(obj, i);
- }
-
- public void setLong(Object obj, long l)
- throws IllegalArgumentException, IllegalAccessException
- {
- ensureObj(obj);
- if (isFinal) {
- throwFinalFieldIllegalAccessException(l);
- }
- unsafe.putLong(obj, fieldOffset, l);
- }
-
- public void setFloat(Object obj, float f)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(f);
- }
-
- public void setDouble(Object obj, double d)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(d);
- }
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/UnsafeObjectFieldAccessorImpl.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,134 +0,0 @@
-/*
- * Copyright (c) 2001, 2005, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-import java.lang.reflect.Field;
-
-class UnsafeObjectFieldAccessorImpl extends UnsafeFieldAccessorImpl {
- UnsafeObjectFieldAccessorImpl(Field field) {
- super(field);
- }
-
- public Object get(Object obj) throws IllegalArgumentException {
- ensureObj(obj);
- return unsafe.getObject(obj, fieldOffset);
- }
-
- public boolean getBoolean(Object obj) throws IllegalArgumentException {
- throw newGetBooleanIllegalArgumentException();
- }
-
- public byte getByte(Object obj) throws IllegalArgumentException {
- throw newGetByteIllegalArgumentException();
- }
-
- public char getChar(Object obj) throws IllegalArgumentException {
- throw newGetCharIllegalArgumentException();
- }
-
- public short getShort(Object obj) throws IllegalArgumentException {
- throw newGetShortIllegalArgumentException();
- }
-
- public int getInt(Object obj) throws IllegalArgumentException {
- throw newGetIntIllegalArgumentException();
- }
-
- public long getLong(Object obj) throws IllegalArgumentException {
- throw newGetLongIllegalArgumentException();
- }
-
- public float getFloat(Object obj) throws IllegalArgumentException {
- throw newGetFloatIllegalArgumentException();
- }
-
- public double getDouble(Object obj) throws IllegalArgumentException {
- throw newGetDoubleIllegalArgumentException();
- }
-
- public void set(Object obj, Object value)
- throws IllegalArgumentException, IllegalAccessException
- {
- ensureObj(obj);
- if (isFinal) {
- throwFinalFieldIllegalAccessException(value);
- }
- if (value != null) {
- if (!field.getType().isAssignableFrom(value.getClass())) {
- throwSetIllegalArgumentException(value);
- }
- }
- unsafe.putObject(obj, fieldOffset, value);
- }
-
- public void setBoolean(Object obj, boolean z)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(z);
- }
-
- public void setByte(Object obj, byte b)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(b);
- }
-
- public void setChar(Object obj, char c)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(c);
- }
-
- public void setShort(Object obj, short s)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(s);
- }
-
- public void setInt(Object obj, int i)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(i);
- }
-
- public void setLong(Object obj, long l)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(l);
- }
-
- public void setFloat(Object obj, float f)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(f);
- }
-
- public void setDouble(Object obj, double d)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(d);
- }
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/UnsafeQualifiedBooleanFieldAccessorImpl.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,142 +0,0 @@
-/*
- * Copyright (c) 2004, 2005, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-import java.lang.reflect.Field;
-
-class UnsafeQualifiedBooleanFieldAccessorImpl
- extends UnsafeQualifiedFieldAccessorImpl
-{
- UnsafeQualifiedBooleanFieldAccessorImpl(Field field, boolean isReadOnly) {
- super(field, isReadOnly);
- }
-
- public Object get(Object obj) throws IllegalArgumentException {
- return Boolean.valueOf(getBoolean(obj));
- }
-
- public boolean getBoolean(Object obj) throws IllegalArgumentException {
- ensureObj(obj);
- return unsafe.getBooleanVolatile(obj, fieldOffset);
- }
-
- public byte getByte(Object obj) throws IllegalArgumentException {
- throw newGetByteIllegalArgumentException();
- }
-
- public char getChar(Object obj) throws IllegalArgumentException {
- throw newGetCharIllegalArgumentException();
- }
-
- public short getShort(Object obj) throws IllegalArgumentException {
- throw newGetShortIllegalArgumentException();
- }
-
- public int getInt(Object obj) throws IllegalArgumentException {
- throw newGetIntIllegalArgumentException();
- }
-
- public long getLong(Object obj) throws IllegalArgumentException {
- throw newGetLongIllegalArgumentException();
- }
-
- public float getFloat(Object obj) throws IllegalArgumentException {
- throw newGetFloatIllegalArgumentException();
- }
-
- public double getDouble(Object obj) throws IllegalArgumentException {
- throw newGetDoubleIllegalArgumentException();
- }
-
- public void set(Object obj, Object value)
- throws IllegalArgumentException, IllegalAccessException
- {
- ensureObj(obj);
- if (isReadOnly) {
- throwFinalFieldIllegalAccessException(value);
- }
- if (value == null) {
- throwSetIllegalArgumentException(value);
- }
- if (value instanceof Boolean) {
- unsafe.putBooleanVolatile(obj, fieldOffset, ((Boolean) value).booleanValue());
- return;
- }
- throwSetIllegalArgumentException(value);
- }
-
- public void setBoolean(Object obj, boolean z)
- throws IllegalArgumentException, IllegalAccessException
- {
- ensureObj(obj);
- if (isReadOnly) {
- throwFinalFieldIllegalAccessException(z);
- }
- unsafe.putBooleanVolatile(obj, fieldOffset, z);
- }
-
- public void setByte(Object obj, byte b)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(b);
- }
-
- public void setChar(Object obj, char c)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(c);
- }
-
- public void setShort(Object obj, short s)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(s);
- }
-
- public void setInt(Object obj, int i)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(i);
- }
-
- public void setLong(Object obj, long l)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(l);
- }
-
- public void setFloat(Object obj, float f)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(f);
- }
-
- public void setDouble(Object obj, double d)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(d);
- }
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/UnsafeQualifiedByteFieldAccessorImpl.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,142 +0,0 @@
-/*
- * Copyright (c) 2004, 2005, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-import java.lang.reflect.Field;
-
-class UnsafeQualifiedByteFieldAccessorImpl
- extends UnsafeQualifiedFieldAccessorImpl
-{
- UnsafeQualifiedByteFieldAccessorImpl(Field field, boolean isReadOnly) {
- super(field, isReadOnly);
- }
-
- public Object get(Object obj) throws IllegalArgumentException {
- return Byte.valueOf(getByte(obj));
- }
-
- public boolean getBoolean(Object obj) throws IllegalArgumentException {
- throw newGetBooleanIllegalArgumentException();
- }
-
- public byte getByte(Object obj) throws IllegalArgumentException {
- ensureObj(obj);
- return unsafe.getByteVolatile(obj, fieldOffset);
- }
-
- public char getChar(Object obj) throws IllegalArgumentException {
- throw newGetCharIllegalArgumentException();
- }
-
- public short getShort(Object obj) throws IllegalArgumentException {
- return getByte(obj);
- }
-
- public int getInt(Object obj) throws IllegalArgumentException {
- return getByte(obj);
- }
-
- public long getLong(Object obj) throws IllegalArgumentException {
- return getByte(obj);
- }
-
- public float getFloat(Object obj) throws IllegalArgumentException {
- return getByte(obj);
- }
-
- public double getDouble(Object obj) throws IllegalArgumentException {
- return getByte(obj);
- }
-
- public void set(Object obj, Object value)
- throws IllegalArgumentException, IllegalAccessException
- {
- ensureObj(obj);
- if (isReadOnly) {
- throwFinalFieldIllegalAccessException(value);
- }
- if (value == null) {
- throwSetIllegalArgumentException(value);
- }
- if (value instanceof Byte) {
- unsafe.putByteVolatile(obj, fieldOffset, ((Byte) value).byteValue());
- return;
- }
- throwSetIllegalArgumentException(value);
- }
-
- public void setBoolean(Object obj, boolean z)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(z);
- }
-
- public void setByte(Object obj, byte b)
- throws IllegalArgumentException, IllegalAccessException
- {
- ensureObj(obj);
- if (isReadOnly) {
- throwFinalFieldIllegalAccessException(b);
- }
- unsafe.putByteVolatile(obj, fieldOffset, b);
- }
-
- public void setChar(Object obj, char c)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(c);
- }
-
- public void setShort(Object obj, short s)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(s);
- }
-
- public void setInt(Object obj, int i)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(i);
- }
-
- public void setLong(Object obj, long l)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(l);
- }
-
- public void setFloat(Object obj, float f)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(f);
- }
-
- public void setDouble(Object obj, double d)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(d);
- }
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/UnsafeQualifiedCharacterFieldAccessorImpl.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,142 +0,0 @@
-/*
- * Copyright (c) 2004, 2005, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-import java.lang.reflect.Field;
-
-class UnsafeQualifiedCharacterFieldAccessorImpl
- extends UnsafeQualifiedFieldAccessorImpl
-{
- UnsafeQualifiedCharacterFieldAccessorImpl(Field field, boolean isReadOnly) {
- super(field, isReadOnly);
- }
-
- public Object get(Object obj) throws IllegalArgumentException {
- return Character.valueOf(getChar(obj));
- }
-
- public boolean getBoolean(Object obj) throws IllegalArgumentException {
- throw newGetBooleanIllegalArgumentException();
- }
-
- public byte getByte(Object obj) throws IllegalArgumentException {
- throw newGetByteIllegalArgumentException();
- }
-
- public char getChar(Object obj) throws IllegalArgumentException {
- ensureObj(obj);
- return unsafe.getCharVolatile(obj, fieldOffset);
- }
-
- public short getShort(Object obj) throws IllegalArgumentException {
- throw newGetShortIllegalArgumentException();
- }
-
- public int getInt(Object obj) throws IllegalArgumentException {
- return getChar(obj);
- }
-
- public long getLong(Object obj) throws IllegalArgumentException {
- return getChar(obj);
- }
-
- public float getFloat(Object obj) throws IllegalArgumentException {
- return getChar(obj);
- }
-
- public double getDouble(Object obj) throws IllegalArgumentException {
- return getChar(obj);
- }
-
- public void set(Object obj, Object value)
- throws IllegalArgumentException, IllegalAccessException
- {
- ensureObj(obj);
- if (isReadOnly) {
- throwFinalFieldIllegalAccessException(value);
- }
- if (value == null) {
- throwSetIllegalArgumentException(value);
- }
- if (value instanceof Character) {
- unsafe.putCharVolatile(obj, fieldOffset, ((Character) value).charValue());
- return;
- }
- throwSetIllegalArgumentException(value);
- }
-
- public void setBoolean(Object obj, boolean z)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(z);
- }
-
- public void setByte(Object obj, byte b)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(b);
- }
-
- public void setChar(Object obj, char c)
- throws IllegalArgumentException, IllegalAccessException
- {
- ensureObj(obj);
- if (isReadOnly) {
- throwFinalFieldIllegalAccessException(c);
- }
- unsafe.putCharVolatile(obj, fieldOffset, c);
- }
-
- public void setShort(Object obj, short s)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(s);
- }
-
- public void setInt(Object obj, int i)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(i);
- }
-
- public void setLong(Object obj, long l)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(l);
- }
-
- public void setFloat(Object obj, float f)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(f);
- }
-
- public void setDouble(Object obj, double d)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(d);
- }
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/UnsafeQualifiedDoubleFieldAccessorImpl.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,166 +0,0 @@
-/*
- * Copyright (c) 2004, 2005, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-import java.lang.reflect.Field;
-
-class UnsafeQualifiedDoubleFieldAccessorImpl
- extends UnsafeQualifiedFieldAccessorImpl
-{
- UnsafeQualifiedDoubleFieldAccessorImpl(Field field, boolean isReadOnly) {
- super(field, isReadOnly);
- }
-
- public Object get(Object obj) throws IllegalArgumentException {
- return Double.valueOf(getDouble(obj));
- }
-
- public boolean getBoolean(Object obj) throws IllegalArgumentException {
- throw newGetBooleanIllegalArgumentException();
- }
-
- public byte getByte(Object obj) throws IllegalArgumentException {
- throw newGetByteIllegalArgumentException();
- }
-
- public char getChar(Object obj) throws IllegalArgumentException {
- throw newGetCharIllegalArgumentException();
- }
-
- public short getShort(Object obj) throws IllegalArgumentException {
- throw newGetShortIllegalArgumentException();
- }
-
- public int getInt(Object obj) throws IllegalArgumentException {
- throw newGetIntIllegalArgumentException();
- }
-
- public long getLong(Object obj) throws IllegalArgumentException {
- throw newGetLongIllegalArgumentException();
- }
-
- public float getFloat(Object obj) throws IllegalArgumentException {
- throw newGetFloatIllegalArgumentException();
- }
-
- public double getDouble(Object obj) throws IllegalArgumentException {
- ensureObj(obj);
- return unsafe.getDoubleVolatile(obj, fieldOffset);
- }
-
- public void set(Object obj, Object value)
- throws IllegalArgumentException, IllegalAccessException
- {
- ensureObj(obj);
- if (isReadOnly) {
- throwFinalFieldIllegalAccessException(value);
- }
- if (value == null) {
- throwSetIllegalArgumentException(value);
- }
- if (value instanceof Byte) {
- unsafe.putDoubleVolatile(obj, fieldOffset, ((Byte) value).byteValue());
- return;
- }
- if (value instanceof Short) {
- unsafe.putDoubleVolatile(obj, fieldOffset, ((Short) value).shortValue());
- return;
- }
- if (value instanceof Character) {
- unsafe.putDoubleVolatile(obj, fieldOffset, ((Character) value).charValue());
- return;
- }
- if (value instanceof Integer) {
- unsafe.putDoubleVolatile(obj, fieldOffset, ((Integer) value).intValue());
- return;
- }
- if (value instanceof Long) {
- unsafe.putDoubleVolatile(obj, fieldOffset, ((Long) value).longValue());
- return;
- }
- if (value instanceof Float) {
- unsafe.putDoubleVolatile(obj, fieldOffset, ((Float) value).floatValue());
- return;
- }
- if (value instanceof Double) {
- unsafe.putDoubleVolatile(obj, fieldOffset, ((Double) value).doubleValue());
- return;
- }
- throwSetIllegalArgumentException(value);
- }
-
- public void setBoolean(Object obj, boolean z)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(z);
- }
-
- public void setByte(Object obj, byte b)
- throws IllegalArgumentException, IllegalAccessException
- {
- setDouble(obj, b);
- }
-
- public void setChar(Object obj, char c)
- throws IllegalArgumentException, IllegalAccessException
- {
- setDouble(obj, c);
- }
-
- public void setShort(Object obj, short s)
- throws IllegalArgumentException, IllegalAccessException
- {
- setDouble(obj, s);
- }
-
- public void setInt(Object obj, int i)
- throws IllegalArgumentException, IllegalAccessException
- {
- setDouble(obj, i);
- }
-
- public void setLong(Object obj, long l)
- throws IllegalArgumentException, IllegalAccessException
- {
- setDouble(obj, l);
- }
-
- public void setFloat(Object obj, float f)
- throws IllegalArgumentException, IllegalAccessException
- {
- setDouble(obj, f);
- }
-
- public void setDouble(Object obj, double d)
- throws IllegalArgumentException, IllegalAccessException
- {
- ensureObj(obj);
- if (isReadOnly) {
- throwFinalFieldIllegalAccessException(d);
- }
- unsafe.putDoubleVolatile(obj, fieldOffset, d);
- }
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/UnsafeQualifiedFieldAccessorImpl.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 2004, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
-import jdk.internal.misc.Unsafe;
-
-/**
- * Base class for jdk.internal.misc.Unsafe-based FieldAccessors for fields with
- * final or volatile qualifiers. These differ from unqualified
- * versions in that (1) they check for read-only status (2) they use
- * the volatile forms of Unsafe get/put methods. (When accessed via
- * reflection, finals act as slightly "lighter" forms of volatiles. So
- * the volatile forms are heavier than necessary in terms of
- * underlying reordering rules and memory barriers, but preserve
- * correctness.)
- */
-
-abstract class UnsafeQualifiedFieldAccessorImpl
- extends UnsafeFieldAccessorImpl
-{
- protected final boolean isReadOnly;
-
- UnsafeQualifiedFieldAccessorImpl(Field field, boolean isReadOnly) {
- super(field);
- this.isReadOnly = isReadOnly;
- }
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/UnsafeQualifiedFloatFieldAccessorImpl.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,162 +0,0 @@
-/*
- * Copyright (c) 2004, 2005, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-import java.lang.reflect.Field;
-
-class UnsafeQualifiedFloatFieldAccessorImpl
- extends UnsafeQualifiedFieldAccessorImpl
-{
- UnsafeQualifiedFloatFieldAccessorImpl(Field field, boolean isReadOnly) {
- super(field, isReadOnly);
- }
-
- public Object get(Object obj) throws IllegalArgumentException {
- return Float.valueOf(getFloat(obj));
- }
-
- public boolean getBoolean(Object obj) throws IllegalArgumentException {
- throw newGetBooleanIllegalArgumentException();
- }
-
- public byte getByte(Object obj) throws IllegalArgumentException {
- throw newGetByteIllegalArgumentException();
- }
-
- public char getChar(Object obj) throws IllegalArgumentException {
- throw newGetCharIllegalArgumentException();
- }
-
- public short getShort(Object obj) throws IllegalArgumentException {
- throw newGetShortIllegalArgumentException();
- }
-
- public int getInt(Object obj) throws IllegalArgumentException {
- throw newGetIntIllegalArgumentException();
- }
-
- public long getLong(Object obj) throws IllegalArgumentException {
- throw newGetLongIllegalArgumentException();
- }
-
- public float getFloat(Object obj) throws IllegalArgumentException {
- ensureObj(obj);
- return unsafe.getFloatVolatile(obj, fieldOffset);
- }
-
- public double getDouble(Object obj) throws IllegalArgumentException {
- return getFloat(obj);
- }
-
- public void set(Object obj, Object value)
- throws IllegalArgumentException, IllegalAccessException
- {
- ensureObj(obj);
- if (isReadOnly) {
- throwFinalFieldIllegalAccessException(value);
- }
- if (value == null) {
- throwSetIllegalArgumentException(value);
- }
- if (value instanceof Byte) {
- unsafe.putFloatVolatile(obj, fieldOffset, ((Byte) value).byteValue());
- return;
- }
- if (value instanceof Short) {
- unsafe.putFloatVolatile(obj, fieldOffset, ((Short) value).shortValue());
- return;
- }
- if (value instanceof Character) {
- unsafe.putFloatVolatile(obj, fieldOffset, ((Character) value).charValue());
- return;
- }
- if (value instanceof Integer) {
- unsafe.putFloatVolatile(obj, fieldOffset, ((Integer) value).intValue());
- return;
- }
- if (value instanceof Long) {
- unsafe.putFloatVolatile(obj, fieldOffset, ((Long) value).longValue());
- return;
- }
- if (value instanceof Float) {
- unsafe.putFloatVolatile(obj, fieldOffset, ((Float) value).floatValue());
- return;
- }
- throwSetIllegalArgumentException(value);
- }
-
- public void setBoolean(Object obj, boolean z)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(z);
- }
-
- public void setByte(Object obj, byte b)
- throws IllegalArgumentException, IllegalAccessException
- {
- setFloat(obj, b);
- }
-
- public void setChar(Object obj, char c)
- throws IllegalArgumentException, IllegalAccessException
- {
- setFloat(obj, c);
- }
-
- public void setShort(Object obj, short s)
- throws IllegalArgumentException, IllegalAccessException
- {
- setFloat(obj, s);
- }
-
- public void setInt(Object obj, int i)
- throws IllegalArgumentException, IllegalAccessException
- {
- setFloat(obj, i);
- }
-
- public void setLong(Object obj, long l)
- throws IllegalArgumentException, IllegalAccessException
- {
- setFloat(obj, l);
- }
-
- public void setFloat(Object obj, float f)
- throws IllegalArgumentException, IllegalAccessException
- {
- ensureObj(obj);
- if (isReadOnly) {
- throwFinalFieldIllegalAccessException(f);
- }
- unsafe.putFloatVolatile(obj, fieldOffset, f);
- }
-
- public void setDouble(Object obj, double d)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(d);
- }
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/UnsafeQualifiedIntegerFieldAccessorImpl.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,154 +0,0 @@
-/*
- * Copyright (c) 2004, 2005, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-import java.lang.reflect.Field;
-
-class UnsafeQualifiedIntegerFieldAccessorImpl
- extends UnsafeQualifiedFieldAccessorImpl
-{
- UnsafeQualifiedIntegerFieldAccessorImpl(Field field, boolean isReadOnly) {
- super(field, isReadOnly);
- }
-
- public Object get(Object obj) throws IllegalArgumentException {
- return Integer.valueOf(getInt(obj));
- }
-
- public boolean getBoolean(Object obj) throws IllegalArgumentException {
- throw newGetBooleanIllegalArgumentException();
- }
-
- public byte getByte(Object obj) throws IllegalArgumentException {
- throw newGetByteIllegalArgumentException();
- }
-
- public char getChar(Object obj) throws IllegalArgumentException {
- throw newGetCharIllegalArgumentException();
- }
-
- public short getShort(Object obj) throws IllegalArgumentException {
- throw newGetShortIllegalArgumentException();
- }
-
- public int getInt(Object obj) throws IllegalArgumentException {
- ensureObj(obj);
- return unsafe.getIntVolatile(obj, fieldOffset);
- }
-
- public long getLong(Object obj) throws IllegalArgumentException {
- return getInt(obj);
- }
-
- public float getFloat(Object obj) throws IllegalArgumentException {
- return getInt(obj);
- }
-
- public double getDouble(Object obj) throws IllegalArgumentException {
- return getInt(obj);
- }
-
- public void set(Object obj, Object value)
- throws IllegalArgumentException, IllegalAccessException
- {
- ensureObj(obj);
- if (isReadOnly) {
- throwFinalFieldIllegalAccessException(value);
- }
- if (value == null) {
- throwSetIllegalArgumentException(value);
- }
- if (value instanceof Byte) {
- unsafe.putIntVolatile(obj, fieldOffset, ((Byte) value).byteValue());
- return;
- }
- if (value instanceof Short) {
- unsafe.putIntVolatile(obj, fieldOffset, ((Short) value).shortValue());
- return;
- }
- if (value instanceof Character) {
- unsafe.putIntVolatile(obj, fieldOffset, ((Character) value).charValue());
- return;
- }
- if (value instanceof Integer) {
- unsafe.putIntVolatile(obj, fieldOffset, ((Integer) value).intValue());
- return;
- }
- throwSetIllegalArgumentException(value);
- }
-
- public void setBoolean(Object obj, boolean z)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(z);
- }
-
- public void setByte(Object obj, byte b)
- throws IllegalArgumentException, IllegalAccessException
- {
- setInt(obj, b);
- }
-
- public void setChar(Object obj, char c)
- throws IllegalArgumentException, IllegalAccessException
- {
- setInt(obj, c);
- }
-
- public void setShort(Object obj, short s)
- throws IllegalArgumentException, IllegalAccessException
- {
- setInt(obj, s);
- }
-
- public void setInt(Object obj, int i)
- throws IllegalArgumentException, IllegalAccessException
- {
- ensureObj(obj);
- if (isReadOnly) {
- throwFinalFieldIllegalAccessException(i);
- }
- unsafe.putIntVolatile(obj, fieldOffset, i);
- }
-
- public void setLong(Object obj, long l)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(l);
- }
-
- public void setFloat(Object obj, float f)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(f);
- }
-
- public void setDouble(Object obj, double d)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(d);
- }
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/UnsafeQualifiedLongFieldAccessorImpl.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,158 +0,0 @@
-/*
- * Copyright (c) 2004, 2005, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-import java.lang.reflect.Field;
-
-class UnsafeQualifiedLongFieldAccessorImpl
- extends UnsafeQualifiedFieldAccessorImpl
-{
- UnsafeQualifiedLongFieldAccessorImpl(Field field, boolean isReadOnly) {
- super(field, isReadOnly);
- }
-
- public Object get(Object obj) throws IllegalArgumentException {
- return Long.valueOf(getLong(obj));
- }
-
- public boolean getBoolean(Object obj) throws IllegalArgumentException {
- throw newGetBooleanIllegalArgumentException();
- }
-
- public byte getByte(Object obj) throws IllegalArgumentException {
- throw newGetByteIllegalArgumentException();
- }
-
- public char getChar(Object obj) throws IllegalArgumentException {
- throw newGetCharIllegalArgumentException();
- }
-
- public short getShort(Object obj) throws IllegalArgumentException {
- throw newGetShortIllegalArgumentException();
- }
-
- public int getInt(Object obj) throws IllegalArgumentException {
- throw newGetIntIllegalArgumentException();
- }
-
- public long getLong(Object obj) throws IllegalArgumentException {
- ensureObj(obj);
- return unsafe.getLongVolatile(obj, fieldOffset);
- }
-
- public float getFloat(Object obj) throws IllegalArgumentException {
- return getLong(obj);
- }
-
- public double getDouble(Object obj) throws IllegalArgumentException {
- return getLong(obj);
- }
-
- public void set(Object obj, Object value)
- throws IllegalArgumentException, IllegalAccessException
- {
- ensureObj(obj);
- if (isReadOnly) {
- throwFinalFieldIllegalAccessException(value);
- }
- if (value == null) {
- throwSetIllegalArgumentException(value);
- }
- if (value instanceof Byte) {
- unsafe.putLongVolatile(obj, fieldOffset, ((Byte) value).byteValue());
- return;
- }
- if (value instanceof Short) {
- unsafe.putLongVolatile(obj, fieldOffset, ((Short) value).shortValue());
- return;
- }
- if (value instanceof Character) {
- unsafe.putLongVolatile(obj, fieldOffset, ((Character) value).charValue());
- return;
- }
- if (value instanceof Integer) {
- unsafe.putLongVolatile(obj, fieldOffset, ((Integer) value).intValue());
- return;
- }
- if (value instanceof Long) {
- unsafe.putLongVolatile(obj, fieldOffset, ((Long) value).longValue());
- return;
- }
- throwSetIllegalArgumentException(value);
- }
-
- public void setBoolean(Object obj, boolean z)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(z);
- }
-
- public void setByte(Object obj, byte b)
- throws IllegalArgumentException, IllegalAccessException
- {
- setLong(obj, b);
- }
-
- public void setChar(Object obj, char c)
- throws IllegalArgumentException, IllegalAccessException
- {
- setLong(obj, c);
- }
-
- public void setShort(Object obj, short s)
- throws IllegalArgumentException, IllegalAccessException
- {
- setLong(obj, s);
- }
-
- public void setInt(Object obj, int i)
- throws IllegalArgumentException, IllegalAccessException
- {
- setLong(obj, i);
- }
-
- public void setLong(Object obj, long l)
- throws IllegalArgumentException, IllegalAccessException
- {
- ensureObj(obj);
- if (isReadOnly) {
- throwFinalFieldIllegalAccessException(l);
- }
- unsafe.putLongVolatile(obj, fieldOffset, l);
- }
-
- public void setFloat(Object obj, float f)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(f);
- }
-
- public void setDouble(Object obj, double d)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(d);
- }
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/UnsafeQualifiedObjectFieldAccessorImpl.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,136 +0,0 @@
-/*
- * Copyright (c) 2004, 2005, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-import java.lang.reflect.Field;
-
-class UnsafeQualifiedObjectFieldAccessorImpl
- extends UnsafeQualifiedFieldAccessorImpl
-{
- UnsafeQualifiedObjectFieldAccessorImpl(Field field, boolean isReadOnly) {
- super(field, isReadOnly);
- }
-
- public Object get(Object obj) throws IllegalArgumentException {
- ensureObj(obj);
- return unsafe.getObjectVolatile(obj, fieldOffset);
- }
-
- public boolean getBoolean(Object obj) throws IllegalArgumentException {
- throw newGetBooleanIllegalArgumentException();
- }
-
- public byte getByte(Object obj) throws IllegalArgumentException {
- throw newGetByteIllegalArgumentException();
- }
-
- public char getChar(Object obj) throws IllegalArgumentException {
- throw newGetCharIllegalArgumentException();
- }
-
- public short getShort(Object obj) throws IllegalArgumentException {
- throw newGetShortIllegalArgumentException();
- }
-
- public int getInt(Object obj) throws IllegalArgumentException {
- throw newGetIntIllegalArgumentException();
- }
-
- public long getLong(Object obj) throws IllegalArgumentException {
- throw newGetLongIllegalArgumentException();
- }
-
- public float getFloat(Object obj) throws IllegalArgumentException {
- throw newGetFloatIllegalArgumentException();
- }
-
- public double getDouble(Object obj) throws IllegalArgumentException {
- throw newGetDoubleIllegalArgumentException();
- }
-
- public void set(Object obj, Object value)
- throws IllegalArgumentException, IllegalAccessException
- {
- ensureObj(obj);
- if (isReadOnly) {
- throwFinalFieldIllegalAccessException(value);
- }
- if (value != null) {
- if (!field.getType().isAssignableFrom(value.getClass())) {
- throwSetIllegalArgumentException(value);
- }
- }
- unsafe.putObjectVolatile(obj, fieldOffset, value);
- }
-
- public void setBoolean(Object obj, boolean z)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(z);
- }
-
- public void setByte(Object obj, byte b)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(b);
- }
-
- public void setChar(Object obj, char c)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(c);
- }
-
- public void setShort(Object obj, short s)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(s);
- }
-
- public void setInt(Object obj, int i)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(i);
- }
-
- public void setLong(Object obj, long l)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(l);
- }
-
- public void setFloat(Object obj, float f)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(f);
- }
-
- public void setDouble(Object obj, double d)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(d);
- }
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/UnsafeQualifiedShortFieldAccessorImpl.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,146 +0,0 @@
-/*
- * Copyright (c) 2004, 2005, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-import java.lang.reflect.Field;
-
-class UnsafeQualifiedShortFieldAccessorImpl
- extends UnsafeQualifiedFieldAccessorImpl
-{
- UnsafeQualifiedShortFieldAccessorImpl(Field field, boolean isReadOnly) {
- super(field, isReadOnly);
- }
-
- public Object get(Object obj) throws IllegalArgumentException {
- return Short.valueOf(getShort(obj));
- }
-
- public boolean getBoolean(Object obj) throws IllegalArgumentException {
- throw newGetBooleanIllegalArgumentException();
- }
-
- public byte getByte(Object obj) throws IllegalArgumentException {
- throw newGetByteIllegalArgumentException();
- }
-
- public char getChar(Object obj) throws IllegalArgumentException {
- throw newGetCharIllegalArgumentException();
- }
-
- public short getShort(Object obj) throws IllegalArgumentException {
- ensureObj(obj);
- return unsafe.getShortVolatile(obj, fieldOffset);
- }
-
- public int getInt(Object obj) throws IllegalArgumentException {
- return getShort(obj);
- }
-
- public long getLong(Object obj) throws IllegalArgumentException {
- return getShort(obj);
- }
-
- public float getFloat(Object obj) throws IllegalArgumentException {
- return getShort(obj);
- }
-
- public double getDouble(Object obj) throws IllegalArgumentException {
- return getShort(obj);
- }
-
- public void set(Object obj, Object value)
- throws IllegalArgumentException, IllegalAccessException
- {
- ensureObj(obj);
- if (isReadOnly) {
- throwFinalFieldIllegalAccessException(value);
- }
- if (value == null) {
- throwSetIllegalArgumentException(value);
- }
- if (value instanceof Byte) {
- unsafe.putShortVolatile(obj, fieldOffset, ((Byte) value).byteValue());
- return;
- }
- if (value instanceof Short) {
- unsafe.putShortVolatile(obj, fieldOffset, ((Short) value).shortValue());
- return;
- }
- throwSetIllegalArgumentException(value);
- }
-
- public void setBoolean(Object obj, boolean z)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(z);
- }
-
- public void setByte(Object obj, byte b)
- throws IllegalArgumentException, IllegalAccessException
- {
- setShort(obj, b);
- }
-
- public void setChar(Object obj, char c)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(c);
- }
-
- public void setShort(Object obj, short s)
- throws IllegalArgumentException, IllegalAccessException
- {
- ensureObj(obj);
- if (isReadOnly) {
- throwFinalFieldIllegalAccessException(s);
- }
- unsafe.putShortVolatile(obj, fieldOffset, s);
- }
-
- public void setInt(Object obj, int i)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(i);
- }
-
- public void setLong(Object obj, long l)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(l);
- }
-
- public void setFloat(Object obj, float f)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(f);
- }
-
- public void setDouble(Object obj, double d)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(d);
- }
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/UnsafeQualifiedStaticBooleanFieldAccessorImpl.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,139 +0,0 @@
-/*
- * Copyright (c) 2004, 2005, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-import java.lang.reflect.Field;
-
-class UnsafeQualifiedStaticBooleanFieldAccessorImpl
- extends UnsafeQualifiedStaticFieldAccessorImpl
-{
- UnsafeQualifiedStaticBooleanFieldAccessorImpl(Field field, boolean isReadOnly) {
- super(field, isReadOnly);
- }
-
- public Object get(Object obj) throws IllegalArgumentException {
- return Boolean.valueOf(getBoolean(obj));
- }
-
- public boolean getBoolean(Object obj) throws IllegalArgumentException {
- return unsafe.getBooleanVolatile(base, fieldOffset);
- }
-
- public byte getByte(Object obj) throws IllegalArgumentException {
- throw newGetByteIllegalArgumentException();
- }
-
- public char getChar(Object obj) throws IllegalArgumentException {
- throw newGetCharIllegalArgumentException();
- }
-
- public short getShort(Object obj) throws IllegalArgumentException {
- throw newGetShortIllegalArgumentException();
- }
-
- public int getInt(Object obj) throws IllegalArgumentException {
- throw newGetIntIllegalArgumentException();
- }
-
- public long getLong(Object obj) throws IllegalArgumentException {
- throw newGetLongIllegalArgumentException();
- }
-
- public float getFloat(Object obj) throws IllegalArgumentException {
- throw newGetFloatIllegalArgumentException();
- }
-
- public double getDouble(Object obj) throws IllegalArgumentException {
- throw newGetDoubleIllegalArgumentException();
- }
-
- public void set(Object obj, Object value)
- throws IllegalArgumentException, IllegalAccessException
- {
- if (isReadOnly) {
- throwFinalFieldIllegalAccessException(value);
- }
- if (value == null) {
- throwSetIllegalArgumentException(value);
- }
- if (value instanceof Boolean) {
- unsafe.putBooleanVolatile(base, fieldOffset, ((Boolean) value).booleanValue());
- return;
- }
- throwSetIllegalArgumentException(value);
- }
-
- public void setBoolean(Object obj, boolean z)
- throws IllegalArgumentException, IllegalAccessException
- {
- if (isReadOnly) {
- throwFinalFieldIllegalAccessException(z);
- }
- unsafe.putBooleanVolatile(base, fieldOffset, z);
- }
-
- public void setByte(Object obj, byte b)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(b);
- }
-
- public void setChar(Object obj, char c)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(c);
- }
-
- public void setShort(Object obj, short s)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(s);
- }
-
- public void setInt(Object obj, int i)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(i);
- }
-
- public void setLong(Object obj, long l)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(l);
- }
-
- public void setFloat(Object obj, float f)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(f);
- }
-
- public void setDouble(Object obj, double d)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(d);
- }
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/UnsafeQualifiedStaticByteFieldAccessorImpl.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,139 +0,0 @@
-/*
- * Copyright (c) 2004, 2005, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-import java.lang.reflect.Field;
-
-class UnsafeQualifiedStaticByteFieldAccessorImpl
- extends UnsafeQualifiedStaticFieldAccessorImpl
-{
- UnsafeQualifiedStaticByteFieldAccessorImpl(Field field, boolean isReadOnly) {
- super(field, isReadOnly);
- }
-
- public Object get(Object obj) throws IllegalArgumentException {
- return Byte.valueOf(getByte(obj));
- }
-
- public boolean getBoolean(Object obj) throws IllegalArgumentException {
- throw newGetBooleanIllegalArgumentException();
- }
-
- public byte getByte(Object obj) throws IllegalArgumentException {
- return unsafe.getByteVolatile(base, fieldOffset);
- }
-
- public char getChar(Object obj) throws IllegalArgumentException {
- throw newGetCharIllegalArgumentException();
- }
-
- public short getShort(Object obj) throws IllegalArgumentException {
- return getByte(obj);
- }
-
- public int getInt(Object obj) throws IllegalArgumentException {
- return getByte(obj);
- }
-
- public long getLong(Object obj) throws IllegalArgumentException {
- return getByte(obj);
- }
-
- public float getFloat(Object obj) throws IllegalArgumentException {
- return getByte(obj);
- }
-
- public double getDouble(Object obj) throws IllegalArgumentException {
- return getByte(obj);
- }
-
- public void set(Object obj, Object value)
- throws IllegalArgumentException, IllegalAccessException
- {
- if (isReadOnly) {
- throwFinalFieldIllegalAccessException(value);
- }
- if (value == null) {
- throwSetIllegalArgumentException(value);
- }
- if (value instanceof Byte) {
- unsafe.putByteVolatile(base, fieldOffset, ((Byte) value).byteValue());
- return;
- }
- throwSetIllegalArgumentException(value);
- }
-
- public void setBoolean(Object obj, boolean z)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(z);
- }
-
- public void setByte(Object obj, byte b)
- throws IllegalArgumentException, IllegalAccessException
- {
- if (isReadOnly) {
- throwFinalFieldIllegalAccessException(b);
- }
- unsafe.putByteVolatile(base, fieldOffset, b);
- }
-
- public void setChar(Object obj, char c)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(c);
- }
-
- public void setShort(Object obj, short s)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(s);
- }
-
- public void setInt(Object obj, int i)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(i);
- }
-
- public void setLong(Object obj, long l)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(l);
- }
-
- public void setFloat(Object obj, float f)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(f);
- }
-
- public void setDouble(Object obj, double d)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(d);
- }
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/UnsafeQualifiedStaticCharacterFieldAccessorImpl.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,139 +0,0 @@
-/*
- * Copyright (c) 2004, 2005, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-import java.lang.reflect.Field;
-
-class UnsafeQualifiedStaticCharacterFieldAccessorImpl
- extends UnsafeQualifiedStaticFieldAccessorImpl
-{
- UnsafeQualifiedStaticCharacterFieldAccessorImpl(Field field, boolean isReadOnly) {
- super(field, isReadOnly);
- }
-
- public Object get(Object obj) throws IllegalArgumentException {
- return Character.valueOf(getChar(obj));
- }
-
- public boolean getBoolean(Object obj) throws IllegalArgumentException {
- throw newGetBooleanIllegalArgumentException();
- }
-
- public byte getByte(Object obj) throws IllegalArgumentException {
- throw newGetByteIllegalArgumentException();
- }
-
- public char getChar(Object obj) throws IllegalArgumentException {
- return unsafe.getCharVolatile(base, fieldOffset);
- }
-
- public short getShort(Object obj) throws IllegalArgumentException {
- throw newGetShortIllegalArgumentException();
- }
-
- public int getInt(Object obj) throws IllegalArgumentException {
- return getChar(obj);
- }
-
- public long getLong(Object obj) throws IllegalArgumentException {
- return getChar(obj);
- }
-
- public float getFloat(Object obj) throws IllegalArgumentException {
- return getChar(obj);
- }
-
- public double getDouble(Object obj) throws IllegalArgumentException {
- return getChar(obj);
- }
-
- public void set(Object obj, Object value)
- throws IllegalArgumentException, IllegalAccessException
- {
- if (isReadOnly) {
- throwFinalFieldIllegalAccessException(value);
- }
- if (value == null) {
- throwSetIllegalArgumentException(value);
- }
- if (value instanceof Character) {
- unsafe.putCharVolatile(base, fieldOffset, ((Character) value).charValue());
- return;
- }
- throwSetIllegalArgumentException(value);
- }
-
- public void setBoolean(Object obj, boolean z)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(z);
- }
-
- public void setByte(Object obj, byte b)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(b);
- }
-
- public void setChar(Object obj, char c)
- throws IllegalArgumentException, IllegalAccessException
- {
- if (isReadOnly) {
- throwFinalFieldIllegalAccessException(c);
- }
- unsafe.putCharVolatile(base, fieldOffset, c);
- }
-
- public void setShort(Object obj, short s)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(s);
- }
-
- public void setInt(Object obj, int i)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(i);
- }
-
- public void setLong(Object obj, long l)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(l);
- }
-
- public void setFloat(Object obj, float f)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(f);
- }
-
- public void setDouble(Object obj, double d)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(d);
- }
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/UnsafeQualifiedStaticDoubleFieldAccessorImpl.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,163 +0,0 @@
-/*
- * Copyright (c) 2004, 2005, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-import java.lang.reflect.Field;
-
-class UnsafeQualifiedStaticDoubleFieldAccessorImpl
- extends UnsafeQualifiedStaticFieldAccessorImpl
-{
- UnsafeQualifiedStaticDoubleFieldAccessorImpl(Field field, boolean isReadOnly) {
- super(field, isReadOnly);
- }
-
- public Object get(Object obj) throws IllegalArgumentException {
- return Double.valueOf(getDouble(obj));
- }
-
- public boolean getBoolean(Object obj) throws IllegalArgumentException {
- throw newGetBooleanIllegalArgumentException();
- }
-
- public byte getByte(Object obj) throws IllegalArgumentException {
- throw newGetByteIllegalArgumentException();
- }
-
- public char getChar(Object obj) throws IllegalArgumentException {
- throw newGetCharIllegalArgumentException();
- }
-
- public short getShort(Object obj) throws IllegalArgumentException {
- throw newGetShortIllegalArgumentException();
- }
-
- public int getInt(Object obj) throws IllegalArgumentException {
- throw newGetIntIllegalArgumentException();
- }
-
- public long getLong(Object obj) throws IllegalArgumentException {
- throw newGetLongIllegalArgumentException();
- }
-
- public float getFloat(Object obj) throws IllegalArgumentException {
- throw newGetFloatIllegalArgumentException();
- }
-
- public double getDouble(Object obj) throws IllegalArgumentException {
- return unsafe.getDoubleVolatile(base, fieldOffset);
- }
-
- public void set(Object obj, Object value)
- throws IllegalArgumentException, IllegalAccessException
- {
- if (isReadOnly) {
- throwFinalFieldIllegalAccessException(value);
- }
- if (value == null) {
- throwSetIllegalArgumentException(value);
- }
- if (value instanceof Byte) {
- unsafe.putDoubleVolatile(base, fieldOffset, ((Byte) value).byteValue());
- return;
- }
- if (value instanceof Short) {
- unsafe.putDoubleVolatile(base, fieldOffset, ((Short) value).shortValue());
- return;
- }
- if (value instanceof Character) {
- unsafe.putDoubleVolatile(base, fieldOffset, ((Character) value).charValue());
- return;
- }
- if (value instanceof Integer) {
- unsafe.putDoubleVolatile(base, fieldOffset, ((Integer) value).intValue());
- return;
- }
- if (value instanceof Long) {
- unsafe.putDoubleVolatile(base, fieldOffset, ((Long) value).longValue());
- return;
- }
- if (value instanceof Float) {
- unsafe.putDoubleVolatile(base, fieldOffset, ((Float) value).floatValue());
- return;
- }
- if (value instanceof Double) {
- unsafe.putDoubleVolatile(base, fieldOffset, ((Double) value).doubleValue());
- return;
- }
- throwSetIllegalArgumentException(value);
- }
-
- public void setBoolean(Object obj, boolean z)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(z);
- }
-
- public void setByte(Object obj, byte b)
- throws IllegalArgumentException, IllegalAccessException
- {
- setDouble(obj, b);
- }
-
- public void setChar(Object obj, char c)
- throws IllegalArgumentException, IllegalAccessException
- {
- setDouble(obj, c);
- }
-
- public void setShort(Object obj, short s)
- throws IllegalArgumentException, IllegalAccessException
- {
- setDouble(obj, s);
- }
-
- public void setInt(Object obj, int i)
- throws IllegalArgumentException, IllegalAccessException
- {
- setDouble(obj, i);
- }
-
- public void setLong(Object obj, long l)
- throws IllegalArgumentException, IllegalAccessException
- {
- setDouble(obj, l);
- }
-
- public void setFloat(Object obj, float f)
- throws IllegalArgumentException, IllegalAccessException
- {
- setDouble(obj, f);
- }
-
- public void setDouble(Object obj, double d)
- throws IllegalArgumentException, IllegalAccessException
- {
- if (isReadOnly) {
- throwFinalFieldIllegalAccessException(d);
- }
- unsafe.putDoubleVolatile(base, fieldOffset, d);
- }
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/UnsafeQualifiedStaticFieldAccessorImpl.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2004, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
-import java.security.AccessController;
-import jdk.internal.misc.Unsafe;
-
-/** Base class for jdk.internal.misc.Unsafe-based FieldAccessors for final or
- static volatile fields. */
-
-abstract class UnsafeQualifiedStaticFieldAccessorImpl
- extends UnsafeStaticFieldAccessorImpl
-{
- protected final boolean isReadOnly;
-
- UnsafeQualifiedStaticFieldAccessorImpl(Field field, boolean isReadOnly) {
- super(field);
- this.isReadOnly = isReadOnly;
- }
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/UnsafeQualifiedStaticFloatFieldAccessorImpl.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,159 +0,0 @@
-/*
- * Copyright (c) 2004, 2005, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-import java.lang.reflect.Field;
-
-class UnsafeQualifiedStaticFloatFieldAccessorImpl
- extends UnsafeQualifiedStaticFieldAccessorImpl
-{
- UnsafeQualifiedStaticFloatFieldAccessorImpl(Field field, boolean isReadOnly) {
- super(field, isReadOnly);
- }
-
- public Object get(Object obj) throws IllegalArgumentException {
- return Float.valueOf(getFloat(obj));
- }
-
- public boolean getBoolean(Object obj) throws IllegalArgumentException {
- throw newGetBooleanIllegalArgumentException();
- }
-
- public byte getByte(Object obj) throws IllegalArgumentException {
- throw newGetByteIllegalArgumentException();
- }
-
- public char getChar(Object obj) throws IllegalArgumentException {
- throw newGetCharIllegalArgumentException();
- }
-
- public short getShort(Object obj) throws IllegalArgumentException {
- throw newGetShortIllegalArgumentException();
- }
-
- public int getInt(Object obj) throws IllegalArgumentException {
- throw newGetIntIllegalArgumentException();
- }
-
- public long getLong(Object obj) throws IllegalArgumentException {
- throw newGetLongIllegalArgumentException();
- }
-
- public float getFloat(Object obj) throws IllegalArgumentException {
- return unsafe.getFloatVolatile(base, fieldOffset);
- }
-
- public double getDouble(Object obj) throws IllegalArgumentException {
- return getFloat(obj);
- }
-
- public void set(Object obj, Object value)
- throws IllegalArgumentException, IllegalAccessException
- {
- if (isReadOnly) {
- throwFinalFieldIllegalAccessException(value);
- }
- if (value == null) {
- throwSetIllegalArgumentException(value);
- }
- if (value instanceof Byte) {
- unsafe.putFloatVolatile(base, fieldOffset, ((Byte) value).byteValue());
- return;
- }
- if (value instanceof Short) {
- unsafe.putFloatVolatile(base, fieldOffset, ((Short) value).shortValue());
- return;
- }
- if (value instanceof Character) {
- unsafe.putFloatVolatile(base, fieldOffset, ((Character) value).charValue());
- return;
- }
- if (value instanceof Integer) {
- unsafe.putFloatVolatile(base, fieldOffset, ((Integer) value).intValue());
- return;
- }
- if (value instanceof Long) {
- unsafe.putFloatVolatile(base, fieldOffset, ((Long) value).longValue());
- return;
- }
- if (value instanceof Float) {
- unsafe.putFloatVolatile(base, fieldOffset, ((Float) value).floatValue());
- return;
- }
- throwSetIllegalArgumentException(value);
- }
-
- public void setBoolean(Object obj, boolean z)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(z);
- }
-
- public void setByte(Object obj, byte b)
- throws IllegalArgumentException, IllegalAccessException
- {
- setFloat(obj, b);
- }
-
- public void setChar(Object obj, char c)
- throws IllegalArgumentException, IllegalAccessException
- {
- setFloat(obj, c);
- }
-
- public void setShort(Object obj, short s)
- throws IllegalArgumentException, IllegalAccessException
- {
- setFloat(obj, s);
- }
-
- public void setInt(Object obj, int i)
- throws IllegalArgumentException, IllegalAccessException
- {
- setFloat(obj, i);
- }
-
- public void setLong(Object obj, long l)
- throws IllegalArgumentException, IllegalAccessException
- {
- setFloat(obj, l);
- }
-
- public void setFloat(Object obj, float f)
- throws IllegalArgumentException, IllegalAccessException
- {
- if (isReadOnly) {
- throwFinalFieldIllegalAccessException(f);
- }
- unsafe.putFloatVolatile(base, fieldOffset, f);
- }
-
- public void setDouble(Object obj, double d)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(d);
- }
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/UnsafeQualifiedStaticIntegerFieldAccessorImpl.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,151 +0,0 @@
-/*
- * Copyright (c) 2004, 2005, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-import java.lang.reflect.Field;
-
-class UnsafeQualifiedStaticIntegerFieldAccessorImpl
- extends UnsafeQualifiedStaticFieldAccessorImpl
-{
- UnsafeQualifiedStaticIntegerFieldAccessorImpl(Field field, boolean isReadOnly) {
- super(field, isReadOnly);
- }
-
- public Object get(Object obj) throws IllegalArgumentException {
- return Integer.valueOf(getInt(obj));
- }
-
- public boolean getBoolean(Object obj) throws IllegalArgumentException {
- throw newGetBooleanIllegalArgumentException();
- }
-
- public byte getByte(Object obj) throws IllegalArgumentException {
- throw newGetByteIllegalArgumentException();
- }
-
- public char getChar(Object obj) throws IllegalArgumentException {
- throw newGetCharIllegalArgumentException();
- }
-
- public short getShort(Object obj) throws IllegalArgumentException {
- throw newGetShortIllegalArgumentException();
- }
-
- public int getInt(Object obj) throws IllegalArgumentException {
- return unsafe.getIntVolatile(base, fieldOffset);
- }
-
- public long getLong(Object obj) throws IllegalArgumentException {
- return getInt(obj);
- }
-
- public float getFloat(Object obj) throws IllegalArgumentException {
- return getInt(obj);
- }
-
- public double getDouble(Object obj) throws IllegalArgumentException {
- return getInt(obj);
- }
-
- public void set(Object obj, Object value)
- throws IllegalArgumentException, IllegalAccessException
- {
- if (isReadOnly) {
- throwFinalFieldIllegalAccessException(value);
- }
- if (value == null) {
- throwSetIllegalArgumentException(value);
- }
- if (value instanceof Byte) {
- unsafe.putIntVolatile(base, fieldOffset, ((Byte) value).byteValue());
- return;
- }
- if (value instanceof Short) {
- unsafe.putIntVolatile(base, fieldOffset, ((Short) value).shortValue());
- return;
- }
- if (value instanceof Character) {
- unsafe.putIntVolatile(base, fieldOffset, ((Character) value).charValue());
- return;
- }
- if (value instanceof Integer) {
- unsafe.putIntVolatile(base, fieldOffset, ((Integer) value).intValue());
- return;
- }
- throwSetIllegalArgumentException(value);
- }
-
- public void setBoolean(Object obj, boolean z)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(z);
- }
-
- public void setByte(Object obj, byte b)
- throws IllegalArgumentException, IllegalAccessException
- {
- setInt(obj, b);
- }
-
- public void setChar(Object obj, char c)
- throws IllegalArgumentException, IllegalAccessException
- {
- setInt(obj, c);
- }
-
- public void setShort(Object obj, short s)
- throws IllegalArgumentException, IllegalAccessException
- {
- setInt(obj, s);
- }
-
- public void setInt(Object obj, int i)
- throws IllegalArgumentException, IllegalAccessException
- {
- if (isReadOnly) {
- throwFinalFieldIllegalAccessException(i);
- }
- unsafe.putIntVolatile(base, fieldOffset, i);
- }
-
- public void setLong(Object obj, long l)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(l);
- }
-
- public void setFloat(Object obj, float f)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(f);
- }
-
- public void setDouble(Object obj, double d)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(d);
- }
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/UnsafeQualifiedStaticLongFieldAccessorImpl.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,155 +0,0 @@
-/*
- * Copyright (c) 2004, 2005, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-import java.lang.reflect.Field;
-
-class UnsafeQualifiedStaticLongFieldAccessorImpl
- extends UnsafeQualifiedStaticFieldAccessorImpl
-{
- UnsafeQualifiedStaticLongFieldAccessorImpl(Field field, boolean isReadOnly) {
- super(field, isReadOnly);
- }
-
- public Object get(Object obj) throws IllegalArgumentException {
- return Long.valueOf(getLong(obj));
- }
-
- public boolean getBoolean(Object obj) throws IllegalArgumentException {
- throw newGetBooleanIllegalArgumentException();
- }
-
- public byte getByte(Object obj) throws IllegalArgumentException {
- throw newGetByteIllegalArgumentException();
- }
-
- public char getChar(Object obj) throws IllegalArgumentException {
- throw newGetCharIllegalArgumentException();
- }
-
- public short getShort(Object obj) throws IllegalArgumentException {
- throw newGetShortIllegalArgumentException();
- }
-
- public int getInt(Object obj) throws IllegalArgumentException {
- throw newGetIntIllegalArgumentException();
- }
-
- public long getLong(Object obj) throws IllegalArgumentException {
- return unsafe.getLongVolatile(base, fieldOffset);
- }
-
- public float getFloat(Object obj) throws IllegalArgumentException {
- return getLong(obj);
- }
-
- public double getDouble(Object obj) throws IllegalArgumentException {
- return getLong(obj);
- }
-
- public void set(Object obj, Object value)
- throws IllegalArgumentException, IllegalAccessException
- {
- if (isReadOnly) {
- throwFinalFieldIllegalAccessException(value);
- }
- if (value == null) {
- throwSetIllegalArgumentException(value);
- }
- if (value instanceof Byte) {
- unsafe.putLongVolatile(base, fieldOffset, ((Byte) value).byteValue());
- return;
- }
- if (value instanceof Short) {
- unsafe.putLongVolatile(base, fieldOffset, ((Short) value).shortValue());
- return;
- }
- if (value instanceof Character) {
- unsafe.putLongVolatile(base, fieldOffset, ((Character) value).charValue());
- return;
- }
- if (value instanceof Integer) {
- unsafe.putLongVolatile(base, fieldOffset, ((Integer) value).intValue());
- return;
- }
- if (value instanceof Long) {
- unsafe.putLongVolatile(base, fieldOffset, ((Long) value).longValue());
- return;
- }
- throwSetIllegalArgumentException(value);
- }
-
- public void setBoolean(Object obj, boolean z)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(z);
- }
-
- public void setByte(Object obj, byte b)
- throws IllegalArgumentException, IllegalAccessException
- {
- setLong(obj, b);
- }
-
- public void setChar(Object obj, char c)
- throws IllegalArgumentException, IllegalAccessException
- {
- setLong(obj, c);
- }
-
- public void setShort(Object obj, short s)
- throws IllegalArgumentException, IllegalAccessException
- {
- setLong(obj, s);
- }
-
- public void setInt(Object obj, int i)
- throws IllegalArgumentException, IllegalAccessException
- {
- setLong(obj, i);
- }
-
- public void setLong(Object obj, long l)
- throws IllegalArgumentException, IllegalAccessException
- {
- if (isReadOnly) {
- throwFinalFieldIllegalAccessException(l);
- }
- unsafe.putLongVolatile(base, fieldOffset, l);
- }
-
- public void setFloat(Object obj, float f)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(f);
- }
-
- public void setDouble(Object obj, double d)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(d);
- }
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/UnsafeQualifiedStaticObjectFieldAccessorImpl.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,134 +0,0 @@
-/*
- * Copyright (c) 2004, 2005, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-import java.lang.reflect.Field;
-
-class UnsafeQualifiedStaticObjectFieldAccessorImpl
- extends UnsafeQualifiedStaticFieldAccessorImpl
-{
- UnsafeQualifiedStaticObjectFieldAccessorImpl(Field field, boolean isReadOnly) {
- super(field, isReadOnly);
- }
-
- public Object get(Object obj) throws IllegalArgumentException {
- return unsafe.getObjectVolatile(base, fieldOffset);
- }
-
- public boolean getBoolean(Object obj) throws IllegalArgumentException {
- throw newGetBooleanIllegalArgumentException();
- }
-
- public byte getByte(Object obj) throws IllegalArgumentException {
- throw newGetByteIllegalArgumentException();
- }
-
- public char getChar(Object obj) throws IllegalArgumentException {
- throw newGetCharIllegalArgumentException();
- }
-
- public short getShort(Object obj) throws IllegalArgumentException {
- throw newGetShortIllegalArgumentException();
- }
-
- public int getInt(Object obj) throws IllegalArgumentException {
- throw newGetIntIllegalArgumentException();
- }
-
- public long getLong(Object obj) throws IllegalArgumentException {
- throw newGetLongIllegalArgumentException();
- }
-
- public float getFloat(Object obj) throws IllegalArgumentException {
- throw newGetFloatIllegalArgumentException();
- }
-
- public double getDouble(Object obj) throws IllegalArgumentException {
- throw newGetDoubleIllegalArgumentException();
- }
-
- public void set(Object obj, Object value)
- throws IllegalArgumentException, IllegalAccessException
- {
- if (isReadOnly) {
- throwFinalFieldIllegalAccessException(value);
- }
- if (value != null) {
- if (!field.getType().isAssignableFrom(value.getClass())) {
- throwSetIllegalArgumentException(value);
- }
- }
- unsafe.putObjectVolatile(base, fieldOffset, value);
- }
-
- public void setBoolean(Object obj, boolean z)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(z);
- }
-
- public void setByte(Object obj, byte b)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(b);
- }
-
- public void setChar(Object obj, char c)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(c);
- }
-
- public void setShort(Object obj, short s)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(s);
- }
-
- public void setInt(Object obj, int i)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(i);
- }
-
- public void setLong(Object obj, long l)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(l);
- }
-
- public void setFloat(Object obj, float f)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(f);
- }
-
- public void setDouble(Object obj, double d)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(d);
- }
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/UnsafeQualifiedStaticShortFieldAccessorImpl.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,143 +0,0 @@
-/*
- * Copyright (c) 2004, 2005, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-import java.lang.reflect.Field;
-
-class UnsafeQualifiedStaticShortFieldAccessorImpl
- extends UnsafeQualifiedStaticFieldAccessorImpl
-{
- UnsafeQualifiedStaticShortFieldAccessorImpl(Field field, boolean isReadOnly) {
- super(field, isReadOnly);
- }
-
- public Object get(Object obj) throws IllegalArgumentException {
- return Short.valueOf(getShort(obj));
- }
-
- public boolean getBoolean(Object obj) throws IllegalArgumentException {
- throw newGetBooleanIllegalArgumentException();
- }
-
- public byte getByte(Object obj) throws IllegalArgumentException {
- throw newGetByteIllegalArgumentException();
- }
-
- public char getChar(Object obj) throws IllegalArgumentException {
- throw newGetCharIllegalArgumentException();
- }
-
- public short getShort(Object obj) throws IllegalArgumentException {
- return unsafe.getShortVolatile(base, fieldOffset);
- }
-
- public int getInt(Object obj) throws IllegalArgumentException {
- return getShort(obj);
- }
-
- public long getLong(Object obj) throws IllegalArgumentException {
- return getShort(obj);
- }
-
- public float getFloat(Object obj) throws IllegalArgumentException {
- return getShort(obj);
- }
-
- public double getDouble(Object obj) throws IllegalArgumentException {
- return getShort(obj);
- }
-
- public void set(Object obj, Object value)
- throws IllegalArgumentException, IllegalAccessException
- {
- if (isReadOnly) {
- throwFinalFieldIllegalAccessException(value);
- }
- if (value == null) {
- throwSetIllegalArgumentException(value);
- }
- if (value instanceof Byte) {
- unsafe.putShortVolatile(base, fieldOffset, ((Byte) value).byteValue());
- return;
- }
- if (value instanceof Short) {
- unsafe.putShortVolatile(base, fieldOffset, ((Short) value).shortValue());
- return;
- }
- throwSetIllegalArgumentException(value);
- }
-
- public void setBoolean(Object obj, boolean z)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(z);
- }
-
- public void setByte(Object obj, byte b)
- throws IllegalArgumentException, IllegalAccessException
- {
- setShort(obj, b);
- }
-
- public void setChar(Object obj, char c)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(c);
- }
-
- public void setShort(Object obj, short s)
- throws IllegalArgumentException, IllegalAccessException
- {
- if (isReadOnly) {
- throwFinalFieldIllegalAccessException(s);
- }
- unsafe.putShortVolatile(base, fieldOffset, s);
- }
-
- public void setInt(Object obj, int i)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(i);
- }
-
- public void setLong(Object obj, long l)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(l);
- }
-
- public void setFloat(Object obj, float f)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(f);
- }
-
- public void setDouble(Object obj, double d)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(d);
- }
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/UnsafeShortFieldAccessorImpl.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,144 +0,0 @@
-/*
- * Copyright (c) 2001, 2005, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-import java.lang.reflect.Field;
-
-class UnsafeShortFieldAccessorImpl extends UnsafeFieldAccessorImpl {
- UnsafeShortFieldAccessorImpl(Field field) {
- super(field);
- }
-
- public Object get(Object obj) throws IllegalArgumentException {
- return Short.valueOf(getShort(obj));
- }
-
- public boolean getBoolean(Object obj) throws IllegalArgumentException {
- throw newGetBooleanIllegalArgumentException();
- }
-
- public byte getByte(Object obj) throws IllegalArgumentException {
- throw newGetByteIllegalArgumentException();
- }
-
- public char getChar(Object obj) throws IllegalArgumentException {
- throw newGetCharIllegalArgumentException();
- }
-
- public short getShort(Object obj) throws IllegalArgumentException {
- ensureObj(obj);
- return unsafe.getShort(obj, fieldOffset);
- }
-
- public int getInt(Object obj) throws IllegalArgumentException {
- return getShort(obj);
- }
-
- public long getLong(Object obj) throws IllegalArgumentException {
- return getShort(obj);
- }
-
- public float getFloat(Object obj) throws IllegalArgumentException {
- return getShort(obj);
- }
-
- public double getDouble(Object obj) throws IllegalArgumentException {
- return getShort(obj);
- }
-
- public void set(Object obj, Object value)
- throws IllegalArgumentException, IllegalAccessException
- {
- ensureObj(obj);
- if (isFinal) {
- throwFinalFieldIllegalAccessException(value);
- }
- if (value == null) {
- throwSetIllegalArgumentException(value);
- }
- if (value instanceof Byte) {
- unsafe.putShort(obj, fieldOffset, ((Byte) value).byteValue());
- return;
- }
- if (value instanceof Short) {
- unsafe.putShort(obj, fieldOffset, ((Short) value).shortValue());
- return;
- }
- throwSetIllegalArgumentException(value);
- }
-
- public void setBoolean(Object obj, boolean z)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(z);
- }
-
- public void setByte(Object obj, byte b)
- throws IllegalArgumentException, IllegalAccessException
- {
- setShort(obj, b);
- }
-
- public void setChar(Object obj, char c)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(c);
- }
-
- public void setShort(Object obj, short s)
- throws IllegalArgumentException, IllegalAccessException
- {
- ensureObj(obj);
- if (isFinal) {
- throwFinalFieldIllegalAccessException(s);
- }
- unsafe.putShort(obj, fieldOffset, s);
- }
-
- public void setInt(Object obj, int i)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(i);
- }
-
- public void setLong(Object obj, long l)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(l);
- }
-
- public void setFloat(Object obj, float f)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(f);
- }
-
- public void setDouble(Object obj, double d)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(d);
- }
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/UnsafeStaticBooleanFieldAccessorImpl.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,137 +0,0 @@
-/*
- * Copyright (c) 2001, 2005, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-import java.lang.reflect.Field;
-
-class UnsafeStaticBooleanFieldAccessorImpl extends UnsafeStaticFieldAccessorImpl {
- UnsafeStaticBooleanFieldAccessorImpl(Field field) {
- super(field);
- }
-
- public Object get(Object obj) throws IllegalArgumentException {
- return Boolean.valueOf(getBoolean(obj));
- }
-
- public boolean getBoolean(Object obj) throws IllegalArgumentException {
- return unsafe.getBoolean(base, fieldOffset);
- }
-
- public byte getByte(Object obj) throws IllegalArgumentException {
- throw newGetByteIllegalArgumentException();
- }
-
- public char getChar(Object obj) throws IllegalArgumentException {
- throw newGetCharIllegalArgumentException();
- }
-
- public short getShort(Object obj) throws IllegalArgumentException {
- throw newGetShortIllegalArgumentException();
- }
-
- public int getInt(Object obj) throws IllegalArgumentException {
- throw newGetIntIllegalArgumentException();
- }
-
- public long getLong(Object obj) throws IllegalArgumentException {
- throw newGetLongIllegalArgumentException();
- }
-
- public float getFloat(Object obj) throws IllegalArgumentException {
- throw newGetFloatIllegalArgumentException();
- }
-
- public double getDouble(Object obj) throws IllegalArgumentException {
- throw newGetDoubleIllegalArgumentException();
- }
-
- public void set(Object obj, Object value)
- throws IllegalArgumentException, IllegalAccessException
- {
- if (isFinal) {
- throwFinalFieldIllegalAccessException(value);
- }
- if (value == null) {
- throwSetIllegalArgumentException(value);
- }
- if (value instanceof Boolean) {
- unsafe.putBoolean(base, fieldOffset, ((Boolean) value).booleanValue());
- return;
- }
- throwSetIllegalArgumentException(value);
- }
-
- public void setBoolean(Object obj, boolean z)
- throws IllegalArgumentException, IllegalAccessException
- {
- if (isFinal) {
- throwFinalFieldIllegalAccessException(z);
- }
- unsafe.putBoolean(base, fieldOffset, z);
- }
-
- public void setByte(Object obj, byte b)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(b);
- }
-
- public void setChar(Object obj, char c)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(c);
- }
-
- public void setShort(Object obj, short s)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(s);
- }
-
- public void setInt(Object obj, int i)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(i);
- }
-
- public void setLong(Object obj, long l)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(l);
- }
-
- public void setFloat(Object obj, float f)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(f);
- }
-
- public void setDouble(Object obj, double d)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(d);
- }
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/UnsafeStaticByteFieldAccessorImpl.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,137 +0,0 @@
-/*
- * Copyright (c) 2001, 2005, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-import java.lang.reflect.Field;
-
-class UnsafeStaticByteFieldAccessorImpl extends UnsafeStaticFieldAccessorImpl {
- UnsafeStaticByteFieldAccessorImpl(Field field) {
- super(field);
- }
-
- public Object get(Object obj) throws IllegalArgumentException {
- return Byte.valueOf(getByte(obj));
- }
-
- public boolean getBoolean(Object obj) throws IllegalArgumentException {
- throw newGetBooleanIllegalArgumentException();
- }
-
- public byte getByte(Object obj) throws IllegalArgumentException {
- return unsafe.getByte(base, fieldOffset);
- }
-
- public char getChar(Object obj) throws IllegalArgumentException {
- throw newGetCharIllegalArgumentException();
- }
-
- public short getShort(Object obj) throws IllegalArgumentException {
- return getByte(obj);
- }
-
- public int getInt(Object obj) throws IllegalArgumentException {
- return getByte(obj);
- }
-
- public long getLong(Object obj) throws IllegalArgumentException {
- return getByte(obj);
- }
-
- public float getFloat(Object obj) throws IllegalArgumentException {
- return getByte(obj);
- }
-
- public double getDouble(Object obj) throws IllegalArgumentException {
- return getByte(obj);
- }
-
- public void set(Object obj, Object value)
- throws IllegalArgumentException, IllegalAccessException
- {
- if (isFinal) {
- throwFinalFieldIllegalAccessException(value);
- }
- if (value == null) {
- throwSetIllegalArgumentException(value);
- }
- if (value instanceof Byte) {
- unsafe.putByte(base, fieldOffset, ((Byte) value).byteValue());
- return;
- }
- throwSetIllegalArgumentException(value);
- }
-
- public void setBoolean(Object obj, boolean z)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(z);
- }
-
- public void setByte(Object obj, byte b)
- throws IllegalArgumentException, IllegalAccessException
- {
- if (isFinal) {
- throwFinalFieldIllegalAccessException(b);
- }
- unsafe.putByte(base, fieldOffset, b);
- }
-
- public void setChar(Object obj, char c)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(c);
- }
-
- public void setShort(Object obj, short s)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(s);
- }
-
- public void setInt(Object obj, int i)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(i);
- }
-
- public void setLong(Object obj, long l)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(l);
- }
-
- public void setFloat(Object obj, float f)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(f);
- }
-
- public void setDouble(Object obj, double d)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(d);
- }
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/UnsafeStaticCharacterFieldAccessorImpl.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,137 +0,0 @@
-/*
- * Copyright (c) 2001, 2005, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-import java.lang.reflect.Field;
-
-class UnsafeStaticCharacterFieldAccessorImpl extends UnsafeStaticFieldAccessorImpl {
- UnsafeStaticCharacterFieldAccessorImpl(Field field) {
- super(field);
- }
-
- public Object get(Object obj) throws IllegalArgumentException {
- return Character.valueOf(getChar(obj));
- }
-
- public boolean getBoolean(Object obj) throws IllegalArgumentException {
- throw newGetBooleanIllegalArgumentException();
- }
-
- public byte getByte(Object obj) throws IllegalArgumentException {
- throw newGetByteIllegalArgumentException();
- }
-
- public char getChar(Object obj) throws IllegalArgumentException {
- return unsafe.getChar(base, fieldOffset);
- }
-
- public short getShort(Object obj) throws IllegalArgumentException {
- throw newGetShortIllegalArgumentException();
- }
-
- public int getInt(Object obj) throws IllegalArgumentException {
- return getChar(obj);
- }
-
- public long getLong(Object obj) throws IllegalArgumentException {
- return getChar(obj);
- }
-
- public float getFloat(Object obj) throws IllegalArgumentException {
- return getChar(obj);
- }
-
- public double getDouble(Object obj) throws IllegalArgumentException {
- return getChar(obj);
- }
-
- public void set(Object obj, Object value)
- throws IllegalArgumentException, IllegalAccessException
- {
- if (isFinal) {
- throwFinalFieldIllegalAccessException(value);
- }
- if (value == null) {
- throwSetIllegalArgumentException(value);
- }
- if (value instanceof Character) {
- unsafe.putChar(base, fieldOffset, ((Character) value).charValue());
- return;
- }
- throwSetIllegalArgumentException(value);
- }
-
- public void setBoolean(Object obj, boolean z)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(z);
- }
-
- public void setByte(Object obj, byte b)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(b);
- }
-
- public void setChar(Object obj, char c)
- throws IllegalArgumentException, IllegalAccessException
- {
- if (isFinal) {
- throwFinalFieldIllegalAccessException(c);
- }
- unsafe.putChar(base, fieldOffset, c);
- }
-
- public void setShort(Object obj, short s)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(s);
- }
-
- public void setInt(Object obj, int i)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(i);
- }
-
- public void setLong(Object obj, long l)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(l);
- }
-
- public void setFloat(Object obj, float f)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(f);
- }
-
- public void setDouble(Object obj, double d)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(d);
- }
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/UnsafeStaticDoubleFieldAccessorImpl.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,161 +0,0 @@
-/*
- * Copyright (c) 2001, 2005, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-import java.lang.reflect.Field;
-
-class UnsafeStaticDoubleFieldAccessorImpl extends UnsafeStaticFieldAccessorImpl {
- UnsafeStaticDoubleFieldAccessorImpl(Field field) {
- super(field);
- }
-
- public Object get(Object obj) throws IllegalArgumentException {
- return Double.valueOf(getDouble(obj));
- }
-
- public boolean getBoolean(Object obj) throws IllegalArgumentException {
- throw newGetBooleanIllegalArgumentException();
- }
-
- public byte getByte(Object obj) throws IllegalArgumentException {
- throw newGetByteIllegalArgumentException();
- }
-
- public char getChar(Object obj) throws IllegalArgumentException {
- throw newGetCharIllegalArgumentException();
- }
-
- public short getShort(Object obj) throws IllegalArgumentException {
- throw newGetShortIllegalArgumentException();
- }
-
- public int getInt(Object obj) throws IllegalArgumentException {
- throw newGetIntIllegalArgumentException();
- }
-
- public long getLong(Object obj) throws IllegalArgumentException {
- throw newGetLongIllegalArgumentException();
- }
-
- public float getFloat(Object obj) throws IllegalArgumentException {
- throw newGetFloatIllegalArgumentException();
- }
-
- public double getDouble(Object obj) throws IllegalArgumentException {
- return unsafe.getDouble(base, fieldOffset);
- }
-
- public void set(Object obj, Object value)
- throws IllegalArgumentException, IllegalAccessException
- {
- if (isFinal) {
- throwFinalFieldIllegalAccessException(value);
- }
- if (value == null) {
- throwSetIllegalArgumentException(value);
- }
- if (value instanceof Byte) {
- unsafe.putDouble(base, fieldOffset, ((Byte) value).byteValue());
- return;
- }
- if (value instanceof Short) {
- unsafe.putDouble(base, fieldOffset, ((Short) value).shortValue());
- return;
- }
- if (value instanceof Character) {
- unsafe.putDouble(base, fieldOffset, ((Character) value).charValue());
- return;
- }
- if (value instanceof Integer) {
- unsafe.putDouble(base, fieldOffset, ((Integer) value).intValue());
- return;
- }
- if (value instanceof Long) {
- unsafe.putDouble(base, fieldOffset, ((Long) value).longValue());
- return;
- }
- if (value instanceof Float) {
- unsafe.putDouble(base, fieldOffset, ((Float) value).floatValue());
- return;
- }
- if (value instanceof Double) {
- unsafe.putDouble(base, fieldOffset, ((Double) value).doubleValue());
- return;
- }
- throwSetIllegalArgumentException(value);
- }
-
- public void setBoolean(Object obj, boolean z)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(z);
- }
-
- public void setByte(Object obj, byte b)
- throws IllegalArgumentException, IllegalAccessException
- {
- setDouble(obj, b);
- }
-
- public void setChar(Object obj, char c)
- throws IllegalArgumentException, IllegalAccessException
- {
- setDouble(obj, c);
- }
-
- public void setShort(Object obj, short s)
- throws IllegalArgumentException, IllegalAccessException
- {
- setDouble(obj, s);
- }
-
- public void setInt(Object obj, int i)
- throws IllegalArgumentException, IllegalAccessException
- {
- setDouble(obj, i);
- }
-
- public void setLong(Object obj, long l)
- throws IllegalArgumentException, IllegalAccessException
- {
- setDouble(obj, l);
- }
-
- public void setFloat(Object obj, float f)
- throws IllegalArgumentException, IllegalAccessException
- {
- setDouble(obj, f);
- }
-
- public void setDouble(Object obj, double d)
- throws IllegalArgumentException, IllegalAccessException
- {
- if (isFinal) {
- throwFinalFieldIllegalAccessException(d);
- }
- unsafe.putDouble(base, fieldOffset, d);
- }
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/UnsafeStaticFieldAccessorImpl.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 2001, 2012, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
-import java.security.AccessController;
-import jdk.internal.misc.Unsafe;
-
-/** Base class for jdk.internal.misc.Unsafe-based FieldAccessors for static
- fields. The observation is that there are only nine types of
- fields from the standpoint of reflection code: the eight primitive
- types and Object. Using class Unsafe instead of generated
- bytecodes saves memory and loading time for the
- dynamically-generated FieldAccessors. */
-
-abstract class UnsafeStaticFieldAccessorImpl extends UnsafeFieldAccessorImpl {
- static {
- Reflection.registerFieldsToFilter(UnsafeStaticFieldAccessorImpl.class,
- new String[] { "base" });
- }
-
- protected final Object base; // base
-
- UnsafeStaticFieldAccessorImpl(Field field) {
- super(field);
- base = unsafe.staticFieldBase(field);
- }
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/UnsafeStaticFloatFieldAccessorImpl.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,157 +0,0 @@
-/*
- * Copyright (c) 2001, 2005, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-import java.lang.reflect.Field;
-
-class UnsafeStaticFloatFieldAccessorImpl extends UnsafeStaticFieldAccessorImpl {
- UnsafeStaticFloatFieldAccessorImpl(Field field) {
- super(field);
- }
-
- public Object get(Object obj) throws IllegalArgumentException {
- return Float.valueOf(getFloat(obj));
- }
-
- public boolean getBoolean(Object obj) throws IllegalArgumentException {
- throw newGetBooleanIllegalArgumentException();
- }
-
- public byte getByte(Object obj) throws IllegalArgumentException {
- throw newGetByteIllegalArgumentException();
- }
-
- public char getChar(Object obj) throws IllegalArgumentException {
- throw newGetCharIllegalArgumentException();
- }
-
- public short getShort(Object obj) throws IllegalArgumentException {
- throw newGetShortIllegalArgumentException();
- }
-
- public int getInt(Object obj) throws IllegalArgumentException {
- throw newGetIntIllegalArgumentException();
- }
-
- public long getLong(Object obj) throws IllegalArgumentException {
- throw newGetLongIllegalArgumentException();
- }
-
- public float getFloat(Object obj) throws IllegalArgumentException {
- return unsafe.getFloat(base, fieldOffset);
- }
-
- public double getDouble(Object obj) throws IllegalArgumentException {
- return getFloat(obj);
- }
-
- public void set(Object obj, Object value)
- throws IllegalArgumentException, IllegalAccessException
- {
- if (isFinal) {
- throwFinalFieldIllegalAccessException(value);
- }
- if (value == null) {
- throwSetIllegalArgumentException(value);
- }
- if (value instanceof Byte) {
- unsafe.putFloat(base, fieldOffset, ((Byte) value).byteValue());
- return;
- }
- if (value instanceof Short) {
- unsafe.putFloat(base, fieldOffset, ((Short) value).shortValue());
- return;
- }
- if (value instanceof Character) {
- unsafe.putFloat(base, fieldOffset, ((Character) value).charValue());
- return;
- }
- if (value instanceof Integer) {
- unsafe.putFloat(base, fieldOffset, ((Integer) value).intValue());
- return;
- }
- if (value instanceof Long) {
- unsafe.putFloat(base, fieldOffset, ((Long) value).longValue());
- return;
- }
- if (value instanceof Float) {
- unsafe.putFloat(base, fieldOffset, ((Float) value).floatValue());
- return;
- }
- throwSetIllegalArgumentException(value);
- }
-
- public void setBoolean(Object obj, boolean z)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(z);
- }
-
- public void setByte(Object obj, byte b)
- throws IllegalArgumentException, IllegalAccessException
- {
- setFloat(obj, b);
- }
-
- public void setChar(Object obj, char c)
- throws IllegalArgumentException, IllegalAccessException
- {
- setFloat(obj, c);
- }
-
- public void setShort(Object obj, short s)
- throws IllegalArgumentException, IllegalAccessException
- {
- setFloat(obj, s);
- }
-
- public void setInt(Object obj, int i)
- throws IllegalArgumentException, IllegalAccessException
- {
- setFloat(obj, i);
- }
-
- public void setLong(Object obj, long l)
- throws IllegalArgumentException, IllegalAccessException
- {
- setFloat(obj, l);
- }
-
- public void setFloat(Object obj, float f)
- throws IllegalArgumentException, IllegalAccessException
- {
- if (isFinal) {
- throwFinalFieldIllegalAccessException(f);
- }
- unsafe.putFloat(base, fieldOffset, f);
- }
-
- public void setDouble(Object obj, double d)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(d);
- }
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/UnsafeStaticIntegerFieldAccessorImpl.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,149 +0,0 @@
-/*
- * Copyright (c) 2001, 2005, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-import java.lang.reflect.Field;
-
-class UnsafeStaticIntegerFieldAccessorImpl extends UnsafeStaticFieldAccessorImpl {
- UnsafeStaticIntegerFieldAccessorImpl(Field field) {
- super(field);
- }
-
- public Object get(Object obj) throws IllegalArgumentException {
- return Integer.valueOf(getInt(obj));
- }
-
- public boolean getBoolean(Object obj) throws IllegalArgumentException {
- throw newGetBooleanIllegalArgumentException();
- }
-
- public byte getByte(Object obj) throws IllegalArgumentException {
- throw newGetByteIllegalArgumentException();
- }
-
- public char getChar(Object obj) throws IllegalArgumentException {
- throw newGetCharIllegalArgumentException();
- }
-
- public short getShort(Object obj) throws IllegalArgumentException {
- throw newGetShortIllegalArgumentException();
- }
-
- public int getInt(Object obj) throws IllegalArgumentException {
- return unsafe.getInt(base, fieldOffset);
- }
-
- public long getLong(Object obj) throws IllegalArgumentException {
- return getInt(obj);
- }
-
- public float getFloat(Object obj) throws IllegalArgumentException {
- return getInt(obj);
- }
-
- public double getDouble(Object obj) throws IllegalArgumentException {
- return getInt(obj);
- }
-
- public void set(Object obj, Object value)
- throws IllegalArgumentException, IllegalAccessException
- {
- if (isFinal) {
- throwFinalFieldIllegalAccessException(value);
- }
- if (value == null) {
- throwSetIllegalArgumentException(value);
- }
- if (value instanceof Byte) {
- unsafe.putInt(base, fieldOffset, ((Byte) value).byteValue());
- return;
- }
- if (value instanceof Short) {
- unsafe.putInt(base, fieldOffset, ((Short) value).shortValue());
- return;
- }
- if (value instanceof Character) {
- unsafe.putInt(base, fieldOffset, ((Character) value).charValue());
- return;
- }
- if (value instanceof Integer) {
- unsafe.putInt(base, fieldOffset, ((Integer) value).intValue());
- return;
- }
- throwSetIllegalArgumentException(value);
- }
-
- public void setBoolean(Object obj, boolean z)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(z);
- }
-
- public void setByte(Object obj, byte b)
- throws IllegalArgumentException, IllegalAccessException
- {
- setInt(obj, b);
- }
-
- public void setChar(Object obj, char c)
- throws IllegalArgumentException, IllegalAccessException
- {
- setInt(obj, c);
- }
-
- public void setShort(Object obj, short s)
- throws IllegalArgumentException, IllegalAccessException
- {
- setInt(obj, s);
- }
-
- public void setInt(Object obj, int i)
- throws IllegalArgumentException, IllegalAccessException
- {
- if (isFinal) {
- throwFinalFieldIllegalAccessException(i);
- }
- unsafe.putInt(base, fieldOffset, i);
- }
-
- public void setLong(Object obj, long l)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(l);
- }
-
- public void setFloat(Object obj, float f)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(f);
- }
-
- public void setDouble(Object obj, double d)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(d);
- }
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/UnsafeStaticLongFieldAccessorImpl.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,153 +0,0 @@
-/*
- * Copyright (c) 2001, 2005, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-import java.lang.reflect.Field;
-
-class UnsafeStaticLongFieldAccessorImpl extends UnsafeStaticFieldAccessorImpl {
- UnsafeStaticLongFieldAccessorImpl(Field field) {
- super(field);
- }
-
- public Object get(Object obj) throws IllegalArgumentException {
- return Long.valueOf(getLong(obj));
- }
-
- public boolean getBoolean(Object obj) throws IllegalArgumentException {
- throw newGetBooleanIllegalArgumentException();
- }
-
- public byte getByte(Object obj) throws IllegalArgumentException {
- throw newGetByteIllegalArgumentException();
- }
-
- public char getChar(Object obj) throws IllegalArgumentException {
- throw newGetCharIllegalArgumentException();
- }
-
- public short getShort(Object obj) throws IllegalArgumentException {
- throw newGetShortIllegalArgumentException();
- }
-
- public int getInt(Object obj) throws IllegalArgumentException {
- throw newGetIntIllegalArgumentException();
- }
-
- public long getLong(Object obj) throws IllegalArgumentException {
- return unsafe.getLong(base, fieldOffset);
- }
-
- public float getFloat(Object obj) throws IllegalArgumentException {
- return getLong(obj);
- }
-
- public double getDouble(Object obj) throws IllegalArgumentException {
- return getLong(obj);
- }
-
- public void set(Object obj, Object value)
- throws IllegalArgumentException, IllegalAccessException
- {
- if (isFinal) {
- throwFinalFieldIllegalAccessException(value);
- }
- if (value == null) {
- throwSetIllegalArgumentException(value);
- }
- if (value instanceof Byte) {
- unsafe.putLong(base, fieldOffset, ((Byte) value).byteValue());
- return;
- }
- if (value instanceof Short) {
- unsafe.putLong(base, fieldOffset, ((Short) value).shortValue());
- return;
- }
- if (value instanceof Character) {
- unsafe.putLong(base, fieldOffset, ((Character) value).charValue());
- return;
- }
- if (value instanceof Integer) {
- unsafe.putLong(base, fieldOffset, ((Integer) value).intValue());
- return;
- }
- if (value instanceof Long) {
- unsafe.putLong(base, fieldOffset, ((Long) value).longValue());
- return;
- }
- throwSetIllegalArgumentException(value);
- }
-
- public void setBoolean(Object obj, boolean z)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(z);
- }
-
- public void setByte(Object obj, byte b)
- throws IllegalArgumentException, IllegalAccessException
- {
- setLong(obj, b);
- }
-
- public void setChar(Object obj, char c)
- throws IllegalArgumentException, IllegalAccessException
- {
- setLong(obj, c);
- }
-
- public void setShort(Object obj, short s)
- throws IllegalArgumentException, IllegalAccessException
- {
- setLong(obj, s);
- }
-
- public void setInt(Object obj, int i)
- throws IllegalArgumentException, IllegalAccessException
- {
- setLong(obj, i);
- }
-
- public void setLong(Object obj, long l)
- throws IllegalArgumentException, IllegalAccessException
- {
- if (isFinal) {
- throwFinalFieldIllegalAccessException(l);
- }
- unsafe.putLong(base, fieldOffset, l);
- }
-
- public void setFloat(Object obj, float f)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(f);
- }
-
- public void setDouble(Object obj, double d)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(d);
- }
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/UnsafeStaticObjectFieldAccessorImpl.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,132 +0,0 @@
-/*
- * Copyright (c) 2001, 2005, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-import java.lang.reflect.Field;
-
-class UnsafeStaticObjectFieldAccessorImpl extends UnsafeStaticFieldAccessorImpl {
- UnsafeStaticObjectFieldAccessorImpl(Field field) {
- super(field);
- }
-
- public Object get(Object obj) throws IllegalArgumentException {
- return unsafe.getObject(base, fieldOffset);
- }
-
- public boolean getBoolean(Object obj) throws IllegalArgumentException {
- throw newGetBooleanIllegalArgumentException();
- }
-
- public byte getByte(Object obj) throws IllegalArgumentException {
- throw newGetByteIllegalArgumentException();
- }
-
- public char getChar(Object obj) throws IllegalArgumentException {
- throw newGetCharIllegalArgumentException();
- }
-
- public short getShort(Object obj) throws IllegalArgumentException {
- throw newGetShortIllegalArgumentException();
- }
-
- public int getInt(Object obj) throws IllegalArgumentException {
- throw newGetIntIllegalArgumentException();
- }
-
- public long getLong(Object obj) throws IllegalArgumentException {
- throw newGetLongIllegalArgumentException();
- }
-
- public float getFloat(Object obj) throws IllegalArgumentException {
- throw newGetFloatIllegalArgumentException();
- }
-
- public double getDouble(Object obj) throws IllegalArgumentException {
- throw newGetDoubleIllegalArgumentException();
- }
-
- public void set(Object obj, Object value)
- throws IllegalArgumentException, IllegalAccessException
- {
- if (isFinal) {
- throwFinalFieldIllegalAccessException(value);
- }
- if (value != null) {
- if (!field.getType().isAssignableFrom(value.getClass())) {
- throwSetIllegalArgumentException(value);
- }
- }
- unsafe.putObject(base, fieldOffset, value);
- }
-
- public void setBoolean(Object obj, boolean z)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(z);
- }
-
- public void setByte(Object obj, byte b)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(b);
- }
-
- public void setChar(Object obj, char c)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(c);
- }
-
- public void setShort(Object obj, short s)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(s);
- }
-
- public void setInt(Object obj, int i)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(i);
- }
-
- public void setLong(Object obj, long l)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(l);
- }
-
- public void setFloat(Object obj, float f)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(f);
- }
-
- public void setDouble(Object obj, double d)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(d);
- }
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/UnsafeStaticShortFieldAccessorImpl.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,141 +0,0 @@
-/*
- * Copyright (c) 2001, 2005, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.reflect;
-
-import java.lang.reflect.Field;
-
-class UnsafeStaticShortFieldAccessorImpl extends UnsafeStaticFieldAccessorImpl {
- UnsafeStaticShortFieldAccessorImpl(Field field) {
- super(field);
- }
-
- public Object get(Object obj) throws IllegalArgumentException {
- return Short.valueOf(getShort(obj));
- }
-
- public boolean getBoolean(Object obj) throws IllegalArgumentException {
- throw newGetBooleanIllegalArgumentException();
- }
-
- public byte getByte(Object obj) throws IllegalArgumentException {
- throw newGetByteIllegalArgumentException();
- }
-
- public char getChar(Object obj) throws IllegalArgumentException {
- throw newGetCharIllegalArgumentException();
- }
-
- public short getShort(Object obj) throws IllegalArgumentException {
- return unsafe.getShort(base, fieldOffset);
- }
-
- public int getInt(Object obj) throws IllegalArgumentException {
- return getShort(obj);
- }
-
- public long getLong(Object obj) throws IllegalArgumentException {
- return getShort(obj);
- }
-
- public float getFloat(Object obj) throws IllegalArgumentException {
- return getShort(obj);
- }
-
- public double getDouble(Object obj) throws IllegalArgumentException {
- return getShort(obj);
- }
-
- public void set(Object obj, Object value)
- throws IllegalArgumentException, IllegalAccessException
- {
- if (isFinal) {
- throwFinalFieldIllegalAccessException(value);
- }
- if (value == null) {
- throwSetIllegalArgumentException(value);
- }
- if (value instanceof Byte) {
- unsafe.putShort(base, fieldOffset, ((Byte) value).byteValue());
- return;
- }
- if (value instanceof Short) {
- unsafe.putShort(base, fieldOffset, ((Short) value).shortValue());
- return;
- }
- throwSetIllegalArgumentException(value);
- }
-
- public void setBoolean(Object obj, boolean z)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(z);
- }
-
- public void setByte(Object obj, byte b)
- throws IllegalArgumentException, IllegalAccessException
- {
- setShort(obj, b);
- }
-
- public void setChar(Object obj, char c)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(c);
- }
-
- public void setShort(Object obj, short s)
- throws IllegalArgumentException, IllegalAccessException
- {
- if (isFinal) {
- throwFinalFieldIllegalAccessException(s);
- }
- unsafe.putShort(base, fieldOffset, s);
- }
-
- public void setInt(Object obj, int i)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(i);
- }
-
- public void setLong(Object obj, long l)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(l);
- }
-
- public void setFloat(Object obj, float f)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(f);
- }
-
- public void setDouble(Object obj, double d)
- throws IllegalArgumentException, IllegalAccessException
- {
- throwSetIllegalArgumentException(d);
- }
-}
--- a/jdk/src/java.base/share/classes/sun/reflect/annotation/AnnotationParser.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/sun/reflect/annotation/AnnotationParser.java Wed Jul 05 21:35:27 2017 +0200
@@ -32,7 +32,7 @@
import java.lang.reflect.*;
import java.security.AccessController;
import java.security.PrivilegedAction;
-import sun.reflect.ConstantPool;
+import jdk.internal.reflect.ConstantPool;
import sun.reflect.generics.parser.SignatureParser;
import sun.reflect.generics.tree.TypeSignature;
--- a/jdk/src/java.base/share/classes/sun/reflect/annotation/AnnotationSupport.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/sun/reflect/annotation/AnnotationSupport.java Wed Jul 05 21:35:27 2017 +0200
@@ -37,7 +37,7 @@
import jdk.internal.misc.SharedSecrets;
import jdk.internal.misc.JavaLangAccess;
-import sun.reflect.ReflectionFactory;
+import jdk.internal.reflect.ReflectionFactory;
public final class AnnotationSupport {
private static final JavaLangAccess LANG_ACCESS = SharedSecrets.getJavaLangAccess();
--- a/jdk/src/java.base/share/classes/sun/reflect/annotation/TypeAnnotationParser.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/sun/reflect/annotation/TypeAnnotationParser.java Wed Jul 05 21:35:27 2017 +0200
@@ -36,7 +36,7 @@
import java.util.Map;
import jdk.internal.misc.SharedSecrets;
import jdk.internal.misc.JavaLangAccess;
-import sun.reflect.ConstantPool;
+import jdk.internal.reflect.ConstantPool;
import static sun.reflect.annotation.TypeAnnotation.*;
/**
--- a/jdk/src/java.base/share/classes/sun/reflect/misc/ReflectUtil.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/sun/reflect/misc/ReflectUtil.java Wed Jul 05 21:35:27 2017 +0200
@@ -30,7 +30,7 @@
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.lang.reflect.Proxy;
-import sun.reflect.Reflection;
+import jdk.internal.reflect.Reflection;
import sun.security.util.SecurityConstants;
public final class ReflectUtil {
--- a/jdk/src/java.base/share/classes/sun/security/provider/DSAKeyPairGenerator.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/sun/security/provider/DSAKeyPairGenerator.java Wed Jul 05 21:35:27 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2012, 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
@@ -46,7 +46,7 @@
*
*/
public class DSAKeyPairGenerator extends KeyPairGenerator
-implements java.security.interfaces.DSAKeyPairGenerator {
+ implements java.security.interfaces.DSAKeyPairGenerator {
/* Length for prime P and subPrime Q in bits */
private int plen;
@@ -74,6 +74,8 @@
// N=160
} else if (sizeP == 2048 && (sizeQ == 224 || sizeQ == 256)) {
// L=2048, N=224 or 256
+ } else if (sizeP == 3072 && sizeQ == 256) {
+ // L=3072, N=256
} else {
throw new InvalidParameterException
("Unsupported prime and subprime size combination: " +
@@ -91,12 +93,17 @@
* Initializes the DSA key pair generator. If <code>genParams</code>
* is false, a set of pre-computed parameters is used.
*/
- public void initialize(int modlen, boolean genParams, SecureRandom random) {
+ @Override
+ public void initialize(int modlen, boolean genParams, SecureRandom random)
+ throws InvalidParameterException {
+
int subPrimeLen = -1;
if (modlen <= 1024) {
subPrimeLen = 160;
} else if (modlen == 2048) {
subPrimeLen = 224;
+ } else if (modlen == 3072) {
+ subPrimeLen = 256;
}
checkStrength(modlen, subPrimeLen);
if (genParams) {
@@ -122,7 +129,10 @@
*
* @param params a fully initialized DSA parameter object.
*/
- public void initialize(DSAParams params, SecureRandom random) {
+ @Override
+ public void initialize(DSAParams params, SecureRandom random)
+ throws InvalidParameterException {
+
if (params == null) {
throw new InvalidParameterException("Params must not be null");
}
--- a/jdk/src/java.base/share/classes/sun/security/provider/DSAParameterGenerator.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/sun/security/provider/DSAParameterGenerator.java Wed Jul 05 21:35:27 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2012, 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
@@ -68,11 +68,6 @@
// the source of randomness
private SecureRandom random;
- // useful constants
- private static final BigInteger ZERO = BigInteger.valueOf(0);
- private static final BigInteger ONE = BigInteger.valueOf(1);
- private static final BigInteger TWO = BigInteger.valueOf(2);
-
public DSAParameterGenerator() {
}
@@ -83,16 +78,18 @@
* @param strength the strength (size of prime) in bits
* @param random the source of randomness
*/
+ @Override
protected void engineInit(int strength, SecureRandom random) {
if ((strength >= 512) && (strength <= 1024) && (strength % 64 == 0)) {
this.valueN = 160;
} else if (strength == 2048) {
this.valueN = 224;
-// } else if (strength == 3072) {
-// this.valueN = 256;
+ } else if (strength == 3072) {
+ this.valueN = 256;
} else {
- throw new InvalidParameterException
- ("Prime size should be 512 - 1024, or 2048");
+ throw new InvalidParameterException(
+ "Unexpected strength (size of prime): " + strength + ". " +
+ "Prime size should be 512 - 1024, or 2048, 3072");
}
this.valueL = strength;
this.seedLen = valueN;
@@ -103,26 +100,24 @@
* Initializes this parameter generator with a set of
* algorithm-specific parameter generation values.
*
- * @param genParamSpec the set of algorithm-specific parameter generation values
+ * @param genParamSpec the set of algorithm-specific parameter
+ * generation values
* @param random the source of randomness
*
* @exception InvalidAlgorithmParameterException if the given parameter
* generation values are inappropriate for this parameter generator
*/
+ @Override
protected void engineInit(AlgorithmParameterSpec genParamSpec,
- SecureRandom random)
- throws InvalidAlgorithmParameterException {
+ SecureRandom random) throws InvalidAlgorithmParameterException {
+
if (!(genParamSpec instanceof DSAGenParameterSpec)) {
throw new InvalidAlgorithmParameterException("Invalid parameter");
}
- DSAGenParameterSpec dsaGenParams = (DSAGenParameterSpec) genParamSpec;
- int primePLen = dsaGenParams.getPrimePLength();
- if (primePLen > 2048) {
- throw new InvalidParameterException
- ("No support for prime size " + primePLen);
- }
+ DSAGenParameterSpec dsaGenParams = (DSAGenParameterSpec)genParamSpec;
+
// directly initialize using the already validated values
- this.valueL = primePLen;
+ this.valueL = dsaGenParams.getPrimePLength();
this.valueN = dsaGenParams.getSubprimeQLength();
this.seedLen = dsaGenParams.getSeedLength();
this.random = random;
@@ -133,6 +128,7 @@
*
* @return the new AlgorithmParameters object
*/
+ @Override
protected AlgorithmParameters engineGenerateParameters() {
AlgorithmParameters algParams = null;
try {
@@ -209,12 +205,12 @@
int n = (valueL - 1) / outLen;
int b = (valueL - 1) % outLen;
byte[] seedBytes = new byte[seedLen/8];
- BigInteger twoSl = TWO.pow(seedLen);
+ BigInteger twoSl = BigInteger.TWO.pow(seedLen);
int primeCertainty = 80; // for 1024-bit prime P
if (valueL == 2048) {
primeCertainty = 112;
- //} else if (valueL == 3072) {
- // primeCertainty = 128;
+ } else if (valueL == 3072) {
+ primeCertainty = 128;
}
BigInteger resultP, resultQ, seed = null;
@@ -227,14 +223,17 @@
/* Step 6 */
BigInteger U = new BigInteger(1, hashObj.digest(seedBytes)).
- mod(TWO.pow(valueN - 1));
+ mod(BigInteger.TWO.pow(valueN - 1));
/* Step 7 */
- resultQ = TWO.pow(valueN - 1).add(U).add(ONE). subtract(U.mod(TWO));
+ resultQ = BigInteger.TWO.pow(valueN - 1)
+ .add(U)
+ .add(BigInteger.ONE)
+ .subtract(U.mod(BigInteger.TWO));
} while (!resultQ.isProbablePrime(primeCertainty));
/* Step 10 */
- BigInteger offset = ONE;
+ BigInteger offset = BigInteger.ONE;
/* Step 11 */
for (counter = 0; counter < 4*valueL; counter++) {
BigInteger[] V = new BigInteger[n + 1];
@@ -248,15 +247,16 @@
/* Step 11.2 */
BigInteger W = V[0];
for (int i = 1; i < n; i++) {
- W = W.add(V[i].multiply(TWO.pow(i * outLen)));
+ W = W.add(V[i].multiply(BigInteger.TWO.pow(i * outLen)));
}
- W = W.add((V[n].mod(TWO.pow(b))).multiply(TWO.pow(n * outLen)));
+ W = W.add((V[n].mod(BigInteger.TWO.pow(b)))
+ .multiply(BigInteger.TWO.pow(n * outLen)));
/* Step 11.3 */
- BigInteger twoLm1 = TWO.pow(valueL - 1);
+ BigInteger twoLm1 = BigInteger.TWO.pow(valueL - 1);
BigInteger X = W.add(twoLm1);
/* Step 11.4, 11.5 */
- BigInteger c = X.mod(resultQ.multiply(TWO));
- resultP = X.subtract(c.subtract(ONE));
+ BigInteger c = X.mod(resultQ.multiply(BigInteger.TWO));
+ resultP = X.subtract(c.subtract(BigInteger.ONE));
/* Step 11.6, 11.7 */
if (resultP.compareTo(twoLm1) > -1
&& resultP.isProbablePrime(primeCertainty)) {
@@ -266,7 +266,7 @@
return result;
}
/* Step 11.9 */
- offset = offset.add(BigInteger.valueOf(n)).add(ONE);
+ offset = offset.add(BigInteger.valueOf(n)).add(BigInteger.ONE);
}
}
@@ -281,14 +281,14 @@
* @param the <code>g</code>
*/
private static BigInteger generateG(BigInteger p, BigInteger q) {
- BigInteger h = ONE;
+ BigInteger h = BigInteger.ONE;
/* Step 1 */
- BigInteger pMinusOneOverQ = (p.subtract(ONE)).divide(q);
- BigInteger resultG = ONE;
- while (resultG.compareTo(TWO) < 0) {
+ BigInteger pMinusOneOverQ = (p.subtract(BigInteger.ONE)).divide(q);
+ BigInteger resultG = BigInteger.ONE;
+ while (resultG.compareTo(BigInteger.TWO) < 0) {
/* Step 3 */
resultG = h.modPow(pMinusOneOverQ, p);
- h = h.add(ONE);
+ h = h.add(BigInteger.ONE);
}
return resultG;
}
--- a/jdk/src/java.base/share/classes/sun/security/provider/ParameterCache.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/sun/security/provider/ParameterCache.java Wed Jul 05 21:35:27 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2012, 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
@@ -65,7 +65,7 @@
// case#1: (512 <= p <= 1024) AND q=160
// case#2: p=2048 AND q=224
// case#3: p=2048 AND q=256
- // (NOT-YET-SUPPORTED)case#4: p=3072 AND q=256
+ // case#4: p=3072 AND q=256
return dsaCache.get(Integer.valueOf(primeLen+subprimeLen));
}
@@ -90,6 +90,8 @@
return getDSAParameterSpec(primeLen, 160, random);
} else if (primeLen == 2048) {
return getDSAParameterSpec(primeLen, 224, random);
+ } else if (primeLen == 3072) {
+ return getDSAParameterSpec(primeLen, 256, random);
} else {
return null;
}
@@ -165,8 +167,8 @@
/*
* We support precomputed parameter for legacy 512, 768 bit moduli,
- * and (L, N) combinations of (1024, 160), (2048, 224), (2048, 256).
- * In this file we provide both the seed and counter
+ * and (L, N) combinations of (1024, 160), (2048, 224), (2048, 256),
+ * (3072, 256). In this file we provide both the seed and counter
* value of the generation process for each of these seeds,
* for validation purposes. We also include the test vectors
* from the DSA specification, FIPS 186, and the FIPS 186
@@ -288,12 +290,14 @@
"af02112b0d1f02da30973224fe27aeda8b9d4b2922" +
"d9ba8be39ed9e103a63c52810bc688b7e2ed4316e1" +
"ef17dbde", 16);
+
dsaCache.put(Integer.valueOf(2048+224),
new DSAParameterSpec(p2048_224, q2048_224, g2048_224));
/*
* L = 2048, N = 256
- * SEED = b0b4417601b59cbc9d8ac8f935cadaec4f5fbb2f23785609ae466748d9b5a536
+ * SEED = b0b4417601b59cbc9d8ac8f935cadaec \
+ * 4f5fbb2f23785609ae466748d9b5a536
* counter = 497
*/
BigInteger p2048_256 =
@@ -329,14 +333,245 @@
"8d15bbac65212a55239cfc7e58fae38d7250ab9991" +
"ffbc97134025fe8ce04c4399ad96569be91a546f49" +
"78693c7a", 16);
+
dsaCache.put(Integer.valueOf(2048+256),
- new DSAParameterSpec(p2048_256, q2048_256, g2048_256));
+ new DSAParameterSpec(p2048_256, q2048_256, g2048_256));
+
+
+ /*
+ * L = 3072, N = 256
+ * SEED = 9fe304be4d6b9919559f39d5911d12e9 \
+ * 5158d6946598cd59775b8f3b8fff3a3f
+ * counter = 1186
+ */
+ BigInteger p3072_256 = new BigInteger(
+ "ea9cda9f5fbda66dd830494609405687ab7cf38538e058d1" +
+ "e2f68dea95364866e1c05beacded24227edee28cad80bcec" +
+ "ad39913be3b713267b3b96c8d9f0f6a03b5dfc9222d5cfe4" +
+ "afcc9982f33784f760c3b759aebe3bbe9098a6b84c96f1fd" +
+ "e44ce11c084c2a082c7a76a0ef142928b4f328406ab9beb2" +
+ "4f84577dd0f46ce86fd8f08488269998bf4742d6425f7a0e" +
+ "c75d8660c5dd6f4e3b3d3bee81b2c21afe8c9e8b84b87192" +
+ "e2cc20f961d2bcd8133afcf3675ab80681cb374c78f33e29" +
+ "d1011083d89f9c5728b94676fccb1b57bc60288c15d85ae8" +
+ "38ae1941c5a20ae2b2049b3583fe30da455ddb3e6ad9b995" +
+ "5cd9bb5681431622beb0f92da533fcab496cebc447aa1bb5" +
+ "a8039522f2da98ff416289323a64df626ab6881870927dce" +
+ "e387f13b5c9d24d6cba1d82ed375a082506ee87bc7ae3006" +
+ "7f4a94e2ee363d992c40f2725b5db4b3525ebde22bbbfd0f" +
+ "a124a588b0f5a4acb3a86951aff09f8c8198fb5b53da0c93" +
+ "1cedc598b4f835b779d04d99026c7ba08c4b27f118ac1e3d", 16);
+
+ BigInteger q3072_256 = new BigInteger(
+ "c4eeac2bbab79bd831946d717a56a6e687547aa8e9c5494a" +
+ "5a4b2f4ca13d6c11", 16);
+
+ BigInteger g3072_256 = new BigInteger(
+ "42e5fa7844f8fa9d8998d830d004e7b15b1d276bcbe5f12c" +
+ "35ec90c1a25f5832018a6724bd9cdbe803b675509bed167f" +
+ "3d7cf8599fc865c6d5a0f79158c1bc918f00a944d0ad0f38" +
+ "f520fb91d85d82674d0d5f874faa5fcdfe56cd178c1afdc7" +
+ "ce8795727b7dee966ed0b3c5cedcef8aca628befebf2d105" +
+ "c7aff8eb0da9c9610737dd64dce1237b82c1b2bc8608d55f" +
+ "fda98d7189444e65883315669c05716bde36c78b130aa3df" +
+ "2e4d609914c7c8dc470f4e300187c775f81e7b1a9c0dce40" +
+ "5d6eab2cbb9d9c4ef44412ba573dd403c4ed7bc2364772f5" +
+ "6a30c48de78f5003f9371c55262d2c8ac2246ade3b02fdcf" +
+ "cf5cbfde74fbcbfe6e0e0fdf3160764f84d311c179a40af6" +
+ "79a8f47ab13c8f706893245eb11edcce451fa2ab98001998" +
+ "7f125d8dc96622d419ba0d71f16c6024dce9d364c3b26d8e" +
+ "c1a3c828f6c9d14b1d0333b95db77bfdbe3c6bce5337a1a5" +
+ "a7ace10111219448447197e2a344cc423be768bb89e27be6" +
+ "cbd22085614a5a3360be23b1bfbb6e6e6471363d32c85d31", 16);
+
+ dsaCache.put(Integer.valueOf(3072+256),
+ new DSAParameterSpec(p3072_256, q3072_256, g3072_256));
+
+ //
+ // Diffie-Hellman Groups
+ //
+
+ // the common generator
+ BigInteger dhG = BigInteger.TWO;
+
+ //
+ // From RFC 7296
+
+ // The prime is: 2^768 - 2 ^704 - 1 + 2^64 * { [2^638 pi] + 149686 }
+ BigInteger dhP768 = new BigInteger(
+ "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1" +
+ "29024E088A67CC74020BBEA63B139B22514A08798E3404DD" +
+ "EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245" +
+ "E485B576625E7EC6F44C42E9A63A3620FFFFFFFFFFFFFFFF", 16);
+
+ // The prime is 2^1024 - 2^960 - 1 + 2^64 * { [2^894 pi] + 129093 }
+ BigInteger dhP1024 = new BigInteger(
+ "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1" +
+ "29024E088A67CC74020BBEA63B139B22514A08798E3404DD" +
+ "EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245" +
+ "E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED" +
+ "EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE65381" +
+ "FFFFFFFFFFFFFFFF", 16);
+
+ //
+ // From RFC 3526
+
+ // The prime is: 2^1536 - 2^1472 - 1 + 2^64 * { [2^1406 pi] + 741804 }
+ BigInteger dhP1536 = new BigInteger(
+ "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1" +
+ "29024E088A67CC74020BBEA63B139B22514A08798E3404DD" +
+ "EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245" +
+ "E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED" +
+ "EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3D" +
+ "C2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F" +
+ "83655D23DCA3AD961C62F356208552BB9ED529077096966D" +
+ "670C354E4ABC9804F1746C08CA237327FFFFFFFFFFFFFFFF", 16);
+
+ // This prime is: 2^2048 - 2^1984 - 1 + 2^64 * { [2^1918 pi] + 124476 }
+ BigInteger dhP2048 = new BigInteger(
+ "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1" +
+ "29024E088A67CC74020BBEA63B139B22514A08798E3404DD" +
+ "EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245" +
+ "E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED" +
+ "EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3D" +
+ "C2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F" +
+ "83655D23DCA3AD961C62F356208552BB9ED529077096966D" +
+ "670C354E4ABC9804F1746C08CA18217C32905E462E36CE3B" +
+ "E39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9" +
+ "DE2BCBF6955817183995497CEA956AE515D2261898FA0510" +
+ "15728E5A8AACAA68FFFFFFFFFFFFFFFF", 16);
- // use DSA parameters for DH as well
+ // This prime is: 2^3072 - 2^3008 - 1 + 2^64 * { [2^2942 pi] + 1690314 }
+ BigInteger dhP3072 = new BigInteger(
+ "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1" +
+ "29024E088A67CC74020BBEA63B139B22514A08798E3404DD" +
+ "EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245" +
+ "E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED" +
+ "EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3D" +
+ "C2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F" +
+ "83655D23DCA3AD961C62F356208552BB9ED529077096966D" +
+ "670C354E4ABC9804F1746C08CA18217C32905E462E36CE3B" +
+ "E39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9" +
+ "DE2BCBF6955817183995497CEA956AE515D2261898FA0510" +
+ "15728E5A8AAAC42DAD33170D04507A33A85521ABDF1CBA64" +
+ "ECFB850458DBEF0A8AEA71575D060C7DB3970F85A6E1E4C7" +
+ "ABF5AE8CDB0933D71E8C94E04A25619DCEE3D2261AD2EE6B" +
+ "F12FFA06D98A0864D87602733EC86A64521F2B18177B200C" +
+ "BBE117577A615D6C770988C0BAD946E208E24FA074E5AB31" +
+ "43DB5BFCE0FD108E4B82D120A93AD2CAFFFFFFFFFFFFFFFF", 16);
+
+ // This prime is: 2^4096 - 2^4032 - 1 + 2^64 * { [2^3966 pi] + 240904 }
+ BigInteger dhP4096 = new BigInteger(
+ "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1" +
+ "29024E088A67CC74020BBEA63B139B22514A08798E3404DD" +
+ "EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245" +
+ "E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED" +
+ "EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3D" +
+ "C2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F" +
+ "83655D23DCA3AD961C62F356208552BB9ED529077096966D" +
+ "670C354E4ABC9804F1746C08CA18217C32905E462E36CE3B" +
+ "E39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9" +
+ "DE2BCBF6955817183995497CEA956AE515D2261898FA0510" +
+ "15728E5A8AAAC42DAD33170D04507A33A85521ABDF1CBA64" +
+ "ECFB850458DBEF0A8AEA71575D060C7DB3970F85A6E1E4C7" +
+ "ABF5AE8CDB0933D71E8C94E04A25619DCEE3D2261AD2EE6B" +
+ "F12FFA06D98A0864D87602733EC86A64521F2B18177B200C" +
+ "BBE117577A615D6C770988C0BAD946E208E24FA074E5AB31" +
+ "43DB5BFCE0FD108E4B82D120A92108011A723C12A787E6D7" +
+ "88719A10BDBA5B2699C327186AF4E23C1A946834B6150BDA" +
+ "2583E9CA2AD44CE8DBBBC2DB04DE8EF92E8EFC141FBECAA6" +
+ "287C59474E6BC05D99B2964FA090C3A2233BA186515BE7ED" +
+ "1F612970CEE2D7AFB81BDD762170481CD0069127D5B05AA9" +
+ "93B4EA988D8FDDC186FFB7DC90A6C08F4DF435C934063199" +
+ "FFFFFFFFFFFFFFFF", 16);
+
+ // This prime is: 2^6144 - 2^6080 - 1 + 2^64 * { [2^6014 pi] + 929484 }
+ BigInteger dhP6144 = new BigInteger(
+ "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E08" +
+ "8A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B" +
+ "302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9" +
+ "A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE6" +
+ "49286651ECE45B3DC2007CB8A163BF0598DA48361C55D39A69163FA8" +
+ "FD24CF5F83655D23DCA3AD961C62F356208552BB9ED529077096966D" +
+ "670C354E4ABC9804F1746C08CA18217C32905E462E36CE3BE39E772C" +
+ "180E86039B2783A2EC07A28FB5C55DF06F4C52C9DE2BCBF695581718" +
+ "3995497CEA956AE515D2261898FA051015728E5A8AAAC42DAD33170D" +
+ "04507A33A85521ABDF1CBA64ECFB850458DBEF0A8AEA71575D060C7D" +
+ "B3970F85A6E1E4C7ABF5AE8CDB0933D71E8C94E04A25619DCEE3D226" +
+ "1AD2EE6BF12FFA06D98A0864D87602733EC86A64521F2B18177B200C" +
+ "BBE117577A615D6C770988C0BAD946E208E24FA074E5AB3143DB5BFC" +
+ "E0FD108E4B82D120A92108011A723C12A787E6D788719A10BDBA5B26" +
+ "99C327186AF4E23C1A946834B6150BDA2583E9CA2AD44CE8DBBBC2DB" +
+ "04DE8EF92E8EFC141FBECAA6287C59474E6BC05D99B2964FA090C3A2" +
+ "233BA186515BE7ED1F612970CEE2D7AFB81BDD762170481CD0069127" +
+ "D5B05AA993B4EA988D8FDDC186FFB7DC90A6C08F4DF435C934028492" +
+ "36C3FAB4D27C7026C1D4DCB2602646DEC9751E763DBA37BDF8FF9406" +
+ "AD9E530EE5DB382F413001AEB06A53ED9027D831179727B0865A8918" +
+ "DA3EDBEBCF9B14ED44CE6CBACED4BB1BDB7F1447E6CC254B33205151" +
+ "2BD7AF426FB8F401378CD2BF5983CA01C64B92ECF032EA15D1721D03" +
+ "F482D7CE6E74FEF6D55E702F46980C82B5A84031900B1C9E59E7C97F" +
+ "BEC7E8F323A97A7E36CC88BE0F1D45B7FF585AC54BD407B22B4154AA" +
+ "CC8F6D7EBF48E1D814CC5ED20F8037E0A79715EEF29BE32806A1D58B" +
+ "B7C5DA76F550AA3D8A1FBFF0EB19CCB1A313D55CDA56C9EC2EF29632" +
+ "387FE8D76E3C0468043E8F663F4860EE12BF2D5B0B7474D6E694F91E" +
+ "6DCC4024FFFFFFFFFFFFFFFF", 16);
+
+ // This prime is: 2^8192 - 2^8128 - 1 + 2^64 * { [2^8062 pi] + 4743158 }
+ BigInteger dhP8192 = new BigInteger(
+ "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1" +
+ "29024E088A67CC74020BBEA63B139B22514A08798E3404DD" +
+ "EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245" +
+ "E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED" +
+ "EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3D" +
+ "C2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F" +
+ "83655D23DCA3AD961C62F356208552BB9ED529077096966D" +
+ "670C354E4ABC9804F1746C08CA18217C32905E462E36CE3B" +
+ "E39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9" +
+ "DE2BCBF6955817183995497CEA956AE515D2261898FA0510" +
+ "15728E5A8AAAC42DAD33170D04507A33A85521ABDF1CBA64" +
+ "ECFB850458DBEF0A8AEA71575D060C7DB3970F85A6E1E4C7" +
+ "ABF5AE8CDB0933D71E8C94E04A25619DCEE3D2261AD2EE6B" +
+ "F12FFA06D98A0864D87602733EC86A64521F2B18177B200C" +
+ "BBE117577A615D6C770988C0BAD946E208E24FA074E5AB31" +
+ "43DB5BFCE0FD108E4B82D120A92108011A723C12A787E6D7" +
+ "88719A10BDBA5B2699C327186AF4E23C1A946834B6150BDA" +
+ "2583E9CA2AD44CE8DBBBC2DB04DE8EF92E8EFC141FBECAA6" +
+ "287C59474E6BC05D99B2964FA090C3A2233BA186515BE7ED" +
+ "1F612970CEE2D7AFB81BDD762170481CD0069127D5B05AA9" +
+ "93B4EA988D8FDDC186FFB7DC90A6C08F4DF435C934028492" +
+ "36C3FAB4D27C7026C1D4DCB2602646DEC9751E763DBA37BD" +
+ "F8FF9406AD9E530EE5DB382F413001AEB06A53ED9027D831" +
+ "179727B0865A8918DA3EDBEBCF9B14ED44CE6CBACED4BB1B" +
+ "DB7F1447E6CC254B332051512BD7AF426FB8F401378CD2BF" +
+ "5983CA01C64B92ECF032EA15D1721D03F482D7CE6E74FEF6" +
+ "D55E702F46980C82B5A84031900B1C9E59E7C97FBEC7E8F3" +
+ "23A97A7E36CC88BE0F1D45B7FF585AC54BD407B22B4154AA" +
+ "CC8F6D7EBF48E1D814CC5ED20F8037E0A79715EEF29BE328" +
+ "06A1D58BB7C5DA76F550AA3D8A1FBFF0EB19CCB1A313D55C" +
+ "DA56C9EC2EF29632387FE8D76E3C0468043E8F663F4860EE" +
+ "12BF2D5B0B7474D6E694F91E6DBE115974A3926F12FEE5E4" +
+ "38777CB6A932DF8CD8BEC4D073B931BA3BC832B68D9DD300" +
+ "741FA7BF8AFC47ED2576F6936BA424663AAB639C5AE4F568" +
+ "3423B4742BF1C978238F16CBE39D652DE3FDB8BEFC848AD9" +
+ "22222E04A4037C0713EB57A81A23F0C73473FC646CEA306B" +
+ "4BCBC8862F8385DDFA9D4B7FA2C087E879683303ED5BDD3A" +
+ "062B3CF5B3A278A66D2A13F83F44F82DDF310EE074AB6A36" +
+ "4597E899A0255DC164F31CC50846851DF9AB48195DED7EA1" +
+ "B1D510BD7EE74D73FAF36BC31ECFA268359046F4EB879F92" +
+ "4009438B481C6CD7889A002ED5EE382BC9190DA6FC026E47" +
+ "9558E4475677E9AA9E3050E2765694DFC81F56E880B96E71" +
+ "60C980DD98EDD3DFFFFFFFFFFFFFFFFF", 16);
+
+ // use DSA parameters for DH for sizes not defined in RFC 7296, 3526
dhCache.put(Integer.valueOf(512), new DHParameterSpec(p512, g512));
- dhCache.put(Integer.valueOf(768), new DHParameterSpec(p768, g768));
- dhCache.put(Integer.valueOf(1024), new DHParameterSpec(p1024, g1024));
- dhCache.put(Integer.valueOf(2048), new DHParameterSpec(p2048_224, g2048_224));
+
+ dhCache.put(Integer.valueOf(768), new DHParameterSpec(dhP768, dhG));
+ dhCache.put(Integer.valueOf(1024), new DHParameterSpec(dhP1024, dhG));
+ dhCache.put(Integer.valueOf(1536), new DHParameterSpec(dhP1536, dhG));
+ dhCache.put(Integer.valueOf(2048), new DHParameterSpec(dhP2048, dhG));
+ dhCache.put(Integer.valueOf(3072), new DHParameterSpec(dhP3072, dhG));
+ dhCache.put(Integer.valueOf(4096), new DHParameterSpec(dhP4096, dhG));
+ dhCache.put(Integer.valueOf(6144), new DHParameterSpec(dhP6144, dhG));
+ dhCache.put(Integer.valueOf(8192), new DHParameterSpec(dhP8192, dhG));
}
-
}
--- a/jdk/src/java.base/share/classes/sun/security/ssl/DHCrypt.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/DHCrypt.java Wed Jul 05 21:35:27 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 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
@@ -151,7 +151,7 @@
params.getP(), params.getG());
}
try {
- KeyFactory factory = JsseJce.getKeyFactory("DH");
+ KeyFactory factory = JsseJce.getKeyFactory("DiffieHellman");
return factory.getKeySpec(key, DHPublicKeySpec.class);
} catch (Exception e) {
throw new RuntimeException(e);
@@ -283,8 +283,6 @@
//
// Default DH ephemeral parameters
//
- private static final BigInteger g2 = BigInteger.valueOf(2);
-
private static final BigInteger p512 = new BigInteger( // generated
"D87780E15FF50B4ABBE89870188B049406B5BEA98AB23A02" +
"41D88EA75B7755E669C08093D3F0CA7FC3A5A25CF067DCB9" +
@@ -302,7 +300,16 @@
"E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED" +
"EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE65381" +
"FFFFFFFFFFFFFFFF", 16);
- private static final BigInteger p2048 = new BigInteger( // TLS FEDHE
+ private static final BigInteger p1536 = new BigInteger( // RFC 3526
+ "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1" +
+ "29024E088A67CC74020BBEA63B139B22514A08798E3404DD" +
+ "EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245" +
+ "E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED" +
+ "EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3D" +
+ "C2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F" +
+ "83655D23DCA3AD961C62F356208552BB9ED529077096966D" +
+ "670C354E4ABC9804F1746C08CA237327FFFFFFFFFFFFFFFF", 16);
+ private static final BigInteger p2048 = new BigInteger( // TLS FFDHE
"FFFFFFFFFFFFFFFFADF85458A2BB4A9AAFDC5620273D3CF1" +
"D8B9C583CE2D3695A9E13641146433FBCC939DCE249B3EF9" +
"7D2FE363630C75D8F681B202AEC4617AD3DF1ED5D5FD6561" +
@@ -314,9 +321,126 @@
"9172FE9CE98583FF8E4F1232EEF28183C3FE3B1B4C6FAD73" +
"3BB5FCBC2EC22005C58EF1837D1683B2C6F34A26C1B2EFFA" +
"886B423861285C97FFFFFFFFFFFFFFFF", 16);
+ private static final BigInteger p3072 = new BigInteger( // TLS FFDHE
+ "FFFFFFFFFFFFFFFFADF85458A2BB4A9AAFDC5620273D3CF1" +
+ "D8B9C583CE2D3695A9E13641146433FBCC939DCE249B3EF9" +
+ "7D2FE363630C75D8F681B202AEC4617AD3DF1ED5D5FD6561" +
+ "2433F51F5F066ED0856365553DED1AF3B557135E7F57C935" +
+ "984F0C70E0E68B77E2A689DAF3EFE8721DF158A136ADE735" +
+ "30ACCA4F483A797ABC0AB182B324FB61D108A94BB2C8E3FB" +
+ "B96ADAB760D7F4681D4F42A3DE394DF4AE56EDE76372BB19" +
+ "0B07A7C8EE0A6D709E02FCE1CDF7E2ECC03404CD28342F61" +
+ "9172FE9CE98583FF8E4F1232EEF28183C3FE3B1B4C6FAD73" +
+ "3BB5FCBC2EC22005C58EF1837D1683B2C6F34A26C1B2EFFA" +
+ "886B4238611FCFDCDE355B3B6519035BBC34F4DEF99C0238" +
+ "61B46FC9D6E6C9077AD91D2691F7F7EE598CB0FAC186D91C" +
+ "AEFE130985139270B4130C93BC437944F4FD4452E2D74DD3" +
+ "64F2E21E71F54BFF5CAE82AB9C9DF69EE86D2BC522363A0D" +
+ "ABC521979B0DEADA1DBF9A42D5C4484E0ABCD06BFA53DDEF" +
+ "3C1B20EE3FD59D7C25E41D2B66C62E37FFFFFFFFFFFFFFFF", 16);
+ private static final BigInteger p4096 = new BigInteger( // TLS FFDHE
+ "FFFFFFFFFFFFFFFFADF85458A2BB4A9AAFDC5620273D3CF1" +
+ "D8B9C583CE2D3695A9E13641146433FBCC939DCE249B3EF9" +
+ "7D2FE363630C75D8F681B202AEC4617AD3DF1ED5D5FD6561" +
+ "2433F51F5F066ED0856365553DED1AF3B557135E7F57C935" +
+ "984F0C70E0E68B77E2A689DAF3EFE8721DF158A136ADE735" +
+ "30ACCA4F483A797ABC0AB182B324FB61D108A94BB2C8E3FB" +
+ "B96ADAB760D7F4681D4F42A3DE394DF4AE56EDE76372BB19" +
+ "0B07A7C8EE0A6D709E02FCE1CDF7E2ECC03404CD28342F61" +
+ "9172FE9CE98583FF8E4F1232EEF28183C3FE3B1B4C6FAD73" +
+ "3BB5FCBC2EC22005C58EF1837D1683B2C6F34A26C1B2EFFA" +
+ "886B4238611FCFDCDE355B3B6519035BBC34F4DEF99C0238" +
+ "61B46FC9D6E6C9077AD91D2691F7F7EE598CB0FAC186D91C" +
+ "AEFE130985139270B4130C93BC437944F4FD4452E2D74DD3" +
+ "64F2E21E71F54BFF5CAE82AB9C9DF69EE86D2BC522363A0D" +
+ "ABC521979B0DEADA1DBF9A42D5C4484E0ABCD06BFA53DDEF" +
+ "3C1B20EE3FD59D7C25E41D2B669E1EF16E6F52C3164DF4FB" +
+ "7930E9E4E58857B6AC7D5F42D69F6D187763CF1D55034004" +
+ "87F55BA57E31CC7A7135C886EFB4318AED6A1E012D9E6832" +
+ "A907600A918130C46DC778F971AD0038092999A333CB8B7A" +
+ "1A1DB93D7140003C2A4ECEA9F98D0ACC0A8291CDCEC97DCF" +
+ "8EC9B55A7F88A46B4DB5A851F44182E1C68A007E5E655F6A" +
+ "FFFFFFFFFFFFFFFF", 16);
+ private static final BigInteger p6144 = new BigInteger( // TLS FFDHE
+ "FFFFFFFFFFFFFFFFADF85458A2BB4A9AAFDC5620273D3CF1" +
+ "D8B9C583CE2D3695A9E13641146433FBCC939DCE249B3EF9" +
+ "7D2FE363630C75D8F681B202AEC4617AD3DF1ED5D5FD6561" +
+ "2433F51F5F066ED0856365553DED1AF3B557135E7F57C935" +
+ "984F0C70E0E68B77E2A689DAF3EFE8721DF158A136ADE735" +
+ "30ACCA4F483A797ABC0AB182B324FB61D108A94BB2C8E3FB" +
+ "B96ADAB760D7F4681D4F42A3DE394DF4AE56EDE76372BB19" +
+ "0B07A7C8EE0A6D709E02FCE1CDF7E2ECC03404CD28342F61" +
+ "9172FE9CE98583FF8E4F1232EEF28183C3FE3B1B4C6FAD73" +
+ "3BB5FCBC2EC22005C58EF1837D1683B2C6F34A26C1B2EFFA" +
+ "886B4238611FCFDCDE355B3B6519035BBC34F4DEF99C0238" +
+ "61B46FC9D6E6C9077AD91D2691F7F7EE598CB0FAC186D91C" +
+ "AEFE130985139270B4130C93BC437944F4FD4452E2D74DD3" +
+ "64F2E21E71F54BFF5CAE82AB9C9DF69EE86D2BC522363A0D" +
+ "ABC521979B0DEADA1DBF9A42D5C4484E0ABCD06BFA53DDEF" +
+ "3C1B20EE3FD59D7C25E41D2B669E1EF16E6F52C3164DF4FB" +
+ "7930E9E4E58857B6AC7D5F42D69F6D187763CF1D55034004" +
+ "87F55BA57E31CC7A7135C886EFB4318AED6A1E012D9E6832" +
+ "A907600A918130C46DC778F971AD0038092999A333CB8B7A" +
+ "1A1DB93D7140003C2A4ECEA9F98D0ACC0A8291CDCEC97DCF" +
+ "8EC9B55A7F88A46B4DB5A851F44182E1C68A007E5E0DD902" +
+ "0BFD64B645036C7A4E677D2C38532A3A23BA4442CAF53EA6" +
+ "3BB454329B7624C8917BDD64B1C0FD4CB38E8C334C701C3A" +
+ "CDAD0657FCCFEC719B1F5C3E4E46041F388147FB4CFDB477" +
+ "A52471F7A9A96910B855322EDB6340D8A00EF092350511E3" +
+ "0ABEC1FFF9E3A26E7FB29F8C183023C3587E38DA0077D9B4" +
+ "763E4E4B94B2BBC194C6651E77CAF992EEAAC0232A281BF6" +
+ "B3A739C1226116820AE8DB5847A67CBEF9C9091B462D538C" +
+ "D72B03746AE77F5E62292C311562A846505DC82DB854338A" +
+ "E49F5235C95B91178CCF2DD5CACEF403EC9D1810C6272B04" +
+ "5B3B71F9DC6B80D63FDD4A8E9ADB1E6962A69526D43161C1" +
+ "A41D570D7938DAD4A40E329CD0E40E65FFFFFFFFFFFFFFFF", 16);
+ private static final BigInteger p8192 = new BigInteger( // TLS FFDHE
+ "FFFFFFFFFFFFFFFFADF85458A2BB4A9AAFDC5620273D3CF1" +
+ "D8B9C583CE2D3695A9E13641146433FBCC939DCE249B3EF9" +
+ "7D2FE363630C75D8F681B202AEC4617AD3DF1ED5D5FD6561" +
+ "2433F51F5F066ED0856365553DED1AF3B557135E7F57C935" +
+ "984F0C70E0E68B77E2A689DAF3EFE8721DF158A136ADE735" +
+ "30ACCA4F483A797ABC0AB182B324FB61D108A94BB2C8E3FB" +
+ "B96ADAB760D7F4681D4F42A3DE394DF4AE56EDE76372BB19" +
+ "0B07A7C8EE0A6D709E02FCE1CDF7E2ECC03404CD28342F61" +
+ "9172FE9CE98583FF8E4F1232EEF28183C3FE3B1B4C6FAD73" +
+ "3BB5FCBC2EC22005C58EF1837D1683B2C6F34A26C1B2EFFA" +
+ "886B4238611FCFDCDE355B3B6519035BBC34F4DEF99C0238" +
+ "61B46FC9D6E6C9077AD91D2691F7F7EE598CB0FAC186D91C" +
+ "AEFE130985139270B4130C93BC437944F4FD4452E2D74DD3" +
+ "64F2E21E71F54BFF5CAE82AB9C9DF69EE86D2BC522363A0D" +
+ "ABC521979B0DEADA1DBF9A42D5C4484E0ABCD06BFA53DDEF" +
+ "3C1B20EE3FD59D7C25E41D2B669E1EF16E6F52C3164DF4FB" +
+ "7930E9E4E58857B6AC7D5F42D69F6D187763CF1D55034004" +
+ "87F55BA57E31CC7A7135C886EFB4318AED6A1E012D9E6832" +
+ "A907600A918130C46DC778F971AD0038092999A333CB8B7A" +
+ "1A1DB93D7140003C2A4ECEA9F98D0ACC0A8291CDCEC97DCF" +
+ "8EC9B55A7F88A46B4DB5A851F44182E1C68A007E5E0DD902" +
+ "0BFD64B645036C7A4E677D2C38532A3A23BA4442CAF53EA6" +
+ "3BB454329B7624C8917BDD64B1C0FD4CB38E8C334C701C3A" +
+ "CDAD0657FCCFEC719B1F5C3E4E46041F388147FB4CFDB477" +
+ "A52471F7A9A96910B855322EDB6340D8A00EF092350511E3" +
+ "0ABEC1FFF9E3A26E7FB29F8C183023C3587E38DA0077D9B4" +
+ "763E4E4B94B2BBC194C6651E77CAF992EEAAC0232A281BF6" +
+ "B3A739C1226116820AE8DB5847A67CBEF9C9091B462D538C" +
+ "D72B03746AE77F5E62292C311562A846505DC82DB854338A" +
+ "E49F5235C95B91178CCF2DD5CACEF403EC9D1810C6272B04" +
+ "5B3B71F9DC6B80D63FDD4A8E9ADB1E6962A69526D43161C1" +
+ "A41D570D7938DAD4A40E329CCFF46AAA36AD004CF600C838" +
+ "1E425A31D951AE64FDB23FCEC9509D43687FEB69EDD1CC5E" +
+ "0B8CC3BDF64B10EF86B63142A3AB8829555B2F747C932665" +
+ "CB2C0F1CC01BD70229388839D2AF05E454504AC78B758282" +
+ "2846C0BA35C35F5C59160CC046FD8251541FC68C9C86B022" +
+ "BB7099876A460E7451A8A93109703FEE1C217E6C3826E52C" +
+ "51AA691E0E423CFC99E9E31650C1217B624816CDAD9A95F9" +
+ "D5B8019488D9C0A0A1FE3075A577E23183F81D4A3F2FA457" +
+ "1EFC8CE0BA8A4FE8B6855DFE72B0A66EDED2FBABFBE58A30" +
+ "FAFABE1C5D71A87E2F741EF8C1FE86FEA6BBFDE530677F0D" +
+ "97D11D49F7A8443D0822E506A9F4614E011E2A94838FF88C" +
+ "D68C8BB7C5C6424CFFFFFFFFFFFFFFFF", 16);
private static final BigInteger[] supportedPrimes = {
- p512, p768, p1024, p2048};
+ p512, p768, p1024, p1536, p2048, p3072, p4096, p6144, p8192};
// a measure of the uncertainty that prime modulus p is not a prime
//
@@ -401,7 +525,8 @@
for (BigInteger p : supportedPrimes) {
int primeLen = p.bitLength();
- defaultParams.putIfAbsent(primeLen, new DHParameterSpec(p, g2));
+ defaultParams.putIfAbsent(primeLen,
+ new DHParameterSpec(p, BigInteger.TWO));
}
definedParams =
--- a/jdk/src/java.base/share/classes/sun/security/ssl/ServerHandshaker.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/ServerHandshaker.java Wed Jul 05 21:35:27 2017 +0200
@@ -138,11 +138,17 @@
useSmartEphemeralDHKeys = false;
try {
+ // DH parameter generation can be extremely slow, best to
+ // use one of the supported pre-computed DH parameters
+ // (see DHCrypt class).
customizedDHKeySize = Integer.parseUnsignedInt(property);
- if (customizedDHKeySize < 1024 || customizedDHKeySize > 2048) {
+ if (customizedDHKeySize < 1024 || customizedDHKeySize > 8192 ||
+ (customizedDHKeySize & 0x3f) != 0) {
throw new IllegalArgumentException(
- "Customized DH key size should be positive integer " +
- "between 1024 and 2048 bits, inclusive");
+ "Unsupported customized DH key size: " +
+ customizedDHKeySize + ". " +
+ "The key size must be multiple of 64, " +
+ "and can only range from 1024 to 8192 (inclusive)");
}
} catch (NumberFormatException nfe) {
throw new IllegalArgumentException(
@@ -1520,15 +1526,11 @@
* Applications may also want to customize the ephemeral DH key size
* to a fixed length for non-exportable cipher suites. This can be
* approached by setting system property "jdk.tls.ephemeralDHKeySize"
- * to a valid positive integer between 1024 and 2048 bits, inclusive.
+ * to a valid positive integer between 1024 and 8192 bits, inclusive.
*
* Note that the minimum acceptable key size is 1024 bits except
* exportable cipher suites or legacy mode.
*
- * Note that the maximum acceptable key size is 2048 bits because
- * DH keys bigger than 2048 are not always supported by underlying
- * JCE providers.
- *
* Note that per RFC 2246, the key size limit of DH is 512 bits for
* exportable cipher suites. Because of the weakness, exportable
* cipher suites are deprecated since TLS v1.1 and they are not
@@ -1543,10 +1545,17 @@
} else if (useSmartEphemeralDHKeys) { // matched mode
if (key != null) {
int ks = KeyUtil.getKeySize(key);
- // Note that SunJCE provider only supports 2048 bits DH
- // keys bigger than 1024. Please DON'T use value other
- // than 1024 and 2048 at present. We may improve the
- // underlying providers and key size here in the future.
+
+ // DH parameter generation can be extremely slow, make
+ // sure to use one of the supported pre-computed DH
+ // parameters (see DHCrypt class).
+ //
+ // Old deployed applications may not be ready to support
+ // DH key sizes bigger than 2048 bits. Please DON'T use
+ // value other than 1024 and 2048 at present. May improve
+ // the underlying providers and key size limit in the
+ // future when the compatibility and interoperability
+ // impact is limited.
//
// keySize = ks <= 1024 ? 1024 : (ks >= 2048 ? 2048 : ks);
keySize = ks <= 1024 ? 1024 : 2048;
--- a/jdk/src/java.base/share/classes/sun/security/util/ObjectIdentifier.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/classes/sun/security/util/ObjectIdentifier.java Wed Jul 05 21:35:27 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 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
@@ -619,8 +619,7 @@
}
}
private static void checkFirstComponent(BigInteger first) throws IOException {
- if (first.signum() == -1 ||
- first.compareTo(BigInteger.valueOf(2)) == 1) {
+ if (first.signum() == -1 || first.compareTo(BigInteger.TWO) > 0) {
throw new IOException("ObjectIdentifier() -- " +
"First oid component is invalid ");
}
--- a/jdk/src/java.base/share/conf/security/java.security Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/conf/security/java.security Wed Jul 05 21:35:27 2017 +0200
@@ -271,7 +271,6 @@
jdk.internal.,\
jdk.nashorn.internal.,\
jdk.nashorn.tools.,\
- jdk.rmi.rmic.,\
jdk.tools.jimage.,\
com.sun.activation.registries.,\
com.sun.java.accessibility.util.internal.,\
@@ -328,7 +327,6 @@
jdk.internal.,\
jdk.nashorn.internal.,\
jdk.nashorn.tools.,\
- jdk.rmi.rmic.,\
jdk.tools.jimage.,\
com.sun.activation.registries.,\
com.sun.java.accessibility.util.internal.,\
--- a/jdk/src/java.base/share/native/include/jvm.h Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/native/include/jvm.h Wed Jul 05 21:35:27 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2015, 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
@@ -171,11 +171,8 @@
JNIEXPORT void JNICALL
JVM_FillInStackTrace(JNIEnv *env, jobject throwable);
-JNIEXPORT jint JNICALL
-JVM_GetStackTraceDepth(JNIEnv *env, jobject throwable);
-
-JNIEXPORT jobject JNICALL
-JVM_GetStackTraceElement(JNIEnv *env, jobject throwable, jint index);
+JNIEXPORT void JNICALL
+JVM_GetStackTraceElements(JNIEnv *env, jobject throwable, jobjectArray elements);
/*
* java.lang.StackWalker
--- a/jdk/src/java.base/share/native/libjava/Class.c Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/native/libjava/Class.c Wed Jul 05 21:35:27 2017 +0200
@@ -43,7 +43,7 @@
#define OBJ "Ljava/lang/Object;"
#define CLS "Ljava/lang/Class;"
-#define CPL "Lsun/reflect/ConstantPool;"
+#define CPL "Ljdk/internal/reflect/ConstantPool;"
#define STR "Ljava/lang/String;"
#define FLD "Ljava/lang/reflect/Field;"
#define MHD "Ljava/lang/reflect/Method;"
--- a/jdk/src/java.base/share/native/libjava/ConstantPool.c Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/native/libjava/ConstantPool.c Wed Jul 05 21:35:27 2017 +0200
@@ -24,111 +24,111 @@
*/
#include "jvm.h"
-#include "sun_reflect_ConstantPool.h"
+#include "jdk_internal_reflect_ConstantPool.h"
-JNIEXPORT jint JNICALL Java_sun_reflect_ConstantPool_getSize0
+JNIEXPORT jint JNICALL Java_jdk_internal_reflect_ConstantPool_getSize0
(JNIEnv *env, jobject unused, jobject jcpool)
{
return JVM_ConstantPoolGetSize(env, unused, jcpool);
}
-JNIEXPORT jclass JNICALL Java_sun_reflect_ConstantPool_getClassAt0
+JNIEXPORT jclass JNICALL Java_jdk_internal_reflect_ConstantPool_getClassAt0
(JNIEnv *env, jobject unused, jobject jcpool, jint index)
{
return JVM_ConstantPoolGetClassAt(env, unused, jcpool, index);
}
-JNIEXPORT jclass JNICALL Java_sun_reflect_ConstantPool_getClassAtIfLoaded0
+JNIEXPORT jclass JNICALL Java_jdk_internal_reflect_ConstantPool_getClassAtIfLoaded0
(JNIEnv *env, jobject unused, jobject jcpool, jint index)
{
return JVM_ConstantPoolGetClassAtIfLoaded(env, unused, jcpool, index);
}
-JNIEXPORT jint JNICALL Java_sun_reflect_ConstantPool_getClassRefIndexAt0
+JNIEXPORT jint JNICALL Java_jdk_internal_reflect_ConstantPool_getClassRefIndexAt0
(JNIEnv *env, jobject unused, jobject jcpool, jint index)
{
return JVM_ConstantPoolGetClassRefIndexAt(env, unused, jcpool, index);
}
-JNIEXPORT jobject JNICALL Java_sun_reflect_ConstantPool_getMethodAt0
+JNIEXPORT jobject JNICALL Java_jdk_internal_reflect_ConstantPool_getMethodAt0
(JNIEnv *env, jobject unused, jobject jcpool, jint index)
{
return JVM_ConstantPoolGetMethodAt(env, unused, jcpool, index);
}
-JNIEXPORT jobject JNICALL Java_sun_reflect_ConstantPool_getMethodAtIfLoaded0
+JNIEXPORT jobject JNICALL Java_jdk_internal_reflect_ConstantPool_getMethodAtIfLoaded0
(JNIEnv *env, jobject unused, jobject jcpool, jint index)
{
return JVM_ConstantPoolGetMethodAtIfLoaded(env, unused, jcpool, index);
}
-JNIEXPORT jobject JNICALL Java_sun_reflect_ConstantPool_getFieldAt0
+JNIEXPORT jobject JNICALL Java_jdk_internal_reflect_ConstantPool_getFieldAt0
(JNIEnv *env, jobject unused, jobject jcpool, jint index)
{
return JVM_ConstantPoolGetFieldAt(env, unused, jcpool, index);
}
-JNIEXPORT jobject JNICALL Java_sun_reflect_ConstantPool_getFieldAtIfLoaded0
+JNIEXPORT jobject JNICALL Java_jdk_internal_reflect_ConstantPool_getFieldAtIfLoaded0
(JNIEnv *env, jobject unused, jobject jcpool, jint index)
{
return JVM_ConstantPoolGetFieldAtIfLoaded(env, unused, jcpool, index);
}
-JNIEXPORT jobjectArray JNICALL Java_sun_reflect_ConstantPool_getMemberRefInfoAt0
+JNIEXPORT jobjectArray JNICALL Java_jdk_internal_reflect_ConstantPool_getMemberRefInfoAt0
(JNIEnv *env, jobject unused, jobject jcpool, jint index)
{
return JVM_ConstantPoolGetMemberRefInfoAt(env, unused, jcpool, index);
}
-JNIEXPORT jint JNICALL Java_sun_reflect_ConstantPool_getNameAndTypeRefIndexAt0
+JNIEXPORT jint JNICALL Java_jdk_internal_reflect_ConstantPool_getNameAndTypeRefIndexAt0
(JNIEnv *env, jobject unused, jobject jcpool, jint index)
{
return JVM_ConstantPoolGetNameAndTypeRefIndexAt(env, unused, jcpool, index);
}
-JNIEXPORT jobjectArray JNICALL Java_sun_reflect_ConstantPool_getNameAndTypeRefInfoAt0
+JNIEXPORT jobjectArray JNICALL Java_jdk_internal_reflect_ConstantPool_getNameAndTypeRefInfoAt0
(JNIEnv *env, jobject unused, jobject jcpool, jint index)
{
return JVM_ConstantPoolGetNameAndTypeRefInfoAt(env, unused, jcpool, index);
}
-JNIEXPORT jint JNICALL Java_sun_reflect_ConstantPool_getIntAt0
+JNIEXPORT jint JNICALL Java_jdk_internal_reflect_ConstantPool_getIntAt0
(JNIEnv *env, jobject unused, jobject jcpool, jint index)
{
return JVM_ConstantPoolGetIntAt(env, unused, jcpool, index);
}
-JNIEXPORT jlong JNICALL Java_sun_reflect_ConstantPool_getLongAt0
+JNIEXPORT jlong JNICALL Java_jdk_internal_reflect_ConstantPool_getLongAt0
(JNIEnv *env, jobject unused, jobject jcpool, jint index)
{
return JVM_ConstantPoolGetLongAt(env, unused, jcpool, index);
}
-JNIEXPORT jfloat JNICALL Java_sun_reflect_ConstantPool_getFloatAt0
+JNIEXPORT jfloat JNICALL Java_jdk_internal_reflect_ConstantPool_getFloatAt0
(JNIEnv *env, jobject unused, jobject jcpool, jint index)
{
return JVM_ConstantPoolGetFloatAt(env, unused, jcpool, index);
}
-JNIEXPORT jdouble JNICALL Java_sun_reflect_ConstantPool_getDoubleAt0
+JNIEXPORT jdouble JNICALL Java_jdk_internal_reflect_ConstantPool_getDoubleAt0
(JNIEnv *env, jobject unused, jobject jcpool, jint index)
{
return JVM_ConstantPoolGetDoubleAt(env, unused, jcpool, index);
}
-JNIEXPORT jstring JNICALL Java_sun_reflect_ConstantPool_getStringAt0
+JNIEXPORT jstring JNICALL Java_jdk_internal_reflect_ConstantPool_getStringAt0
(JNIEnv *env, jobject unused, jobject jcpool, jint index)
{
return JVM_ConstantPoolGetStringAt(env, unused, jcpool, index);
}
-JNIEXPORT jstring JNICALL Java_sun_reflect_ConstantPool_getUTF8At0
+JNIEXPORT jstring JNICALL Java_jdk_internal_reflect_ConstantPool_getUTF8At0
(JNIEnv *env, jobject unused, jobject jcpool, jint index)
{
return JVM_ConstantPoolGetUTF8At(env, unused, jcpool, index);
}
-JNIEXPORT jbyte JNICALL Java_sun_reflect_ConstantPool_getTagAt0
+JNIEXPORT jbyte JNICALL Java_jdk_internal_reflect_ConstantPool_getTagAt0
(JNIEnv *env, jobject unused, jobject jcpool, jint index)
{
return JVM_ConstantPoolGetTagAt(env, unused, jcpool, index);
--- a/jdk/src/java.base/share/native/libjava/NativeAccessors.c Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/native/libjava/NativeAccessors.c Wed Jul 05 21:35:27 2017 +0200
@@ -24,16 +24,16 @@
*/
#include "jvm.h"
-#include "sun_reflect_NativeConstructorAccessorImpl.h"
-#include "sun_reflect_NativeMethodAccessorImpl.h"
+#include "jdk_internal_reflect_NativeConstructorAccessorImpl.h"
+#include "jdk_internal_reflect_NativeMethodAccessorImpl.h"
-JNIEXPORT jobject JNICALL Java_sun_reflect_NativeMethodAccessorImpl_invoke0
+JNIEXPORT jobject JNICALL Java_jdk_internal_reflect_NativeMethodAccessorImpl_invoke0
(JNIEnv *env, jclass unused, jobject m, jobject obj, jobjectArray args)
{
return JVM_InvokeMethod(env, m, obj, args);
}
-JNIEXPORT jobject JNICALL Java_sun_reflect_NativeConstructorAccessorImpl_newInstance0
+JNIEXPORT jobject JNICALL Java_jdk_internal_reflect_NativeConstructorAccessorImpl_newInstance0
(JNIEnv *env, jclass unused, jobject c, jobjectArray args)
{
return JVM_NewInstanceFromConstructor(env, c, args);
--- a/jdk/src/java.base/share/native/libjava/Reflection.c Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/native/libjava/Reflection.c Wed Jul 05 21:35:27 2017 +0200
@@ -25,22 +25,22 @@
#include "jni.h"
#include "jvm.h"
-#include "sun_reflect_Reflection.h"
+#include "jdk_internal_reflect_Reflection.h"
JNIEXPORT jclass JNICALL
-Java_sun_reflect_Reflection_getCallerClass__(JNIEnv *env, jclass unused)
+Java_jdk_internal_reflect_Reflection_getCallerClass__(JNIEnv *env, jclass unused)
{
return JVM_GetCallerClass(env, JVM_CALLER_DEPTH);
}
JNIEXPORT jclass JNICALL
-Java_sun_reflect_Reflection_getCallerClass__I(JNIEnv *env, jclass unused, jint depth)
+Java_jdk_internal_reflect_Reflection_getCallerClass__I(JNIEnv *env, jclass unused, jint depth)
{
return JVM_GetCallerClass(env, depth);
}
JNIEXPORT jint JNICALL
-Java_sun_reflect_Reflection_getClassAccessFlags(JNIEnv *env, jclass unused, jclass cls)
+Java_jdk_internal_reflect_Reflection_getClassAccessFlags(JNIEnv *env, jclass unused, jclass cls)
{
return JVM_GetClassAccessFlags(env, cls);
}
--- a/jdk/src/java.base/share/native/libjava/Throwable.c Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/native/libjava/Throwable.c Wed Jul 05 21:35:27 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1994, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 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
@@ -50,15 +50,9 @@
return throwable;
}
-JNIEXPORT jint JNICALL
-Java_java_lang_Throwable_getStackTraceDepth(JNIEnv *env, jobject throwable)
+JNIEXPORT void JNICALL
+Java_java_lang_Throwable_getStackTraceElements(JNIEnv *env,
+ jobject throwable, jobjectArray elements)
{
- return JVM_GetStackTraceDepth(env, throwable);
+ JVM_GetStackTraceElements(env, throwable, elements);
}
-
-JNIEXPORT jobject JNICALL
-Java_java_lang_Throwable_getStackTraceElement(JNIEnv *env,
- jobject throwable, jint index)
-{
- return JVM_GetStackTraceElement(env, throwable, index);
-}
--- a/jdk/src/java.base/share/native/libjli/java.h Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/share/native/libjli/java.h Wed Jul 05 21:35:27 2017 +0200
@@ -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
@@ -228,7 +228,7 @@
};
static const char *launchModeNames[]
- = { "Unknown", "Main class", "JAR file" };
+ = { "Unknown", "Main class", "JAR file", "Module" };
typedef struct {
int argc;
--- a/jdk/src/java.base/unix/classes/sun/nio/fs/UnixFileSystemProvider.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/unix/classes/sun/nio/fs/UnixFileSystemProvider.java Wed Jul 05 21:35:27 2017 +0200
@@ -499,6 +499,29 @@
}
}
+ @Override
+ public final boolean isDirectory(Path obj) {
+ UnixPath file = UnixPath.toUnixPath(obj);
+ file.checkRead();
+ int mode = UnixNativeDispatcher.stat(file);
+ return ((mode & UnixConstants.S_IFMT) == UnixConstants.S_IFDIR);
+ }
+
+ @Override
+ public final boolean isRegularFile(Path obj) {
+ UnixPath file = UnixPath.toUnixPath(obj);
+ file.checkRead();
+ int mode = UnixNativeDispatcher.stat(file);
+ return ((mode & UnixConstants.S_IFMT) == UnixConstants.S_IFREG);
+ }
+
+ @Override
+ public final boolean exists(Path obj) {
+ UnixPath file = UnixPath.toUnixPath(obj);
+ file.checkRead();
+ return UnixNativeDispatcher.exists(file);
+ }
+
/**
* Returns a {@code FileTypeDetector} for this platform.
*/
--- a/jdk/src/java.base/unix/classes/sun/nio/fs/UnixNativeDispatcher.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/unix/classes/sun/nio/fs/UnixNativeDispatcher.java Wed Jul 05 21:35:27 2017 +0200
@@ -296,6 +296,23 @@
private static native void stat0(long pathAddress, UnixFileAttributes attrs)
throws UnixException;
+
+ /**
+ * stat(const char* path, struct stat* buf)
+ *
+ * @return st_mode (file type and mode) or 0 if an error occurs.
+ */
+ static int stat(UnixPath path) {
+ NativeBuffer buffer = copyToNativeBuffer(path);
+ try {
+ return stat1(buffer.address());
+ } finally {
+ buffer.release();
+ }
+ }
+ private static native int stat1(long pathAddress);
+
+
/**
* lstat(const char* path, struct stat* buf)
*/
@@ -459,6 +476,22 @@
private static native void access0(long pathAddress, int amode) throws UnixException;
/**
+ * access(constant char* path, F_OK)
+ *
+ * @return true if the file exists, false otherwise
+ */
+ static boolean exists(UnixPath path) {
+ NativeBuffer buffer = copyToNativeBuffer(path);
+ try {
+ return exists0(buffer.address());
+ } finally {
+ buffer.release();
+ }
+ }
+ private static native boolean exists0(long pathAddress);
+
+
+ /**
* struct passwd *getpwuid(uid_t uid);
*
* @return passwd->pw_name
--- a/jdk/src/java.base/unix/classes/sun/nio/fs/UnixUriUtils.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/unix/classes/sun/nio/fs/UnixUriUtils.java Wed Jul 05 21:35:27 2017 +0200
@@ -114,12 +114,9 @@
// trailing slash if directory
if (sb.charAt(sb.length()-1) != '/') {
- try {
- if (UnixFileAttributes.get(up, true).isDirectory())
- sb.append('/');
- } catch (UnixException x) {
- // ignore
- }
+ int mode = UnixNativeDispatcher.stat(up);
+ if ((mode & UnixConstants.S_IFMT) == UnixConstants.S_IFDIR)
+ sb.append('/');
}
try {
--- a/jdk/src/java.base/unix/native/libnio/fs/UnixNativeDispatcher.c Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/unix/native/libnio/fs/UnixNativeDispatcher.c Wed Jul 05 21:35:27 2017 +0200
@@ -483,6 +483,20 @@
}
}
+JNIEXPORT jint JNICALL
+Java_sun_nio_fs_UnixNativeDispatcher_stat1(JNIEnv* env, jclass this, jlong pathAddress) {
+ int err;
+ struct stat64 buf;
+ const char* path = (const char*)jlong_to_ptr(pathAddress);
+
+ RESTARTABLE(stat64(path, &buf), err);
+ if (err == -1) {
+ return 0;
+ } else {
+ return (jint)buf.st_mode;
+ }
+}
+
JNIEXPORT void JNICALL
Java_sun_nio_fs_UnixNativeDispatcher_lstat0(JNIEnv* env, jclass this,
jlong pathAddress, jobject attrs)
@@ -897,6 +911,14 @@
}
}
+JNIEXPORT jboolean JNICALL
+Java_sun_nio_fs_UnixNativeDispatcher_exists0(JNIEnv* env, jclass this, jlong pathAddress) {
+ int err;
+ const char* path = (const char*)jlong_to_ptr(pathAddress);
+ RESTARTABLE(access(path, F_OK), err);
+ return (err == 0) ? JNI_TRUE : JNI_FALSE;
+}
+
JNIEXPORT void JNICALL
Java_sun_nio_fs_UnixNativeDispatcher_statvfs0(JNIEnv* env, jclass this,
jlong pathAddress, jobject attrs)
--- a/jdk/src/java.base/windows/classes/java/net/DefaultDatagramSocketImplFactory.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/windows/classes/java/net/DefaultDatagramSocketImplFactory.java Wed Jul 05 21:35:27 2017 +0200
@@ -26,6 +26,7 @@
import java.security.AccessController;
import java.security.PrivilegedAction;
+import sun.security.action.GetPropertyAction;
/**
* This class defines a factory for creating DatagramSocketImpls. It defaults
@@ -47,64 +48,30 @@
{
private static final Class<?> prefixImplClass;
- /* the windows version. */
- private static float version;
-
/* java.net.preferIPv4Stack */
- private static boolean preferIPv4Stack = false;
-
- /* If the version supports a dual stack TCP implementation */
- private static final boolean useDualStackImpl;
-
- /* sun.net.useExclusiveBind */
- private static String exclBindProp;
+ private static final boolean preferIPv4Stack;
/* True if exclusive binding is on for Windows */
private static final boolean exclusiveBind;
static {
Class<?> prefixImplClassLocal = null;
- boolean useDualStackImplLocal = false;
- boolean exclusiveBindLocal = true;
+
+ preferIPv4Stack = Boolean.parseBoolean(
+ AccessController.doPrivileged(
+ new GetPropertyAction("java.net.preferIPv4Stack")));
- // Determine Windows Version.
- java.security.AccessController.doPrivileged(
- new PrivilegedAction<Object>() {
- public Object run() {
- version = 0;
- try {
- version = Float.parseFloat(System.getProperties()
- .getProperty("os.version"));
- preferIPv4Stack = Boolean.parseBoolean(
- System.getProperties()
- .getProperty(
- "java.net.preferIPv4Stack"));
- exclBindProp = System.getProperty(
- "sun.net.useExclusiveBind");
- } catch (NumberFormatException e) {
- assert false : e;
- }
- return null; // nothing to return
- }
- });
-
- // (version >= 6.0) implies Vista or greater.
- if (version >= 6.0 && !preferIPv4Stack) {
- useDualStackImplLocal = true;
- }
- if (exclBindProp != null) {
- // sun.net.useExclusiveBind is true
- exclusiveBindLocal = exclBindProp.length() == 0 ? true
- : Boolean.parseBoolean(exclBindProp);
- } else if (version < 6.0) {
- exclusiveBindLocal = false;
- }
+ String exclBindProp = AccessController.doPrivileged(
+ new GetPropertyAction("sun.net.useExclusiveBind", ""));
+ exclusiveBind = (exclBindProp.isEmpty())
+ ? true
+ : Boolean.parseBoolean(exclBindProp);
// impl.prefix
String prefix = null;
try {
prefix = AccessController.doPrivileged(
- new sun.security.action.GetPropertyAction("impl.prefix", null));
+ new GetPropertyAction("impl.prefix", null));
if (prefix != null)
prefixImplClassLocal = Class.forName("java.net."+prefix+"DatagramSocketImpl");
} catch (Exception e) {
@@ -114,8 +81,6 @@
}
prefixImplClass = prefixImplClassLocal;
- useDualStackImpl = useDualStackImplLocal;
- exclusiveBind = exclusiveBindLocal;
}
/**
@@ -133,7 +98,7 @@
throw new SocketException("can't instantiate DatagramSocketImpl");
}
} else {
- if (useDualStackImpl && !isMulticast)
+ if (!preferIPv4Stack && !isMulticast)
return new DualStackPlainDatagramSocketImpl(exclusiveBind);
else
return new TwoStacksPlainDatagramSocketImpl(exclusiveBind && !isMulticast);
--- a/jdk/src/java.base/windows/classes/java/net/PlainSocketImpl.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/windows/classes/java/net/PlainSocketImpl.java Wed Jul 05 21:35:27 2017 +0200
@@ -25,7 +25,9 @@
package java.net;
import java.io.*;
+import java.security.AccessController;
import java.security.PrivilegedAction;
+import sun.security.action.GetPropertyAction;
/*
* This class PlainSocketImpl simply delegates to the appropriate real
@@ -45,55 +47,29 @@
{
private AbstractPlainSocketImpl impl;
- /* the windows version. */
- private static float version;
-
/* java.net.preferIPv4Stack */
- private static boolean preferIPv4Stack = false;
-
- /* If the version supports a dual stack TCP implementation */
- private static boolean useDualStackImpl = false;
-
- /* sun.net.useExclusiveBind */
- private static String exclBindProp;
+ private static final boolean preferIPv4Stack;
/* True if exclusive binding is on for Windows */
- private static boolean exclusiveBind = true;
+ private static final boolean exclusiveBind;
static {
- java.security.AccessController.doPrivileged( new PrivilegedAction<Object>() {
- public Object run() {
- version = 0;
- try {
- version = Float.parseFloat(System.getProperties().getProperty("os.version"));
- preferIPv4Stack = Boolean.parseBoolean(
- System.getProperties().getProperty("java.net.preferIPv4Stack"));
- exclBindProp = System.getProperty("sun.net.useExclusiveBind");
- } catch (NumberFormatException e ) {
- assert false : e;
- }
- return null; // nothing to return
- } });
+ preferIPv4Stack = Boolean.parseBoolean(
+ AccessController.doPrivileged(
+ new GetPropertyAction("java.net.preferIPv4Stack")));
- // (version >= 6.0) implies Vista or greater.
- if (version >= 6.0 && !preferIPv4Stack) {
- useDualStackImpl = true;
- }
-
- if (exclBindProp != null) {
- // sun.net.useExclusiveBind is true
- exclusiveBind = exclBindProp.length() == 0 ? true
- : Boolean.parseBoolean(exclBindProp);
- } else if (version < 6.0) {
- exclusiveBind = false;
- }
+ String exclBindProp = AccessController.doPrivileged(
+ new GetPropertyAction("sun.net.useExclusiveBind", ""));
+ exclusiveBind = (exclBindProp.isEmpty())
+ ? true
+ : Boolean.parseBoolean(exclBindProp);
}
/**
* Constructs an empty instance.
*/
PlainSocketImpl() {
- if (useDualStackImpl) {
+ if (!preferIPv4Stack) {
impl = new DualStackPlainSocketImpl(exclusiveBind);
} else {
impl = new TwoStacksPlainSocketImpl(exclusiveBind);
@@ -104,7 +80,7 @@
* Constructs an instance with the given file descriptor.
*/
PlainSocketImpl(FileDescriptor fd) {
- if (useDualStackImpl) {
+ if (!preferIPv4Stack) {
impl = new DualStackPlainSocketImpl(fd, exclusiveBind);
} else {
impl = new TwoStacksPlainSocketImpl(fd, exclusiveBind);
--- a/jdk/src/java.base/windows/classes/sun/nio/ch/Iocp.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/windows/classes/sun/nio/ch/Iocp.java Wed Jul 05 21:35:27 2017 +0200
@@ -34,8 +34,6 @@
import java.util.concurrent.*;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
-import java.security.AccessController;
-import sun.security.action.GetPropertyAction;
import jdk.internal.misc.Unsafe;
/**
@@ -46,7 +44,6 @@
class Iocp extends AsynchronousChannelGroupImpl {
private static final Unsafe unsafe = Unsafe.getUnsafe();
private static final long INVALID_HANDLE_VALUE = -1L;
- private static final boolean supportsThreadAgnosticIo;
// maps completion key to channel
private final ReadWriteLock keyToChannelLock = new ReentrantReadWriteLock();
@@ -90,13 +87,6 @@
<V,A> PendingFuture<V,A> getByOverlapped(long overlapped);
}
- /**
- * Indicates if this operating system supports thread agnostic I/O.
- */
- static boolean supportsThreadAgnosticIo() {
- return supportsThreadAgnosticIo;
- }
-
// release all resources
void implClose() {
synchronized (this) {
@@ -445,11 +435,5 @@
static {
IOUtil.load();
initIDs();
-
- // thread agnostic I/O on Vista/2008 or newer
- String osversion = AccessController.doPrivileged(
- new GetPropertyAction("os.version"));
- String vers[] = osversion.split("\\.");
- supportsThreadAgnosticIo = Integer.parseInt(vers[0]) >= 6;
}
}
--- a/jdk/src/java.base/windows/classes/sun/nio/ch/WindowsAsynchronousFileChannelImpl.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/windows/classes/sun/nio/ch/WindowsAsynchronousFileChannelImpl.java Wed Jul 05 21:35:27 2017 +0200
@@ -318,20 +318,7 @@
result.setContext(lockTask);
// initiate I/O
- if (Iocp.supportsThreadAgnosticIo()) {
- lockTask.run();
- } else {
- boolean executed = false;
- try {
- Invoker.invokeOnThreadInThreadPool(this, lockTask);
- executed = true;
- } finally {
- if (!executed) {
- // rollback
- removeFromFileLockTable(fli);
- }
- }
- }
+ lockTask.run();
return result;
}
@@ -556,11 +543,7 @@
result.setContext(readTask);
// initiate I/O
- if (Iocp.supportsThreadAgnosticIo()) {
- readTask.run();
- } else {
- Invoker.invokeOnThreadInThreadPool(this, readTask);
- }
+ readTask.run();
return result;
}
@@ -730,11 +713,7 @@
result.setContext(writeTask);
// initiate I/O
- if (Iocp.supportsThreadAgnosticIo()) {
- writeTask.run();
- } else {
- Invoker.invokeOnThreadInThreadPool(this, writeTask);
- }
+ writeTask.run();
return result;
}
--- a/jdk/src/java.base/windows/classes/sun/nio/ch/WindowsAsynchronousServerSocketChannelImpl.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/windows/classes/sun/nio/ch/WindowsAsynchronousServerSocketChannelImpl.java Wed Jul 05 21:35:27 2017 +0200
@@ -342,11 +342,7 @@
throw new AcceptPendingException();
// initiate I/O
- if (Iocp.supportsThreadAgnosticIo()) {
- task.run();
- } else {
- Invoker.invokeOnThreadInThreadPool(this, task);
- }
+ task.run();
return result;
}
--- a/jdk/src/java.base/windows/classes/sun/nio/ch/WindowsAsynchronousSocketChannelImpl.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/windows/classes/sun/nio/ch/WindowsAsynchronousSocketChannelImpl.java Wed Jul 05 21:35:27 2017 +0200
@@ -378,11 +378,7 @@
result.setContext(task);
// initiate I/O
- if (Iocp.supportsThreadAgnosticIo()) {
- task.run();
- } else {
- Invoker.invokeOnThreadInThreadPool(this, task);
- }
+ task.run();
return result;
}
@@ -653,11 +649,7 @@
}
// initiate I/O
- if (Iocp.supportsThreadAgnosticIo()) {
- readTask.run();
- } else {
- Invoker.invokeOnThreadInThreadPool(this, readTask);
- }
+ readTask.run();
return result;
}
@@ -910,13 +902,8 @@
result.setTimeoutTask(timeoutTask);
}
- // initiate I/O (can only be done from thread in thread pool)
// initiate I/O
- if (Iocp.supportsThreadAgnosticIo()) {
- writeTask.run();
- } else {
- Invoker.invokeOnThreadInThreadPool(this, writeTask);
- }
+ writeTask.run();
return result;
}
--- a/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsFileAttributeViews.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsFileAttributeViews.java Wed Jul 05 21:35:27 2017 +0200
@@ -79,7 +79,7 @@
long handle = -1L;
try {
int flags = FILE_FLAG_BACKUP_SEMANTICS;
- if (!followLinks && file.getFileSystem().supportsLinks())
+ if (!followLinks)
flags |= FILE_FLAG_OPEN_REPARSE_POINT;
handle = CreateFile(file.getPathForWin32Calls(),
--- a/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsFileCopy.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsFileCopy.java Wed Jul 05 21:35:27 2017 +0200
@@ -168,9 +168,7 @@
// Use CopyFileEx if the file is not a directory or junction
if (!sourceAttrs.isDirectory() && !sourceAttrs.isDirectoryLink()) {
- final int flags =
- (source.getFileSystem().supportsLinks() && !followLinks) ?
- COPY_FILE_COPY_SYMLINK : 0;
+ final int flags = (!followLinks) ? COPY_FILE_COPY_SYMLINK : 0;
if (interruptible) {
// interruptible copy
--- a/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsFileStore.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsFileStore.java Wed Jul 05 21:35:27 2017 +0200
@@ -78,14 +78,7 @@
// if the file is a link then GetVolumePathName returns the
// volume that the link is on so we need to call it with the
// final target
- String target;
- if (file.getFileSystem().supportsLinks()) {
- target = WindowsLinkSupport.getFinalPath(file, true);
- } else {
- // file must exist
- WindowsFileAttributes.get(file, true);
- target = file.getPathForWin32Calls();
- }
+ String target = WindowsLinkSupport.getFinalPath(file, true);
try {
return createFromPath(target);
} catch (WindowsException e) {
--- a/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsFileSystem.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsFileSystem.java Wed Jul 05 21:35:27 2017 +0200
@@ -31,9 +31,6 @@
import java.util.*;
import java.util.regex.Pattern;
import java.io.IOException;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import sun.security.action.GetPropertyAction;
class WindowsFileSystem
extends FileSystem
@@ -44,9 +41,6 @@
private final String defaultDirectory;
private final String defaultRoot;
- private final boolean supportsLinks;
- private final boolean supportsStreamEnumeration;
-
// package-private
WindowsFileSystem(WindowsFileSystemProvider provider,
String dir)
@@ -61,18 +55,6 @@
throw new AssertionError("Default directory is not an absolute path");
this.defaultDirectory = result.path();
this.defaultRoot = result.root();
-
- PrivilegedAction<String> pa = new GetPropertyAction("os.version");
- String osversion = AccessController.doPrivileged(pa);
- String[] vers = Util.split(osversion, '.');
- int major = Integer.parseInt(vers[0]);
- int minor = Integer.parseInt(vers[1]);
-
- // symbolic links available on Vista and newer
- supportsLinks = (major >= 6);
-
- // enumeration of data streams available on Windows Server 2003 and newer
- supportsStreamEnumeration = (major >= 6) || (major == 5 && minor >= 2);
}
// package-private
@@ -84,14 +66,6 @@
return defaultRoot;
}
- boolean supportsLinks() {
- return supportsLinks;
- }
-
- boolean supportsStreamEnumeration() {
- return supportsStreamEnumeration;
- }
-
@Override
public FileSystemProvider provider() {
return provider;
--- a/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsFileSystemProvider.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsFileSystemProvider.java Wed Jul 05 21:35:27 2017 +0200
@@ -526,11 +526,6 @@
WindowsPath link = WindowsPath.toWindowsPath(obj1);
WindowsPath target = WindowsPath.toWindowsPath(obj2);
- if (!link.getFileSystem().supportsLinks()) {
- throw new UnsupportedOperationException("Symbolic links not supported "
- + "on this operating system");
- }
-
// no attributes allowed
if (attrs.length > 0) {
WindowsSecurityDescriptor.fromAttribute(attrs); // may throw NPE or UOE
@@ -614,9 +609,6 @@
public Path readSymbolicLink(Path obj1) throws IOException {
WindowsPath link = WindowsPath.toWindowsPath(obj1);
WindowsFileSystem fs = link.getFileSystem();
- if (!fs.supportsLinks()) {
- throw new UnsupportedOperationException("symbolic links not supported");
- }
// permission check
SecurityManager sm = System.getSecurityManager();
--- a/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsLinkSupport.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsLinkSupport.java Wed Jul 05 21:35:27 2017 +0200
@@ -96,7 +96,7 @@
WindowsFileSystem fs = input.getFileSystem();
try {
// if not following links then don't need final path
- if (!followLinks || !fs.supportsLinks())
+ if (!followLinks)
return input.getPathForWin32Calls();
// if file is not a sym link then don't need final path
@@ -157,8 +157,6 @@
throws IOException
{
WindowsFileSystem fs = input.getFileSystem();
- if (resolveLinks && !fs.supportsLinks())
- resolveLinks = false;
// Start with absolute path
String path = null;
--- a/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsNativeDispatcher.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsNativeDispatcher.java Wed Jul 05 21:35:27 2017 +0200
@@ -1071,54 +1071,6 @@
static native int GetOverlappedResult(long hFile, long lpOverlapped)
throws WindowsException;
- /**
- * BackupRead(
- * HANDLE hFile,
- * LPBYTE lpBuffer,
- * DWORD nNumberOfBytesToRead,
- * LPDWORD lpNumberOfBytesRead,
- * BOOL bAbort,
- * BOOL bProcessSecurity,
- * LPVOID* lpContext
- * )
- */
- static BackupResult BackupRead(long hFile,
- long bufferAddress,
- int bufferSize,
- boolean abort,
- long context)
- throws WindowsException
- {
- BackupResult result = new BackupResult();
- BackupRead0(hFile, bufferAddress, bufferSize, abort, context, result);
- return result;
- }
- static class BackupResult {
- private int bytesTransferred;
- private long context;
- private BackupResult() { }
-
- int bytesTransferred() { return bytesTransferred; }
- long context() { return context; }
- }
- private static native void BackupRead0(long hFile, long bufferAddress,
- int bufferSize, boolean abort, long context, BackupResult result)
- throws WindowsException;
-
- /**
- * BackupSeek(
- * HANDLE hFile,
- * DWORD dwLowBytesToSeek,
- * DWORD dwHighBytesToSeek,
- * LPDWORD lpdwLowByteSeeked,
- * LPDWORD lpdwHighByteSeeked,
- * LPVOID* lpContext
- * )
- */
- static native void BackupSeek(long hFile, long bytesToSeek, long context)
- throws WindowsException;
-
-
// -- support for copying String with a NativeBuffer --
private static final Unsafe unsafe = Unsafe.getUnsafe();
--- a/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsPath.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsPath.java Wed Jul 05 21:35:27 2017 +0200
@@ -780,7 +780,7 @@
throws WindowsException
{
int flags = FILE_FLAG_BACKUP_SEMANTICS;
- if (!followLinks && getFileSystem().supportsLinks())
+ if (!followLinks)
flags |= FILE_FLAG_OPEN_REPARSE_POINT;
return CreateFile(getPathForWin32Calls(),
FILE_READ_ATTRIBUTES,
--- a/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsUserDefinedFileAttributeView.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsUserDefinedFileAttributeView.java Wed Jul 05 21:35:27 2017 +0200
@@ -91,121 +91,11 @@
return Collections.unmodifiableList(list);
}
- // enumerates the file streams by reading the stream headers using
- // BackupRead
- private List<String> listUsingBackupRead() throws IOException {
- long handle = -1L;
- try {
- int flags = FILE_FLAG_BACKUP_SEMANTICS;
- if (!followLinks && file.getFileSystem().supportsLinks())
- flags |= FILE_FLAG_OPEN_REPARSE_POINT;
-
- handle = CreateFile(file.getPathForWin32Calls(),
- GENERIC_READ,
- FILE_SHARE_READ, // no write as we depend on file size
- OPEN_EXISTING,
- flags);
- } catch (WindowsException x) {
- x.rethrowAsIOException(file);
- }
-
- // buffer to read stream header and stream name.
- final int BUFFER_SIZE = 4096;
- NativeBuffer buffer = null;
-
- // result with names of alternative data streams
- final List<String> list = new ArrayList<>();
-
- try {
- buffer = NativeBuffers.getNativeBuffer(BUFFER_SIZE);
- long address = buffer.address();
-
- /**
- * typedef struct _WIN32_STREAM_ID {
- * DWORD dwStreamId;
- * DWORD dwStreamAttributes;
- * LARGE_INTEGER Size;
- * DWORD dwStreamNameSize;
- * WCHAR cStreamName[ANYSIZE_ARRAY];
- * } WIN32_STREAM_ID;
- */
- final int SIZEOF_STREAM_HEADER = 20;
- final int OFFSETOF_STREAM_ID = 0;
- final int OFFSETOF_STREAM_SIZE = 8;
- final int OFFSETOF_STREAM_NAME_SIZE = 16;
-
- long context = 0L;
- try {
- for (;;) {
- // read stream header
- BackupResult result = BackupRead(handle, address,
- SIZEOF_STREAM_HEADER, false, context);
- context = result.context();
- if (result.bytesTransferred() == 0)
- break;
-
- int streamId = unsafe.getInt(address + OFFSETOF_STREAM_ID);
- long streamSize = unsafe.getLong(address + OFFSETOF_STREAM_SIZE);
- int nameSize = unsafe.getInt(address + OFFSETOF_STREAM_NAME_SIZE);
-
- // read stream name
- if (nameSize > 0) {
- result = BackupRead(handle, address, nameSize, false, context);
- if (result.bytesTransferred() != nameSize)
- break;
- }
-
- // check for alternative data stream
- if (streamId == BACKUP_ALTERNATE_DATA) {
- char[] nameAsArray = new char[nameSize/2];
- unsafe.copyMemory(null, address, nameAsArray,
- Unsafe.ARRAY_CHAR_BASE_OFFSET, nameSize);
-
- String[] segs = new String(nameAsArray).split(":");
- if (segs.length == 3)
- list.add(segs[1]);
- }
-
- // sparse blocks not currently handled as documentation
- // is not sufficient on how the spase block can be skipped.
- if (streamId == BACKUP_SPARSE_BLOCK) {
- throw new IOException("Spare blocks not handled");
- }
-
- // seek to end of stream
- if (streamSize > 0L) {
- BackupSeek(handle, streamSize, context);
- }
- }
- } catch (WindowsException x) {
- // failed to read or seek
- throw new IOException(x.errorString());
- } finally {
- // release context
- if (context != 0L) {
- try {
- BackupRead(handle, 0L, 0, true, context);
- } catch (WindowsException ignore) { }
- }
- }
- } finally {
- if (buffer != null)
- buffer.release();
- CloseHandle(handle);
- }
- return Collections.unmodifiableList(list);
- }
-
@Override
public List<String> list() throws IOException {
if (System.getSecurityManager() != null)
checkAccess(file.getPathForPermissionCheck(), true, false);
- // use stream APIs on Windows Server 2003 and newer
- if (file.getFileSystem().supportsStreamEnumeration()) {
- return listUsingStreamEnumeration();
- } else {
- return listUsingBackupRead();
- }
+ return listUsingStreamEnumeration();
}
@Override
--- a/jdk/src/java.base/windows/native/libnet/Inet4AddressImpl.c Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/windows/native/libnet/Inet4AddressImpl.c Wed Jul 05 21:35:27 2017 +0200
@@ -275,6 +275,151 @@
return JNU_NewStringPlatform(env, hp->h_name);
}
+static jboolean
+tcp_ping4(JNIEnv *env,
+ jbyteArray addrArray,
+ jint timeout,
+ jbyteArray ifArray,
+ jint ttl)
+{
+ jint addr;
+ jbyte caddr[4];
+ jint fd;
+ struct sockaddr_in him;
+ struct sockaddr_in* netif = NULL;
+ struct sockaddr_in inf;
+ int len = 0;
+ WSAEVENT hEvent;
+ int connect_rv = -1;
+ int sz;
+
+ /**
+ * Convert IP address from byte array to integer
+ */
+ sz = (*env)->GetArrayLength(env, addrArray);
+ if (sz != 4) {
+ return JNI_FALSE;
+ }
+ memset((char *) &him, 0, sizeof(him));
+ memset((char *) caddr, 0, sizeof(caddr));
+ (*env)->GetByteArrayRegion(env, addrArray, 0, 4, caddr);
+ addr = ((caddr[0]<<24) & 0xff000000);
+ addr |= ((caddr[1] <<16) & 0xff0000);
+ addr |= ((caddr[2] <<8) & 0xff00);
+ addr |= (caddr[3] & 0xff);
+ addr = htonl(addr);
+ /**
+ * Socket address
+ */
+ him.sin_addr.s_addr = addr;
+ him.sin_family = AF_INET;
+ len = sizeof(him);
+
+ /**
+ * If a network interface was specified, let's convert its address
+ * as well.
+ */
+ if (!(IS_NULL(ifArray))) {
+ memset((char *) caddr, 0, sizeof(caddr));
+ (*env)->GetByteArrayRegion(env, ifArray, 0, 4, caddr);
+ addr = ((caddr[0]<<24) & 0xff000000);
+ addr |= ((caddr[1] <<16) & 0xff0000);
+ addr |= ((caddr[2] <<8) & 0xff00);
+ addr |= (caddr[3] & 0xff);
+ addr = htonl(addr);
+ inf.sin_addr.s_addr = addr;
+ inf.sin_family = AF_INET;
+ inf.sin_port = 0;
+ netif = &inf;
+ }
+
+ /*
+ * Can't create a raw socket, so let's try a TCP socket
+ */
+ fd = NET_Socket(AF_INET, SOCK_STREAM, 0);
+ if (fd == -1) {
+ /* note: if you run out of fds, you may not be able to load
+ * the exception class, and get a NoClassDefFoundError
+ * instead.
+ */
+ NET_ThrowNew(env, WSAGetLastError(), "Can't create socket");
+ return JNI_FALSE;
+ }
+ if (ttl > 0) {
+ setsockopt(fd, IPPROTO_IP, IP_TTL, (const char *)&ttl, sizeof(ttl));
+ }
+ /*
+ * A network interface was specified, so let's bind to it.
+ */
+ if (netif != NULL) {
+ if (bind(fd, (struct sockaddr*)netif, sizeof(struct sockaddr_in)) < 0) {
+ NET_ThrowNew(env, WSAGetLastError(), "Can't bind socket");
+ closesocket(fd);
+ return JNI_FALSE;
+ }
+ }
+
+ /*
+ * Make the socket non blocking so we can use select/poll.
+ */
+ hEvent = WSACreateEvent();
+ WSAEventSelect(fd, hEvent, FD_READ|FD_CONNECT|FD_CLOSE);
+
+ /* no need to use NET_Connect as non-blocking */
+ him.sin_port = htons(7); /* Echo */
+ connect_rv = connect(fd, (struct sockaddr *)&him, len);
+
+ /**
+ * connection established or refused immediately, either way it means
+ * we were able to reach the host!
+ */
+ if (connect_rv == 0 || WSAGetLastError() == WSAECONNREFUSED) {
+ WSACloseEvent(hEvent);
+ closesocket(fd);
+ return JNI_TRUE;
+ } else {
+ int optlen;
+
+ switch (WSAGetLastError()) {
+ case WSAEHOSTUNREACH: /* Host Unreachable */
+ case WSAENETUNREACH: /* Network Unreachable */
+ case WSAENETDOWN: /* Network is down */
+ case WSAEPFNOSUPPORT: /* Protocol Family unsupported */
+ WSACloseEvent(hEvent);
+ closesocket(fd);
+ return JNI_FALSE;
+ }
+
+ if (WSAGetLastError() != WSAEWOULDBLOCK) {
+ NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "ConnectException",
+ "connect failed");
+ WSACloseEvent(hEvent);
+ closesocket(fd);
+ return JNI_FALSE;
+ }
+
+ timeout = NET_Wait(env, fd, NET_WAIT_CONNECT, timeout);
+
+ /* has connection been established */
+
+ if (timeout >= 0) {
+ optlen = sizeof(connect_rv);
+ if (getsockopt(fd, SOL_SOCKET, SO_ERROR, (void*)&connect_rv,
+ &optlen) <0) {
+ connect_rv = WSAGetLastError();
+ }
+
+ if (connect_rv == 0 || connect_rv == WSAECONNREFUSED) {
+ WSACloseEvent(hEvent);
+ closesocket(fd);
+ return JNI_TRUE;
+ }
+ }
+ }
+ WSACloseEvent(hEvent);
+ closesocket(fd);
+ return JNI_FALSE;
+}
/**
* ping implementation.
@@ -286,23 +431,17 @@
ping4(JNIEnv *env,
unsigned long src_addr,
unsigned long dest_addr,
- jint timeout)
+ jint timeout,
+ HANDLE hIcmpFile)
{
// See https://msdn.microsoft.com/en-us/library/aa366050%28VS.85%29.aspx
- HANDLE hIcmpFile;
DWORD dwRetVal = 0;
char SendData[32] = {0};
LPVOID ReplyBuffer = NULL;
DWORD ReplySize = 0;
jboolean ret = JNI_FALSE;
- hIcmpFile = IcmpCreateFile();
- if (hIcmpFile == INVALID_HANDLE_VALUE) {
- NET_ThrowNew(env, WSAGetLastError(), "Unable to open handle");
- return JNI_FALSE;
- }
-
ReplySize = sizeof(ICMP_ECHO_REPLY) + sizeof(SendData);
ReplyBuffer = (VOID*) malloc(ReplySize);
if (ReplyBuffer == NULL) {
@@ -366,6 +505,7 @@
jint dest_addr = 0;
jbyte caddr[4];
int sz;
+ HANDLE hIcmpFile;
/**
* Convert IP address from byte array to integer
@@ -396,6 +536,18 @@
src_addr = htonl(src_addr);
}
- return ping4(env, src_addr, dest_addr, timeout);
+ hIcmpFile = IcmpCreateFile();
+ if (hIcmpFile == INVALID_HANDLE_VALUE) {
+ int err = WSAGetLastError();
+ if (err == ERROR_ACCESS_DENIED) {
+ // fall back to TCP echo if access is denied to ICMP
+ return tcp_ping4(env, addrArray, timeout, ifArray, ttl);
+ } else {
+ NET_ThrowNew(env, err, "Unable to create ICMP file handle");
+ return JNI_FALSE;
+ }
+ } else {
+ return ping4(env, src_addr, dest_addr, timeout, hIcmpFile);
+ }
}
--- a/jdk/src/java.base/windows/native/libnet/Inet6AddressImpl.c Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/windows/native/libnet/Inet6AddressImpl.c Wed Jul 05 21:35:27 2017 +0200
@@ -326,6 +326,109 @@
#ifdef AF_INET6
+/**
+ * ping implementation using tcp port 7 (echo)
+ */
+static jboolean
+tcp_ping6(JNIEnv *env,
+ jint timeout,
+ jint ttl,
+ struct sockaddr_in6 him6,
+ struct sockaddr_in6* netif,
+ int len)
+{
+ jint fd;
+ WSAEVENT hEvent;
+ int connect_rv = -1;
+
+ fd = NET_Socket(AF_INET6, SOCK_STREAM, 0);
+ if (fd == SOCKET_ERROR) {
+ /* note: if you run out of fds, you may not be able to load
+ * the exception class, and get a NoClassDefFoundError
+ * instead.
+ */
+ NET_ThrowNew(env, errno, "Can't create socket");
+ return JNI_FALSE;
+ }
+
+ /**
+ * A TTL was specified, let's set the socket option.
+ */
+ if (ttl > 0) {
+ setsockopt(fd, IPPROTO_IPV6, IPV6_UNICAST_HOPS, (const char *)&ttl, sizeof(ttl));
+ }
+
+ /**
+ * A network interface was specified, let's bind to it.
+ */
+ if (netif != NULL) {
+ if (NET_Bind(fd, (struct sockaddr*)netif, sizeof(struct sockaddr_in6)) < 0) {
+ NET_ThrowNew(env, WSAGetLastError(), "Can't bind socket to interface");
+ closesocket(fd);
+ return JNI_FALSE;
+ }
+ }
+
+ /**
+ * Make the socket non blocking.
+ */
+ hEvent = WSACreateEvent();
+ WSAEventSelect(fd, hEvent, FD_READ|FD_CONNECT|FD_CLOSE);
+
+ /* no need to use NET_Connect as non-blocking */
+ him6.sin6_port = htons((short) 7); /* Echo port */
+ connect_rv = connect(fd, (struct sockaddr *)&him6, len);
+
+ /**
+ * connection established or refused immediately, either way it means
+ * we were able to reach the host!
+ */
+ if (connect_rv == 0 || WSAGetLastError() == WSAECONNREFUSED) {
+ WSACloseEvent(hEvent);
+ closesocket(fd);
+ return JNI_TRUE;
+ } else {
+ int optlen;
+
+ switch (WSAGetLastError()) {
+ case WSAEHOSTUNREACH: /* Host Unreachable */
+ case WSAENETUNREACH: /* Network Unreachable */
+ case WSAENETDOWN: /* Network is down */
+ case WSAEPFNOSUPPORT: /* Protocol Family unsupported */
+ WSACloseEvent(hEvent);
+ closesocket(fd);
+ return JNI_FALSE;
+ }
+
+ if (WSAGetLastError() != WSAEWOULDBLOCK) {
+ NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "ConnectException",
+ "connect failed");
+ WSACloseEvent(hEvent);
+ closesocket(fd);
+ return JNI_FALSE;
+ }
+
+ timeout = NET_Wait(env, fd, NET_WAIT_CONNECT, timeout);
+
+ if (timeout >= 0) {
+ /* has connection been established? */
+ optlen = sizeof(connect_rv);
+ if (getsockopt(fd, SOL_SOCKET, SO_ERROR, (void*)&connect_rv,
+ &optlen) <0) {
+ connect_rv = WSAGetLastError();
+ }
+
+ if (connect_rv == 0 || connect_rv == WSAECONNREFUSED) {
+ WSACloseEvent(hEvent);
+ closesocket(fd);
+ return JNI_TRUE;
+ }
+ }
+ }
+ WSACloseEvent(hEvent);
+ closesocket(fd);
+ return JNI_FALSE;
+}
/**
* ping implementation.
@@ -337,9 +440,9 @@
ping6(JNIEnv *env,
struct sockaddr_in6* src,
struct sockaddr_in6* dest,
- jint timeout)
+ jint timeout,
+ HANDLE hIcmpFile)
{
- HANDLE hIcmpFile;
DWORD dwRetVal = 0;
char SendData[32] = {0};
LPVOID ReplyBuffer = NULL;
@@ -347,12 +450,6 @@
IP_OPTION_INFORMATION ipInfo = {255, 0, 0, 0, NULL};
struct sockaddr_in6 sa6Source;
- hIcmpFile = Icmp6CreateFile();
- if (hIcmpFile == INVALID_HANDLE_VALUE) {
- NET_ThrowNew(env, WSAGetLastError(), "Unable to open handle");
- return JNI_FALSE;
- }
-
ReplySize = sizeof(ICMPV6_ECHO_REPLY) + sizeof(SendData);
ReplyBuffer = (VOID*) malloc(ReplySize);
if (ReplyBuffer == NULL) {
@@ -411,7 +508,7 @@
struct sockaddr_in6* netif = NULL;
struct sockaddr_in6 inf6;
int len = 0;
- int connect_rv = -1;
+ HANDLE hIcmpFile;
/*
* If IPv6 is not enable, then we can't reach an IPv6 address, can we?
@@ -456,7 +553,19 @@
netif = &inf6;
}
- return ping6(env, netif, &him6, timeout);
+ hIcmpFile = Icmp6CreateFile();
+ if (hIcmpFile == INVALID_HANDLE_VALUE) {
+ int err = WSAGetLastError();
+ if (err == ERROR_ACCESS_DENIED) {
+ // fall back to TCP echo if access is denied to ICMP
+ return tcp_ping6(env, timeout, ttl, him6, netif, len);
+ } else {
+ NET_ThrowNew(env, err, "Unable to create ICMP file handle");
+ return JNI_FALSE;
+ }
+ } else {
+ return ping6(env, netif, &him6, timeout, hIcmpFile);
+ }
#endif /* AF_INET6 */
return JNI_FALSE;
--- a/jdk/src/java.base/windows/native/libnio/fs/WindowsNativeDispatcher.c Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.base/windows/native/libnio/fs/WindowsNativeDispatcher.c Wed Jul 05 21:35:27 2017 +0200
@@ -69,10 +69,6 @@
static jfieldID completionStatus_bytesTransferred;
static jfieldID completionStatus_completionKey;
-static jfieldID backupResult_bytesTransferred;
-static jfieldID backupResult_context;
-
-
static void throwWindowsException(JNIEnv* env, DWORD lastError) {
jobject x = JNU_NewObjectByName(env, "sun/nio/fs/WindowsException",
"(I)V", lastError);
@@ -148,13 +144,6 @@
CHECK_NULL(completionStatus_bytesTransferred);
completionStatus_completionKey = (*env)->GetFieldID(env, clazz, "completionKey", "J");
CHECK_NULL(completionStatus_completionKey);
-
- clazz = (*env)->FindClass(env, "sun/nio/fs/WindowsNativeDispatcher$BackupResult");
- CHECK_NULL(clazz);
- backupResult_bytesTransferred = (*env)->GetFieldID(env, clazz, "bytesTransferred", "I");
- CHECK_NULL(backupResult_bytesTransferred);
- backupResult_context = (*env)->GetFieldID(env, clazz, "context", "J");
- CHECK_NULL(backupResult_context);
}
JNIEXPORT jlong JNICALL
@@ -1228,52 +1217,3 @@
throwWindowsException(env, GetLastError());
}
}
-
-JNIEXPORT void JNICALL
-Java_sun_nio_fs_WindowsNativeDispatcher_BackupRead0(JNIEnv* env, jclass this,
- jlong hFile, jlong bufferAddress, jint bufferSize, jboolean abort,
- jlong context, jobject obj)
-{
- BOOL res;
- DWORD bytesTransferred;
- BOOL a = (abort == JNI_TRUE) ? TRUE : FALSE;
- VOID* pContext = (VOID*)jlong_to_ptr(context);
-
- res = BackupRead((HANDLE)jlong_to_ptr(hFile),
- (LPBYTE)jlong_to_ptr(bufferAddress),
- (DWORD)bufferSize,
- &bytesTransferred,
- a,
- FALSE,
- &pContext);
- if (res == 0) {
- throwWindowsException(env, GetLastError());
- } else {
- (*env)->SetIntField(env, obj, backupResult_bytesTransferred,
- bytesTransferred);
- (*env)->SetLongField(env, obj, backupResult_context,
- ptr_to_jlong(pContext));
- }
-}
-
-JNIEXPORT void JNICALL
-Java_sun_nio_fs_WindowsNativeDispatcher_BackupSeek(JNIEnv* env, jclass this,
- jlong hFile, jlong bytesToSeek, jlong context)
-{
- BOOL res;
- jint lowBytesToSeek = (jint)bytesToSeek;
- jint highBytesToSeek = (jint)(bytesToSeek >> 32);
- DWORD lowBytesSeeked;
- DWORD highBytesSeeked;
- VOID* pContext = jlong_to_ptr(context);
-
- res = BackupSeek((HANDLE)jlong_to_ptr(hFile),
- (DWORD)lowBytesToSeek,
- (DWORD)highBytesToSeek,
- &lowBytesSeeked,
- &highBytesSeeked,
- &pContext);
- if (res == 0) {
- throwWindowsException(env, GetLastError());
- }
-}
--- a/jdk/src/java.logging/share/classes/java/util/logging/Logger.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.logging/share/classes/java/util/logging/Logger.java Wed Jul 05 21:35:27 2017 +0200
@@ -38,8 +38,8 @@
import java.util.ResourceBundle;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.function.Supplier;
-import sun.reflect.CallerSensitive;
-import sun.reflect.Reflection;
+import jdk.internal.reflect.CallerSensitive;
+import jdk.internal.reflect.Reflection;
/**
* A Logger object is used to log messages for a specific
--- a/jdk/src/java.management/share/classes/javax/management/remote/JMXServiceURL.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.management/share/classes/javax/management/remote/JMXServiceURL.java Wed Jul 05 21:35:27 2017 +0200
@@ -34,10 +34,15 @@
import java.io.ObjectInputStream;
import java.io.Serializable;
+import java.net.Inet4Address;
+import java.net.Inet6Address;
import java.net.InetAddress;
import java.net.MalformedURLException;
+import java.net.NetworkInterface;
+import java.net.SocketException;
import java.net.UnknownHostException;
import java.util.BitSet;
+import java.util.Enumeration;
import java.util.Locale;
import java.util.StringTokenizer;
@@ -236,10 +241,13 @@
* @param protocol the protocol part of the URL. If null, defaults
* to <code>jmxmp</code>.
*
- * @param host the host part of the URL. If null, defaults to the
- * local host name, as determined by
- * <code>InetAddress.getLocalHost().getHostName()</code>. If it
- * is a numeric IPv6 address, it can optionally be enclosed in
+ * @param host the host part of the URL. If host is null and if
+ * local host name can be resolved to an IP, then host defaults
+ * to local host name as determined by
+ * <code>InetAddress.getLocalHost().getHostName()</code>. If host is null
+ * and if local host name cannot be resolved to an IP, then host
+ * defaults to numeric IP address of one of the active network interfaces.
+ * If host is a numeric IPv6 address, it can optionally be enclosed in
* square brackets <code>[]</code>.
*
* @param port the port part of the URL.
@@ -260,10 +268,13 @@
* @param protocol the protocol part of the URL. If null, defaults
* to <code>jmxmp</code>.
*
- * @param host the host part of the URL. If null, defaults to the
- * local host name, as determined by
- * <code>InetAddress.getLocalHost().getHostName()</code>. If it
- * is a numeric IPv6 address, it can optionally be enclosed in
+ * @param host the host part of the URL. If host is null and if
+ * local host name can be resolved to an IP, then host defaults
+ * to local host name as determined by
+ * <code>InetAddress.getLocalHost().getHostName()</code>. If host is null
+ * and if local host name cannot be resolved to an IP, then host
+ * defaults to numeric IP address of one of the active network interfaces.
+ * If host is a numeric IPv6 address, it can optionally be enclosed in
* square brackets <code>[]</code>.
*
* @param port the port part of the URL.
@@ -286,32 +297,45 @@
InetAddress local;
try {
local = InetAddress.getLocalHost();
- } catch (UnknownHostException e) {
- throw new MalformedURLException("Local host name unknown: " +
- e);
- }
-
- host = local.getHostName();
+ host = local.getHostName();
- /* We might have a hostname that violates DNS naming
- rules, for example that contains an `_'. While we
- could be strict and throw an exception, this is rather
- user-hostile. Instead we use its numerical IP address.
- We can only reasonably do this for the host==null case.
- If we're given an explicit host name that is illegal we
- have to reject it. (Bug 5057532.) */
- try {
- validateHost(host, port);
- } catch (MalformedURLException e) {
- if (logger.fineOn()) {
+ /* We might have a hostname that violates DNS naming
+ rules, for example that contains an `_'. While we
+ could be strict and throw an exception, this is rather
+ user-hostile. Instead we use its numerical IP address.
+ We can only reasonably do this for the host==null case.
+ If we're given an explicit host name that is illegal we
+ have to reject it. (Bug 5057532.) */
+ try {
+ validateHost(host, port);
+ } catch (MalformedURLException e) {
+ if (logger.fineOn()) {
logger.fine("JMXServiceURL",
"Replacing illegal local host name " +
host + " with numeric IP address " +
"(see RFC 1034)", e);
}
host = local.getHostAddress();
- /* Use the numeric address, which could be either IPv4
- or IPv6. validateHost will accept either. */
+ }
+ } catch (UnknownHostException e) {
+ try {
+ /*
+ If hostname cannot be resolved, we will try and use numeric
+ IPv4/IPv6 address. If host=null while starting agent,
+ we know that it will be started on all interfaces - 0.0.0.0.
+ Hence we will use IP address of first active non-loopback
+ interface
+ */
+ host = getActiveNetworkInterfaceIP();
+ if (host == null) {
+ throw new MalformedURLException("Unable"
+ + " to resolve hostname or "
+ + "get valid IP address");
+ }
+ } catch (SocketException ex) {
+ throw new MalformedURLException("Unable"
+ + " to resolve hostname or get valid IP address");
+ }
}
}
@@ -340,6 +364,33 @@
validate();
}
+ private String getActiveNetworkInterfaceIP() throws SocketException {
+ Enumeration<NetworkInterface>
+ networkInterface = NetworkInterface.getNetworkInterfaces();
+ String ipv6AddrStr = null;
+ while (networkInterface.hasMoreElements()) {
+ NetworkInterface nic = networkInterface.nextElement();
+ if (nic.isUp() && !nic.isLoopback()) {
+ Enumeration<InetAddress> inet = nic.getInetAddresses();
+ while (inet.hasMoreElements()) {
+ InetAddress addr = inet.nextElement();
+ if (addr instanceof Inet4Address
+ && !addr.isLinkLocalAddress()) {
+ return addr.getHostAddress();
+ }else if (addr instanceof Inet6Address
+ && !addr.isLinkLocalAddress()) {
+ /*
+ We save last seen IPv6 address which we will return
+ if we do not find any interface with IPv4 address.
+ */
+ ipv6AddrStr = addr.getHostAddress();
+ }
+ }
+ }
+ }
+ return ipv6AddrStr;
+ }
+
private static final String INVALID_INSTANCE_MSG =
"Trying to deserialize an invalid instance of JMXServiceURL";
private void readObject(ObjectInputStream inputStream) throws IOException, ClassNotFoundException {
@@ -540,7 +591,9 @@
* constructor that takes a separate host parameter, the result is
* the string that was specified. If that string was null, the
* result is
- * <code>InetAddress.getLocalHost().getHostName()</code>.</p>
+ * <code>InetAddress.getLocalHost().getHostName()</code> if local host name
+ * can be resolved to an IP. Else numeric IP address of an active
+ * network interface will be used.</p>
*
* <p>In either case, if the host was specified using the
* <code>[...]</code> syntax for numeric IPv6 addresses, the
--- a/jdk/src/java.management/share/classes/sun/management/jdp/JdpBroadcaster.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.management/share/classes/sun/management/jdp/JdpBroadcaster.java Wed Jul 05 21:35:27 2017 +0200
@@ -99,30 +99,7 @@
throw new JdpException("Unable to bind to source address");
}
channel.setOption(StandardSocketOptions.IP_MULTICAST_IF, interf);
- } else {
- Enumeration<NetworkInterface> nics = NetworkInterface.getNetworkInterfaces();
- boolean succeed = false;
-
- while (nics.hasMoreElements()) {
- NetworkInterface nic = nics.nextElement();
-
- if (nic.isUp() && nic.supportsMulticast()) {
- try {
- channel.setOption(StandardSocketOptions.IP_MULTICAST_IF, nic);
- succeed = true;
- } catch (IOException ex) {
- // pass
- }
- }
-
- }
-
- if (!succeed) {
- throw new JdpException("Unable to bind to any interfaces.");
- }
-
}
-
}
/**
--- a/jdk/src/java.naming/share/classes/com/sun/jndi/ldap/LdapReferralContext.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.naming/share/classes/com/sun/jndi/ldap/LdapReferralContext.java Wed Jul 05 21:35:27 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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
@@ -92,7 +92,12 @@
try {
referral = refEx.getNextReferral();
if (referral == null) {
- throw (NamingException)(previousEx.fillInStackTrace());
+ if (previousEx != null) {
+ throw (NamingException)(previousEx.fillInStackTrace());
+ } else {
+ throw new NamingException(
+ "Illegal encoding: referral is empty");
+ }
}
} catch (LdapReferralException e) {
--- a/jdk/src/java.security.sasl/share/classes/javax/security/sasl/Sasl.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.security.sasl/share/classes/javax/security/sasl/Sasl.java Wed Jul 05 21:35:27 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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
@@ -312,7 +312,8 @@
*
* @implNote
* The JDK Reference Implementation additionally uses the
- * {@code jdk.security.provider.preferred} property to determine
+ * {@code jdk.security.provider.preferred}
+ * {@link Security#getProperty(String) Security} property to determine
* the preferred provider order for the specified algorithm. This
* may be different than the order of providers returned by
* {@link Security#getProviders() Security.getProviders()}.
@@ -461,7 +462,8 @@
*
* @implNote
* The JDK Reference Implementation additionally uses the
- * {@code jdk.security.provider.preferred} property to determine
+ * {@code jdk.security.provider.preferred}
+ * {@link Security#getProperty(String) Security} property to determine
* the preferred provider order for the specified algorithm. This
* may be different than the order of providers returned by
* {@link Security#getProviders() Security.getProviders()}.
--- a/jdk/src/java.smartcardio/share/classes/javax/smartcardio/TerminalFactory.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.smartcardio/share/classes/javax/smartcardio/TerminalFactory.java Wed Jul 05 21:35:27 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2015, 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
@@ -231,7 +231,8 @@
*
* @implNote
* The JDK Reference Implementation additionally uses the
- * {@code jdk.security.provider.preferred} property to determine
+ * {@code jdk.security.provider.preferred}
+ * {@link Security#getProperty(String) Security} property to determine
* the preferred provider order for the specified algorithm. This
* may be different than the order of providers returned by
* {@link Security#getProviders() Security.getProviders()}.
--- a/jdk/src/java.sql.rowset/share/classes/javax/sql/rowset/serial/SerialJavaObject.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.sql.rowset/share/classes/javax/sql/rowset/serial/SerialJavaObject.java Wed Jul 05 21:35:27 2017 +0200
@@ -30,8 +30,8 @@
import java.util.Arrays;
import java.util.Vector;
import javax.sql.rowset.RowSetWarning;
-import sun.reflect.CallerSensitive;
-import sun.reflect.Reflection;
+import jdk.internal.reflect.CallerSensitive;
+import jdk.internal.reflect.Reflection;
import sun.reflect.misc.ReflectUtil;
/**
@@ -141,7 +141,7 @@
* Check if the caller is allowed to access the specified class's package.
* If access is denied, throw a SecurityException.
*/
- Class<?> caller = sun.reflect.Reflection.getCallerClass();
+ Class<?> caller = Reflection.getCallerClass();
if (ReflectUtil.needsPackageAccessCheck(caller.getClassLoader(),
c.getClassLoader())) {
ReflectUtil.checkPackageAccess(c);
--- a/jdk/src/java.sql/share/classes/java/sql/DriverManager.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.sql/share/classes/java/sql/DriverManager.java Wed Jul 05 21:35:27 2017 +0200
@@ -36,8 +36,8 @@
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.stream.Stream;
-import sun.reflect.CallerSensitive;
-import sun.reflect.Reflection;
+import jdk.internal.reflect.CallerSensitive;
+import jdk.internal.reflect.Reflection;
/**
--- a/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/TransformService.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/TransformService.java Wed Jul 05 21:35:27 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2015, 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
@@ -138,7 +138,8 @@
*
* @implNote
* The JDK Reference Implementation additionally uses the
- * {@code jdk.security.provider.preferred} property to determine
+ * {@code jdk.security.provider.preferred}
+ * {@link Security#getProperty(String) Security} property to determine
* the preferred provider order for the specified algorithm. This
* may be different than the order of providers returned by
* {@link Security#getProviders() Security.getProviders()}.
--- a/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/XMLSignatureFactory.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/XMLSignatureFactory.java Wed Jul 05 21:35:27 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2015, 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
@@ -175,7 +175,8 @@
*
* @implNote
* The JDK Reference Implementation additionally uses the
- * {@code jdk.security.provider.preferred} property to determine
+ * {@code jdk.security.provider.preferred}
+ * {@link Security#getProperty(String) Security} property to determine
* the preferred provider order for the specified algorithm. This
* may be different than the order of providers returned by
* {@link Security#getProviders() Security.getProviders()}.
--- a/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/keyinfo/KeyInfoFactory.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/keyinfo/KeyInfoFactory.java Wed Jul 05 21:35:27 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2015, 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
@@ -131,7 +131,8 @@
*
* @implNote
* The JDK Reference Implementation additionally uses the
- * {@code jdk.security.provider.preferred} property to determine
+ * {@code jdk.security.provider.preferred}
+ * {@link Security#getProperty(String) Security} property to determine
* the preferred provider order for the specified algorithm. This
* may be different than the order of providers returned by
* {@link Security#getProviders() Security.getProviders()}.
@@ -272,7 +273,8 @@
*
* @implNote
* The JDK Reference Implementation additionally uses the
- * {@code jdk.security.provider.preferred} property to determine
+ * {@code jdk.security.provider.preferred}
+ * {@link Security#getProperty(String) Security} property to determine
* the preferred provider order for the specified algorithm. This
* may be different than the order of providers returned by
* {@link Security#getProviders() Security.getProviders()}.
--- a/jdk/src/jdk.crypto.pkcs11/share/classes/sun/security/pkcs11/P11KeyPairGenerator.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/jdk.crypto.pkcs11/share/classes/sun/security/pkcs11/P11KeyPairGenerator.java Wed Jul 05 21:35:27 2017 +0200
@@ -141,6 +141,7 @@
}
// see JCA spec
+ @Override
public void initialize(int keySize, SecureRandom random) {
token.ensureValid();
try {
@@ -162,6 +163,7 @@
}
// see JCA spec
+ @Override
public void initialize(AlgorithmParameterSpec params, SecureRandom random)
throws InvalidAlgorithmParameterException {
token.ensureValid();
@@ -173,7 +175,7 @@
}
DHParameterSpec dhParams = (DHParameterSpec) params;
tmpKeySize = dhParams.getP().bitLength();
- checkKeySize(tmpKeySize, null);
+ checkKeySize(tmpKeySize, dhParams);
// XXX sanity check params
} else if (algorithm.equals("RSA")) {
if (params instanceof RSAKeyGenParameterSpec == false) {
@@ -195,7 +197,7 @@
}
DSAParameterSpec dsaParams = (DSAParameterSpec) params;
tmpKeySize = dsaParams.getP().bitLength();
- checkKeySize(tmpKeySize, null);
+ checkKeySize(tmpKeySize, dsaParams);
// XXX sanity check params
} else if (algorithm.equals("EC")) {
ECParameterSpec ecParams;
@@ -220,7 +222,7 @@
("ECParameterSpec or ECGenParameterSpec required for EC");
}
tmpKeySize = ecParams.getCurve().getField().getFieldSize();
- checkKeySize(tmpKeySize, null);
+ checkKeySize(tmpKeySize, ecParams);
} else {
throw new ProviderException("Unknown algorithm: " + algorithm);
}
@@ -229,40 +231,45 @@
this.random = random;
}
- // NOTE: 'params' is only used for checking RSA keys currently.
- private void checkKeySize(int keySize, RSAKeyGenParameterSpec params)
+ private void checkKeySize(int keySize, AlgorithmParameterSpec params)
throws InvalidAlgorithmParameterException {
// check native range first
if ((minKeySize != -1) && (keySize < minKeySize)) {
throw new InvalidAlgorithmParameterException(algorithm +
- " key must be at least " + minKeySize + " bits");
+ " key must be at least " + minKeySize + " bits. " +
+ "The specific key size " + keySize + " is not supported");
}
if ((maxKeySize != -1) && (keySize > maxKeySize)) {
throw new InvalidAlgorithmParameterException(algorithm +
- " key must be at most " + maxKeySize + " bits");
+ " key must be at most " + maxKeySize + " bits. " +
+ "The specific key size " + keySize + " is not supported");
}
// check our own algorithm-specific limits also
if (algorithm.equals("EC")) {
if (keySize < 112) {
- throw new InvalidAlgorithmParameterException
- ("Key size must be at least 112 bit");
+ throw new InvalidAlgorithmParameterException(
+ "EC key size must be at least 112 bit. " +
+ "The specific key size " + keySize + " is not supported");
}
if (keySize > 2048) {
// sanity check, nobody really wants keys this large
- throw new InvalidAlgorithmParameterException
- ("Key size must be at most 2048 bit");
+ throw new InvalidAlgorithmParameterException(
+ "EC key size must be at most 2048 bit. " +
+ "The specific key size " + keySize + " is not supported");
}
} else {
// RSA, DH, DSA
if (keySize < 512) {
- throw new InvalidAlgorithmParameterException
- ("Key size must be at least 512 bit");
+ throw new InvalidAlgorithmParameterException(algorithm +
+ " key size must be at least 512 bit. " +
+ "The specific key size " + keySize + " is not supported");
}
if (algorithm.equals("RSA")) {
BigInteger tmpExponent = rsaPublicExponent;
if (params != null) {
- tmpExponent = params.getPublicExponent();
+ tmpExponent =
+ ((RSAKeyGenParameterSpec)params).getPublicExponent();
}
try {
// Reuse the checking in SunRsaSign provider.
@@ -272,31 +279,55 @@
minKeySize,
(maxKeySize==-1? Integer.MAX_VALUE:maxKeySize));
} catch (InvalidKeyException e) {
- throw new InvalidAlgorithmParameterException(e.getMessage());
+ throw new InvalidAlgorithmParameterException(e);
}
- } else {
- if (algorithm.equals("DH") && (params != null)) {
+ } else if (algorithm.equals("DH")) {
+ if (params != null) { // initialized with specified parameters
// sanity check, nobody really wants keys this large
if (keySize > 64 * 1024) {
- throw new InvalidAlgorithmParameterException
- ("Key size must be at most 65536 bit");
+ throw new InvalidAlgorithmParameterException(
+ "DH key size must be at most 65536 bit. " +
+ "The specific key size " +
+ keySize + " is not supported");
+ }
+ } else { // default parameters will be used.
+ // Range is based on the values in
+ // sun.security.provider.ParameterCache class.
+ if ((keySize > 8192) || (keySize < 512) ||
+ ((keySize & 0x3f) != 0)) {
+ throw new InvalidAlgorithmParameterException(
+ "DH key size must be multiple of 64, and can " +
+ "only range from 512 to 8192 (inclusive). " +
+ "The specific key size " +
+ keySize + " is not supported");
}
- } else {
- // this restriction is in the spec for DSA
- // since we currently use DSA parameters for DH as well,
- // it also applies to DH if no parameters are specified
- if ((keySize != 2048) &&
+
+ DHParameterSpec cache =
+ ParameterCache.getCachedDHParameterSpec(keySize);
+ // Except 2048 and 3072, not yet support generation of
+ // parameters bigger than 1024 bits.
+ if ((cache == null) && (keySize > 1024)) {
+ throw new InvalidAlgorithmParameterException(
+ "Unsupported " + keySize +
+ "-bit DH parameter generation");
+ }
+ }
+ } else {
+ // this restriction is in the spec for DSA
+ if ((keySize != 3072) && (keySize != 2048) &&
((keySize > 1024) || ((keySize & 0x3f) != 0))) {
- throw new InvalidAlgorithmParameterException(algorithm +
- " key must be multiples of 64 if less than 1024 bits" +
- ", or 2048 bits");
- }
+ throw new InvalidAlgorithmParameterException(
+ "DSA key must be multiples of 64 if less than " +
+ "1024 bits, or 2048, 3072 bits. " +
+ "The specific key size " +
+ keySize + " is not supported");
}
}
}
}
// see JCA spec
+ @Override
public KeyPair generateKeyPair() {
token.ensureValid();
CK_ATTRIBUTE[] publicKeyTemplate;
--- a/jdk/src/jdk.rmic/share/classes/jdk/rmi/rmic/Main.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * 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.rmi.rmic;
-
-/**
- * The initial class for the rmic tool.
- */
-
-public class Main {
- public static void main(String[] args) {
- sun.rmi.rmic.Main.main(args);
- }
-}
--- a/jdk/src/jdk.rmic/share/classes/module-info.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/jdk.rmic/share/classes/module-info.java Wed Jul 05 21:35:27 2017 +0200
@@ -27,6 +27,5 @@
requires java.corba;
requires jdk.compiler;
requires jdk.javadoc;
- exports jdk.rmi.rmic;
}
--- a/jdk/src/jdk.unsupported/share/classes/module-info.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/jdk.unsupported/share/classes/module-info.java Wed Jul 05 21:35:27 2017 +0200
@@ -25,6 +25,6 @@
module jdk.unsupported {
exports sun.misc;
- //exports sun.reflect;
+ exports sun.reflect;
}
--- a/jdk/src/jdk.unsupported/share/classes/sun/misc/Unsafe.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/src/jdk.unsupported/share/classes/sun/misc/Unsafe.java Wed Jul 05 21:35:27 2017 +0200
@@ -27,8 +27,8 @@
import jdk.internal.vm.annotation.ForceInline;
import jdk.internal.misc.VM;
-import sun.reflect.CallerSensitive;
-import sun.reflect.Reflection;
+import jdk.internal.reflect.CallerSensitive;
+import jdk.internal.reflect.Reflection;
import java.lang.reflect.Field;
import java.security.ProtectionDomain;
@@ -55,7 +55,7 @@
public final class Unsafe {
static {
- sun.reflect.Reflection.registerMethodsToFilter(Unsafe.class, "getUnsafe");
+ Reflection.registerMethodsToFilter(Unsafe.class, "getUnsafe");
}
private Unsafe() {}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.unsupported/share/classes/sun/reflect/Reflection.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2001, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.reflect;
+
+public class Reflection {
+
+ private Reflection() { }
+
+ /**
+ * @deprecated This method is an internal API and will be removed.
+ * Use {@link StackWalker} to walk the stack and obtain the caller class
+ * with {@link StackWalker.StackFrame#getDeclaringClass} instead.
+ */
+ @Deprecated(forRemoval=true)
+ public static Class<?> getCallerClass(int depth) {
+ if (depth < 0)
+ throw new InternalError("depth must be positive");
+
+ // increase depth to account for delegation to the internal impl
+ return jdk.internal.reflect.Reflection.getCallerClass(depth + 1);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.unsupported/share/classes/sun/reflect/ReflectionFactory.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2001, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.reflect;
+
+import java.lang.reflect.Constructor;
+import java.security.AccessController;
+import java.security.Permission;
+import java.security.PrivilegedAction;
+
+public class ReflectionFactory {
+
+ private static final ReflectionFactory soleInstance = new ReflectionFactory();
+ private final jdk.internal.reflect.ReflectionFactory delegate;
+
+ private ReflectionFactory() {
+ delegate = AccessController.doPrivileged(
+ new PrivilegedAction<jdk.internal.reflect.ReflectionFactory>() {
+ public jdk.internal.reflect.ReflectionFactory run() {
+ return jdk.internal.reflect.ReflectionFactory.getReflectionFactory();
+ }
+ });
+ }
+
+ private static final Permission REFLECTION_FACTORY_ACCESS_PERM
+ = new RuntimePermission("reflectionFactoryAccess");
+
+ /**
+ * Provides the caller with the capability to instantiate reflective
+ * objects.
+ *
+ * <p> First, if there is a security manager, its {@code checkPermission}
+ * method is called with a {@link java.lang.RuntimePermission} with target
+ * {@code "reflectionFactoryAccess"}. This may result in a securit
+ * exception.
+ *
+ * <p> The returned {@code ReflectionFactory} object should be carefully
+ * guarded by the caller, since it can be used to read and write private
+ * data and invoke private methods, as well as to load unverified bytecodes.
+ * It must never be passed to untrusted code.
+ *
+ * @throws SecurityException if a security manager exists and its
+ * {@code checkPermission} method doesn't allow access to
+ * the RuntimePermission "reflectionFactoryAccess".
+ */
+ public static ReflectionFactory getReflectionFactory() {
+ SecurityManager security = System.getSecurityManager();
+ if (security != null) {
+ security.checkPermission(REFLECTION_FACTORY_ACCESS_PERM);
+ }
+ return soleInstance;
+ }
+
+ public Constructor<?> newConstructorForSerialization(Class<?> classToInstantiate,
+ Constructor<?> constructorToCall)
+ {
+ return delegate.newConstructorForSerialization(classToInstantiate,
+ constructorToCall);
+ }
+}
+
--- a/jdk/test/Makefile Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/Makefile Wed Jul 05 21:35:27 2017 +0200
@@ -125,6 +125,24 @@
JTREG_NATIVE_PATH = -nativepath:$(shell $(GETMIXEDPATH) "$(TESTNATIVE_DIR)/jdk/jtreg/native")
endif
+# jtreg failure handler config
+ifeq ($(FAILURE_HANDLER_DIR), )
+ ifneq ($(TESTNATIVE_DIR), )
+ FAILURE_HANDLER_DIR := $(TESTNATIVE_DIR)/failure_handler
+ endif
+endif
+ifneq ($(FAILURE_HANDLER_DIR), )
+ FAILURE_HANDLER_DIR_MIXED := $(shell $(GETMIXEDPATH) "$(FAILURE_HANDLER_DIR)")
+ JTREG_FAILURE_HANDLER_OPTIONS := \
+ -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
+ ifeq ($(UNAME_S), CYGWIN)
+ JTREG_FAILURE_HANDLER_OPTIONS += -J-Djava.library.path="$(FAILURE_HANDLER_DIR_MIXED)"
+ endif
+endif
+
# Expect JPRT to set JPRT_ARCHIVE_BUNDLE (path to zip bundle for results)
ifdef JPRT_ARCHIVE_BUNDLE
ARCHIVE_BUNDLE = $(JPRT_ARCHIVE_BUNDLE)
@@ -329,6 +347,7 @@
-w:$(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/JTwork") \
-jdk:$(shell $(GETMIXEDPATH) "$(PRODUCT_HOME)") \
$(JTREG_NATIVE_PATH) \
+ $(JTREG_FAILURE_HANDLER_OPTIONS) \
$(JTREG_EXCLUSIONS) \
$(JTREG_TEST_OPTIONS) \
$(TEST_SELECTION) \
--- a/jdk/test/ProblemList.txt Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/ProblemList.txt Wed Jul 05 21:35:27 2017 +0200
@@ -153,8 +153,6 @@
javax/management/remote/mandatory/notif/NotifReconnectDeadlockTest.java 8042215 generic-all
-sun/management/jmxremote/bootstrap/JMXInterfaceBindingTest.java 8147985 generic-all
-
############################################################################
# jdk_net
@@ -236,7 +234,7 @@
sun/security/pkcs11/MessageDigest/ReinitDigest.java 8077138,8023434 windows-all
sun/security/pkcs11/MessageDigest/TestCloning.java 8077138,8023434 windows-all
sun/security/pkcs11/Provider/ConfigQuotedString.sh 8077138,8023434 windows-all
-sun/security/pkcs11/Provider/Login.sh 8077138,8023434,8153545 windows-all,linux-all
+sun/security/pkcs11/Provider/Login.sh 8077138,8023434 windows-all
sun/security/pkcs11/SampleTest.java 8077138,8023434 windows-all
sun/security/pkcs11/Secmod/AddPrivateKey.java 8077138,8023434 windows-all
sun/security/pkcs11/Secmod/AddTrustedCert.java 8077138,8023434 windows-all
@@ -337,6 +335,10 @@
com/sun/jdi/GetLocalVariables4Test.sh 8067354 windows-all
+com/sun/jdi/InterfaceMethodsTest.java 8152586 generic-all
+
+com/sun/jdi/InvokeTest.java 8152586 generic-all
+
############################################################################
# jdk_util
--- a/jdk/test/TEST.groups Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/TEST.groups Wed Jul 05 21:35:27 2017 +0200
@@ -76,6 +76,7 @@
sun/invoke \
sun/misc \
sun/reflect \
+ jdk/internal/reflect \
jdk/lambda \
jdk/internal/misc \
jdk/internal/ref \
@@ -495,8 +496,8 @@
sun/management/jmxremote/bootstrap/CustomLauncherTest.java \
sun/misc/JarIndex/metaInfFilenames/Basic.java \
sun/misc/JarIndex/JarIndexMergeForClassLoaderTest.java \
- sun/reflect/CallerSensitive/CallerSensitiveFinder.java \
- sun/reflect/CallerSensitive/MissingCallerSensitive.java \
+ jdk/internal/reflect/CallerSensitive/CallerSensitiveFinder.java \
+ jdk/internal/reflect/CallerSensitive/MissingCallerSensitive.java \
sun/security/util/Resources/NewNamesFormat.java \
vm/verifier/defaultMethods/DefaultMethodRegressionTestsRun.java \
javax/xml/ws/clientjar/TestWsImport.java \
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/com/sun/crypto/provider/KeyAgreement/SupportedDHKeys.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,110 @@
+/*
+ * 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 8072452
+ * @summary Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
+ */
+
+import java.math.BigInteger;
+
+import java.security.*;
+import javax.crypto.*;
+import javax.crypto.interfaces.*;
+import javax.crypto.spec.*;
+
+public class SupportedDHKeys {
+
+ /*
+ * Sizes and values for various lengths.
+ */
+ private enum SupportedKeySize {
+ dhp512(512), dhp768(768), dhp832(832),
+ dhp1024(1024), dhp1536(1536), dhp2048(2048),
+ dhp3072(3072), dhp4096(4096), dhp6144(6144),
+ dhp8192(8192);
+
+ final int primeSize;
+
+ SupportedKeySize(int primeSize) {
+ this.primeSize = primeSize;
+ }
+ }
+
+ public static void main(String[] args) throws Exception {
+ for (SupportedKeySize keySize : SupportedKeySize.values()) {
+ System.out.println("Checking " + keySize.primeSize + " ...");
+ KeyPairGenerator kpg = KeyPairGenerator.getInstance("DH", "SunJCE");
+ kpg.initialize(keySize.primeSize);
+ KeyPair kp = kpg.generateKeyPair();
+ checkKeyPair(kp, keySize.primeSize);
+
+ DHPublicKey publicKey = (DHPublicKey)kp.getPublic();
+ BigInteger p = publicKey.getParams().getP();
+ BigInteger g = publicKey.getParams().getG();
+ kpg.initialize(new DHParameterSpec(p, g));
+ kp = kpg.generateKeyPair();
+ checkKeyPair(kp, keySize.primeSize);
+ }
+ }
+
+ private static void checkKeyPair(KeyPair kp, int pSize) throws Exception {
+
+ DHPrivateKey privateKey = (DHPrivateKey)kp.getPrivate();
+ BigInteger p = privateKey.getParams().getP();
+ if (p.bitLength() != pSize) {
+ throw new Exception(
+ "Invalid modulus size: " + p.bitLength() + "/" + pSize);
+ }
+
+ // System.out.println("P(" + pSize + "): " + p.toString());
+ if (!p.isProbablePrime(128)) {
+ throw new Exception("Good luck, the modulus is composite!");
+ }
+
+ DHPublicKey publicKey = (DHPublicKey)kp.getPublic();
+ p = publicKey.getParams().getP();
+ if (p.bitLength() != pSize) {
+ throw new Exception(
+ "Invalid modulus size: " + p.bitLength() + "/" + pSize);
+ }
+
+ BigInteger leftOpen = BigInteger.ONE;
+ BigInteger rightOpen = p.subtract(BigInteger.ONE);
+
+ BigInteger x = privateKey.getX();
+ if ((x.compareTo(leftOpen) <= 0) ||
+ (x.compareTo(rightOpen) >= 0)) {
+ throw new Exception(
+ "X outside range [2, p - 2]: x: " + x + " p: " + p);
+ }
+
+ BigInteger y = publicKey.getY();
+ if ((y.compareTo(leftOpen) <= 0) ||
+ (y.compareTo(rightOpen) >= 0)) {
+ throw new Exception(
+ "Y outside range [2, p - 2]: x: " + x + " p: " + p);
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/com/sun/crypto/provider/KeyAgreement/SupportedDHParamGens.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,98 @@
+/*
+ * 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 8072452
+ * @summary Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
+ * @run main/timeout=300 SupportedDHParamGens 512
+ * @run main/timeout=300 SupportedDHParamGens 768
+ * @run main/timeout=300 SupportedDHParamGens 832
+ * @run main/timeout=300 SupportedDHParamGens 1024
+ * @run main/timeout=300 SupportedDHParamGens 2048
+ * @run main/timeout=450 SupportedDHParamGens 3072
+ */
+
+import java.math.BigInteger;
+
+import java.security.*;
+import javax.crypto.*;
+import javax.crypto.interfaces.*;
+import javax.crypto.spec.*;
+
+public class SupportedDHParamGens {
+
+ public static void main(String[] args) throws Exception {
+ int primeSize = Integer.valueOf(args[0]).intValue();
+
+ System.out.println("Checking " + primeSize + " ...");
+ AlgorithmParameterGenerator apg =
+ AlgorithmParameterGenerator.getInstance("DH", "SunJCE");
+ apg.init(primeSize);
+ AlgorithmParameters ap = apg.generateParameters();
+ DHParameterSpec spec = ap.getParameterSpec(DHParameterSpec.class);
+
+ KeyPairGenerator kpg = KeyPairGenerator.getInstance("DH", "SunJCE");
+ kpg.initialize(spec);
+ KeyPair kp = kpg.generateKeyPair();
+ checkKeyPair(kp, primeSize);
+ }
+
+ private static void checkKeyPair(KeyPair kp, int pSize) throws Exception {
+
+ DHPrivateKey privateKey = (DHPrivateKey)kp.getPrivate();
+ BigInteger p = privateKey.getParams().getP();
+ if (p.bitLength() != pSize) {
+ throw new Exception(
+ "Invalid modulus size: " + p.bitLength() + "/" + pSize);
+ }
+
+ if (!p.isProbablePrime(128)) {
+ throw new Exception("Good luck, the modulus is composite!");
+ }
+
+ DHPublicKey publicKey = (DHPublicKey)kp.getPublic();
+ p = publicKey.getParams().getP();
+ if (p.bitLength() != pSize) {
+ throw new Exception(
+ "Invalid modulus size: " + p.bitLength() + "/" + pSize);
+ }
+
+ BigInteger leftOpen = BigInteger.ONE;
+ BigInteger rightOpen = p.subtract(BigInteger.ONE);
+
+ BigInteger x = privateKey.getX();
+ if ((x.compareTo(leftOpen) <= 0) ||
+ (x.compareTo(rightOpen) >= 0)) {
+ throw new Exception(
+ "X outside range [2, p - 2]: x: " + x + " p: " + p);
+ }
+
+ BigInteger y = publicKey.getY();
+ if ((y.compareTo(leftOpen) <= 0) ||
+ (y.compareTo(rightOpen) >= 0)) {
+ throw new Exception(
+ "Y outside range [2, p - 2]: x: " + x + " p: " + p);
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/com/sun/crypto/provider/KeyAgreement/UnsupportedDHKeys.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,73 @@
+/*
+ * 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 8072452
+ * @summary Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
+ */
+
+import java.math.BigInteger;
+
+import java.security.*;
+import javax.crypto.*;
+import javax.crypto.interfaces.*;
+import javax.crypto.spec.*;
+
+public class UnsupportedDHKeys {
+
+ /*
+ * Sizes and values for various lengths.
+ */
+ private enum UnsupportedKeySize {
+ // not multiple of 64
+ dhp513(513), dhp769(769), dhp895(895),
+ dhp1023(1023), dhp1535(1535), dhp2047(2047),
+
+ // unsupported
+ dhp2176(2176), dhp3008(3008), dhp4032(4032),
+ dhp5120(5120), dhp6400(6400), dhp7680(7680),
+ dhp8191(8191), dhp8128(8128), dhp8260(8260);
+
+ final int primeSize;
+
+ UnsupportedKeySize(int primeSize) {
+ this.primeSize = primeSize;
+ }
+ }
+
+ public static void main(String[] args) throws Exception {
+ for (UnsupportedKeySize keySize : UnsupportedKeySize.values()) {
+ try {
+ System.out.println("Checking " + keySize.primeSize + " ...");
+ KeyPairGenerator kpg =
+ KeyPairGenerator.getInstance("DH", "SunJCE");
+ kpg.initialize(keySize.primeSize);
+
+ throw new Exception("Should not support " + keySize.primeSize);
+ } catch (InvalidParameterException ipe) {
+ System.out.println("\tOk, unsupported");
+ }
+ }
+ }
+}
--- a/jdk/test/com/sun/jdi/InterruptHangTest.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/com/sun/jdi/InterruptHangTest.java Wed Jul 05 21:35:27 2017 +0200
@@ -153,14 +153,17 @@
timerThread = new Thread("test timer") {
public void run() {
int mySteps = 0;
+ float timeoutFactor = Float.parseFloat(System.getProperty("test.timeout.factor", "1.0"));
+ long sleepSeconds = (long)(20 * timeoutFactor);
+ println("Timer watching for steps every " + sleepSeconds + " seconds");
while (true) {
try {
- Thread.sleep(20000);
+ Thread.sleep(sleepSeconds * 1000);
synchronized(sync) {
- System.out.println("steps = " + nSteps);
+ println("steps = " + nSteps);
if (mySteps == nSteps) {
- // no step for 10 secs
- failure("failure: Debuggee appears to be hung");
+ // no step for a long time
+ failure("failure: Debuggee appears to be hung (no steps for " + sleepSeconds + "s)");
vm().exit(-1);
break;
}
--- a/jdk/test/com/sun/jdi/ShellScaffold.sh Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/com/sun/jdi/ShellScaffold.sh Wed Jul 05 21:35:27 2017 +0200
@@ -131,6 +131,9 @@
# This can be increased if timing seems to be an issue.
sleep_seconds=1
+if [ -n "$TIMEOUT_FACTOR" ] ; then
+ sleep_seconds=$(echo $TIMEOUT_FACTOR $sleep_seconds | awk '{printf "%d\n", int($1 * $2)}')
+fi
echo "ShellScaffold.sh: Version" >& 2
topPid=$$
--- a/jdk/test/com/sun/jdi/TestScaffold.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/com/sun/jdi/TestScaffold.java Wed Jul 05 21:35:27 2017 +0200
@@ -64,6 +64,7 @@
boolean vmDisconnected = false;
final String[] args;
protected boolean testFailed = false;
+ protected long startTime;
static private class ArgInfo {
String targetVMArgs = "";
@@ -425,6 +426,7 @@
abstract protected void runTests() throws Exception;
final public void startTests() throws Exception {
+ startTime = System.currentTimeMillis();
try {
runTests();
} finally {
@@ -433,7 +435,8 @@
}
protected void println(String str) {
- System.err.println(str);
+ long elapsed = System.currentTimeMillis() - startTime;
+ System.err.println("[" + elapsed + "ms] " + str);
}
protected void print(String str) {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/Math/FusedMultiplyAddTests.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,385 @@
+/*
+ * 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 4851642
+ * @summary Tests for Math.fusedMac and StrictMath.fusedMac.
+ * @build Tests
+ * @build FusedMultiplyAddTests
+ * @run main FusedMultiplyAddTests
+ */
+
+/**
+ * The specifications for both Math.fusedMac and StrictMath.fusedMac
+ * are the same and both are exactly specified. Therefore, both
+ * methods are tested in this file.
+ */
+
+public class FusedMultiplyAddTests {
+ private FusedMultiplyAddTests(){}
+
+ private static final double Infinity = Double.POSITIVE_INFINITY;
+ private static final float InfinityF = Float.POSITIVE_INFINITY;
+ private static final double NaN = Double.NaN;
+ private static final float NaNf = Float.NaN;
+
+ public static void main(String... args) {
+ int failures = 0;
+
+ failures += testNonFiniteD();
+ failures += testZeroesD();
+ failures += testSimpleD();
+
+ failures += testNonFiniteF();
+ failures += testZeroesF();
+ failures += testSimpleF();
+
+ if (failures > 0) {
+ System.err.println("Testing fma incurred "
+ + failures + " failures.");
+ throw new RuntimeException();
+ }
+ }
+
+ private static int testNonFiniteD() {
+ int failures = 0;
+
+ double [][] testCases = {
+ {Infinity, Infinity, Infinity,
+ Infinity,
+ },
+
+ {-Infinity, Infinity, -Infinity,
+ -Infinity,
+ },
+
+ {-Infinity, Infinity, Infinity,
+ NaN,
+ },
+
+ {Infinity, Infinity, -Infinity,
+ NaN,
+ },
+
+ {1.0, Infinity, 2.0,
+ Infinity,
+ },
+
+ {1.0, 2.0, Infinity,
+ Infinity,
+ },
+
+ {Infinity, 1.0, Infinity,
+ Infinity,
+ },
+
+ {Double.MAX_VALUE, 2.0, -Infinity,
+ -Infinity},
+
+ {Infinity, 1.0, -Infinity,
+ NaN,
+ },
+
+ {-Infinity, 1.0, Infinity,
+ NaN,
+ },
+
+ {1.0, NaN, 2.0,
+ NaN,
+ },
+
+ {1.0, 2.0, NaN,
+ NaN,
+ },
+
+ {Infinity, 2.0, NaN,
+ NaN,
+ },
+
+ {NaN, 2.0, Infinity,
+ NaN,
+ },
+ };
+
+ for (double[] testCase: testCases)
+ failures += testFusedMacCase(testCase[0], testCase[1], testCase[2], testCase[3]);
+
+ return failures;
+ }
+
+ private static int testZeroesD() {
+ int failures = 0;
+
+ double [][] testCases = {
+ {+0.0, +0.0, +0.0,
+ +0.0,
+ },
+
+ {-0.0, +0.0, +0.0,
+ +0.0,
+ },
+
+ {+0.0, +0.0, -0.0,
+ +0.0,
+ },
+
+ {+0.0, +0.0, -0.0,
+ +0.0,
+ },
+
+ {-0.0, +0.0, -0.0,
+ -0.0,
+ },
+
+ {-0.0, -0.0, -0.0,
+ +0.0,
+ },
+
+ {-1.0, +0.0, -0.0,
+ -0.0,
+ },
+
+ {-1.0, +0.0, +0.0,
+ +0.0,
+ },
+
+ {-2.0, +0.0, -0.0,
+ -0.0,
+ },
+
+ {-2.0, +0.0, +0.0,
+ +0.0,
+ },
+ };
+
+ for (double[] testCase: testCases)
+ failures += testFusedMacCase(testCase[0], testCase[1], testCase[2], testCase[3]);
+
+ return failures;
+ }
+
+ private static int testSimpleD() {
+ int failures = 0;
+
+ double [][] testCases = {
+ {1.0, 2.0, 3.0,
+ 5.0,},
+
+ {1.0, 2.0, -2.0,
+ 0.0,},
+
+ {5.0, 5.0, -25.0,
+ 0.0,},
+
+ {Double.MAX_VALUE, 2.0, -Double.MAX_VALUE,
+ Double.MAX_VALUE},
+
+ {Double.MAX_VALUE, 2.0, 1.0,
+ Infinity},
+
+ {Double.MIN_VALUE, -Double.MIN_VALUE, +0.0,
+ -0.0},
+
+ {Double.MIN_VALUE, -Double.MIN_VALUE, -0.0,
+ -0.0},
+
+ {Double.MIN_VALUE, Double.MIN_VALUE, +0.0,
+ +0.0},
+
+ {Double.MIN_VALUE, Double.MIN_VALUE, -0.0,
+ +0.0},
+
+ {Double.MIN_VALUE, +0.0, -0.0,
+ +0.0},
+
+ {Double.MIN_VALUE, -0.0, -0.0,
+ -0.0},
+
+ {Double.MIN_VALUE, +0.0, +0.0,
+ +0.0},
+
+ {Double.MIN_VALUE, -0.0, +0.0,
+ +0.0},
+ };
+
+ for (double[] testCase: testCases)
+ failures += testFusedMacCase(testCase[0], testCase[1], testCase[2], testCase[3]);
+
+ return failures;
+ }
+
+ private static int testNonFiniteF() {
+ int failures = 0;
+
+ float [][] testCases = {
+ {1.0f, InfinityF, 2.0f,
+ InfinityF,
+ },
+
+ {1.0f, 2.0f, InfinityF,
+ InfinityF,
+ },
+
+ {InfinityF, 1.0f, InfinityF,
+ InfinityF,
+ },
+
+ {Float.MAX_VALUE, 2.0f, -InfinityF,
+ -InfinityF},
+
+ {InfinityF, 1.0f, -InfinityF,
+ NaNf,
+ },
+
+ {-InfinityF, 1.0f, InfinityF,
+ NaNf,
+ },
+
+ {1.0f, NaNf, 2.0f,
+ NaNf,
+ },
+
+ {1.0f, 2.0f, NaNf,
+ NaNf,
+ },
+
+ {InfinityF, 2.0f, NaNf,
+ NaNf,
+ },
+
+ {NaNf, 2.0f, InfinityF,
+ NaNf,
+ },
+ };
+
+ for (float[] testCase: testCases)
+ failures += testFusedMacCase(testCase[0], testCase[1], testCase[2], testCase[3]);
+
+ return failures;
+ }
+
+ private static int testZeroesF() {
+ int failures = 0;
+
+ float [][] testCases = {
+ {+0.0f, +0.0f, +0.0f,
+ +0.0f,
+ },
+
+ {-0.0f, +0.0f, +0.0f,
+ +0.0f,
+ },
+
+ {+0.0f, +0.0f, -0.0f,
+ +0.0f,
+ },
+
+ {+0.0f, +0.0f, -0.0f,
+ +0.0f,
+ },
+
+ {-0.0f, +0.0f, -0.0f,
+ -0.0f,
+ },
+
+ {-0.0f, -0.0f, -0.0f,
+ +0.0f,
+ },
+
+ {-1.0f, +0.0f, -0.0f,
+ -0.0f,
+ },
+
+ {-1.0f, +0.0f, +0.0f,
+ +0.0f,
+ },
+
+ {-2.0f, +0.0f, -0.0f,
+ -0.0f,
+ },
+ };
+
+ for (float[] testCase: testCases)
+ failures += testFusedMacCase(testCase[0], testCase[1], testCase[2], testCase[3]);
+
+ return failures;
+ }
+
+ private static int testSimpleF() {
+ int failures = 0;
+
+ float [][] testCases = {
+ {1.0f, 2.0f, 3.0f,
+ 5.0f,},
+
+ {1.0f, 2.0f, -2.0f,
+ 0.0f,},
+
+ {5.0f, 5.0f, -25.0f,
+ 0.0f,},
+
+ {Float.MAX_VALUE, 2.0f, -Float.MAX_VALUE,
+ Float.MAX_VALUE},
+
+ {Float.MAX_VALUE, 2.0f, 1.0f,
+ InfinityF},
+ };
+
+ for (float[] testCase: testCases)
+ failures += testFusedMacCase(testCase[0], testCase[1], testCase[2], testCase[3]);
+
+ return failures;
+ }
+
+
+ private static int testFusedMacCase(double input1, double input2, double input3, double expected) {
+ int failures = 0;
+ failures += Tests.test("Math.fma(double)", input1, input2, input3,
+ Math.fma(input1, input2, input3), expected);
+ failures += Tests.test("StrictMath.fma(double)", input1, input2, input3,
+ StrictMath.fma(input1, input2, input3), expected);
+
+ // Permute first two inputs
+ failures += Tests.test("Math.fma(double)", input2, input1, input3,
+ Math.fma(input2, input1, input3), expected);
+ failures += Tests.test("StrictMath.fma(double)", input2, input1, input3,
+ StrictMath.fma(input2, input1, input3), expected);
+ return failures;
+ }
+
+ private static int testFusedMacCase(float input1, float input2, float input3, float expected) {
+ int failures = 0;
+ failures += Tests.test("Math.fma(float)", input1, input2, input3,
+ Math.fma(input1, input2, input3), expected);
+ failures += Tests.test("StrictMath.fma(float)", input1, input2, input3,
+ StrictMath.fma(input1, input2, input3), expected);
+
+ // Permute first two inputs
+ failures += Tests.test("Math.fma(float)", input2, input1, input3,
+ Math.fma(input2, input1, input3), expected);
+ failures += Tests.test("StrictMath.fma(float)", input2, input1, input3,
+ StrictMath.fma(input2, input1, input3), expected);
+ return failures;
+ }
+}
--- a/jdk/test/java/lang/Math/Tests.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/java/lang/Math/Tests.java Wed Jul 05 21:35:27 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2012, 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
@@ -391,6 +391,38 @@
return 0;
}
+ public static int test(String testName,
+ float input1, float input2, float input3,
+ float result, float expected) {
+ if (Float.compare(expected, result ) != 0) {
+ System.err.println("Failure for " + testName + ":\n" +
+ "\tFor inputs " + input1 + "\t(" + toHexString(input1) + ") and "
+ + input2 + "\t(" + toHexString(input2) + ") and"
+ + input3 + "\t(" + toHexString(input3) + ")\n" +
+ "\texpected " + expected + "\t(" + toHexString(expected) + ")\n" +
+ "\tgot " + result + "\t(" + toHexString(result) + ").");
+ return 1;
+ }
+ else
+ return 0;
+ }
+
+ public static int test(String testName,
+ double input1, double input2, double input3,
+ double result, double expected) {
+ if (Double.compare(expected, result ) != 0) {
+ System.err.println("Failure for " + testName + ":\n" +
+ "\tFor inputs " + input1 + "\t(" + toHexString(input1) + ") and "
+ + input2 + "\t(" + toHexString(input2) + ") and"
+ + input3 + "\t(" + toHexString(input3) + ")\n" +
+ "\texpected " + expected + "\t(" + toHexString(expected) + ")\n" +
+ "\tgot " + result + "\t(" + toHexString(result) + ").");
+ return 1;
+ }
+ else
+ return 0;
+ }
+
static int testUlpCore(double result, double expected, double ulps) {
// We assume we won't be unlucky and have an inexact expected
// be nextDown(2^i) when 2^i would be the correctly rounded
--- a/jdk/test/java/lang/SecurityManager/RestrictedPackages.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/java/lang/SecurityManager/RestrictedPackages.java Wed Jul 05 21:35:27 2017 +0200
@@ -77,7 +77,6 @@
"jdk.internal.",
"jdk.nashorn.internal.",
"jdk.nashorn.tools.",
- "jdk.rmi.rmic.",
"jdk.tools.jimage.",
"com.sun.activation.registries.",
"com.sun.java.accessibility.util.internal."
--- a/jdk/test/java/lang/StackWalker/DumpStackTest.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/java/lang/StackWalker/DumpStackTest.java Wed Jul 05 21:35:27 2017 +0200
@@ -85,9 +85,9 @@
new CallFrame(DumpStackTest.class, "test"),
new CallFrame(DumpStackTest.class, "main"),
// if invoked from jtreg
- new CallFrame("sun.reflect.NativeMethodAccessorImpl", "invoke0"), // non-public class
- new CallFrame("sun.reflect.NativeMethodAccessorImpl", "invoke"),
- new CallFrame("sun.reflect.DelegatingMethodAccessorImpl", "invoke"),
+ new CallFrame("jdk.internal.reflect.NativeMethodAccessorImpl", "invoke0"), // non-public class
+ new CallFrame("jdk.internal.reflect.NativeMethodAccessorImpl", "invoke"),
+ new CallFrame("jdk.internal.reflect.DelegatingMethodAccessorImpl", "invoke"),
new CallFrame(Method.class, "invoke"),
new CallFrame(Thread.class, "run"),
};
@@ -141,9 +141,9 @@
new CallFrame(DumpStackTest.class, "testLambda"),
new CallFrame(DumpStackTest.class, "main"),
// if invoked from jtreg
- new CallFrame("sun.reflect.NativeMethodAccessorImpl", "invoke0"),
- new CallFrame("sun.reflect.NativeMethodAccessorImpl", "invoke"),
- new CallFrame("sun.reflect.DelegatingMethodAccessorImpl", "invoke"),
+ new CallFrame("jdk.internal.reflect.NativeMethodAccessorImpl", "invoke0"),
+ new CallFrame("jdk.internal.reflect.NativeMethodAccessorImpl", "invoke"),
+ new CallFrame("jdk.internal.reflect.DelegatingMethodAccessorImpl", "invoke"),
new CallFrame(Method.class, "invoke"),
new CallFrame(Thread.class, "run")
};
@@ -164,16 +164,16 @@
CallFrame[] callStack = new CallFrame[] {
new CallFrame(Thread.class, "getStackTrace"),
new CallFrame(DumpStackTest.class, "methodInvoke"),
- new CallFrame("sun.reflect.NativeMethodAccessorImpl", "invoke0"),
- new CallFrame("sun.reflect.NativeMethodAccessorImpl", "invoke"),
- new CallFrame("sun.reflect.DelegatingMethodAccessorImpl", "invoke"),
+ new CallFrame("jdk.internal.reflect.NativeMethodAccessorImpl", "invoke0"),
+ new CallFrame("jdk.internal.reflect.NativeMethodAccessorImpl", "invoke"),
+ new CallFrame("jdk.internal.reflect.DelegatingMethodAccessorImpl", "invoke"),
new CallFrame(Method.class, "invoke"),
new CallFrame(DumpStackTest.class, "testMethodInvoke"),
new CallFrame(DumpStackTest.class, "main"),
// if invoked from jtreg
- new CallFrame("sun.reflect.NativeMethodAccessorImpl", "invoke0"),
- new CallFrame("sun.reflect.NativeMethodAccessorImpl", "invoke"),
- new CallFrame("sun.reflect.DelegatingMethodAccessorImpl", "invoke"),
+ new CallFrame("jdk.internal.reflect.NativeMethodAccessorImpl", "invoke0"),
+ new CallFrame("jdk.internal.reflect.NativeMethodAccessorImpl", "invoke"),
+ new CallFrame("jdk.internal.reflect.DelegatingMethodAccessorImpl", "invoke"),
new CallFrame(Method.class, "invoke"),
new CallFrame(Thread.class, "run")
};
@@ -199,9 +199,9 @@
new CallFrame(DumpStackTest.class, "testMethodHandle"),
new CallFrame(DumpStackTest.class, "main"),
// if invoked from jtreg
- new CallFrame("sun.reflect.NativeMethodAccessorImpl", "invoke0"),
- new CallFrame("sun.reflect.NativeMethodAccessorImpl", "invoke"),
- new CallFrame("sun.reflect.DelegatingMethodAccessorImpl", "invoke"),
+ new CallFrame("jdk.internal.reflect.NativeMethodAccessorImpl", "invoke0"),
+ new CallFrame("jdk.internal.reflect.NativeMethodAccessorImpl", "invoke"),
+ new CallFrame("jdk.internal.reflect.DelegatingMethodAccessorImpl", "invoke"),
new CallFrame(Method.class, "invoke"),
new CallFrame(Thread.class, "run")
};
--- a/jdk/test/java/lang/StackWalker/EmbeddedStackWalkTest.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/java/lang/StackWalker/EmbeddedStackWalkTest.java Wed Jul 05 21:35:27 2017 +0200
@@ -75,7 +75,7 @@
if (loops == 0) {
String caller = walker.walk(s ->
s.map(StackFrame::getClassName)
- .filter(cn -> !cn.startsWith("sun.reflect.") && !cn.startsWith("java.lang.invoke"))
+ .filter(cn -> !cn.startsWith("jdk.internal.reflect.") && !cn.startsWith("java.lang.invoke"))
.skip(2).findFirst()
).get();
assertEquals(caller, C1.class.getName());
@@ -122,7 +122,7 @@
static void call(StackWalker walker) {
String caller = walker.walk(s ->
s.map(StackFrame::getClassName)
- .filter(cn -> !cn.startsWith("sun.reflect.") && !cn.startsWith("java.lang.invoke"))
+ .filter(cn -> !cn.startsWith("jdk.internal.reflect.") && !cn.startsWith("java.lang.invoke"))
.skip(2).findFirst()
).get();
assertEquals(caller, C2.class.getName());
--- a/jdk/test/java/lang/StackWalker/HiddenFrames.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/java/lang/StackWalker/HiddenFrames.java Wed Jul 05 21:35:27 2017 +0200
@@ -98,7 +98,7 @@
void checkFrame(StackFrame frame) {
String cn = frame.getClassName();
- if (cn.startsWith("java.lang.reflect.") || cn.startsWith("sun.reflect.")) {
+ if (cn.startsWith("java.lang.reflect.") || cn.startsWith("jdk.internal.reflect.")) {
reflects.add(frame);
}
if (cn.contains("$$Lambda$")) {
--- a/jdk/test/java/lang/StackWalker/MultiThreadStackWalk.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/java/lang/StackWalker/MultiThreadStackWalk.java Wed Jul 05 21:35:27 2017 +0200
@@ -46,8 +46,8 @@
public class MultiThreadStackWalk {
static Set<String> infrastructureClasses = new TreeSet<>(Arrays.asList(
- "sun.reflect.NativeMethodAccessorImpl",
- "sun.reflect.DelegatingMethodAccessorImpl",
+ "jdk.internal.reflect.NativeMethodAccessorImpl",
+ "jdk.internal.reflect.DelegatingMethodAccessorImpl",
"java.lang.reflect.Method",
"com.sun.javatest.regtest.MainWrapper$MainThread",
"java.lang.Thread"
--- a/jdk/test/java/lang/StackWalker/StackWalkTest.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/java/lang/StackWalker/StackWalkTest.java Wed Jul 05 21:35:27 2017 +0200
@@ -59,8 +59,8 @@
private static final int MAX_RANDOM_DEPTH = 1000;
static final Set<String> infrastructureClasses = new TreeSet<>(Arrays.asList(
- "sun.reflect.NativeMethodAccessorImpl",
- "sun.reflect.DelegatingMethodAccessorImpl",
+ "jdk.internal.reflect.NativeMethodAccessorImpl",
+ "jdk.internal.reflect.DelegatingMethodAccessorImpl",
"java.lang.reflect.Method",
"com.sun.javatest.regtest.MainWrapper$MainThread",
"com.sun.javatest.regtest.agent.MainWrapper$MainThread",
--- a/jdk/test/java/lang/StackWalker/VerifyStackTrace.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/java/lang/StackWalker/VerifyStackTrace.java Wed Jul 05 21:35:27 2017 +0200
@@ -101,9 +101,9 @@
"2: VerifyStackTrace$Handle.execute(VerifyStackTrace.java:147)\n" +
"3: VerifyStackTrace$Handle.run(VerifyStackTrace.java:160)\n" +
"4: VerifyStackTrace.invoke(VerifyStackTrace.java:190)\n" +
- "5: sun.reflect.NativeMethodAccessorImpl.invoke0(java.base/Native Method)\n" +
- "6: sun.reflect.NativeMethodAccessorImpl.invoke(java.base/NativeMethodAccessorImpl.java:62)\n" +
- "7: sun.reflect.DelegatingMethodAccessorImpl.invoke(java.base/DelegatingMethodAccessorImpl.java:43)\n" +
+ "5: jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(java.base/Native Method)\n" +
+ "6: jdk.internal.reflect.NativeMethodAccessorImpl.invoke(java.base/NativeMethodAccessorImpl.java:62)\n" +
+ "7: jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(java.base/DelegatingMethodAccessorImpl.java:43)\n" +
"8: java.lang.reflect.Method.invoke(java.base/Method.java:520)\n" +
"9: VerifyStackTrace$1.run(VerifyStackTrace.java:220)\n" +
"10: java.security.AccessController.doPrivileged(java.base/Native Method)\n" +
@@ -138,9 +138,9 @@
"5: java.lang.invoke.LambdaForm$MH/1395089624.invoke_MT(java.base/LambdaForm$MH)\n" +
"6: VerifyStackTrace$Handle.run(VerifyStackTrace.java:162)\n" +
"7: VerifyStackTrace.invoke(VerifyStackTrace.java:192)\n" +
- "8: sun.reflect.NativeMethodAccessorImpl.invoke0(java.base/Native Method)\n" +
- "9: sun.reflect.NativeMethodAccessorImpl.invoke(java.base/NativeMethodAccessorImpl.java:62)\n" +
- "10: sun.reflect.DelegatingMethodAccessorImpl.invoke(java.base/DelegatingMethodAccessorImpl.java:43)\n" +
+ "8: jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(java.base/Native Method)\n" +
+ "9: jdk.internal.reflect.NativeMethodAccessorImpl.invoke(java.base/NativeMethodAccessorImpl.java:62)\n" +
+ "10: jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(java.base/DelegatingMethodAccessorImpl.java:43)\n" +
"11: java.lang.reflect.Method.invoke(java.base/Method.java:520)\n" +
"12: VerifyStackTrace$1.run(VerifyStackTrace.java:222)\n" +
"13: java.security.AccessController.doPrivileged(java.base/Native Method)\n" +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/invoke/ConstantIdentityMHTest.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,83 @@
+/*
+ * 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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
+ * @summary unit tests for java.lang.invoke.MethodHandles
+ * @run testng/othervm -ea -esa test.java.lang.invoke.ConstantIdentityMHTest
+ */
+package test.java.lang.invoke;
+
+import java.lang.invoke.MethodHandle;
+import java.lang.invoke.MethodHandles;
+import java.lang.invoke.MethodType;
+import java.util.List;
+import static java.lang.invoke.MethodHandles.*;
+import static java.lang.invoke.MethodType.*;
+import static org.testng.AssertJUnit.*;
+import org.testng.annotations.*;
+
+public class ConstantIdentityMHTest {
+
+ @DataProvider(name = "testZeroData")
+ private Object[][] testZeroData() {
+ return new Object[][] {
+ {void.class, "()void"},
+ {int.class, "()int"},
+ {byte.class, "()byte"},
+ {short.class, "()short"},
+ {long.class, "()long"},
+ {float.class, "()float"},
+ {double.class, "()double"},
+ {boolean.class, "()boolean"},
+ {char.class, "()char"},
+ {Integer.class, "()Integer"}
+ };
+ }
+
+ @Test(dataProvider = "testZeroData")
+ public void testZero(Class<?> expectedtype, String expected) throws Throwable {
+ assertEquals(MethodHandles.zero(expectedtype).type().toString(), expected);
+ }
+
+ @Test
+ @ExpectedExceptions(NullPointerException.class)
+ public void testZeroNPE() {
+ MethodHandle mh = MethodHandles.zero(null);
+ }
+
+ @Test
+ void testEmpty() throws Throwable {
+ MethodHandle cat = lookup().findVirtual(String.class, "concat", methodType(String.class, String.class));
+ assertEquals("xy", (String)cat.invoke("x","y"));
+ MethodHandle mhEmpty = MethodHandles.empty(cat.type());
+ assertEquals(null, (String)mhEmpty.invoke("x","y"));
+ }
+
+ @Test
+ @ExpectedExceptions(NullPointerException.class)
+ void testEmptyNPE() {
+ MethodHandle lenEmptyMH = MethodHandles.empty(null);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/invoke/DropArgumentsTest.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,90 @@
+/*
+ * 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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
+ * @summary unit tests for java.lang.invoke.MethodHandles
+ * @run testng/othervm -ea -esa test.java.lang.invoke.DropArgumentsTest
+ */
+package test.java.lang.invoke;
+
+import java.lang.invoke.MethodHandle;
+import java.lang.invoke.MethodHandles;
+import java.lang.invoke.MethodType;
+import java.util.List;
+import static java.lang.invoke.MethodHandles.*;
+import static java.lang.invoke.MethodType.*;
+import static org.testng.AssertJUnit.*;
+import org.testng.annotations.*;
+
+public class DropArgumentsTest {
+
+ @Test
+ public void testDropArgumentsToMatch() throws Throwable {
+ MethodHandle cat = lookup().findVirtual(String.class, "concat", methodType(String.class, String.class));
+ MethodType bigType = cat.type().insertParameterTypes(0, String.class, String.class, int.class);
+ MethodHandle d0 = MethodHandles.dropArgumentsToMatch(cat, 0, bigType.parameterList(), 3);
+ assertEquals("xy",(String)d0.invokeExact("m", "n", 1, "x", "y"));
+ MethodHandle d1 = MethodHandles.dropArgumentsToMatch(cat, 0, bigType.parameterList(), 0);
+ assertEquals("mn",(String)d1.invokeExact("m", "n", 1, "x", "y"));
+ MethodHandle d2 = MethodHandles.dropArgumentsToMatch(cat, 1, bigType.parameterList(), 4);
+ assertEquals("xy",(String)d2.invokeExact("x", "b", "c", 1, "a", "y"));
+
+ }
+
+ @DataProvider(name = "dropArgumentsToMatchNPEData")
+ private Object[][] dropArgumentsToMatchNPEData()
+ throws NoSuchMethodException, IllegalAccessException {
+ MethodHandle cat = lookup().findVirtual(String.class, "concat", methodType(String.class, String.class));
+ return new Object[][] {
+ { (MethodHandle) null, 0, cat.type().parameterList(), 0 },
+ { cat, 0, null, 0 }
+ };
+ }
+
+ @Test(dataProvider = "dropArgumentsToMatchNPEData")
+ @ExpectedExceptions(NullPointerException.class)
+ public void dropArgumentsToMatchNPE(MethodHandle target, int pos, List<Class<?>> valueType, int skip) {
+ MethodHandles.dropArgumentsToMatch(target, pos, valueType , skip);
+ }
+
+ @DataProvider(name = "dropArgumentsToMatchIAEData")
+ private Object[][] dropArgumentsToMatchIAEData()
+ throws NoSuchMethodException, IllegalAccessException {
+ MethodHandle cat = lookup().findVirtual(String.class, "concat", methodType(String.class, String.class));
+ MethodType bigType = cat.type().insertParameterTypes(0, String.class, String.class, int.class);
+ return new Object[][] {
+ {cat, -1, bigType.parameterList(), 0},
+ {cat, 0, bigType.parameterList(), -1},
+ {cat, 3, bigType.parameterList(), 0},
+ {cat, 0, bigType.parameterList(), 2}
+ };
+ }
+
+ @Test(dataProvider = "dropArgumentsToMatchIAEData")
+ @ExpectedExceptions(IllegalArgumentException.class)
+ public void dropArgumentsToMatchIAE(MethodHandle target, int pos, List<Class<?>> valueType, int skip) {
+ MethodHandles.dropArgumentsToMatch(target, pos, valueType , skip);
+ }
+}
--- a/jdk/test/java/lang/invoke/JavaDocExamplesTest.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/java/lang/invoke/JavaDocExamplesTest.java Wed Jul 05 21:35:27 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009, 2013, 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
@@ -57,7 +57,9 @@
testFindVirtual();
testFindSpecial();
testPermuteArguments();
+ testZero();
testDropArguments();
+ testDropArgumentsToMatch();
testFilterArguments();
testFoldArguments();
testFoldArguments2();
@@ -235,6 +237,17 @@
}}
}
+@Test public void testZero() throws Throwable {
+ {{
+{} /// JAVADOC
+Class<?> type = Double.class;
+MethodHandle mh1 = MethodHandles.explicitCastArguments(MethodHandles.constant(Object.class, null), methodType(type));
+assertEquals("()Double", mh1.type().toString());
+MethodHandle mh2 = MethodHandles.empty(methodType(type));
+assertEquals("()Double", mh2.type().toString());
+ }}
+ }
+
@Test public void testDropArguments() throws Throwable {
{{
{} /// JAVADOC
@@ -262,6 +275,24 @@
}}
}
+ @Test public void testDropArgumentsToMatch() throws Throwable {
+ {{
+{} /// JAVADOC
+MethodHandle h0= constant(boolean.class, true);
+MethodHandle h1 = lookup().findVirtual(String.class, "concat", methodType(String.class, String.class));
+MethodType bigType = h1.type().insertParameterTypes(1, String.class, int.class);
+MethodHandle h2 = dropArguments(h1, 0, bigType.parameterList());
+if (h1.type().parameterCount() < h2.type().parameterCount()) {
+ h1 = dropArgumentsToMatch(h1, 0, h2.type().parameterList(), 0); // lengthen h1
+}
+else {
+ h2 = dropArgumentsToMatch(h2, 0, h1.type().parameterList(), 0); // lengthen h2
+}
+MethodHandle h3 = guardWithTest(h0, h1, h2);
+assertEquals("xy", h3.invoke("x", "y", 1, "a", "b", "c"));
+ }}
+ }
+
@Test public void testFilterArguments() throws Throwable {
{{
{} /// JAVADOC
--- a/jdk/test/java/lang/invoke/LoopCombinatorTest.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/java/lang/invoke/LoopCombinatorTest.java Wed Jul 05 21:35:27 2017 +0200
@@ -26,6 +26,8 @@
/* @test
* @bug 8139885
* @bug 8150635
+ * @bug 8150957
+ * @bug 8153637
* @run testng/othervm -ea -esa test.java.lang.invoke.LoopCombinatorTest
*/
@@ -302,6 +304,18 @@
}
@Test
+ public static void testCountedLoopCounterInit() throws Throwable {
+ // int x = 0; for (int i = 0; i < 5; ++i) { x += i; } return x; => 10
+ // (only if counter's first value in body is 0)
+ MethodHandle iter = MethodHandles.constant(int.class, 5);
+ MethodHandle init = MethodHandles.constant(int.class, 0);
+ MethodHandle body = Counted.MH_addCounter;
+ MethodHandle loop = MethodHandles.countedLoop(iter, init, body);
+ assertEquals(Counted.MT_counterInit, loop.type());
+ assertEquals(10, loop.invoke());
+ }
+
+ @Test
public static void testIterateSum() throws Throwable {
// Integer[] a = new Integer[]{1,2,3,4,5,6}; int sum = 0; for (int e : a) { sum += e; } return sum; => 21
MethodHandle loop = MethodHandles.iteratedLoop(Iterate.MH_sumIterator, Iterate.MH_sumInit, Iterate.MH_sumStep);
@@ -667,12 +681,17 @@
System.out.print("hello");
}
+ static int addCounter(int counter, int x) {
+ return x + counter;
+ }
+
static final Class<Counted> COUNTED = Counted.class;
static final MethodType MT_start = methodType(String.class, String.class);
static final MethodType MT_step = methodType(String.class, int.class, String.class, String.class);
static final MethodType MT_stepUpdateArray = methodType(void.class, int.class, int[].class);
static final MethodType MT_printHello = methodType(void.class, int.class);
+ static final MethodType MT_addCounter = methodType(int.class, int.class, int.class);
static final MethodHandle MH_13;
static final MethodHandle MH_m5;
@@ -681,10 +700,12 @@
static final MethodHandle MH_step;
static final MethodHandle MH_stepUpdateArray;
static final MethodHandle MH_printHello;
+ static final MethodHandle MH_addCounter;
static final MethodType MT_counted = methodType(String.class, String.class);
static final MethodType MT_arrayCounted = methodType(void.class, int[].class);
static final MethodType MT_countedPrinting = methodType(void.class);
+ static final MethodType MT_counterInit = methodType(int.class);
static {
try {
@@ -695,6 +716,7 @@
MH_step = LOOKUP.findStatic(COUNTED, "step", MT_step);
MH_stepUpdateArray = LOOKUP.findStatic(COUNTED, "stepUpdateArray", MT_stepUpdateArray);
MH_printHello = LOOKUP.findStatic(COUNTED, "printHello", MT_printHello);
+ MH_addCounter = LOOKUP.findStatic(COUNTED, "addCounter", MT_addCounter);
} catch (Exception e) {
throw new ExceptionInInitializerError(e);
}
--- a/jdk/test/java/lang/invoke/RevealDirectTest.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/java/lang/invoke/RevealDirectTest.java Wed Jul 05 21:35:27 2017 +0200
@@ -24,7 +24,7 @@
/*
* @test
* @summary verify Lookup.revealDirect on a variety of input handles
- * @modules java.base/sun.reflect
+ * @modules java.base/jdk.internal.reflect
* @compile -XDignore.symbol.file RevealDirectTest.java
* @run junit/othervm -ea -esa test.java.lang.invoke.RevealDirectTest
*
@@ -311,7 +311,7 @@
if (!(mem instanceof AnnotatedElement)) return false;
AnnotatedElement ae = (AnnotatedElement) mem;
if (CS_CLASS != null)
- return ae.isAnnotationPresent(sun.reflect.CallerSensitive.class);
+ return ae.isAnnotationPresent(jdk.internal.reflect.CallerSensitive.class);
for (java.lang.annotation.Annotation a : ae.getDeclaredAnnotations()) {
if (a.toString().contains(".CallerSensitive"))
return true;
@@ -322,7 +322,7 @@
static {
Class<?> c = null;
try {
- c = sun.reflect.CallerSensitive.class;
+ c = jdk.internal.reflect.CallerSensitive.class;
} catch (SecurityException | LinkageError ex) {
}
CS_CLASS = c;
--- a/jdk/test/java/lang/invoke/TryFinallyTest.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/java/lang/invoke/TryFinallyTest.java Wed Jul 05 21:35:27 2017 +0200
@@ -25,6 +25,7 @@
/* @test
* @bug 8139885
+ * @bug 8150824
* @bug 8150825
* @run testng/othervm -ea -esa test.java.lang.invoke.TryFinallyTest
*/
@@ -71,12 +72,32 @@
}
@DataProvider
+ static Object[][] omitTrailingArguments() {
+ MethodHandle c = TryFinally.MH_voidCleanup;
+ return new Object[][]{
+ {c},
+ {MethodHandles.dropArguments(c, 1, int.class)},
+ {MethodHandles.dropArguments(c, 1, int.class, long.class)},
+ {MethodHandles.dropArguments(c, 1, int.class, long.class, Object.class, int.class)},
+ {MethodHandles.dropArguments(c, 1, int.class, long.class, Object.class, int.class, long.class)}
+ };
+ }
+
+ @Test(dataProvider = "omitTrailingArguments")
+ public static void testTryFinallyOmitTrailingArguments(MethodHandle cleanup) throws Throwable {
+ MethodHandle tf = MethodHandles.tryFinally(TryFinally.MH_dummyTarget, cleanup);
+ tf.invoke(1, 2L, "a", 23, 42L, "b");
+ }
+
+ @DataProvider
static Object[][] negativeTestData() {
MethodHandle intid = MethodHandles.identity(int.class);
MethodHandle intco = MethodHandles.constant(int.class, 0);
MethodHandle errTarget = MethodHandles.dropArguments(intco, 0, int.class, double.class, String.class, int.class);
MethodHandle errCleanup = MethodHandles.dropArguments(MethodHandles.constant(int.class, 0), 0, Throwable.class,
int.class, double.class, Object.class);
+ MethodHandle voidTarget = TryFinally.MH_voidTarget;
+ MethodHandle voidICleanup = MethodHandles.dropArguments(TryFinally.MH_voidCleanup, 1, int.class);
return new Object[][]{
{intid, MethodHandles.identity(double.class),
"target and return types must match: double != int"},
@@ -87,9 +108,9 @@
{errTarget, errCleanup,
"cleanup parameters after (Throwable,result) and target parameter list prefix must match: " +
errCleanup.type() + " != " + errTarget.type()},
- {TryFinally.MH_voidTarget, TryFinally.MH_voidCleanup,
+ {voidTarget, voidICleanup,
"cleanup parameters after (Throwable,result) and target parameter list prefix must match: " +
- TryFinally.MH_voidCleanup.type() + " != " + TryFinally.MH_voidTarget.type()}
+ voidICleanup.type() + " != " + voidTarget.type()}
};
}
@@ -133,7 +154,7 @@
static void voidTarget() {}
- static void voidCleanup(Throwable t, int a) {}
+ static void voidCleanup(Throwable t) {}
static final Class<TryFinally> TRY_FINALLY = TryFinally.class;
@@ -144,7 +165,7 @@
static final MethodType MT_greetMore = methodType(String.class, String.class, String.class);
static final MethodType MT_exclaimMore = methodType(String.class, Throwable.class, String.class, String.class);
static final MethodType MT_voidTarget = methodType(void.class);
- static final MethodType MT_voidCleanup = methodType(void.class, Throwable.class, int.class);
+ static final MethodType MT_voidCleanup = methodType(void.class, Throwable.class);
static final MethodHandle MH_greet;
static final MethodHandle MH_exclaim;
@@ -155,6 +176,8 @@
static final MethodHandle MH_voidTarget;
static final MethodHandle MH_voidCleanup;
+ static final MethodHandle MH_dummyTarget;
+
static final MethodType MT_hello = methodType(String.class, String.class);
static final MethodType MT_printHello = methodType(void.class, String.class);
static final MethodType MT_moreHello = methodType(String.class, String.class, String.class);
@@ -169,6 +192,8 @@
MH_exclaimMore = LOOKUP.findStatic(TRY_FINALLY, "exclaimMore", MT_exclaimMore);
MH_voidTarget = LOOKUP.findStatic(TRY_FINALLY, "voidTarget", MT_voidTarget);
MH_voidCleanup = LOOKUP.findStatic(TRY_FINALLY, "voidCleanup", MT_voidCleanup);
+ MH_dummyTarget = MethodHandles.dropArguments(MH_voidTarget, 0, int.class, long.class, Object.class,
+ int.class, long.class, Object.class);
} catch (Exception e) {
throw new ExceptionInInitializerError(e);
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/invoke/VarArgsTest.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,80 @@
+/*
+ * 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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
+ * @summary unit tests for java.lang.invoke.MethodHandles
+ * @run testng/othervm -ea -esa test.java.lang.invoke.VarArgsTest
+ */
+package test.java.lang.invoke;
+
+import java.lang.invoke.MethodHandle;
+import java.lang.invoke.MethodHandles;
+import java.lang.invoke.MethodType;
+import java.util.Arrays;
+import java.util.List;
+import static java.lang.invoke.MethodHandles.*;
+import static java.lang.invoke.MethodType.*;
+import static org.testng.AssertJUnit.*;
+import org.testng.annotations.*;
+
+public class VarArgsTest {
+
+ @Test
+ public void testWithVarargs() throws Throwable {
+ MethodHandle deepToString = publicLookup()
+ .findStatic(Arrays.class, "deepToString", methodType(String.class, Object[].class));
+ assertFalse(deepToString.isVarargsCollector());
+ MethodHandle ts = deepToString.withVarargs(false);
+ assertFalse(ts.isVarargsCollector());
+ MethodHandle ts1 = deepToString.withVarargs(true);
+ assertTrue(ts1.isVarargsCollector());
+ assertEquals("[won]", (String) ts1.invokeExact(new Object[]{"won"}));
+ assertEquals("[won]", (String) ts1.invoke(new Object[]{"won"}));
+ assertEquals("[won]", (String) ts1.invoke("won"));
+ assertEquals("[won, won]", (String) ts1.invoke("won", "won"));
+ assertEquals("[won, won]", (String) ts1.invoke(new Object[]{"won", "won"}));
+ assertEquals("[[won]]", (String) ts1.invoke((Object) new Object[]{"won"}));
+ }
+
+ @Test
+ public void testWithVarargs2() throws Throwable {
+ MethodHandle asList = publicLookup()
+ .findStatic(Arrays.class, "asList", methodType(List.class, Object[].class));
+ MethodHandle asListWithVarargs = asList.withVarargs(asList.isVarargsCollector());
+ assert(asListWithVarargs.isVarargsCollector());
+ assertEquals("[]", asListWithVarargs.invoke().toString());
+ assertEquals("[1]", asListWithVarargs.invoke(1).toString());
+ assertEquals("[two, too]", asListWithVarargs.invoke("two", "too").toString());
+ }
+
+ @Test
+ @ExpectedExceptions(IllegalArgumentException.class)
+ public void testWithVarargsIAE() throws Throwable {
+ MethodHandle lenMH = publicLookup()
+ .findVirtual(String.class, "length", methodType(int.class));
+ MethodHandle lenMHWithVarargs = lenMH.withVarargs(true);
+ }
+
+}
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleBaseTest.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleBaseTest.java Wed Jul 05 21:35:27 2017 +0200
@@ -126,33 +126,33 @@
enum TestAccessType {
- get,
- set,
- compareAndSet,
- compareAndExchange,
- getAndSet,
- getAndAdd;
+ GET,
+ SET,
+ COMPARE_AND_SET,
+ COMPARE_AND_EXCHANGE,
+ GET_AND_SET,
+ GET_AND_ADD;
}
enum TestAccessMode {
- get(TestAccessType.get),
- set(TestAccessType.set),
- getVolatile(TestAccessType.get),
- setVolatile(TestAccessType.set),
- getAcquire(TestAccessType.get),
- setRelease(TestAccessType.set),
- getOpaque(TestAccessType.get),
- setOpaque(TestAccessType.set),
- compareAndSet(TestAccessType.compareAndSet),
- compareAndExchangeVolatile(TestAccessType.compareAndExchange),
- compareAndExchangeAcquire(TestAccessType.compareAndExchange),
- compareAndExchangeRelease(TestAccessType.compareAndExchange),
- weakCompareAndSet(TestAccessType.compareAndSet),
- weakCompareAndSetAcquire(TestAccessType.compareAndSet),
- weakCompareAndSetRelease(TestAccessType.compareAndSet),
- getAndSet(TestAccessType.getAndSet),
- getAndAdd(TestAccessType.getAndAdd),
- addAndGet(TestAccessType.getAndAdd),;
+ GET(TestAccessType.GET),
+ SET(TestAccessType.SET),
+ GET_VOLATILE(TestAccessType.GET),
+ SET_VOLATILE(TestAccessType.SET),
+ GET_ACQUIRE(TestAccessType.GET),
+ SET_RELEASE(TestAccessType.SET),
+ GET_OPAQUE(TestAccessType.GET),
+ SET_OPAQUE(TestAccessType.SET),
+ COMPARE_AND_SET(TestAccessType.COMPARE_AND_SET),
+ COMPARE_AND_EXCHANGE_VOLATILE(TestAccessType.COMPARE_AND_EXCHANGE),
+ COMPARE_AND_EXCHANGE_ACQUIRE(TestAccessType.COMPARE_AND_EXCHANGE),
+ COMPARE_AND_EXCHANGE_RELEASE(TestAccessType.COMPARE_AND_EXCHANGE),
+ WEAK_COMPARE_AND_SET(TestAccessType.COMPARE_AND_SET),
+ WEAK_COMPARE_AND_SET_ACQUIRE(TestAccessType.COMPARE_AND_SET),
+ WEAK_COMPARE_AND_SET_RELEASE(TestAccessType.COMPARE_AND_SET),
+ GET_AND_SET(TestAccessType.GET_AND_SET),
+ GET_AND_ADD(TestAccessType.GET_AND_ADD),
+ ADD_AND_GET(TestAccessType.GET_AND_ADD),;
final TestAccessType at;
final boolean isPolyMorphicInReturnType;
@@ -162,7 +162,8 @@
this.at = at;
try {
- Method m = VarHandle.class.getMethod(name(), Object[].class);
+ VarHandle.AccessMode vh_am = toAccessMode();
+ Method m = VarHandle.class.getMethod(vh_am.methodName(), Object[].class);
this.returnType = m.getReturnType();
isPolyMorphicInReturnType = returnType != Object.class;
}
@@ -214,7 +215,7 @@
try {
mh = MethodHandles.publicLookup().
findVirtual(VarHandle.class,
- tam.name(),
+ tam.toAccessMode().methodName(),
mt);
} catch (Exception e) {
throw new RuntimeException(e);
@@ -441,33 +442,33 @@
assertEquals(amt.parameterList().subList(0, pts.size()), pts);
}
- for (TestAccessMode testAccessMode : testAccessModesOfType(TestAccessType.get)) {
+ for (TestAccessMode testAccessMode : testAccessModesOfType(TestAccessType.GET)) {
MethodType mt = vh.accessModeType(testAccessMode.toAccessMode());
assertEquals(mt.returnType(), vh.varType());
assertEquals(mt.parameterList(), pts);
}
- for (TestAccessMode testAccessMode : testAccessModesOfType(TestAccessType.set)) {
+ for (TestAccessMode testAccessMode : testAccessModesOfType(TestAccessType.SET)) {
MethodType mt = vh.accessModeType(testAccessMode.toAccessMode());
assertEquals(mt.returnType(), void.class);
assertEquals(mt.parameterType(mt.parameterCount() - 1), vh.varType());
}
- for (TestAccessMode testAccessMode : testAccessModesOfType(TestAccessType.compareAndSet)) {
+ for (TestAccessMode testAccessMode : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
MethodType mt = vh.accessModeType(testAccessMode.toAccessMode());
assertEquals(mt.returnType(), boolean.class);
assertEquals(mt.parameterType(mt.parameterCount() - 1), vh.varType());
assertEquals(mt.parameterType(mt.parameterCount() - 2), vh.varType());
}
- for (TestAccessMode testAccessMode : testAccessModesOfType(TestAccessType.compareAndExchange)) {
+ for (TestAccessMode testAccessMode : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
MethodType mt = vh.accessModeType(testAccessMode.toAccessMode());
assertEquals(mt.returnType(), vh.varType());
assertEquals(mt.parameterType(mt.parameterCount() - 1), vh.varType());
assertEquals(mt.parameterType(mt.parameterCount() - 2), vh.varType());
}
- for (TestAccessMode testAccessMode : testAccessModesOfType(TestAccessType.getAndSet, TestAccessType.getAndAdd)) {
+ for (TestAccessMode testAccessMode : testAccessModesOfType(TestAccessType.GET_AND_SET, TestAccessType.GET_AND_ADD)) {
MethodType mt = vh.accessModeType(testAccessMode.toAccessMode());
assertEquals(mt.returnType(), vh.varType());
assertEquals(mt.parameterType(mt.parameterCount() - 1), vh.varType());
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessBoolean.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessBoolean.java Wed Jul 05 21:35:27 2017 +0200
@@ -90,27 +90,27 @@
@Test(dataProvider = "varHandlesProvider")
public void testIsAccessModeSupported(VarHandle vh) {
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.get));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.set));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getVolatile));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.setVolatile));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getAcquire));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.setRelease));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getOpaque));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.setOpaque));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_VOLATILE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_VOLATILE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_ACQUIRE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_RELEASE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_OPAQUE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_OPAQUE));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndSet));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndExchangeVolatile));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndExchangeAcquire));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndExchangeRelease));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSet));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSetAcquire));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSetRelease));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSetRelease));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.getAndSet));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_SET));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_VOLATILE));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.getAndAdd));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.addAndGet));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET));
}
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessByte.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessByte.java Wed Jul 05 21:35:27 2017 +0200
@@ -90,27 +90,27 @@
@Test(dataProvider = "varHandlesProvider")
public void testIsAccessModeSupported(VarHandle vh) {
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.get));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.set));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getVolatile));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.setVolatile));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getAcquire));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.setRelease));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getOpaque));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.setOpaque));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_VOLATILE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_VOLATILE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_ACQUIRE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_RELEASE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_OPAQUE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_OPAQUE));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndSet));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndExchangeVolatile));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndExchangeAcquire));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndExchangeRelease));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSet));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSetAcquire));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSetRelease));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSetRelease));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.getAndSet));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_SET));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_VOLATILE));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.getAndAdd));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.addAndGet));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET));
}
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessChar.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessChar.java Wed Jul 05 21:35:27 2017 +0200
@@ -90,27 +90,27 @@
@Test(dataProvider = "varHandlesProvider")
public void testIsAccessModeSupported(VarHandle vh) {
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.get));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.set));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getVolatile));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.setVolatile));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getAcquire));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.setRelease));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getOpaque));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.setOpaque));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_VOLATILE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_VOLATILE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_ACQUIRE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_RELEASE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_OPAQUE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_OPAQUE));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndSet));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndExchangeVolatile));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndExchangeAcquire));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndExchangeRelease));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSet));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSetAcquire));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSetRelease));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSetRelease));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.getAndSet));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_SET));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_VOLATILE));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.getAndAdd));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.addAndGet));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET));
}
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessDouble.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessDouble.java Wed Jul 05 21:35:27 2017 +0200
@@ -90,27 +90,27 @@
@Test(dataProvider = "varHandlesProvider")
public void testIsAccessModeSupported(VarHandle vh) {
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.get));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.set));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getVolatile));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.setVolatile));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getAcquire));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.setRelease));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getOpaque));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.setOpaque));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_VOLATILE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_VOLATILE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_ACQUIRE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_RELEASE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_OPAQUE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_OPAQUE));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndSet));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndExchangeVolatile));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndExchangeAcquire));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndExchangeRelease));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSet));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSetAcquire));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSetRelease));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSetRelease));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.getAndSet));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_SET));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_VOLATILE));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.getAndAdd));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.addAndGet));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET));
}
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessFloat.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessFloat.java Wed Jul 05 21:35:27 2017 +0200
@@ -90,27 +90,27 @@
@Test(dataProvider = "varHandlesProvider")
public void testIsAccessModeSupported(VarHandle vh) {
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.get));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.set));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getVolatile));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.setVolatile));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getAcquire));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.setRelease));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getOpaque));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.setOpaque));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_VOLATILE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_VOLATILE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_ACQUIRE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_RELEASE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_OPAQUE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_OPAQUE));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndSet));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndExchangeVolatile));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndExchangeAcquire));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndExchangeRelease));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSet));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSetAcquire));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSetRelease));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSetRelease));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.getAndSet));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_SET));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_VOLATILE));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.getAndAdd));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.addAndGet));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET));
}
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessInt.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessInt.java Wed Jul 05 21:35:27 2017 +0200
@@ -90,27 +90,27 @@
@Test(dataProvider = "varHandlesProvider")
public void testIsAccessModeSupported(VarHandle vh) {
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.get));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.set));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getVolatile));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.setVolatile));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getAcquire));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.setRelease));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getOpaque));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.setOpaque));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_VOLATILE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_VOLATILE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_ACQUIRE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_RELEASE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_OPAQUE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_OPAQUE));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndSet));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndExchangeVolatile));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndExchangeAcquire));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndExchangeRelease));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSet));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSetAcquire));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSetRelease));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSetRelease));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getAndSet));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_SET));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_VOLATILE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getAndAdd));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.addAndGet));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET));
}
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessLong.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessLong.java Wed Jul 05 21:35:27 2017 +0200
@@ -90,27 +90,27 @@
@Test(dataProvider = "varHandlesProvider")
public void testIsAccessModeSupported(VarHandle vh) {
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.get));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.set));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getVolatile));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.setVolatile));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getAcquire));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.setRelease));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getOpaque));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.setOpaque));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_VOLATILE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_VOLATILE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_ACQUIRE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_RELEASE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_OPAQUE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_OPAQUE));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndSet));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndExchangeVolatile));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndExchangeAcquire));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndExchangeRelease));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSet));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSetAcquire));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSetRelease));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSetRelease));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getAndSet));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_SET));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_VOLATILE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getAndAdd));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.addAndGet));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET));
}
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessShort.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessShort.java Wed Jul 05 21:35:27 2017 +0200
@@ -90,27 +90,27 @@
@Test(dataProvider = "varHandlesProvider")
public void testIsAccessModeSupported(VarHandle vh) {
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.get));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.set));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getVolatile));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.setVolatile));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getAcquire));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.setRelease));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getOpaque));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.setOpaque));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_VOLATILE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_VOLATILE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_ACQUIRE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_RELEASE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_OPAQUE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_OPAQUE));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndSet));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndExchangeVolatile));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndExchangeAcquire));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndExchangeRelease));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSet));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSetAcquire));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSetRelease));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSetRelease));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.getAndSet));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_SET));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_VOLATILE));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.getAndAdd));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.addAndGet));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET));
}
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessString.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessString.java Wed Jul 05 21:35:27 2017 +0200
@@ -90,27 +90,27 @@
@Test(dataProvider = "varHandlesProvider")
public void testIsAccessModeSupported(VarHandle vh) {
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.get));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.set));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getVolatile));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.setVolatile));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getAcquire));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.setRelease));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getOpaque));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.setOpaque));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_VOLATILE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_VOLATILE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_ACQUIRE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_RELEASE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_OPAQUE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_OPAQUE));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndSet));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndExchangeVolatile));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndExchangeAcquire));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndExchangeRelease));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSet));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSetAcquire));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSetRelease));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSetRelease));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getAndSet));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_SET));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_VOLATILE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.getAndAdd));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.addAndGet));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET));
}
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsChar.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsChar.java Wed Jul 05 21:35:27 2017 +0200
@@ -76,28 +76,28 @@
public void testIsAccessModeSupported(VarHandleSource vhs) {
VarHandle vh = vhs.s;
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.get));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.set));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getVolatile));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.setVolatile));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getAcquire));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.setRelease));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getOpaque));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.setOpaque));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_VOLATILE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_VOLATILE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_ACQUIRE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_RELEASE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_OPAQUE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_OPAQUE));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndSet));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndExchangeVolatile));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndExchangeAcquire));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndExchangeRelease));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSet));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSetAcquire));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSetRelease));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSetRelease));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.getAndSet));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_SET));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_VOLATILE));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.getAndAdd));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.addAndGet));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET));
}
@Test(dataProvider = "typesProvider")
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsDouble.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsDouble.java Wed Jul 05 21:35:27 2017 +0200
@@ -76,28 +76,28 @@
public void testIsAccessModeSupported(VarHandleSource vhs) {
VarHandle vh = vhs.s;
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.get));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.set));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getVolatile));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.setVolatile));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getAcquire));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.setRelease));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getOpaque));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.setOpaque));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_VOLATILE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_VOLATILE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_ACQUIRE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_RELEASE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_OPAQUE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_OPAQUE));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndSet));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndExchangeVolatile));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndExchangeAcquire));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndExchangeRelease));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSet));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSetAcquire));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSetRelease));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSetRelease));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getAndSet));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_SET));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_VOLATILE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.getAndAdd));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.addAndGet));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET));
}
@Test(dataProvider = "typesProvider")
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsFloat.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsFloat.java Wed Jul 05 21:35:27 2017 +0200
@@ -76,28 +76,28 @@
public void testIsAccessModeSupported(VarHandleSource vhs) {
VarHandle vh = vhs.s;
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.get));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.set));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getVolatile));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.setVolatile));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getAcquire));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.setRelease));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getOpaque));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.setOpaque));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_VOLATILE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_VOLATILE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_ACQUIRE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_RELEASE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_OPAQUE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_OPAQUE));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndSet));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndExchangeVolatile));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndExchangeAcquire));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndExchangeRelease));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSet));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSetAcquire));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSetRelease));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSetRelease));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getAndSet));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_SET));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_VOLATILE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.getAndAdd));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.addAndGet));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET));
}
@Test(dataProvider = "typesProvider")
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsInt.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsInt.java Wed Jul 05 21:35:27 2017 +0200
@@ -76,28 +76,28 @@
public void testIsAccessModeSupported(VarHandleSource vhs) {
VarHandle vh = vhs.s;
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.get));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.set));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getVolatile));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.setVolatile));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getAcquire));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.setRelease));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getOpaque));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.setOpaque));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_VOLATILE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_VOLATILE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_ACQUIRE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_RELEASE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_OPAQUE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_OPAQUE));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndSet));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndExchangeVolatile));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndExchangeAcquire));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndExchangeRelease));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSet));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSetAcquire));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSetRelease));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSetRelease));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getAndSet));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_SET));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_VOLATILE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getAndAdd));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.addAndGet));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET));
}
@Test(dataProvider = "typesProvider")
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsLong.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsLong.java Wed Jul 05 21:35:27 2017 +0200
@@ -76,28 +76,28 @@
public void testIsAccessModeSupported(VarHandleSource vhs) {
VarHandle vh = vhs.s;
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.get));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.set));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getVolatile));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.setVolatile));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getAcquire));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.setRelease));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getOpaque));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.setOpaque));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_VOLATILE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_VOLATILE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_ACQUIRE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_RELEASE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_OPAQUE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_OPAQUE));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndSet));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndExchangeVolatile));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndExchangeAcquire));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndExchangeRelease));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSet));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSetAcquire));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSetRelease));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSetRelease));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getAndSet));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_SET));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_VOLATILE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getAndAdd));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.addAndGet));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET));
}
@Test(dataProvider = "typesProvider")
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsShort.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsShort.java Wed Jul 05 21:35:27 2017 +0200
@@ -76,28 +76,28 @@
public void testIsAccessModeSupported(VarHandleSource vhs) {
VarHandle vh = vhs.s;
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.get));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.set));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getVolatile));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.setVolatile));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getAcquire));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.setRelease));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getOpaque));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.setOpaque));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_VOLATILE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_VOLATILE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_ACQUIRE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_RELEASE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_OPAQUE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_OPAQUE));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndSet));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndExchangeVolatile));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndExchangeAcquire));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndExchangeRelease));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSet));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSetAcquire));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSetRelease));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSetRelease));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.getAndSet));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_SET));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_VOLATILE));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.getAndAdd));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.addAndGet));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET));
}
@Test(dataProvider = "typesProvider")
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessBoolean.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessBoolean.java Wed Jul 05 21:35:27 2017 +0200
@@ -121,30 +121,30 @@
static void testInstanceField(VarHandleTestMethodHandleAccessBoolean recv, Handles hs) throws Throwable {
// Plain
{
- hs.get(TestAccessMode.set).invokeExact(recv, true);
- boolean x = (boolean) hs.get(TestAccessMode.get).invokeExact(recv);
+ hs.get(TestAccessMode.SET).invokeExact(recv, true);
+ boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv);
assertEquals(x, true, "set boolean value");
}
// Volatile
{
- hs.get(TestAccessMode.setVolatile).invokeExact(recv, false);
- boolean x = (boolean) hs.get(TestAccessMode.getVolatile).invokeExact(recv);
+ hs.get(TestAccessMode.SET_VOLATILE).invokeExact(recv, false);
+ boolean x = (boolean) hs.get(TestAccessMode.GET_VOLATILE).invokeExact(recv);
assertEquals(x, false, "setVolatile boolean value");
}
// Lazy
{
- hs.get(TestAccessMode.setRelease).invokeExact(recv, true);
- boolean x = (boolean) hs.get(TestAccessMode.getAcquire).invokeExact(recv);
+ hs.get(TestAccessMode.SET_RELEASE).invokeExact(recv, true);
+ boolean x = (boolean) hs.get(TestAccessMode.GET_ACQUIRE).invokeExact(recv);
assertEquals(x, true, "setRelease boolean value");
}
// Opaque
{
- hs.get(TestAccessMode.setOpaque).invokeExact(recv, false);
- boolean x = (boolean) hs.get(TestAccessMode.getOpaque).invokeExact(recv);
+ hs.get(TestAccessMode.SET_OPAQUE).invokeExact(recv, false);
+ boolean x = (boolean) hs.get(TestAccessMode.GET_OPAQUE).invokeExact(recv);
assertEquals(x, false, "setOpaque boolean value");
}
@@ -152,25 +152,25 @@
}
static void testInstanceFieldUnsupported(VarHandleTestMethodHandleAccessBoolean recv, Handles hs) throws Throwable {
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
checkUOE(am, () -> {
boolean r = (boolean) hs.get(am).invokeExact(recv, true, false);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndExchange)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
checkUOE(am, () -> {
boolean r = (boolean) hs.get(am).invokeExact(recv, true, false);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
checkUOE(am, () -> {
boolean r = (boolean) hs.get(am).invokeExact(recv, true);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndAdd)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
checkUOE(am, () -> {
boolean r = (boolean) hs.get(am).invokeExact(recv, true);
});
@@ -181,30 +181,30 @@
static void testStaticField(Handles hs) throws Throwable {
// Plain
{
- hs.get(TestAccessMode.set).invokeExact(true);
- boolean x = (boolean) hs.get(TestAccessMode.get).invokeExact();
+ hs.get(TestAccessMode.SET).invokeExact(true);
+ boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact();
assertEquals(x, true, "set boolean value");
}
// Volatile
{
- hs.get(TestAccessMode.setVolatile).invokeExact(false);
- boolean x = (boolean) hs.get(TestAccessMode.getVolatile).invokeExact();
+ hs.get(TestAccessMode.SET_VOLATILE).invokeExact(false);
+ boolean x = (boolean) hs.get(TestAccessMode.GET_VOLATILE).invokeExact();
assertEquals(x, false, "setVolatile boolean value");
}
// Lazy
{
- hs.get(TestAccessMode.setRelease).invokeExact(true);
- boolean x = (boolean) hs.get(TestAccessMode.getAcquire).invokeExact();
+ hs.get(TestAccessMode.SET_RELEASE).invokeExact(true);
+ boolean x = (boolean) hs.get(TestAccessMode.GET_ACQUIRE).invokeExact();
assertEquals(x, true, "setRelease boolean value");
}
// Opaque
{
- hs.get(TestAccessMode.setOpaque).invokeExact(false);
- boolean x = (boolean) hs.get(TestAccessMode.getOpaque).invokeExact();
+ hs.get(TestAccessMode.SET_OPAQUE).invokeExact(false);
+ boolean x = (boolean) hs.get(TestAccessMode.GET_OPAQUE).invokeExact();
assertEquals(x, false, "setOpaque boolean value");
}
@@ -212,25 +212,25 @@
}
static void testStaticFieldUnsupported(Handles hs) throws Throwable {
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
checkUOE(am, () -> {
boolean r = (boolean) hs.get(am).invokeExact(true, false);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndExchange)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
checkUOE(am, () -> {
boolean r = (boolean) hs.get(am).invokeExact(true, false);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
checkUOE(am, () -> {
boolean r = (boolean) hs.get(am).invokeExact(true);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndAdd)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
checkUOE(am, () -> {
boolean r = (boolean) hs.get(am).invokeExact(true);
});
@@ -244,30 +244,30 @@
for (int i = 0; i < array.length; i++) {
// Plain
{
- hs.get(TestAccessMode.set).invokeExact(array, i, true);
- boolean x = (boolean) hs.get(TestAccessMode.get).invokeExact(array, i);
+ hs.get(TestAccessMode.SET).invokeExact(array, i, true);
+ boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i);
assertEquals(x, true, "get boolean value");
}
// Volatile
{
- hs.get(TestAccessMode.setVolatile).invokeExact(array, i, false);
- boolean x = (boolean) hs.get(TestAccessMode.getVolatile).invokeExact(array, i);
+ hs.get(TestAccessMode.SET_VOLATILE).invokeExact(array, i, false);
+ boolean x = (boolean) hs.get(TestAccessMode.GET_VOLATILE).invokeExact(array, i);
assertEquals(x, false, "setVolatile boolean value");
}
// Lazy
{
- hs.get(TestAccessMode.setRelease).invokeExact(array, i, true);
- boolean x = (boolean) hs.get(TestAccessMode.getAcquire).invokeExact(array, i);
+ hs.get(TestAccessMode.SET_RELEASE).invokeExact(array, i, true);
+ boolean x = (boolean) hs.get(TestAccessMode.GET_ACQUIRE).invokeExact(array, i);
assertEquals(x, true, "setRelease boolean value");
}
// Opaque
{
- hs.get(TestAccessMode.setOpaque).invokeExact(array, i, false);
- boolean x = (boolean) hs.get(TestAccessMode.getOpaque).invokeExact(array, i);
+ hs.get(TestAccessMode.SET_OPAQUE).invokeExact(array, i, false);
+ boolean x = (boolean) hs.get(TestAccessMode.GET_OPAQUE).invokeExact(array, i);
assertEquals(x, false, "setOpaque boolean value");
}
@@ -279,25 +279,25 @@
boolean[] array = new boolean[10];
final int i = 0;
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
checkUOE(am, () -> {
boolean r = (boolean) hs.get(am).invokeExact(array, i, true, false);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndExchange)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
checkUOE(am, () -> {
boolean r = (boolean) hs.get(am).invokeExact(array, i, true, false);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
checkUOE(am, () -> {
boolean r = (boolean) hs.get(am).invokeExact(array, i, true);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndAdd)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
checkUOE(am, () -> {
boolean o = (boolean) hs.get(am).invokeExact(array, i, true);
});
@@ -310,13 +310,13 @@
for (int i : new int[]{-1, Integer.MIN_VALUE, 10, 11, Integer.MAX_VALUE}) {
final int ci = i;
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.get)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
checkIOOBE(am, () -> {
boolean x = (boolean) hs.get(am).invokeExact(array, ci);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.set)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
checkIOOBE(am, () -> {
hs.get(am).invokeExact(array, ci, true);
});
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessByte.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessByte.java Wed Jul 05 21:35:27 2017 +0200
@@ -121,30 +121,30 @@
static void testInstanceField(VarHandleTestMethodHandleAccessByte recv, Handles hs) throws Throwable {
// Plain
{
- hs.get(TestAccessMode.set).invokeExact(recv, (byte)1);
- byte x = (byte) hs.get(TestAccessMode.get).invokeExact(recv);
+ hs.get(TestAccessMode.SET).invokeExact(recv, (byte)1);
+ byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(recv);
assertEquals(x, (byte)1, "set byte value");
}
// Volatile
{
- hs.get(TestAccessMode.setVolatile).invokeExact(recv, (byte)2);
- byte x = (byte) hs.get(TestAccessMode.getVolatile).invokeExact(recv);
+ hs.get(TestAccessMode.SET_VOLATILE).invokeExact(recv, (byte)2);
+ byte x = (byte) hs.get(TestAccessMode.GET_VOLATILE).invokeExact(recv);
assertEquals(x, (byte)2, "setVolatile byte value");
}
// Lazy
{
- hs.get(TestAccessMode.setRelease).invokeExact(recv, (byte)1);
- byte x = (byte) hs.get(TestAccessMode.getAcquire).invokeExact(recv);
+ hs.get(TestAccessMode.SET_RELEASE).invokeExact(recv, (byte)1);
+ byte x = (byte) hs.get(TestAccessMode.GET_ACQUIRE).invokeExact(recv);
assertEquals(x, (byte)1, "setRelease byte value");
}
// Opaque
{
- hs.get(TestAccessMode.setOpaque).invokeExact(recv, (byte)2);
- byte x = (byte) hs.get(TestAccessMode.getOpaque).invokeExact(recv);
+ hs.get(TestAccessMode.SET_OPAQUE).invokeExact(recv, (byte)2);
+ byte x = (byte) hs.get(TestAccessMode.GET_OPAQUE).invokeExact(recv);
assertEquals(x, (byte)2, "setOpaque byte value");
}
@@ -152,25 +152,25 @@
}
static void testInstanceFieldUnsupported(VarHandleTestMethodHandleAccessByte recv, Handles hs) throws Throwable {
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
checkUOE(am, () -> {
boolean r = (boolean) hs.get(am).invokeExact(recv, (byte)1, (byte)2);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndExchange)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
checkUOE(am, () -> {
byte r = (byte) hs.get(am).invokeExact(recv, (byte)1, (byte)2);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
checkUOE(am, () -> {
byte r = (byte) hs.get(am).invokeExact(recv, (byte)1);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndAdd)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
checkUOE(am, () -> {
byte r = (byte) hs.get(am).invokeExact(recv, (byte)1);
});
@@ -181,30 +181,30 @@
static void testStaticField(Handles hs) throws Throwable {
// Plain
{
- hs.get(TestAccessMode.set).invokeExact((byte)1);
- byte x = (byte) hs.get(TestAccessMode.get).invokeExact();
+ hs.get(TestAccessMode.SET).invokeExact((byte)1);
+ byte x = (byte) hs.get(TestAccessMode.GET).invokeExact();
assertEquals(x, (byte)1, "set byte value");
}
// Volatile
{
- hs.get(TestAccessMode.setVolatile).invokeExact((byte)2);
- byte x = (byte) hs.get(TestAccessMode.getVolatile).invokeExact();
+ hs.get(TestAccessMode.SET_VOLATILE).invokeExact((byte)2);
+ byte x = (byte) hs.get(TestAccessMode.GET_VOLATILE).invokeExact();
assertEquals(x, (byte)2, "setVolatile byte value");
}
// Lazy
{
- hs.get(TestAccessMode.setRelease).invokeExact((byte)1);
- byte x = (byte) hs.get(TestAccessMode.getAcquire).invokeExact();
+ hs.get(TestAccessMode.SET_RELEASE).invokeExact((byte)1);
+ byte x = (byte) hs.get(TestAccessMode.GET_ACQUIRE).invokeExact();
assertEquals(x, (byte)1, "setRelease byte value");
}
// Opaque
{
- hs.get(TestAccessMode.setOpaque).invokeExact((byte)2);
- byte x = (byte) hs.get(TestAccessMode.getOpaque).invokeExact();
+ hs.get(TestAccessMode.SET_OPAQUE).invokeExact((byte)2);
+ byte x = (byte) hs.get(TestAccessMode.GET_OPAQUE).invokeExact();
assertEquals(x, (byte)2, "setOpaque byte value");
}
@@ -212,25 +212,25 @@
}
static void testStaticFieldUnsupported(Handles hs) throws Throwable {
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
checkUOE(am, () -> {
boolean r = (boolean) hs.get(am).invokeExact((byte)1, (byte)2);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndExchange)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
checkUOE(am, () -> {
byte r = (byte) hs.get(am).invokeExact((byte)1, (byte)2);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
checkUOE(am, () -> {
byte r = (byte) hs.get(am).invokeExact((byte)1);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndAdd)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
checkUOE(am, () -> {
byte r = (byte) hs.get(am).invokeExact((byte)1);
});
@@ -244,30 +244,30 @@
for (int i = 0; i < array.length; i++) {
// Plain
{
- hs.get(TestAccessMode.set).invokeExact(array, i, (byte)1);
- byte x = (byte) hs.get(TestAccessMode.get).invokeExact(array, i);
+ hs.get(TestAccessMode.SET).invokeExact(array, i, (byte)1);
+ byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(array, i);
assertEquals(x, (byte)1, "get byte value");
}
// Volatile
{
- hs.get(TestAccessMode.setVolatile).invokeExact(array, i, (byte)2);
- byte x = (byte) hs.get(TestAccessMode.getVolatile).invokeExact(array, i);
+ hs.get(TestAccessMode.SET_VOLATILE).invokeExact(array, i, (byte)2);
+ byte x = (byte) hs.get(TestAccessMode.GET_VOLATILE).invokeExact(array, i);
assertEquals(x, (byte)2, "setVolatile byte value");
}
// Lazy
{
- hs.get(TestAccessMode.setRelease).invokeExact(array, i, (byte)1);
- byte x = (byte) hs.get(TestAccessMode.getAcquire).invokeExact(array, i);
+ hs.get(TestAccessMode.SET_RELEASE).invokeExact(array, i, (byte)1);
+ byte x = (byte) hs.get(TestAccessMode.GET_ACQUIRE).invokeExact(array, i);
assertEquals(x, (byte)1, "setRelease byte value");
}
// Opaque
{
- hs.get(TestAccessMode.setOpaque).invokeExact(array, i, (byte)2);
- byte x = (byte) hs.get(TestAccessMode.getOpaque).invokeExact(array, i);
+ hs.get(TestAccessMode.SET_OPAQUE).invokeExact(array, i, (byte)2);
+ byte x = (byte) hs.get(TestAccessMode.GET_OPAQUE).invokeExact(array, i);
assertEquals(x, (byte)2, "setOpaque byte value");
}
@@ -279,25 +279,25 @@
byte[] array = new byte[10];
final int i = 0;
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
checkUOE(am, () -> {
boolean r = (boolean) hs.get(am).invokeExact(array, i, (byte)1, (byte)2);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndExchange)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
checkUOE(am, () -> {
byte r = (byte) hs.get(am).invokeExact(array, i, (byte)1, (byte)2);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
checkUOE(am, () -> {
byte r = (byte) hs.get(am).invokeExact(array, i, (byte)1);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndAdd)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
checkUOE(am, () -> {
byte o = (byte) hs.get(am).invokeExact(array, i, (byte)1);
});
@@ -310,13 +310,13 @@
for (int i : new int[]{-1, Integer.MIN_VALUE, 10, 11, Integer.MAX_VALUE}) {
final int ci = i;
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.get)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
checkIOOBE(am, () -> {
byte x = (byte) hs.get(am).invokeExact(array, ci);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.set)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
checkIOOBE(am, () -> {
hs.get(am).invokeExact(array, ci, (byte)1);
});
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessChar.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessChar.java Wed Jul 05 21:35:27 2017 +0200
@@ -121,30 +121,30 @@
static void testInstanceField(VarHandleTestMethodHandleAccessChar recv, Handles hs) throws Throwable {
// Plain
{
- hs.get(TestAccessMode.set).invokeExact(recv, 'a');
- char x = (char) hs.get(TestAccessMode.get).invokeExact(recv);
+ hs.get(TestAccessMode.SET).invokeExact(recv, 'a');
+ char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv);
assertEquals(x, 'a', "set char value");
}
// Volatile
{
- hs.get(TestAccessMode.setVolatile).invokeExact(recv, 'b');
- char x = (char) hs.get(TestAccessMode.getVolatile).invokeExact(recv);
+ hs.get(TestAccessMode.SET_VOLATILE).invokeExact(recv, 'b');
+ char x = (char) hs.get(TestAccessMode.GET_VOLATILE).invokeExact(recv);
assertEquals(x, 'b', "setVolatile char value");
}
// Lazy
{
- hs.get(TestAccessMode.setRelease).invokeExact(recv, 'a');
- char x = (char) hs.get(TestAccessMode.getAcquire).invokeExact(recv);
+ hs.get(TestAccessMode.SET_RELEASE).invokeExact(recv, 'a');
+ char x = (char) hs.get(TestAccessMode.GET_ACQUIRE).invokeExact(recv);
assertEquals(x, 'a', "setRelease char value");
}
// Opaque
{
- hs.get(TestAccessMode.setOpaque).invokeExact(recv, 'b');
- char x = (char) hs.get(TestAccessMode.getOpaque).invokeExact(recv);
+ hs.get(TestAccessMode.SET_OPAQUE).invokeExact(recv, 'b');
+ char x = (char) hs.get(TestAccessMode.GET_OPAQUE).invokeExact(recv);
assertEquals(x, 'b', "setOpaque char value");
}
@@ -152,25 +152,25 @@
}
static void testInstanceFieldUnsupported(VarHandleTestMethodHandleAccessChar recv, Handles hs) throws Throwable {
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
checkUOE(am, () -> {
boolean r = (boolean) hs.get(am).invokeExact(recv, 'a', 'b');
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndExchange)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
checkUOE(am, () -> {
char r = (char) hs.get(am).invokeExact(recv, 'a', 'b');
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
checkUOE(am, () -> {
char r = (char) hs.get(am).invokeExact(recv, 'a');
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndAdd)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
checkUOE(am, () -> {
char r = (char) hs.get(am).invokeExact(recv, 'a');
});
@@ -181,30 +181,30 @@
static void testStaticField(Handles hs) throws Throwable {
// Plain
{
- hs.get(TestAccessMode.set).invokeExact('a');
- char x = (char) hs.get(TestAccessMode.get).invokeExact();
+ hs.get(TestAccessMode.SET).invokeExact('a');
+ char x = (char) hs.get(TestAccessMode.GET).invokeExact();
assertEquals(x, 'a', "set char value");
}
// Volatile
{
- hs.get(TestAccessMode.setVolatile).invokeExact('b');
- char x = (char) hs.get(TestAccessMode.getVolatile).invokeExact();
+ hs.get(TestAccessMode.SET_VOLATILE).invokeExact('b');
+ char x = (char) hs.get(TestAccessMode.GET_VOLATILE).invokeExact();
assertEquals(x, 'b', "setVolatile char value");
}
// Lazy
{
- hs.get(TestAccessMode.setRelease).invokeExact('a');
- char x = (char) hs.get(TestAccessMode.getAcquire).invokeExact();
+ hs.get(TestAccessMode.SET_RELEASE).invokeExact('a');
+ char x = (char) hs.get(TestAccessMode.GET_ACQUIRE).invokeExact();
assertEquals(x, 'a', "setRelease char value");
}
// Opaque
{
- hs.get(TestAccessMode.setOpaque).invokeExact('b');
- char x = (char) hs.get(TestAccessMode.getOpaque).invokeExact();
+ hs.get(TestAccessMode.SET_OPAQUE).invokeExact('b');
+ char x = (char) hs.get(TestAccessMode.GET_OPAQUE).invokeExact();
assertEquals(x, 'b', "setOpaque char value");
}
@@ -212,25 +212,25 @@
}
static void testStaticFieldUnsupported(Handles hs) throws Throwable {
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
checkUOE(am, () -> {
boolean r = (boolean) hs.get(am).invokeExact('a', 'b');
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndExchange)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
checkUOE(am, () -> {
char r = (char) hs.get(am).invokeExact('a', 'b');
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
checkUOE(am, () -> {
char r = (char) hs.get(am).invokeExact('a');
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndAdd)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
checkUOE(am, () -> {
char r = (char) hs.get(am).invokeExact('a');
});
@@ -244,30 +244,30 @@
for (int i = 0; i < array.length; i++) {
// Plain
{
- hs.get(TestAccessMode.set).invokeExact(array, i, 'a');
- char x = (char) hs.get(TestAccessMode.get).invokeExact(array, i);
+ hs.get(TestAccessMode.SET).invokeExact(array, i, 'a');
+ char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i);
assertEquals(x, 'a', "get char value");
}
// Volatile
{
- hs.get(TestAccessMode.setVolatile).invokeExact(array, i, 'b');
- char x = (char) hs.get(TestAccessMode.getVolatile).invokeExact(array, i);
+ hs.get(TestAccessMode.SET_VOLATILE).invokeExact(array, i, 'b');
+ char x = (char) hs.get(TestAccessMode.GET_VOLATILE).invokeExact(array, i);
assertEquals(x, 'b', "setVolatile char value");
}
// Lazy
{
- hs.get(TestAccessMode.setRelease).invokeExact(array, i, 'a');
- char x = (char) hs.get(TestAccessMode.getAcquire).invokeExact(array, i);
+ hs.get(TestAccessMode.SET_RELEASE).invokeExact(array, i, 'a');
+ char x = (char) hs.get(TestAccessMode.GET_ACQUIRE).invokeExact(array, i);
assertEquals(x, 'a', "setRelease char value");
}
// Opaque
{
- hs.get(TestAccessMode.setOpaque).invokeExact(array, i, 'b');
- char x = (char) hs.get(TestAccessMode.getOpaque).invokeExact(array, i);
+ hs.get(TestAccessMode.SET_OPAQUE).invokeExact(array, i, 'b');
+ char x = (char) hs.get(TestAccessMode.GET_OPAQUE).invokeExact(array, i);
assertEquals(x, 'b', "setOpaque char value");
}
@@ -279,25 +279,25 @@
char[] array = new char[10];
final int i = 0;
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
checkUOE(am, () -> {
boolean r = (boolean) hs.get(am).invokeExact(array, i, 'a', 'b');
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndExchange)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
checkUOE(am, () -> {
char r = (char) hs.get(am).invokeExact(array, i, 'a', 'b');
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
checkUOE(am, () -> {
char r = (char) hs.get(am).invokeExact(array, i, 'a');
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndAdd)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
checkUOE(am, () -> {
char o = (char) hs.get(am).invokeExact(array, i, 'a');
});
@@ -310,13 +310,13 @@
for (int i : new int[]{-1, Integer.MIN_VALUE, 10, 11, Integer.MAX_VALUE}) {
final int ci = i;
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.get)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
checkIOOBE(am, () -> {
char x = (char) hs.get(am).invokeExact(array, ci);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.set)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
checkIOOBE(am, () -> {
hs.get(am).invokeExact(array, ci, 'a');
});
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessDouble.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessDouble.java Wed Jul 05 21:35:27 2017 +0200
@@ -121,30 +121,30 @@
static void testInstanceField(VarHandleTestMethodHandleAccessDouble recv, Handles hs) throws Throwable {
// Plain
{
- hs.get(TestAccessMode.set).invokeExact(recv, 1.0d);
- double x = (double) hs.get(TestAccessMode.get).invokeExact(recv);
+ hs.get(TestAccessMode.SET).invokeExact(recv, 1.0d);
+ double x = (double) hs.get(TestAccessMode.GET).invokeExact(recv);
assertEquals(x, 1.0d, "set double value");
}
// Volatile
{
- hs.get(TestAccessMode.setVolatile).invokeExact(recv, 2.0d);
- double x = (double) hs.get(TestAccessMode.getVolatile).invokeExact(recv);
+ hs.get(TestAccessMode.SET_VOLATILE).invokeExact(recv, 2.0d);
+ double x = (double) hs.get(TestAccessMode.GET_VOLATILE).invokeExact(recv);
assertEquals(x, 2.0d, "setVolatile double value");
}
// Lazy
{
- hs.get(TestAccessMode.setRelease).invokeExact(recv, 1.0d);
- double x = (double) hs.get(TestAccessMode.getAcquire).invokeExact(recv);
+ hs.get(TestAccessMode.SET_RELEASE).invokeExact(recv, 1.0d);
+ double x = (double) hs.get(TestAccessMode.GET_ACQUIRE).invokeExact(recv);
assertEquals(x, 1.0d, "setRelease double value");
}
// Opaque
{
- hs.get(TestAccessMode.setOpaque).invokeExact(recv, 2.0d);
- double x = (double) hs.get(TestAccessMode.getOpaque).invokeExact(recv);
+ hs.get(TestAccessMode.SET_OPAQUE).invokeExact(recv, 2.0d);
+ double x = (double) hs.get(TestAccessMode.GET_OPAQUE).invokeExact(recv);
assertEquals(x, 2.0d, "setOpaque double value");
}
@@ -152,25 +152,25 @@
}
static void testInstanceFieldUnsupported(VarHandleTestMethodHandleAccessDouble recv, Handles hs) throws Throwable {
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
checkUOE(am, () -> {
boolean r = (boolean) hs.get(am).invokeExact(recv, 1.0d, 2.0d);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndExchange)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
checkUOE(am, () -> {
double r = (double) hs.get(am).invokeExact(recv, 1.0d, 2.0d);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
checkUOE(am, () -> {
double r = (double) hs.get(am).invokeExact(recv, 1.0d);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndAdd)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
checkUOE(am, () -> {
double r = (double) hs.get(am).invokeExact(recv, 1.0d);
});
@@ -181,30 +181,30 @@
static void testStaticField(Handles hs) throws Throwable {
// Plain
{
- hs.get(TestAccessMode.set).invokeExact(1.0d);
- double x = (double) hs.get(TestAccessMode.get).invokeExact();
+ hs.get(TestAccessMode.SET).invokeExact(1.0d);
+ double x = (double) hs.get(TestAccessMode.GET).invokeExact();
assertEquals(x, 1.0d, "set double value");
}
// Volatile
{
- hs.get(TestAccessMode.setVolatile).invokeExact(2.0d);
- double x = (double) hs.get(TestAccessMode.getVolatile).invokeExact();
+ hs.get(TestAccessMode.SET_VOLATILE).invokeExact(2.0d);
+ double x = (double) hs.get(TestAccessMode.GET_VOLATILE).invokeExact();
assertEquals(x, 2.0d, "setVolatile double value");
}
// Lazy
{
- hs.get(TestAccessMode.setRelease).invokeExact(1.0d);
- double x = (double) hs.get(TestAccessMode.getAcquire).invokeExact();
+ hs.get(TestAccessMode.SET_RELEASE).invokeExact(1.0d);
+ double x = (double) hs.get(TestAccessMode.GET_ACQUIRE).invokeExact();
assertEquals(x, 1.0d, "setRelease double value");
}
// Opaque
{
- hs.get(TestAccessMode.setOpaque).invokeExact(2.0d);
- double x = (double) hs.get(TestAccessMode.getOpaque).invokeExact();
+ hs.get(TestAccessMode.SET_OPAQUE).invokeExact(2.0d);
+ double x = (double) hs.get(TestAccessMode.GET_OPAQUE).invokeExact();
assertEquals(x, 2.0d, "setOpaque double value");
}
@@ -212,25 +212,25 @@
}
static void testStaticFieldUnsupported(Handles hs) throws Throwable {
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
checkUOE(am, () -> {
boolean r = (boolean) hs.get(am).invokeExact(1.0d, 2.0d);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndExchange)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
checkUOE(am, () -> {
double r = (double) hs.get(am).invokeExact(1.0d, 2.0d);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
checkUOE(am, () -> {
double r = (double) hs.get(am).invokeExact(1.0d);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndAdd)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
checkUOE(am, () -> {
double r = (double) hs.get(am).invokeExact(1.0d);
});
@@ -244,30 +244,30 @@
for (int i = 0; i < array.length; i++) {
// Plain
{
- hs.get(TestAccessMode.set).invokeExact(array, i, 1.0d);
- double x = (double) hs.get(TestAccessMode.get).invokeExact(array, i);
+ hs.get(TestAccessMode.SET).invokeExact(array, i, 1.0d);
+ double x = (double) hs.get(TestAccessMode.GET).invokeExact(array, i);
assertEquals(x, 1.0d, "get double value");
}
// Volatile
{
- hs.get(TestAccessMode.setVolatile).invokeExact(array, i, 2.0d);
- double x = (double) hs.get(TestAccessMode.getVolatile).invokeExact(array, i);
+ hs.get(TestAccessMode.SET_VOLATILE).invokeExact(array, i, 2.0d);
+ double x = (double) hs.get(TestAccessMode.GET_VOLATILE).invokeExact(array, i);
assertEquals(x, 2.0d, "setVolatile double value");
}
// Lazy
{
- hs.get(TestAccessMode.setRelease).invokeExact(array, i, 1.0d);
- double x = (double) hs.get(TestAccessMode.getAcquire).invokeExact(array, i);
+ hs.get(TestAccessMode.SET_RELEASE).invokeExact(array, i, 1.0d);
+ double x = (double) hs.get(TestAccessMode.GET_ACQUIRE).invokeExact(array, i);
assertEquals(x, 1.0d, "setRelease double value");
}
// Opaque
{
- hs.get(TestAccessMode.setOpaque).invokeExact(array, i, 2.0d);
- double x = (double) hs.get(TestAccessMode.getOpaque).invokeExact(array, i);
+ hs.get(TestAccessMode.SET_OPAQUE).invokeExact(array, i, 2.0d);
+ double x = (double) hs.get(TestAccessMode.GET_OPAQUE).invokeExact(array, i);
assertEquals(x, 2.0d, "setOpaque double value");
}
@@ -279,25 +279,25 @@
double[] array = new double[10];
final int i = 0;
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
checkUOE(am, () -> {
boolean r = (boolean) hs.get(am).invokeExact(array, i, 1.0d, 2.0d);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndExchange)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
checkUOE(am, () -> {
double r = (double) hs.get(am).invokeExact(array, i, 1.0d, 2.0d);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
checkUOE(am, () -> {
double r = (double) hs.get(am).invokeExact(array, i, 1.0d);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndAdd)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
checkUOE(am, () -> {
double o = (double) hs.get(am).invokeExact(array, i, 1.0d);
});
@@ -310,13 +310,13 @@
for (int i : new int[]{-1, Integer.MIN_VALUE, 10, 11, Integer.MAX_VALUE}) {
final int ci = i;
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.get)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
checkIOOBE(am, () -> {
double x = (double) hs.get(am).invokeExact(array, ci);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.set)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
checkIOOBE(am, () -> {
hs.get(am).invokeExact(array, ci, 1.0d);
});
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessFloat.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessFloat.java Wed Jul 05 21:35:27 2017 +0200
@@ -121,30 +121,30 @@
static void testInstanceField(VarHandleTestMethodHandleAccessFloat recv, Handles hs) throws Throwable {
// Plain
{
- hs.get(TestAccessMode.set).invokeExact(recv, 1.0f);
- float x = (float) hs.get(TestAccessMode.get).invokeExact(recv);
+ hs.get(TestAccessMode.SET).invokeExact(recv, 1.0f);
+ float x = (float) hs.get(TestAccessMode.GET).invokeExact(recv);
assertEquals(x, 1.0f, "set float value");
}
// Volatile
{
- hs.get(TestAccessMode.setVolatile).invokeExact(recv, 2.0f);
- float x = (float) hs.get(TestAccessMode.getVolatile).invokeExact(recv);
+ hs.get(TestAccessMode.SET_VOLATILE).invokeExact(recv, 2.0f);
+ float x = (float) hs.get(TestAccessMode.GET_VOLATILE).invokeExact(recv);
assertEquals(x, 2.0f, "setVolatile float value");
}
// Lazy
{
- hs.get(TestAccessMode.setRelease).invokeExact(recv, 1.0f);
- float x = (float) hs.get(TestAccessMode.getAcquire).invokeExact(recv);
+ hs.get(TestAccessMode.SET_RELEASE).invokeExact(recv, 1.0f);
+ float x = (float) hs.get(TestAccessMode.GET_ACQUIRE).invokeExact(recv);
assertEquals(x, 1.0f, "setRelease float value");
}
// Opaque
{
- hs.get(TestAccessMode.setOpaque).invokeExact(recv, 2.0f);
- float x = (float) hs.get(TestAccessMode.getOpaque).invokeExact(recv);
+ hs.get(TestAccessMode.SET_OPAQUE).invokeExact(recv, 2.0f);
+ float x = (float) hs.get(TestAccessMode.GET_OPAQUE).invokeExact(recv);
assertEquals(x, 2.0f, "setOpaque float value");
}
@@ -152,25 +152,25 @@
}
static void testInstanceFieldUnsupported(VarHandleTestMethodHandleAccessFloat recv, Handles hs) throws Throwable {
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
checkUOE(am, () -> {
boolean r = (boolean) hs.get(am).invokeExact(recv, 1.0f, 2.0f);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndExchange)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
checkUOE(am, () -> {
float r = (float) hs.get(am).invokeExact(recv, 1.0f, 2.0f);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
checkUOE(am, () -> {
float r = (float) hs.get(am).invokeExact(recv, 1.0f);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndAdd)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
checkUOE(am, () -> {
float r = (float) hs.get(am).invokeExact(recv, 1.0f);
});
@@ -181,30 +181,30 @@
static void testStaticField(Handles hs) throws Throwable {
// Plain
{
- hs.get(TestAccessMode.set).invokeExact(1.0f);
- float x = (float) hs.get(TestAccessMode.get).invokeExact();
+ hs.get(TestAccessMode.SET).invokeExact(1.0f);
+ float x = (float) hs.get(TestAccessMode.GET).invokeExact();
assertEquals(x, 1.0f, "set float value");
}
// Volatile
{
- hs.get(TestAccessMode.setVolatile).invokeExact(2.0f);
- float x = (float) hs.get(TestAccessMode.getVolatile).invokeExact();
+ hs.get(TestAccessMode.SET_VOLATILE).invokeExact(2.0f);
+ float x = (float) hs.get(TestAccessMode.GET_VOLATILE).invokeExact();
assertEquals(x, 2.0f, "setVolatile float value");
}
// Lazy
{
- hs.get(TestAccessMode.setRelease).invokeExact(1.0f);
- float x = (float) hs.get(TestAccessMode.getAcquire).invokeExact();
+ hs.get(TestAccessMode.SET_RELEASE).invokeExact(1.0f);
+ float x = (float) hs.get(TestAccessMode.GET_ACQUIRE).invokeExact();
assertEquals(x, 1.0f, "setRelease float value");
}
// Opaque
{
- hs.get(TestAccessMode.setOpaque).invokeExact(2.0f);
- float x = (float) hs.get(TestAccessMode.getOpaque).invokeExact();
+ hs.get(TestAccessMode.SET_OPAQUE).invokeExact(2.0f);
+ float x = (float) hs.get(TestAccessMode.GET_OPAQUE).invokeExact();
assertEquals(x, 2.0f, "setOpaque float value");
}
@@ -212,25 +212,25 @@
}
static void testStaticFieldUnsupported(Handles hs) throws Throwable {
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
checkUOE(am, () -> {
boolean r = (boolean) hs.get(am).invokeExact(1.0f, 2.0f);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndExchange)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
checkUOE(am, () -> {
float r = (float) hs.get(am).invokeExact(1.0f, 2.0f);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
checkUOE(am, () -> {
float r = (float) hs.get(am).invokeExact(1.0f);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndAdd)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
checkUOE(am, () -> {
float r = (float) hs.get(am).invokeExact(1.0f);
});
@@ -244,30 +244,30 @@
for (int i = 0; i < array.length; i++) {
// Plain
{
- hs.get(TestAccessMode.set).invokeExact(array, i, 1.0f);
- float x = (float) hs.get(TestAccessMode.get).invokeExact(array, i);
+ hs.get(TestAccessMode.SET).invokeExact(array, i, 1.0f);
+ float x = (float) hs.get(TestAccessMode.GET).invokeExact(array, i);
assertEquals(x, 1.0f, "get float value");
}
// Volatile
{
- hs.get(TestAccessMode.setVolatile).invokeExact(array, i, 2.0f);
- float x = (float) hs.get(TestAccessMode.getVolatile).invokeExact(array, i);
+ hs.get(TestAccessMode.SET_VOLATILE).invokeExact(array, i, 2.0f);
+ float x = (float) hs.get(TestAccessMode.GET_VOLATILE).invokeExact(array, i);
assertEquals(x, 2.0f, "setVolatile float value");
}
// Lazy
{
- hs.get(TestAccessMode.setRelease).invokeExact(array, i, 1.0f);
- float x = (float) hs.get(TestAccessMode.getAcquire).invokeExact(array, i);
+ hs.get(TestAccessMode.SET_RELEASE).invokeExact(array, i, 1.0f);
+ float x = (float) hs.get(TestAccessMode.GET_ACQUIRE).invokeExact(array, i);
assertEquals(x, 1.0f, "setRelease float value");
}
// Opaque
{
- hs.get(TestAccessMode.setOpaque).invokeExact(array, i, 2.0f);
- float x = (float) hs.get(TestAccessMode.getOpaque).invokeExact(array, i);
+ hs.get(TestAccessMode.SET_OPAQUE).invokeExact(array, i, 2.0f);
+ float x = (float) hs.get(TestAccessMode.GET_OPAQUE).invokeExact(array, i);
assertEquals(x, 2.0f, "setOpaque float value");
}
@@ -279,25 +279,25 @@
float[] array = new float[10];
final int i = 0;
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
checkUOE(am, () -> {
boolean r = (boolean) hs.get(am).invokeExact(array, i, 1.0f, 2.0f);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndExchange)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
checkUOE(am, () -> {
float r = (float) hs.get(am).invokeExact(array, i, 1.0f, 2.0f);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
checkUOE(am, () -> {
float r = (float) hs.get(am).invokeExact(array, i, 1.0f);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndAdd)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
checkUOE(am, () -> {
float o = (float) hs.get(am).invokeExact(array, i, 1.0f);
});
@@ -310,13 +310,13 @@
for (int i : new int[]{-1, Integer.MIN_VALUE, 10, 11, Integer.MAX_VALUE}) {
final int ci = i;
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.get)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
checkIOOBE(am, () -> {
float x = (float) hs.get(am).invokeExact(array, ci);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.set)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
checkIOOBE(am, () -> {
hs.get(am).invokeExact(array, ci, 1.0f);
});
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessInt.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessInt.java Wed Jul 05 21:35:27 2017 +0200
@@ -121,128 +121,128 @@
static void testInstanceField(VarHandleTestMethodHandleAccessInt recv, Handles hs) throws Throwable {
// Plain
{
- hs.get(TestAccessMode.set).invokeExact(recv, 1);
- int x = (int) hs.get(TestAccessMode.get).invokeExact(recv);
+ hs.get(TestAccessMode.SET).invokeExact(recv, 1);
+ int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv);
assertEquals(x, 1, "set int value");
}
// Volatile
{
- hs.get(TestAccessMode.setVolatile).invokeExact(recv, 2);
- int x = (int) hs.get(TestAccessMode.getVolatile).invokeExact(recv);
+ hs.get(TestAccessMode.SET_VOLATILE).invokeExact(recv, 2);
+ int x = (int) hs.get(TestAccessMode.GET_VOLATILE).invokeExact(recv);
assertEquals(x, 2, "setVolatile int value");
}
// Lazy
{
- hs.get(TestAccessMode.setRelease).invokeExact(recv, 1);
- int x = (int) hs.get(TestAccessMode.getAcquire).invokeExact(recv);
+ hs.get(TestAccessMode.SET_RELEASE).invokeExact(recv, 1);
+ int x = (int) hs.get(TestAccessMode.GET_ACQUIRE).invokeExact(recv);
assertEquals(x, 1, "setRelease int value");
}
// Opaque
{
- hs.get(TestAccessMode.setOpaque).invokeExact(recv, 2);
- int x = (int) hs.get(TestAccessMode.getOpaque).invokeExact(recv);
+ hs.get(TestAccessMode.SET_OPAQUE).invokeExact(recv, 2);
+ int x = (int) hs.get(TestAccessMode.GET_OPAQUE).invokeExact(recv);
assertEquals(x, 2, "setOpaque int value");
}
- hs.get(TestAccessMode.set).invokeExact(recv, 1);
+ hs.get(TestAccessMode.SET).invokeExact(recv, 1);
// Compare
{
- boolean r = (boolean) hs.get(TestAccessMode.compareAndSet).invokeExact(recv, 1, 2);
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(recv, 1, 2);
assertEquals(r, true, "success compareAndSet int");
- int x = (int) hs.get(TestAccessMode.get).invokeExact(recv);
+ int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv);
assertEquals(x, 2, "success compareAndSet int value");
}
{
- boolean r = (boolean) hs.get(TestAccessMode.compareAndSet).invokeExact(recv, 1, 3);
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(recv, 1, 3);
assertEquals(r, false, "failing compareAndSet int");
- int x = (int) hs.get(TestAccessMode.get).invokeExact(recv);
+ int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv);
assertEquals(x, 2, "failing compareAndSet int value");
}
{
- int r = (int) hs.get(TestAccessMode.compareAndExchangeVolatile).invokeExact(recv, 2, 1);
+ int r = (int) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact(recv, 2, 1);
assertEquals(r, 2, "success compareAndExchangeVolatile int");
- int x = (int) hs.get(TestAccessMode.get).invokeExact(recv);
+ int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv);
assertEquals(x, 1, "success compareAndExchangeVolatile int value");
}
{
- int r = (int) hs.get(TestAccessMode.compareAndExchangeVolatile).invokeExact(recv, 2, 3);
+ int r = (int) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact(recv, 2, 3);
assertEquals(r, 1, "failing compareAndExchangeVolatile int");
- int x = (int) hs.get(TestAccessMode.get).invokeExact(recv);
+ int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv);
assertEquals(x, 1, "failing compareAndExchangeVolatile int value");
}
{
- int r = (int) hs.get(TestAccessMode.compareAndExchangeAcquire).invokeExact(recv, 1, 2);
+ int r = (int) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(recv, 1, 2);
assertEquals(r, 1, "success compareAndExchangeAcquire int");
- int x = (int) hs.get(TestAccessMode.get).invokeExact(recv);
+ int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv);
assertEquals(x, 2, "success compareAndExchangeAcquire int value");
}
{
- int r = (int) hs.get(TestAccessMode.compareAndExchangeAcquire).invokeExact(recv, 1, 3);
+ int r = (int) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(recv, 1, 3);
assertEquals(r, 2, "failing compareAndExchangeAcquire int");
- int x = (int) hs.get(TestAccessMode.get).invokeExact(recv);
+ int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv);
assertEquals(x, 2, "failing compareAndExchangeAcquire int value");
}
{
- int r = (int) hs.get(TestAccessMode.compareAndExchangeRelease).invokeExact(recv, 2, 1);
+ int r = (int) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(recv, 2, 1);
assertEquals(r, 2, "success compareAndExchangeRelease int");
- int x = (int) hs.get(TestAccessMode.get).invokeExact(recv);
+ int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv);
assertEquals(x, 1, "success compareAndExchangeRelease int value");
}
{
- int r = (int) hs.get(TestAccessMode.compareAndExchangeRelease).invokeExact(recv, 2, 3);
+ int r = (int) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(recv, 2, 3);
assertEquals(r, 1, "failing compareAndExchangeRelease int");
- int x = (int) hs.get(TestAccessMode.get).invokeExact(recv);
+ int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv);
assertEquals(x, 1, "failing compareAndExchangeRelease int value");
}
{
- boolean r = (boolean) hs.get(TestAccessMode.weakCompareAndSet).invokeExact(recv, 1, 2);
+ boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, 1, 2);
assertEquals(r, true, "weakCompareAndSet int");
- int x = (int) hs.get(TestAccessMode.get).invokeExact(recv);
+ int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv);
assertEquals(x, 2, "weakCompareAndSet int value");
}
{
- boolean r = (boolean) hs.get(TestAccessMode.weakCompareAndSetAcquire).invokeExact(recv, 2, 1);
+ boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(recv, 2, 1);
assertEquals(r, true, "weakCompareAndSetAcquire int");
- int x = (int) hs.get(TestAccessMode.get).invokeExact(recv);
+ int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv);
assertEquals(x, 1, "weakCompareAndSetAcquire int");
}
{
- boolean r = (boolean) hs.get(TestAccessMode.weakCompareAndSetRelease).invokeExact(recv, 1, 2);
+ boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(recv, 1, 2);
assertEquals(r, true, "weakCompareAndSetRelease int");
- int x = (int) hs.get(TestAccessMode.get).invokeExact(recv);
+ int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv);
assertEquals(x, 2, "weakCompareAndSetRelease int");
}
// Compare set and get
{
- int o = (int) hs.get(TestAccessMode.getAndSet).invokeExact(recv, 1);
+ int o = (int) hs.get(TestAccessMode.GET_AND_SET).invokeExact(recv, 1);
assertEquals(o, 2, "getAndSet int");
- int x = (int) hs.get(TestAccessMode.get).invokeExact(recv);
+ int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv);
assertEquals(x, 1, "getAndSet int value");
}
- hs.get(TestAccessMode.set).invokeExact(recv, 1);
+ hs.get(TestAccessMode.SET).invokeExact(recv, 1);
// get and add, add and get
{
- int o = (int) hs.get(TestAccessMode.getAndAdd).invokeExact(recv, 3);
+ int o = (int) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(recv, 3);
assertEquals(o, 1, "getAndAdd int");
- int c = (int) hs.get(TestAccessMode.addAndGet).invokeExact(recv, 3);
+ int c = (int) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(recv, 3);
assertEquals(c, 1 + 3 + 3, "getAndAdd int value");
}
}
@@ -255,128 +255,128 @@
static void testStaticField(Handles hs) throws Throwable {
// Plain
{
- hs.get(TestAccessMode.set).invokeExact(1);
- int x = (int) hs.get(TestAccessMode.get).invokeExact();
+ hs.get(TestAccessMode.SET).invokeExact(1);
+ int x = (int) hs.get(TestAccessMode.GET).invokeExact();
assertEquals(x, 1, "set int value");
}
// Volatile
{
- hs.get(TestAccessMode.setVolatile).invokeExact(2);
- int x = (int) hs.get(TestAccessMode.getVolatile).invokeExact();
+ hs.get(TestAccessMode.SET_VOLATILE).invokeExact(2);
+ int x = (int) hs.get(TestAccessMode.GET_VOLATILE).invokeExact();
assertEquals(x, 2, "setVolatile int value");
}
// Lazy
{
- hs.get(TestAccessMode.setRelease).invokeExact(1);
- int x = (int) hs.get(TestAccessMode.getAcquire).invokeExact();
+ hs.get(TestAccessMode.SET_RELEASE).invokeExact(1);
+ int x = (int) hs.get(TestAccessMode.GET_ACQUIRE).invokeExact();
assertEquals(x, 1, "setRelease int value");
}
// Opaque
{
- hs.get(TestAccessMode.setOpaque).invokeExact(2);
- int x = (int) hs.get(TestAccessMode.getOpaque).invokeExact();
+ hs.get(TestAccessMode.SET_OPAQUE).invokeExact(2);
+ int x = (int) hs.get(TestAccessMode.GET_OPAQUE).invokeExact();
assertEquals(x, 2, "setOpaque int value");
}
- hs.get(TestAccessMode.set).invokeExact(1);
+ hs.get(TestAccessMode.SET).invokeExact(1);
// Compare
{
- boolean r = (boolean) hs.get(TestAccessMode.compareAndSet).invokeExact(1, 2);
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(1, 2);
assertEquals(r, true, "success compareAndSet int");
- int x = (int) hs.get(TestAccessMode.get).invokeExact();
+ int x = (int) hs.get(TestAccessMode.GET).invokeExact();
assertEquals(x, 2, "success compareAndSet int value");
}
{
- boolean r = (boolean) hs.get(TestAccessMode.compareAndSet).invokeExact(1, 3);
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(1, 3);
assertEquals(r, false, "failing compareAndSet int");
- int x = (int) hs.get(TestAccessMode.get).invokeExact();
+ int x = (int) hs.get(TestAccessMode.GET).invokeExact();
assertEquals(x, 2, "failing compareAndSet int value");
}
{
- int r = (int) hs.get(TestAccessMode.compareAndExchangeVolatile).invokeExact(2, 1);
+ int r = (int) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact(2, 1);
assertEquals(r, 2, "success compareAndExchangeVolatile int");
- int x = (int) hs.get(TestAccessMode.get).invokeExact();
+ int x = (int) hs.get(TestAccessMode.GET).invokeExact();
assertEquals(x, 1, "success compareAndExchangeVolatile int value");
}
{
- int r = (int) hs.get(TestAccessMode.compareAndExchangeVolatile).invokeExact(2, 3);
+ int r = (int) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact(2, 3);
assertEquals(r, 1, "failing compareAndExchangeVolatile int");
- int x = (int) hs.get(TestAccessMode.get).invokeExact();
+ int x = (int) hs.get(TestAccessMode.GET).invokeExact();
assertEquals(x, 1, "failing compareAndExchangeVolatile int value");
}
{
- int r = (int) hs.get(TestAccessMode.compareAndExchangeAcquire).invokeExact(1, 2);
+ int r = (int) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(1, 2);
assertEquals(r, 1, "success compareAndExchangeAcquire int");
- int x = (int) hs.get(TestAccessMode.get).invokeExact();
+ int x = (int) hs.get(TestAccessMode.GET).invokeExact();
assertEquals(x, 2, "success compareAndExchangeAcquire int value");
}
{
- int r = (int) hs.get(TestAccessMode.compareAndExchangeAcquire).invokeExact(1, 3);
+ int r = (int) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(1, 3);
assertEquals(r, 2, "failing compareAndExchangeAcquire int");
- int x = (int) hs.get(TestAccessMode.get).invokeExact();
+ int x = (int) hs.get(TestAccessMode.GET).invokeExact();
assertEquals(x, 2, "failing compareAndExchangeAcquire int value");
}
{
- int r = (int) hs.get(TestAccessMode.compareAndExchangeRelease).invokeExact(2, 1);
+ int r = (int) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(2, 1);
assertEquals(r, 2, "success compareAndExchangeRelease int");
- int x = (int) hs.get(TestAccessMode.get).invokeExact();
+ int x = (int) hs.get(TestAccessMode.GET).invokeExact();
assertEquals(x, 1, "success compareAndExchangeRelease int value");
}
{
- int r = (int) hs.get(TestAccessMode.compareAndExchangeRelease).invokeExact(2, 3);
+ int r = (int) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(2, 3);
assertEquals(r, 1, "failing compareAndExchangeRelease int");
- int x = (int) hs.get(TestAccessMode.get).invokeExact();
+ int x = (int) hs.get(TestAccessMode.GET).invokeExact();
assertEquals(x, 1, "failing compareAndExchangeRelease int value");
}
{
- boolean r = (boolean) hs.get(TestAccessMode.weakCompareAndSet).invokeExact(1, 2);
+ boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(1, 2);
assertEquals(r, true, "weakCompareAndSet int");
- int x = (int) hs.get(TestAccessMode.get).invokeExact();
+ int x = (int) hs.get(TestAccessMode.GET).invokeExact();
assertEquals(x, 2, "weakCompareAndSet int value");
}
{
- boolean r = (boolean) hs.get(TestAccessMode.weakCompareAndSetAcquire).invokeExact(2, 1);
+ boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(2, 1);
assertEquals(r, true, "weakCompareAndSetAcquire int");
- int x = (int) hs.get(TestAccessMode.get).invokeExact();
+ int x = (int) hs.get(TestAccessMode.GET).invokeExact();
assertEquals(x, 1, "weakCompareAndSetAcquire int");
}
{
- boolean r = (boolean) hs.get(TestAccessMode.weakCompareAndSetRelease).invokeExact( 1, 2);
+ boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact( 1, 2);
assertEquals(r, true, "weakCompareAndSetRelease int");
- int x = (int) hs.get(TestAccessMode.get).invokeExact();
+ int x = (int) hs.get(TestAccessMode.GET).invokeExact();
assertEquals(x, 2, "weakCompareAndSetRelease int");
}
// Compare set and get
{
- int o = (int) hs.get(TestAccessMode.getAndSet).invokeExact( 1);
+ int o = (int) hs.get(TestAccessMode.GET_AND_SET).invokeExact( 1);
assertEquals(o, 2, "getAndSet int");
- int x = (int) hs.get(TestAccessMode.get).invokeExact();
+ int x = (int) hs.get(TestAccessMode.GET).invokeExact();
assertEquals(x, 1, "getAndSet int value");
}
- hs.get(TestAccessMode.set).invokeExact(1);
+ hs.get(TestAccessMode.SET).invokeExact(1);
// get and add, add and get
{
- int o = (int) hs.get(TestAccessMode.getAndAdd).invokeExact( 3);
+ int o = (int) hs.get(TestAccessMode.GET_AND_ADD).invokeExact( 3);
assertEquals(o, 1, "getAndAdd int");
- int c = (int) hs.get(TestAccessMode.addAndGet).invokeExact(3);
+ int c = (int) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(3);
assertEquals(c, 1 + 3 + 3, "getAndAdd int value");
}
}
@@ -392,128 +392,128 @@
for (int i = 0; i < array.length; i++) {
// Plain
{
- hs.get(TestAccessMode.set).invokeExact(array, i, 1);
- int x = (int) hs.get(TestAccessMode.get).invokeExact(array, i);
+ hs.get(TestAccessMode.SET).invokeExact(array, i, 1);
+ int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i);
assertEquals(x, 1, "get int value");
}
// Volatile
{
- hs.get(TestAccessMode.setVolatile).invokeExact(array, i, 2);
- int x = (int) hs.get(TestAccessMode.getVolatile).invokeExact(array, i);
+ hs.get(TestAccessMode.SET_VOLATILE).invokeExact(array, i, 2);
+ int x = (int) hs.get(TestAccessMode.GET_VOLATILE).invokeExact(array, i);
assertEquals(x, 2, "setVolatile int value");
}
// Lazy
{
- hs.get(TestAccessMode.setRelease).invokeExact(array, i, 1);
- int x = (int) hs.get(TestAccessMode.getAcquire).invokeExact(array, i);
+ hs.get(TestAccessMode.SET_RELEASE).invokeExact(array, i, 1);
+ int x = (int) hs.get(TestAccessMode.GET_ACQUIRE).invokeExact(array, i);
assertEquals(x, 1, "setRelease int value");
}
// Opaque
{
- hs.get(TestAccessMode.setOpaque).invokeExact(array, i, 2);
- int x = (int) hs.get(TestAccessMode.getOpaque).invokeExact(array, i);
+ hs.get(TestAccessMode.SET_OPAQUE).invokeExact(array, i, 2);
+ int x = (int) hs.get(TestAccessMode.GET_OPAQUE).invokeExact(array, i);
assertEquals(x, 2, "setOpaque int value");
}
- hs.get(TestAccessMode.set).invokeExact(array, i, 1);
+ hs.get(TestAccessMode.SET).invokeExact(array, i, 1);
// Compare
{
- boolean r = (boolean) hs.get(TestAccessMode.compareAndSet).invokeExact(array, i, 1, 2);
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(array, i, 1, 2);
assertEquals(r, true, "success compareAndSet int");
- int x = (int) hs.get(TestAccessMode.get).invokeExact(array, i);
+ int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i);
assertEquals(x, 2, "success compareAndSet int value");
}
{
- boolean r = (boolean) hs.get(TestAccessMode.compareAndSet).invokeExact(array, i, 1, 3);
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(array, i, 1, 3);
assertEquals(r, false, "failing compareAndSet int");
- int x = (int) hs.get(TestAccessMode.get).invokeExact(array, i);
+ int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i);
assertEquals(x, 2, "failing compareAndSet int value");
}
{
- int r = (int) hs.get(TestAccessMode.compareAndExchangeVolatile).invokeExact(array, i, 2, 1);
+ int r = (int) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact(array, i, 2, 1);
assertEquals(r, 2, "success compareAndExchangeVolatile int");
- int x = (int) hs.get(TestAccessMode.get).invokeExact(array, i);
+ int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i);
assertEquals(x, 1, "success compareAndExchangeVolatile int value");
}
{
- int r = (int) hs.get(TestAccessMode.compareAndExchangeVolatile).invokeExact(array, i, 2, 3);
+ int r = (int) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact(array, i, 2, 3);
assertEquals(r, 1, "failing compareAndExchangeVolatile int");
- int x = (int) hs.get(TestAccessMode.get).invokeExact(array, i);
+ int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i);
assertEquals(x, 1, "failing compareAndExchangeVolatile int value");
}
{
- int r = (int) hs.get(TestAccessMode.compareAndExchangeAcquire).invokeExact(array, i, 1, 2);
+ int r = (int) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(array, i, 1, 2);
assertEquals(r, 1, "success compareAndExchangeAcquire int");
- int x = (int) hs.get(TestAccessMode.get).invokeExact(array, i);
+ int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i);
assertEquals(x, 2, "success compareAndExchangeAcquire int value");
}
{
- int r = (int) hs.get(TestAccessMode.compareAndExchangeAcquire).invokeExact(array, i, 1, 3);
+ int r = (int) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(array, i, 1, 3);
assertEquals(r, 2, "failing compareAndExchangeAcquire int");
- int x = (int) hs.get(TestAccessMode.get).invokeExact(array, i);
+ int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i);
assertEquals(x, 2, "failing compareAndExchangeAcquire int value");
}
{
- int r = (int) hs.get(TestAccessMode.compareAndExchangeRelease).invokeExact(array, i, 2, 1);
+ int r = (int) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(array, i, 2, 1);
assertEquals(r, 2, "success compareAndExchangeRelease int");
- int x = (int) hs.get(TestAccessMode.get).invokeExact(array, i);
+ int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i);
assertEquals(x, 1, "success compareAndExchangeRelease int value");
}
{
- int r = (int) hs.get(TestAccessMode.compareAndExchangeRelease).invokeExact(array, i, 2, 3);
+ int r = (int) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(array, i, 2, 3);
assertEquals(r, 1, "failing compareAndExchangeRelease int");
- int x = (int) hs.get(TestAccessMode.get).invokeExact(array, i);
+ int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i);
assertEquals(x, 1, "failing compareAndExchangeRelease int value");
}
{
- boolean r = (boolean) hs.get(TestAccessMode.weakCompareAndSet).invokeExact(array, i, 1, 2);
+ boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, 1, 2);
assertEquals(r, true, "weakCompareAndSet int");
- int x = (int) hs.get(TestAccessMode.get).invokeExact(array, i);
+ int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i);
assertEquals(x, 2, "weakCompareAndSet int value");
}
{
- boolean r = (boolean) hs.get(TestAccessMode.weakCompareAndSetAcquire).invokeExact(array, i, 2, 1);
+ boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(array, i, 2, 1);
assertEquals(r, true, "weakCompareAndSetAcquire int");
- int x = (int) hs.get(TestAccessMode.get).invokeExact(array, i);
+ int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i);
assertEquals(x, 1, "weakCompareAndSetAcquire int");
}
{
- boolean r = (boolean) hs.get(TestAccessMode.weakCompareAndSetRelease).invokeExact(array, i, 1, 2);
+ boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(array, i, 1, 2);
assertEquals(r, true, "weakCompareAndSetRelease int");
- int x = (int) hs.get(TestAccessMode.get).invokeExact(array, i);
+ int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i);
assertEquals(x, 2, "weakCompareAndSetRelease int");
}
// Compare set and get
{
- int o = (int) hs.get(TestAccessMode.getAndSet).invokeExact(array, i, 1);
+ int o = (int) hs.get(TestAccessMode.GET_AND_SET).invokeExact(array, i, 1);
assertEquals(o, 2, "getAndSet int");
- int x = (int) hs.get(TestAccessMode.get).invokeExact(array, i);
+ int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i);
assertEquals(x, 1, "getAndSet int value");
}
- hs.get(TestAccessMode.set).invokeExact(array, i, 1);
+ hs.get(TestAccessMode.SET).invokeExact(array, i, 1);
// get and add, add and get
{
- int o = (int) hs.get(TestAccessMode.getAndAdd).invokeExact(array, i, 3);
+ int o = (int) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(array, i, 3);
assertEquals(o, 1, "getAndAdd int");
- int c = (int) hs.get(TestAccessMode.addAndGet).invokeExact(array, i, 3);
+ int c = (int) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(array, i, 3);
assertEquals(c, 1 + 3 + 3, "getAndAdd int value");
}
}
@@ -532,37 +532,37 @@
for (int i : new int[]{-1, Integer.MIN_VALUE, 10, 11, Integer.MAX_VALUE}) {
final int ci = i;
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.get)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
checkIOOBE(am, () -> {
int x = (int) hs.get(am).invokeExact(array, ci);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.set)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
checkIOOBE(am, () -> {
hs.get(am).invokeExact(array, ci, 1);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
checkIOOBE(am, () -> {
boolean r = (boolean) hs.get(am).invokeExact(array, ci, 1, 2);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndExchange)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
checkIOOBE(am, () -> {
int r = (int) hs.get(am).invokeExact(array, ci, 2, 1);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
checkIOOBE(am, () -> {
int o = (int) hs.get(am).invokeExact(array, ci, 1);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndAdd)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
checkIOOBE(am, () -> {
int o = (int) hs.get(am).invokeExact(array, ci, 3);
});
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessLong.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessLong.java Wed Jul 05 21:35:27 2017 +0200
@@ -121,128 +121,128 @@
static void testInstanceField(VarHandleTestMethodHandleAccessLong recv, Handles hs) throws Throwable {
// Plain
{
- hs.get(TestAccessMode.set).invokeExact(recv, 1L);
- long x = (long) hs.get(TestAccessMode.get).invokeExact(recv);
+ hs.get(TestAccessMode.SET).invokeExact(recv, 1L);
+ long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv);
assertEquals(x, 1L, "set long value");
}
// Volatile
{
- hs.get(TestAccessMode.setVolatile).invokeExact(recv, 2L);
- long x = (long) hs.get(TestAccessMode.getVolatile).invokeExact(recv);
+ hs.get(TestAccessMode.SET_VOLATILE).invokeExact(recv, 2L);
+ long x = (long) hs.get(TestAccessMode.GET_VOLATILE).invokeExact(recv);
assertEquals(x, 2L, "setVolatile long value");
}
// Lazy
{
- hs.get(TestAccessMode.setRelease).invokeExact(recv, 1L);
- long x = (long) hs.get(TestAccessMode.getAcquire).invokeExact(recv);
+ hs.get(TestAccessMode.SET_RELEASE).invokeExact(recv, 1L);
+ long x = (long) hs.get(TestAccessMode.GET_ACQUIRE).invokeExact(recv);
assertEquals(x, 1L, "setRelease long value");
}
// Opaque
{
- hs.get(TestAccessMode.setOpaque).invokeExact(recv, 2L);
- long x = (long) hs.get(TestAccessMode.getOpaque).invokeExact(recv);
+ hs.get(TestAccessMode.SET_OPAQUE).invokeExact(recv, 2L);
+ long x = (long) hs.get(TestAccessMode.GET_OPAQUE).invokeExact(recv);
assertEquals(x, 2L, "setOpaque long value");
}
- hs.get(TestAccessMode.set).invokeExact(recv, 1L);
+ hs.get(TestAccessMode.SET).invokeExact(recv, 1L);
// Compare
{
- boolean r = (boolean) hs.get(TestAccessMode.compareAndSet).invokeExact(recv, 1L, 2L);
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(recv, 1L, 2L);
assertEquals(r, true, "success compareAndSet long");
- long x = (long) hs.get(TestAccessMode.get).invokeExact(recv);
+ long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv);
assertEquals(x, 2L, "success compareAndSet long value");
}
{
- boolean r = (boolean) hs.get(TestAccessMode.compareAndSet).invokeExact(recv, 1L, 3L);
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(recv, 1L, 3L);
assertEquals(r, false, "failing compareAndSet long");
- long x = (long) hs.get(TestAccessMode.get).invokeExact(recv);
+ long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv);
assertEquals(x, 2L, "failing compareAndSet long value");
}
{
- long r = (long) hs.get(TestAccessMode.compareAndExchangeVolatile).invokeExact(recv, 2L, 1L);
+ long r = (long) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact(recv, 2L, 1L);
assertEquals(r, 2L, "success compareAndExchangeVolatile long");
- long x = (long) hs.get(TestAccessMode.get).invokeExact(recv);
+ long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv);
assertEquals(x, 1L, "success compareAndExchangeVolatile long value");
}
{
- long r = (long) hs.get(TestAccessMode.compareAndExchangeVolatile).invokeExact(recv, 2L, 3L);
+ long r = (long) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact(recv, 2L, 3L);
assertEquals(r, 1L, "failing compareAndExchangeVolatile long");
- long x = (long) hs.get(TestAccessMode.get).invokeExact(recv);
+ long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv);
assertEquals(x, 1L, "failing compareAndExchangeVolatile long value");
}
{
- long r = (long) hs.get(TestAccessMode.compareAndExchangeAcquire).invokeExact(recv, 1L, 2L);
+ long r = (long) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(recv, 1L, 2L);
assertEquals(r, 1L, "success compareAndExchangeAcquire long");
- long x = (long) hs.get(TestAccessMode.get).invokeExact(recv);
+ long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv);
assertEquals(x, 2L, "success compareAndExchangeAcquire long value");
}
{
- long r = (long) hs.get(TestAccessMode.compareAndExchangeAcquire).invokeExact(recv, 1L, 3L);
+ long r = (long) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(recv, 1L, 3L);
assertEquals(r, 2L, "failing compareAndExchangeAcquire long");
- long x = (long) hs.get(TestAccessMode.get).invokeExact(recv);
+ long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv);
assertEquals(x, 2L, "failing compareAndExchangeAcquire long value");
}
{
- long r = (long) hs.get(TestAccessMode.compareAndExchangeRelease).invokeExact(recv, 2L, 1L);
+ long r = (long) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(recv, 2L, 1L);
assertEquals(r, 2L, "success compareAndExchangeRelease long");
- long x = (long) hs.get(TestAccessMode.get).invokeExact(recv);
+ long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv);
assertEquals(x, 1L, "success compareAndExchangeRelease long value");
}
{
- long r = (long) hs.get(TestAccessMode.compareAndExchangeRelease).invokeExact(recv, 2L, 3L);
+ long r = (long) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(recv, 2L, 3L);
assertEquals(r, 1L, "failing compareAndExchangeRelease long");
- long x = (long) hs.get(TestAccessMode.get).invokeExact(recv);
+ long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv);
assertEquals(x, 1L, "failing compareAndExchangeRelease long value");
}
{
- boolean r = (boolean) hs.get(TestAccessMode.weakCompareAndSet).invokeExact(recv, 1L, 2L);
+ boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, 1L, 2L);
assertEquals(r, true, "weakCompareAndSet long");
- long x = (long) hs.get(TestAccessMode.get).invokeExact(recv);
+ long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv);
assertEquals(x, 2L, "weakCompareAndSet long value");
}
{
- boolean r = (boolean) hs.get(TestAccessMode.weakCompareAndSetAcquire).invokeExact(recv, 2L, 1L);
+ boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(recv, 2L, 1L);
assertEquals(r, true, "weakCompareAndSetAcquire long");
- long x = (long) hs.get(TestAccessMode.get).invokeExact(recv);
+ long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv);
assertEquals(x, 1L, "weakCompareAndSetAcquire long");
}
{
- boolean r = (boolean) hs.get(TestAccessMode.weakCompareAndSetRelease).invokeExact(recv, 1L, 2L);
+ boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(recv, 1L, 2L);
assertEquals(r, true, "weakCompareAndSetRelease long");
- long x = (long) hs.get(TestAccessMode.get).invokeExact(recv);
+ long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv);
assertEquals(x, 2L, "weakCompareAndSetRelease long");
}
// Compare set and get
{
- long o = (long) hs.get(TestAccessMode.getAndSet).invokeExact(recv, 1L);
+ long o = (long) hs.get(TestAccessMode.GET_AND_SET).invokeExact(recv, 1L);
assertEquals(o, 2L, "getAndSet long");
- long x = (long) hs.get(TestAccessMode.get).invokeExact(recv);
+ long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv);
assertEquals(x, 1L, "getAndSet long value");
}
- hs.get(TestAccessMode.set).invokeExact(recv, 1L);
+ hs.get(TestAccessMode.SET).invokeExact(recv, 1L);
// get and add, add and get
{
- long o = (long) hs.get(TestAccessMode.getAndAdd).invokeExact(recv, 3L);
+ long o = (long) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(recv, 3L);
assertEquals(o, 1L, "getAndAdd long");
- long c = (long) hs.get(TestAccessMode.addAndGet).invokeExact(recv, 3L);
+ long c = (long) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(recv, 3L);
assertEquals(c, 1L + 3L + 3L, "getAndAdd long value");
}
}
@@ -255,128 +255,128 @@
static void testStaticField(Handles hs) throws Throwable {
// Plain
{
- hs.get(TestAccessMode.set).invokeExact(1L);
- long x = (long) hs.get(TestAccessMode.get).invokeExact();
+ hs.get(TestAccessMode.SET).invokeExact(1L);
+ long x = (long) hs.get(TestAccessMode.GET).invokeExact();
assertEquals(x, 1L, "set long value");
}
// Volatile
{
- hs.get(TestAccessMode.setVolatile).invokeExact(2L);
- long x = (long) hs.get(TestAccessMode.getVolatile).invokeExact();
+ hs.get(TestAccessMode.SET_VOLATILE).invokeExact(2L);
+ long x = (long) hs.get(TestAccessMode.GET_VOLATILE).invokeExact();
assertEquals(x, 2L, "setVolatile long value");
}
// Lazy
{
- hs.get(TestAccessMode.setRelease).invokeExact(1L);
- long x = (long) hs.get(TestAccessMode.getAcquire).invokeExact();
+ hs.get(TestAccessMode.SET_RELEASE).invokeExact(1L);
+ long x = (long) hs.get(TestAccessMode.GET_ACQUIRE).invokeExact();
assertEquals(x, 1L, "setRelease long value");
}
// Opaque
{
- hs.get(TestAccessMode.setOpaque).invokeExact(2L);
- long x = (long) hs.get(TestAccessMode.getOpaque).invokeExact();
+ hs.get(TestAccessMode.SET_OPAQUE).invokeExact(2L);
+ long x = (long) hs.get(TestAccessMode.GET_OPAQUE).invokeExact();
assertEquals(x, 2L, "setOpaque long value");
}
- hs.get(TestAccessMode.set).invokeExact(1L);
+ hs.get(TestAccessMode.SET).invokeExact(1L);
// Compare
{
- boolean r = (boolean) hs.get(TestAccessMode.compareAndSet).invokeExact(1L, 2L);
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(1L, 2L);
assertEquals(r, true, "success compareAndSet long");
- long x = (long) hs.get(TestAccessMode.get).invokeExact();
+ long x = (long) hs.get(TestAccessMode.GET).invokeExact();
assertEquals(x, 2L, "success compareAndSet long value");
}
{
- boolean r = (boolean) hs.get(TestAccessMode.compareAndSet).invokeExact(1L, 3L);
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(1L, 3L);
assertEquals(r, false, "failing compareAndSet long");
- long x = (long) hs.get(TestAccessMode.get).invokeExact();
+ long x = (long) hs.get(TestAccessMode.GET).invokeExact();
assertEquals(x, 2L, "failing compareAndSet long value");
}
{
- long r = (long) hs.get(TestAccessMode.compareAndExchangeVolatile).invokeExact(2L, 1L);
+ long r = (long) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact(2L, 1L);
assertEquals(r, 2L, "success compareAndExchangeVolatile long");
- long x = (long) hs.get(TestAccessMode.get).invokeExact();
+ long x = (long) hs.get(TestAccessMode.GET).invokeExact();
assertEquals(x, 1L, "success compareAndExchangeVolatile long value");
}
{
- long r = (long) hs.get(TestAccessMode.compareAndExchangeVolatile).invokeExact(2L, 3L);
+ long r = (long) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact(2L, 3L);
assertEquals(r, 1L, "failing compareAndExchangeVolatile long");
- long x = (long) hs.get(TestAccessMode.get).invokeExact();
+ long x = (long) hs.get(TestAccessMode.GET).invokeExact();
assertEquals(x, 1L, "failing compareAndExchangeVolatile long value");
}
{
- long r = (long) hs.get(TestAccessMode.compareAndExchangeAcquire).invokeExact(1L, 2L);
+ long r = (long) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(1L, 2L);
assertEquals(r, 1L, "success compareAndExchangeAcquire long");
- long x = (long) hs.get(TestAccessMode.get).invokeExact();
+ long x = (long) hs.get(TestAccessMode.GET).invokeExact();
assertEquals(x, 2L, "success compareAndExchangeAcquire long value");
}
{
- long r = (long) hs.get(TestAccessMode.compareAndExchangeAcquire).invokeExact(1L, 3L);
+ long r = (long) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(1L, 3L);
assertEquals(r, 2L, "failing compareAndExchangeAcquire long");
- long x = (long) hs.get(TestAccessMode.get).invokeExact();
+ long x = (long) hs.get(TestAccessMode.GET).invokeExact();
assertEquals(x, 2L, "failing compareAndExchangeAcquire long value");
}
{
- long r = (long) hs.get(TestAccessMode.compareAndExchangeRelease).invokeExact(2L, 1L);
+ long r = (long) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(2L, 1L);
assertEquals(r, 2L, "success compareAndExchangeRelease long");
- long x = (long) hs.get(TestAccessMode.get).invokeExact();
+ long x = (long) hs.get(TestAccessMode.GET).invokeExact();
assertEquals(x, 1L, "success compareAndExchangeRelease long value");
}
{
- long r = (long) hs.get(TestAccessMode.compareAndExchangeRelease).invokeExact(2L, 3L);
+ long r = (long) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(2L, 3L);
assertEquals(r, 1L, "failing compareAndExchangeRelease long");
- long x = (long) hs.get(TestAccessMode.get).invokeExact();
+ long x = (long) hs.get(TestAccessMode.GET).invokeExact();
assertEquals(x, 1L, "failing compareAndExchangeRelease long value");
}
{
- boolean r = (boolean) hs.get(TestAccessMode.weakCompareAndSet).invokeExact(1L, 2L);
+ boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(1L, 2L);
assertEquals(r, true, "weakCompareAndSet long");
- long x = (long) hs.get(TestAccessMode.get).invokeExact();
+ long x = (long) hs.get(TestAccessMode.GET).invokeExact();
assertEquals(x, 2L, "weakCompareAndSet long value");
}
{
- boolean r = (boolean) hs.get(TestAccessMode.weakCompareAndSetAcquire).invokeExact(2L, 1L);
+ boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(2L, 1L);
assertEquals(r, true, "weakCompareAndSetAcquire long");
- long x = (long) hs.get(TestAccessMode.get).invokeExact();
+ long x = (long) hs.get(TestAccessMode.GET).invokeExact();
assertEquals(x, 1L, "weakCompareAndSetAcquire long");
}
{
- boolean r = (boolean) hs.get(TestAccessMode.weakCompareAndSetRelease).invokeExact( 1L, 2L);
+ boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact( 1L, 2L);
assertEquals(r, true, "weakCompareAndSetRelease long");
- long x = (long) hs.get(TestAccessMode.get).invokeExact();
+ long x = (long) hs.get(TestAccessMode.GET).invokeExact();
assertEquals(x, 2L, "weakCompareAndSetRelease long");
}
// Compare set and get
{
- long o = (long) hs.get(TestAccessMode.getAndSet).invokeExact( 1L);
+ long o = (long) hs.get(TestAccessMode.GET_AND_SET).invokeExact( 1L);
assertEquals(o, 2L, "getAndSet long");
- long x = (long) hs.get(TestAccessMode.get).invokeExact();
+ long x = (long) hs.get(TestAccessMode.GET).invokeExact();
assertEquals(x, 1L, "getAndSet long value");
}
- hs.get(TestAccessMode.set).invokeExact(1L);
+ hs.get(TestAccessMode.SET).invokeExact(1L);
// get and add, add and get
{
- long o = (long) hs.get(TestAccessMode.getAndAdd).invokeExact( 3L);
+ long o = (long) hs.get(TestAccessMode.GET_AND_ADD).invokeExact( 3L);
assertEquals(o, 1L, "getAndAdd long");
- long c = (long) hs.get(TestAccessMode.addAndGet).invokeExact(3L);
+ long c = (long) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(3L);
assertEquals(c, 1L + 3L + 3L, "getAndAdd long value");
}
}
@@ -392,128 +392,128 @@
for (int i = 0; i < array.length; i++) {
// Plain
{
- hs.get(TestAccessMode.set).invokeExact(array, i, 1L);
- long x = (long) hs.get(TestAccessMode.get).invokeExact(array, i);
+ hs.get(TestAccessMode.SET).invokeExact(array, i, 1L);
+ long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i);
assertEquals(x, 1L, "get long value");
}
// Volatile
{
- hs.get(TestAccessMode.setVolatile).invokeExact(array, i, 2L);
- long x = (long) hs.get(TestAccessMode.getVolatile).invokeExact(array, i);
+ hs.get(TestAccessMode.SET_VOLATILE).invokeExact(array, i, 2L);
+ long x = (long) hs.get(TestAccessMode.GET_VOLATILE).invokeExact(array, i);
assertEquals(x, 2L, "setVolatile long value");
}
// Lazy
{
- hs.get(TestAccessMode.setRelease).invokeExact(array, i, 1L);
- long x = (long) hs.get(TestAccessMode.getAcquire).invokeExact(array, i);
+ hs.get(TestAccessMode.SET_RELEASE).invokeExact(array, i, 1L);
+ long x = (long) hs.get(TestAccessMode.GET_ACQUIRE).invokeExact(array, i);
assertEquals(x, 1L, "setRelease long value");
}
// Opaque
{
- hs.get(TestAccessMode.setOpaque).invokeExact(array, i, 2L);
- long x = (long) hs.get(TestAccessMode.getOpaque).invokeExact(array, i);
+ hs.get(TestAccessMode.SET_OPAQUE).invokeExact(array, i, 2L);
+ long x = (long) hs.get(TestAccessMode.GET_OPAQUE).invokeExact(array, i);
assertEquals(x, 2L, "setOpaque long value");
}
- hs.get(TestAccessMode.set).invokeExact(array, i, 1L);
+ hs.get(TestAccessMode.SET).invokeExact(array, i, 1L);
// Compare
{
- boolean r = (boolean) hs.get(TestAccessMode.compareAndSet).invokeExact(array, i, 1L, 2L);
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(array, i, 1L, 2L);
assertEquals(r, true, "success compareAndSet long");
- long x = (long) hs.get(TestAccessMode.get).invokeExact(array, i);
+ long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i);
assertEquals(x, 2L, "success compareAndSet long value");
}
{
- boolean r = (boolean) hs.get(TestAccessMode.compareAndSet).invokeExact(array, i, 1L, 3L);
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(array, i, 1L, 3L);
assertEquals(r, false, "failing compareAndSet long");
- long x = (long) hs.get(TestAccessMode.get).invokeExact(array, i);
+ long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i);
assertEquals(x, 2L, "failing compareAndSet long value");
}
{
- long r = (long) hs.get(TestAccessMode.compareAndExchangeVolatile).invokeExact(array, i, 2L, 1L);
+ long r = (long) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact(array, i, 2L, 1L);
assertEquals(r, 2L, "success compareAndExchangeVolatile long");
- long x = (long) hs.get(TestAccessMode.get).invokeExact(array, i);
+ long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i);
assertEquals(x, 1L, "success compareAndExchangeVolatile long value");
}
{
- long r = (long) hs.get(TestAccessMode.compareAndExchangeVolatile).invokeExact(array, i, 2L, 3L);
+ long r = (long) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact(array, i, 2L, 3L);
assertEquals(r, 1L, "failing compareAndExchangeVolatile long");
- long x = (long) hs.get(TestAccessMode.get).invokeExact(array, i);
+ long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i);
assertEquals(x, 1L, "failing compareAndExchangeVolatile long value");
}
{
- long r = (long) hs.get(TestAccessMode.compareAndExchangeAcquire).invokeExact(array, i, 1L, 2L);
+ long r = (long) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(array, i, 1L, 2L);
assertEquals(r, 1L, "success compareAndExchangeAcquire long");
- long x = (long) hs.get(TestAccessMode.get).invokeExact(array, i);
+ long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i);
assertEquals(x, 2L, "success compareAndExchangeAcquire long value");
}
{
- long r = (long) hs.get(TestAccessMode.compareAndExchangeAcquire).invokeExact(array, i, 1L, 3L);
+ long r = (long) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(array, i, 1L, 3L);
assertEquals(r, 2L, "failing compareAndExchangeAcquire long");
- long x = (long) hs.get(TestAccessMode.get).invokeExact(array, i);
+ long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i);
assertEquals(x, 2L, "failing compareAndExchangeAcquire long value");
}
{
- long r = (long) hs.get(TestAccessMode.compareAndExchangeRelease).invokeExact(array, i, 2L, 1L);
+ long r = (long) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(array, i, 2L, 1L);
assertEquals(r, 2L, "success compareAndExchangeRelease long");
- long x = (long) hs.get(TestAccessMode.get).invokeExact(array, i);
+ long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i);
assertEquals(x, 1L, "success compareAndExchangeRelease long value");
}
{
- long r = (long) hs.get(TestAccessMode.compareAndExchangeRelease).invokeExact(array, i, 2L, 3L);
+ long r = (long) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(array, i, 2L, 3L);
assertEquals(r, 1L, "failing compareAndExchangeRelease long");
- long x = (long) hs.get(TestAccessMode.get).invokeExact(array, i);
+ long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i);
assertEquals(x, 1L, "failing compareAndExchangeRelease long value");
}
{
- boolean r = (boolean) hs.get(TestAccessMode.weakCompareAndSet).invokeExact(array, i, 1L, 2L);
+ boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, 1L, 2L);
assertEquals(r, true, "weakCompareAndSet long");
- long x = (long) hs.get(TestAccessMode.get).invokeExact(array, i);
+ long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i);
assertEquals(x, 2L, "weakCompareAndSet long value");
}
{
- boolean r = (boolean) hs.get(TestAccessMode.weakCompareAndSetAcquire).invokeExact(array, i, 2L, 1L);
+ boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(array, i, 2L, 1L);
assertEquals(r, true, "weakCompareAndSetAcquire long");
- long x = (long) hs.get(TestAccessMode.get).invokeExact(array, i);
+ long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i);
assertEquals(x, 1L, "weakCompareAndSetAcquire long");
}
{
- boolean r = (boolean) hs.get(TestAccessMode.weakCompareAndSetRelease).invokeExact(array, i, 1L, 2L);
+ boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(array, i, 1L, 2L);
assertEquals(r, true, "weakCompareAndSetRelease long");
- long x = (long) hs.get(TestAccessMode.get).invokeExact(array, i);
+ long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i);
assertEquals(x, 2L, "weakCompareAndSetRelease long");
}
// Compare set and get
{
- long o = (long) hs.get(TestAccessMode.getAndSet).invokeExact(array, i, 1L);
+ long o = (long) hs.get(TestAccessMode.GET_AND_SET).invokeExact(array, i, 1L);
assertEquals(o, 2L, "getAndSet long");
- long x = (long) hs.get(TestAccessMode.get).invokeExact(array, i);
+ long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i);
assertEquals(x, 1L, "getAndSet long value");
}
- hs.get(TestAccessMode.set).invokeExact(array, i, 1L);
+ hs.get(TestAccessMode.SET).invokeExact(array, i, 1L);
// get and add, add and get
{
- long o = (long) hs.get(TestAccessMode.getAndAdd).invokeExact(array, i, 3L);
+ long o = (long) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(array, i, 3L);
assertEquals(o, 1L, "getAndAdd long");
- long c = (long) hs.get(TestAccessMode.addAndGet).invokeExact(array, i, 3L);
+ long c = (long) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(array, i, 3L);
assertEquals(c, 1L + 3L + 3L, "getAndAdd long value");
}
}
@@ -532,37 +532,37 @@
for (int i : new int[]{-1, Integer.MIN_VALUE, 10, 11, Integer.MAX_VALUE}) {
final int ci = i;
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.get)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
checkIOOBE(am, () -> {
long x = (long) hs.get(am).invokeExact(array, ci);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.set)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
checkIOOBE(am, () -> {
hs.get(am).invokeExact(array, ci, 1L);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
checkIOOBE(am, () -> {
boolean r = (boolean) hs.get(am).invokeExact(array, ci, 1L, 2L);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndExchange)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
checkIOOBE(am, () -> {
long r = (long) hs.get(am).invokeExact(array, ci, 2L, 1L);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
checkIOOBE(am, () -> {
long o = (long) hs.get(am).invokeExact(array, ci, 1L);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndAdd)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
checkIOOBE(am, () -> {
long o = (long) hs.get(am).invokeExact(array, ci, 3L);
});
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessShort.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessShort.java Wed Jul 05 21:35:27 2017 +0200
@@ -121,30 +121,30 @@
static void testInstanceField(VarHandleTestMethodHandleAccessShort recv, Handles hs) throws Throwable {
// Plain
{
- hs.get(TestAccessMode.set).invokeExact(recv, (short)1);
- short x = (short) hs.get(TestAccessMode.get).invokeExact(recv);
+ hs.get(TestAccessMode.SET).invokeExact(recv, (short)1);
+ short x = (short) hs.get(TestAccessMode.GET).invokeExact(recv);
assertEquals(x, (short)1, "set short value");
}
// Volatile
{
- hs.get(TestAccessMode.setVolatile).invokeExact(recv, (short)2);
- short x = (short) hs.get(TestAccessMode.getVolatile).invokeExact(recv);
+ hs.get(TestAccessMode.SET_VOLATILE).invokeExact(recv, (short)2);
+ short x = (short) hs.get(TestAccessMode.GET_VOLATILE).invokeExact(recv);
assertEquals(x, (short)2, "setVolatile short value");
}
// Lazy
{
- hs.get(TestAccessMode.setRelease).invokeExact(recv, (short)1);
- short x = (short) hs.get(TestAccessMode.getAcquire).invokeExact(recv);
+ hs.get(TestAccessMode.SET_RELEASE).invokeExact(recv, (short)1);
+ short x = (short) hs.get(TestAccessMode.GET_ACQUIRE).invokeExact(recv);
assertEquals(x, (short)1, "setRelease short value");
}
// Opaque
{
- hs.get(TestAccessMode.setOpaque).invokeExact(recv, (short)2);
- short x = (short) hs.get(TestAccessMode.getOpaque).invokeExact(recv);
+ hs.get(TestAccessMode.SET_OPAQUE).invokeExact(recv, (short)2);
+ short x = (short) hs.get(TestAccessMode.GET_OPAQUE).invokeExact(recv);
assertEquals(x, (short)2, "setOpaque short value");
}
@@ -152,25 +152,25 @@
}
static void testInstanceFieldUnsupported(VarHandleTestMethodHandleAccessShort recv, Handles hs) throws Throwable {
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
checkUOE(am, () -> {
boolean r = (boolean) hs.get(am).invokeExact(recv, (short)1, (short)2);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndExchange)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
checkUOE(am, () -> {
short r = (short) hs.get(am).invokeExact(recv, (short)1, (short)2);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
checkUOE(am, () -> {
short r = (short) hs.get(am).invokeExact(recv, (short)1);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndAdd)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
checkUOE(am, () -> {
short r = (short) hs.get(am).invokeExact(recv, (short)1);
});
@@ -181,30 +181,30 @@
static void testStaticField(Handles hs) throws Throwable {
// Plain
{
- hs.get(TestAccessMode.set).invokeExact((short)1);
- short x = (short) hs.get(TestAccessMode.get).invokeExact();
+ hs.get(TestAccessMode.SET).invokeExact((short)1);
+ short x = (short) hs.get(TestAccessMode.GET).invokeExact();
assertEquals(x, (short)1, "set short value");
}
// Volatile
{
- hs.get(TestAccessMode.setVolatile).invokeExact((short)2);
- short x = (short) hs.get(TestAccessMode.getVolatile).invokeExact();
+ hs.get(TestAccessMode.SET_VOLATILE).invokeExact((short)2);
+ short x = (short) hs.get(TestAccessMode.GET_VOLATILE).invokeExact();
assertEquals(x, (short)2, "setVolatile short value");
}
// Lazy
{
- hs.get(TestAccessMode.setRelease).invokeExact((short)1);
- short x = (short) hs.get(TestAccessMode.getAcquire).invokeExact();
+ hs.get(TestAccessMode.SET_RELEASE).invokeExact((short)1);
+ short x = (short) hs.get(TestAccessMode.GET_ACQUIRE).invokeExact();
assertEquals(x, (short)1, "setRelease short value");
}
// Opaque
{
- hs.get(TestAccessMode.setOpaque).invokeExact((short)2);
- short x = (short) hs.get(TestAccessMode.getOpaque).invokeExact();
+ hs.get(TestAccessMode.SET_OPAQUE).invokeExact((short)2);
+ short x = (short) hs.get(TestAccessMode.GET_OPAQUE).invokeExact();
assertEquals(x, (short)2, "setOpaque short value");
}
@@ -212,25 +212,25 @@
}
static void testStaticFieldUnsupported(Handles hs) throws Throwable {
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
checkUOE(am, () -> {
boolean r = (boolean) hs.get(am).invokeExact((short)1, (short)2);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndExchange)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
checkUOE(am, () -> {
short r = (short) hs.get(am).invokeExact((short)1, (short)2);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
checkUOE(am, () -> {
short r = (short) hs.get(am).invokeExact((short)1);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndAdd)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
checkUOE(am, () -> {
short r = (short) hs.get(am).invokeExact((short)1);
});
@@ -244,30 +244,30 @@
for (int i = 0; i < array.length; i++) {
// Plain
{
- hs.get(TestAccessMode.set).invokeExact(array, i, (short)1);
- short x = (short) hs.get(TestAccessMode.get).invokeExact(array, i);
+ hs.get(TestAccessMode.SET).invokeExact(array, i, (short)1);
+ short x = (short) hs.get(TestAccessMode.GET).invokeExact(array, i);
assertEquals(x, (short)1, "get short value");
}
// Volatile
{
- hs.get(TestAccessMode.setVolatile).invokeExact(array, i, (short)2);
- short x = (short) hs.get(TestAccessMode.getVolatile).invokeExact(array, i);
+ hs.get(TestAccessMode.SET_VOLATILE).invokeExact(array, i, (short)2);
+ short x = (short) hs.get(TestAccessMode.GET_VOLATILE).invokeExact(array, i);
assertEquals(x, (short)2, "setVolatile short value");
}
// Lazy
{
- hs.get(TestAccessMode.setRelease).invokeExact(array, i, (short)1);
- short x = (short) hs.get(TestAccessMode.getAcquire).invokeExact(array, i);
+ hs.get(TestAccessMode.SET_RELEASE).invokeExact(array, i, (short)1);
+ short x = (short) hs.get(TestAccessMode.GET_ACQUIRE).invokeExact(array, i);
assertEquals(x, (short)1, "setRelease short value");
}
// Opaque
{
- hs.get(TestAccessMode.setOpaque).invokeExact(array, i, (short)2);
- short x = (short) hs.get(TestAccessMode.getOpaque).invokeExact(array, i);
+ hs.get(TestAccessMode.SET_OPAQUE).invokeExact(array, i, (short)2);
+ short x = (short) hs.get(TestAccessMode.GET_OPAQUE).invokeExact(array, i);
assertEquals(x, (short)2, "setOpaque short value");
}
@@ -279,25 +279,25 @@
short[] array = new short[10];
final int i = 0;
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
checkUOE(am, () -> {
boolean r = (boolean) hs.get(am).invokeExact(array, i, (short)1, (short)2);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndExchange)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
checkUOE(am, () -> {
short r = (short) hs.get(am).invokeExact(array, i, (short)1, (short)2);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
checkUOE(am, () -> {
short r = (short) hs.get(am).invokeExact(array, i, (short)1);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndAdd)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
checkUOE(am, () -> {
short o = (short) hs.get(am).invokeExact(array, i, (short)1);
});
@@ -310,13 +310,13 @@
for (int i : new int[]{-1, Integer.MIN_VALUE, 10, 11, Integer.MAX_VALUE}) {
final int ci = i;
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.get)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
checkIOOBE(am, () -> {
short x = (short) hs.get(am).invokeExact(array, ci);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.set)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
checkIOOBE(am, () -> {
hs.get(am).invokeExact(array, ci, (short)1);
});
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessString.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessString.java Wed Jul 05 21:35:27 2017 +0200
@@ -121,118 +121,118 @@
static void testInstanceField(VarHandleTestMethodHandleAccessString recv, Handles hs) throws Throwable {
// Plain
{
- hs.get(TestAccessMode.set).invokeExact(recv, "foo");
- String x = (String) hs.get(TestAccessMode.get).invokeExact(recv);
+ hs.get(TestAccessMode.SET).invokeExact(recv, "foo");
+ String x = (String) hs.get(TestAccessMode.GET).invokeExact(recv);
assertEquals(x, "foo", "set String value");
}
// Volatile
{
- hs.get(TestAccessMode.setVolatile).invokeExact(recv, "bar");
- String x = (String) hs.get(TestAccessMode.getVolatile).invokeExact(recv);
+ hs.get(TestAccessMode.SET_VOLATILE).invokeExact(recv, "bar");
+ String x = (String) hs.get(TestAccessMode.GET_VOLATILE).invokeExact(recv);
assertEquals(x, "bar", "setVolatile String value");
}
// Lazy
{
- hs.get(TestAccessMode.setRelease).invokeExact(recv, "foo");
- String x = (String) hs.get(TestAccessMode.getAcquire).invokeExact(recv);
+ hs.get(TestAccessMode.SET_RELEASE).invokeExact(recv, "foo");
+ String x = (String) hs.get(TestAccessMode.GET_ACQUIRE).invokeExact(recv);
assertEquals(x, "foo", "setRelease String value");
}
// Opaque
{
- hs.get(TestAccessMode.setOpaque).invokeExact(recv, "bar");
- String x = (String) hs.get(TestAccessMode.getOpaque).invokeExact(recv);
+ hs.get(TestAccessMode.SET_OPAQUE).invokeExact(recv, "bar");
+ String x = (String) hs.get(TestAccessMode.GET_OPAQUE).invokeExact(recv);
assertEquals(x, "bar", "setOpaque String value");
}
- hs.get(TestAccessMode.set).invokeExact(recv, "foo");
+ hs.get(TestAccessMode.SET).invokeExact(recv, "foo");
// Compare
{
- boolean r = (boolean) hs.get(TestAccessMode.compareAndSet).invokeExact(recv, "foo", "bar");
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(recv, "foo", "bar");
assertEquals(r, true, "success compareAndSet String");
- String x = (String) hs.get(TestAccessMode.get).invokeExact(recv);
+ String x = (String) hs.get(TestAccessMode.GET).invokeExact(recv);
assertEquals(x, "bar", "success compareAndSet String value");
}
{
- boolean r = (boolean) hs.get(TestAccessMode.compareAndSet).invokeExact(recv, "foo", "baz");
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(recv, "foo", "baz");
assertEquals(r, false, "failing compareAndSet String");
- String x = (String) hs.get(TestAccessMode.get).invokeExact(recv);
+ String x = (String) hs.get(TestAccessMode.GET).invokeExact(recv);
assertEquals(x, "bar", "failing compareAndSet String value");
}
{
- String r = (String) hs.get(TestAccessMode.compareAndExchangeVolatile).invokeExact(recv, "bar", "foo");
+ String r = (String) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact(recv, "bar", "foo");
assertEquals(r, "bar", "success compareAndExchangeVolatile String");
- String x = (String) hs.get(TestAccessMode.get).invokeExact(recv);
+ String x = (String) hs.get(TestAccessMode.GET).invokeExact(recv);
assertEquals(x, "foo", "success compareAndExchangeVolatile String value");
}
{
- String r = (String) hs.get(TestAccessMode.compareAndExchangeVolatile).invokeExact(recv, "bar", "baz");
+ String r = (String) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact(recv, "bar", "baz");
assertEquals(r, "foo", "failing compareAndExchangeVolatile String");
- String x = (String) hs.get(TestAccessMode.get).invokeExact(recv);
+ String x = (String) hs.get(TestAccessMode.GET).invokeExact(recv);
assertEquals(x, "foo", "failing compareAndExchangeVolatile String value");
}
{
- String r = (String) hs.get(TestAccessMode.compareAndExchangeAcquire).invokeExact(recv, "foo", "bar");
+ String r = (String) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(recv, "foo", "bar");
assertEquals(r, "foo", "success compareAndExchangeAcquire String");
- String x = (String) hs.get(TestAccessMode.get).invokeExact(recv);
+ String x = (String) hs.get(TestAccessMode.GET).invokeExact(recv);
assertEquals(x, "bar", "success compareAndExchangeAcquire String value");
}
{
- String r = (String) hs.get(TestAccessMode.compareAndExchangeAcquire).invokeExact(recv, "foo", "baz");
+ String r = (String) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(recv, "foo", "baz");
assertEquals(r, "bar", "failing compareAndExchangeAcquire String");
- String x = (String) hs.get(TestAccessMode.get).invokeExact(recv);
+ String x = (String) hs.get(TestAccessMode.GET).invokeExact(recv);
assertEquals(x, "bar", "failing compareAndExchangeAcquire String value");
}
{
- String r = (String) hs.get(TestAccessMode.compareAndExchangeRelease).invokeExact(recv, "bar", "foo");
+ String r = (String) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(recv, "bar", "foo");
assertEquals(r, "bar", "success compareAndExchangeRelease String");
- String x = (String) hs.get(TestAccessMode.get).invokeExact(recv);
+ String x = (String) hs.get(TestAccessMode.GET).invokeExact(recv);
assertEquals(x, "foo", "success compareAndExchangeRelease String value");
}
{
- String r = (String) hs.get(TestAccessMode.compareAndExchangeRelease).invokeExact(recv, "bar", "baz");
+ String r = (String) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(recv, "bar", "baz");
assertEquals(r, "foo", "failing compareAndExchangeRelease String");
- String x = (String) hs.get(TestAccessMode.get).invokeExact(recv);
+ String x = (String) hs.get(TestAccessMode.GET).invokeExact(recv);
assertEquals(x, "foo", "failing compareAndExchangeRelease String value");
}
{
- boolean r = (boolean) hs.get(TestAccessMode.weakCompareAndSet).invokeExact(recv, "foo", "bar");
+ boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, "foo", "bar");
assertEquals(r, true, "weakCompareAndSet String");
- String x = (String) hs.get(TestAccessMode.get).invokeExact(recv);
+ String x = (String) hs.get(TestAccessMode.GET).invokeExact(recv);
assertEquals(x, "bar", "weakCompareAndSet String value");
}
{
- boolean r = (boolean) hs.get(TestAccessMode.weakCompareAndSetAcquire).invokeExact(recv, "bar", "foo");
+ boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(recv, "bar", "foo");
assertEquals(r, true, "weakCompareAndSetAcquire String");
- String x = (String) hs.get(TestAccessMode.get).invokeExact(recv);
+ String x = (String) hs.get(TestAccessMode.GET).invokeExact(recv);
assertEquals(x, "foo", "weakCompareAndSetAcquire String");
}
{
- boolean r = (boolean) hs.get(TestAccessMode.weakCompareAndSetRelease).invokeExact(recv, "foo", "bar");
+ boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(recv, "foo", "bar");
assertEquals(r, true, "weakCompareAndSetRelease String");
- String x = (String) hs.get(TestAccessMode.get).invokeExact(recv);
+ String x = (String) hs.get(TestAccessMode.GET).invokeExact(recv);
assertEquals(x, "bar", "weakCompareAndSetRelease String");
}
// Compare set and get
{
- String o = (String) hs.get(TestAccessMode.getAndSet).invokeExact(recv, "foo");
+ String o = (String) hs.get(TestAccessMode.GET_AND_SET).invokeExact(recv, "foo");
assertEquals(o, "bar", "getAndSet String");
- String x = (String) hs.get(TestAccessMode.get).invokeExact(recv);
+ String x = (String) hs.get(TestAccessMode.GET).invokeExact(recv);
assertEquals(x, "foo", "getAndSet String value");
}
@@ -240,7 +240,7 @@
static void testInstanceFieldUnsupported(VarHandleTestMethodHandleAccessString recv, Handles hs) throws Throwable {
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndAdd)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
checkUOE(am, () -> {
String r = (String) hs.get(am).invokeExact(recv, "foo");
});
@@ -251,118 +251,118 @@
static void testStaticField(Handles hs) throws Throwable {
// Plain
{
- hs.get(TestAccessMode.set).invokeExact("foo");
- String x = (String) hs.get(TestAccessMode.get).invokeExact();
+ hs.get(TestAccessMode.SET).invokeExact("foo");
+ String x = (String) hs.get(TestAccessMode.GET).invokeExact();
assertEquals(x, "foo", "set String value");
}
// Volatile
{
- hs.get(TestAccessMode.setVolatile).invokeExact("bar");
- String x = (String) hs.get(TestAccessMode.getVolatile).invokeExact();
+ hs.get(TestAccessMode.SET_VOLATILE).invokeExact("bar");
+ String x = (String) hs.get(TestAccessMode.GET_VOLATILE).invokeExact();
assertEquals(x, "bar", "setVolatile String value");
}
// Lazy
{
- hs.get(TestAccessMode.setRelease).invokeExact("foo");
- String x = (String) hs.get(TestAccessMode.getAcquire).invokeExact();
+ hs.get(TestAccessMode.SET_RELEASE).invokeExact("foo");
+ String x = (String) hs.get(TestAccessMode.GET_ACQUIRE).invokeExact();
assertEquals(x, "foo", "setRelease String value");
}
// Opaque
{
- hs.get(TestAccessMode.setOpaque).invokeExact("bar");
- String x = (String) hs.get(TestAccessMode.getOpaque).invokeExact();
+ hs.get(TestAccessMode.SET_OPAQUE).invokeExact("bar");
+ String x = (String) hs.get(TestAccessMode.GET_OPAQUE).invokeExact();
assertEquals(x, "bar", "setOpaque String value");
}
- hs.get(TestAccessMode.set).invokeExact("foo");
+ hs.get(TestAccessMode.SET).invokeExact("foo");
// Compare
{
- boolean r = (boolean) hs.get(TestAccessMode.compareAndSet).invokeExact("foo", "bar");
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact("foo", "bar");
assertEquals(r, true, "success compareAndSet String");
- String x = (String) hs.get(TestAccessMode.get).invokeExact();
+ String x = (String) hs.get(TestAccessMode.GET).invokeExact();
assertEquals(x, "bar", "success compareAndSet String value");
}
{
- boolean r = (boolean) hs.get(TestAccessMode.compareAndSet).invokeExact("foo", "baz");
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact("foo", "baz");
assertEquals(r, false, "failing compareAndSet String");
- String x = (String) hs.get(TestAccessMode.get).invokeExact();
+ String x = (String) hs.get(TestAccessMode.GET).invokeExact();
assertEquals(x, "bar", "failing compareAndSet String value");
}
{
- String r = (String) hs.get(TestAccessMode.compareAndExchangeVolatile).invokeExact("bar", "foo");
+ String r = (String) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact("bar", "foo");
assertEquals(r, "bar", "success compareAndExchangeVolatile String");
- String x = (String) hs.get(TestAccessMode.get).invokeExact();
+ String x = (String) hs.get(TestAccessMode.GET).invokeExact();
assertEquals(x, "foo", "success compareAndExchangeVolatile String value");
}
{
- String r = (String) hs.get(TestAccessMode.compareAndExchangeVolatile).invokeExact("bar", "baz");
+ String r = (String) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact("bar", "baz");
assertEquals(r, "foo", "failing compareAndExchangeVolatile String");
- String x = (String) hs.get(TestAccessMode.get).invokeExact();
+ String x = (String) hs.get(TestAccessMode.GET).invokeExact();
assertEquals(x, "foo", "failing compareAndExchangeVolatile String value");
}
{
- String r = (String) hs.get(TestAccessMode.compareAndExchangeAcquire).invokeExact("foo", "bar");
+ String r = (String) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact("foo", "bar");
assertEquals(r, "foo", "success compareAndExchangeAcquire String");
- String x = (String) hs.get(TestAccessMode.get).invokeExact();
+ String x = (String) hs.get(TestAccessMode.GET).invokeExact();
assertEquals(x, "bar", "success compareAndExchangeAcquire String value");
}
{
- String r = (String) hs.get(TestAccessMode.compareAndExchangeAcquire).invokeExact("foo", "baz");
+ String r = (String) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact("foo", "baz");
assertEquals(r, "bar", "failing compareAndExchangeAcquire String");
- String x = (String) hs.get(TestAccessMode.get).invokeExact();
+ String x = (String) hs.get(TestAccessMode.GET).invokeExact();
assertEquals(x, "bar", "failing compareAndExchangeAcquire String value");
}
{
- String r = (String) hs.get(TestAccessMode.compareAndExchangeRelease).invokeExact("bar", "foo");
+ String r = (String) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact("bar", "foo");
assertEquals(r, "bar", "success compareAndExchangeRelease String");
- String x = (String) hs.get(TestAccessMode.get).invokeExact();
+ String x = (String) hs.get(TestAccessMode.GET).invokeExact();
assertEquals(x, "foo", "success compareAndExchangeRelease String value");
}
{
- String r = (String) hs.get(TestAccessMode.compareAndExchangeRelease).invokeExact("bar", "baz");
+ String r = (String) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact("bar", "baz");
assertEquals(r, "foo", "failing compareAndExchangeRelease String");
- String x = (String) hs.get(TestAccessMode.get).invokeExact();
+ String x = (String) hs.get(TestAccessMode.GET).invokeExact();
assertEquals(x, "foo", "failing compareAndExchangeRelease String value");
}
{
- boolean r = (boolean) hs.get(TestAccessMode.weakCompareAndSet).invokeExact("foo", "bar");
+ boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact("foo", "bar");
assertEquals(r, true, "weakCompareAndSet String");
- String x = (String) hs.get(TestAccessMode.get).invokeExact();
+ String x = (String) hs.get(TestAccessMode.GET).invokeExact();
assertEquals(x, "bar", "weakCompareAndSet String value");
}
{
- boolean r = (boolean) hs.get(TestAccessMode.weakCompareAndSetAcquire).invokeExact("bar", "foo");
+ boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact("bar", "foo");
assertEquals(r, true, "weakCompareAndSetAcquire String");
- String x = (String) hs.get(TestAccessMode.get).invokeExact();
+ String x = (String) hs.get(TestAccessMode.GET).invokeExact();
assertEquals(x, "foo", "weakCompareAndSetAcquire String");
}
{
- boolean r = (boolean) hs.get(TestAccessMode.weakCompareAndSetRelease).invokeExact( "foo", "bar");
+ boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact( "foo", "bar");
assertEquals(r, true, "weakCompareAndSetRelease String");
- String x = (String) hs.get(TestAccessMode.get).invokeExact();
+ String x = (String) hs.get(TestAccessMode.GET).invokeExact();
assertEquals(x, "bar", "weakCompareAndSetRelease String");
}
// Compare set and get
{
- String o = (String) hs.get(TestAccessMode.getAndSet).invokeExact( "foo");
+ String o = (String) hs.get(TestAccessMode.GET_AND_SET).invokeExact( "foo");
assertEquals(o, "bar", "getAndSet String");
- String x = (String) hs.get(TestAccessMode.get).invokeExact();
+ String x = (String) hs.get(TestAccessMode.GET).invokeExact();
assertEquals(x, "foo", "getAndSet String value");
}
@@ -370,7 +370,7 @@
static void testStaticFieldUnsupported(Handles hs) throws Throwable {
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndAdd)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
checkUOE(am, () -> {
String r = (String) hs.get(am).invokeExact("foo");
});
@@ -384,118 +384,118 @@
for (int i = 0; i < array.length; i++) {
// Plain
{
- hs.get(TestAccessMode.set).invokeExact(array, i, "foo");
- String x = (String) hs.get(TestAccessMode.get).invokeExact(array, i);
+ hs.get(TestAccessMode.SET).invokeExact(array, i, "foo");
+ String x = (String) hs.get(TestAccessMode.GET).invokeExact(array, i);
assertEquals(x, "foo", "get String value");
}
// Volatile
{
- hs.get(TestAccessMode.setVolatile).invokeExact(array, i, "bar");
- String x = (String) hs.get(TestAccessMode.getVolatile).invokeExact(array, i);
+ hs.get(TestAccessMode.SET_VOLATILE).invokeExact(array, i, "bar");
+ String x = (String) hs.get(TestAccessMode.GET_VOLATILE).invokeExact(array, i);
assertEquals(x, "bar", "setVolatile String value");
}
// Lazy
{
- hs.get(TestAccessMode.setRelease).invokeExact(array, i, "foo");
- String x = (String) hs.get(TestAccessMode.getAcquire).invokeExact(array, i);
+ hs.get(TestAccessMode.SET_RELEASE).invokeExact(array, i, "foo");
+ String x = (String) hs.get(TestAccessMode.GET_ACQUIRE).invokeExact(array, i);
assertEquals(x, "foo", "setRelease String value");
}
// Opaque
{
- hs.get(TestAccessMode.setOpaque).invokeExact(array, i, "bar");
- String x = (String) hs.get(TestAccessMode.getOpaque).invokeExact(array, i);
+ hs.get(TestAccessMode.SET_OPAQUE).invokeExact(array, i, "bar");
+ String x = (String) hs.get(TestAccessMode.GET_OPAQUE).invokeExact(array, i);
assertEquals(x, "bar", "setOpaque String value");
}
- hs.get(TestAccessMode.set).invokeExact(array, i, "foo");
+ hs.get(TestAccessMode.SET).invokeExact(array, i, "foo");
// Compare
{
- boolean r = (boolean) hs.get(TestAccessMode.compareAndSet).invokeExact(array, i, "foo", "bar");
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(array, i, "foo", "bar");
assertEquals(r, true, "success compareAndSet String");
- String x = (String) hs.get(TestAccessMode.get).invokeExact(array, i);
+ String x = (String) hs.get(TestAccessMode.GET).invokeExact(array, i);
assertEquals(x, "bar", "success compareAndSet String value");
}
{
- boolean r = (boolean) hs.get(TestAccessMode.compareAndSet).invokeExact(array, i, "foo", "baz");
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(array, i, "foo", "baz");
assertEquals(r, false, "failing compareAndSet String");
- String x = (String) hs.get(TestAccessMode.get).invokeExact(array, i);
+ String x = (String) hs.get(TestAccessMode.GET).invokeExact(array, i);
assertEquals(x, "bar", "failing compareAndSet String value");
}
{
- String r = (String) hs.get(TestAccessMode.compareAndExchangeVolatile).invokeExact(array, i, "bar", "foo");
+ String r = (String) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact(array, i, "bar", "foo");
assertEquals(r, "bar", "success compareAndExchangeVolatile String");
- String x = (String) hs.get(TestAccessMode.get).invokeExact(array, i);
+ String x = (String) hs.get(TestAccessMode.GET).invokeExact(array, i);
assertEquals(x, "foo", "success compareAndExchangeVolatile String value");
}
{
- String r = (String) hs.get(TestAccessMode.compareAndExchangeVolatile).invokeExact(array, i, "bar", "baz");
+ String r = (String) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact(array, i, "bar", "baz");
assertEquals(r, "foo", "failing compareAndExchangeVolatile String");
- String x = (String) hs.get(TestAccessMode.get).invokeExact(array, i);
+ String x = (String) hs.get(TestAccessMode.GET).invokeExact(array, i);
assertEquals(x, "foo", "failing compareAndExchangeVolatile String value");
}
{
- String r = (String) hs.get(TestAccessMode.compareAndExchangeAcquire).invokeExact(array, i, "foo", "bar");
+ String r = (String) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(array, i, "foo", "bar");
assertEquals(r, "foo", "success compareAndExchangeAcquire String");
- String x = (String) hs.get(TestAccessMode.get).invokeExact(array, i);
+ String x = (String) hs.get(TestAccessMode.GET).invokeExact(array, i);
assertEquals(x, "bar", "success compareAndExchangeAcquire String value");
}
{
- String r = (String) hs.get(TestAccessMode.compareAndExchangeAcquire).invokeExact(array, i, "foo", "baz");
+ String r = (String) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(array, i, "foo", "baz");
assertEquals(r, "bar", "failing compareAndExchangeAcquire String");
- String x = (String) hs.get(TestAccessMode.get).invokeExact(array, i);
+ String x = (String) hs.get(TestAccessMode.GET).invokeExact(array, i);
assertEquals(x, "bar", "failing compareAndExchangeAcquire String value");
}
{
- String r = (String) hs.get(TestAccessMode.compareAndExchangeRelease).invokeExact(array, i, "bar", "foo");
+ String r = (String) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(array, i, "bar", "foo");
assertEquals(r, "bar", "success compareAndExchangeRelease String");
- String x = (String) hs.get(TestAccessMode.get).invokeExact(array, i);
+ String x = (String) hs.get(TestAccessMode.GET).invokeExact(array, i);
assertEquals(x, "foo", "success compareAndExchangeRelease String value");
}
{
- String r = (String) hs.get(TestAccessMode.compareAndExchangeRelease).invokeExact(array, i, "bar", "baz");
+ String r = (String) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(array, i, "bar", "baz");
assertEquals(r, "foo", "failing compareAndExchangeRelease String");
- String x = (String) hs.get(TestAccessMode.get).invokeExact(array, i);
+ String x = (String) hs.get(TestAccessMode.GET).invokeExact(array, i);
assertEquals(x, "foo", "failing compareAndExchangeRelease String value");
}
{
- boolean r = (boolean) hs.get(TestAccessMode.weakCompareAndSet).invokeExact(array, i, "foo", "bar");
+ boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, "foo", "bar");
assertEquals(r, true, "weakCompareAndSet String");
- String x = (String) hs.get(TestAccessMode.get).invokeExact(array, i);
+ String x = (String) hs.get(TestAccessMode.GET).invokeExact(array, i);
assertEquals(x, "bar", "weakCompareAndSet String value");
}
{
- boolean r = (boolean) hs.get(TestAccessMode.weakCompareAndSetAcquire).invokeExact(array, i, "bar", "foo");
+ boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(array, i, "bar", "foo");
assertEquals(r, true, "weakCompareAndSetAcquire String");
- String x = (String) hs.get(TestAccessMode.get).invokeExact(array, i);
+ String x = (String) hs.get(TestAccessMode.GET).invokeExact(array, i);
assertEquals(x, "foo", "weakCompareAndSetAcquire String");
}
{
- boolean r = (boolean) hs.get(TestAccessMode.weakCompareAndSetRelease).invokeExact(array, i, "foo", "bar");
+ boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(array, i, "foo", "bar");
assertEquals(r, true, "weakCompareAndSetRelease String");
- String x = (String) hs.get(TestAccessMode.get).invokeExact(array, i);
+ String x = (String) hs.get(TestAccessMode.GET).invokeExact(array, i);
assertEquals(x, "bar", "weakCompareAndSetRelease String");
}
// Compare set and get
{
- String o = (String) hs.get(TestAccessMode.getAndSet).invokeExact(array, i, "foo");
+ String o = (String) hs.get(TestAccessMode.GET_AND_SET).invokeExact(array, i, "foo");
assertEquals(o, "bar", "getAndSet String");
- String x = (String) hs.get(TestAccessMode.get).invokeExact(array, i);
+ String x = (String) hs.get(TestAccessMode.GET).invokeExact(array, i);
assertEquals(x, "foo", "getAndSet String value");
}
@@ -507,7 +507,7 @@
final int i = 0;
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndAdd)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
checkUOE(am, () -> {
String o = (String) hs.get(am).invokeExact(array, i, "foo");
});
@@ -520,31 +520,31 @@
for (int i : new int[]{-1, Integer.MIN_VALUE, 10, 11, Integer.MAX_VALUE}) {
final int ci = i;
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.get)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
checkIOOBE(am, () -> {
String x = (String) hs.get(am).invokeExact(array, ci);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.set)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
checkIOOBE(am, () -> {
hs.get(am).invokeExact(array, ci, "foo");
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
checkIOOBE(am, () -> {
boolean r = (boolean) hs.get(am).invokeExact(array, ci, "foo", "bar");
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndExchange)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
checkIOOBE(am, () -> {
String r = (String) hs.get(am).invokeExact(array, ci, "bar", "foo");
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
checkIOOBE(am, () -> {
String o = (String) hs.get(am).invokeExact(array, ci, "foo");
});
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeBoolean.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeBoolean.java Wed Jul 05 21:35:27 2017 +0200
@@ -326,7 +326,7 @@
}
static void testInstanceFieldWrongMethodType(VarHandleTestMethodTypeBoolean recv, Handles hs) throws Throwable {
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.get)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
// Incorrect argument types
checkNPE(() -> { // null receiver
boolean x = (boolean) hs.get(am, methodType(boolean.class, Void.class)).
@@ -360,7 +360,7 @@
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.set)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
// Incorrect argument types
checkNPE(() -> { // null receiver
hs.get(am, methodType(void.class, Void.class, boolean.class)).
@@ -509,7 +509,7 @@
static void testStaticFieldWrongMethodType(Handles hs) throws Throwable {
int i = 0;
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.get)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
// Incorrect return type
checkWMTE(() -> { // reference class
Void x = (Void) hs.get(am, methodType(Void.class)).
@@ -526,7 +526,7 @@
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.set)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
checkWMTE(() -> { // value reference class
hs.get(am, methodType(void.class, Class.class)).
invoke(Void.class);
@@ -780,7 +780,7 @@
boolean[] array = new boolean[10];
Arrays.fill(array, true);
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.get)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
// Incorrect argument types
checkNPE(() -> { // null array
boolean x = (boolean) hs.get(am, methodType(boolean.class, Void.class, int.class)).
@@ -818,7 +818,7 @@
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.set)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
// Incorrect argument types
checkNPE(() -> { // null array
hs.get(am, methodType(void.class, Void.class, int.class, boolean.class)).
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeByte.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeByte.java Wed Jul 05 21:35:27 2017 +0200
@@ -326,7 +326,7 @@
}
static void testInstanceFieldWrongMethodType(VarHandleTestMethodTypeByte recv, Handles hs) throws Throwable {
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.get)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
// Incorrect argument types
checkNPE(() -> { // null receiver
byte x = (byte) hs.get(am, methodType(byte.class, Void.class)).
@@ -360,7 +360,7 @@
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.set)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
// Incorrect argument types
checkNPE(() -> { // null receiver
hs.get(am, methodType(void.class, Void.class, byte.class)).
@@ -509,7 +509,7 @@
static void testStaticFieldWrongMethodType(Handles hs) throws Throwable {
int i = 0;
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.get)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
// Incorrect return type
checkWMTE(() -> { // reference class
Void x = (Void) hs.get(am, methodType(Void.class)).
@@ -526,7 +526,7 @@
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.set)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
checkWMTE(() -> { // value reference class
hs.get(am, methodType(void.class, Class.class)).
invoke(Void.class);
@@ -780,7 +780,7 @@
byte[] array = new byte[10];
Arrays.fill(array, (byte)1);
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.get)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
// Incorrect argument types
checkNPE(() -> { // null array
byte x = (byte) hs.get(am, methodType(byte.class, Void.class, int.class)).
@@ -818,7 +818,7 @@
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.set)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
// Incorrect argument types
checkNPE(() -> { // null array
hs.get(am, methodType(void.class, Void.class, int.class, byte.class)).
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeChar.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeChar.java Wed Jul 05 21:35:27 2017 +0200
@@ -326,7 +326,7 @@
}
static void testInstanceFieldWrongMethodType(VarHandleTestMethodTypeChar recv, Handles hs) throws Throwable {
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.get)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
// Incorrect argument types
checkNPE(() -> { // null receiver
char x = (char) hs.get(am, methodType(char.class, Void.class)).
@@ -360,7 +360,7 @@
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.set)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
// Incorrect argument types
checkNPE(() -> { // null receiver
hs.get(am, methodType(void.class, Void.class, char.class)).
@@ -509,7 +509,7 @@
static void testStaticFieldWrongMethodType(Handles hs) throws Throwable {
int i = 0;
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.get)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
// Incorrect return type
checkWMTE(() -> { // reference class
Void x = (Void) hs.get(am, methodType(Void.class)).
@@ -526,7 +526,7 @@
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.set)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
checkWMTE(() -> { // value reference class
hs.get(am, methodType(void.class, Class.class)).
invoke(Void.class);
@@ -780,7 +780,7 @@
char[] array = new char[10];
Arrays.fill(array, 'a');
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.get)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
// Incorrect argument types
checkNPE(() -> { // null array
char x = (char) hs.get(am, methodType(char.class, Void.class, int.class)).
@@ -818,7 +818,7 @@
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.set)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
// Incorrect argument types
checkNPE(() -> { // null array
hs.get(am, methodType(void.class, Void.class, int.class, char.class)).
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeDouble.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeDouble.java Wed Jul 05 21:35:27 2017 +0200
@@ -326,7 +326,7 @@
}
static void testInstanceFieldWrongMethodType(VarHandleTestMethodTypeDouble recv, Handles hs) throws Throwable {
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.get)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
// Incorrect argument types
checkNPE(() -> { // null receiver
double x = (double) hs.get(am, methodType(double.class, Void.class)).
@@ -360,7 +360,7 @@
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.set)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
// Incorrect argument types
checkNPE(() -> { // null receiver
hs.get(am, methodType(void.class, Void.class, double.class)).
@@ -509,7 +509,7 @@
static void testStaticFieldWrongMethodType(Handles hs) throws Throwable {
int i = 0;
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.get)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
// Incorrect return type
checkWMTE(() -> { // reference class
Void x = (Void) hs.get(am, methodType(Void.class)).
@@ -526,7 +526,7 @@
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.set)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
checkWMTE(() -> { // value reference class
hs.get(am, methodType(void.class, Class.class)).
invoke(Void.class);
@@ -780,7 +780,7 @@
double[] array = new double[10];
Arrays.fill(array, 1.0d);
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.get)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
// Incorrect argument types
checkNPE(() -> { // null array
double x = (double) hs.get(am, methodType(double.class, Void.class, int.class)).
@@ -818,7 +818,7 @@
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.set)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
// Incorrect argument types
checkNPE(() -> { // null array
hs.get(am, methodType(void.class, Void.class, int.class, double.class)).
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeFloat.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeFloat.java Wed Jul 05 21:35:27 2017 +0200
@@ -326,7 +326,7 @@
}
static void testInstanceFieldWrongMethodType(VarHandleTestMethodTypeFloat recv, Handles hs) throws Throwable {
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.get)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
// Incorrect argument types
checkNPE(() -> { // null receiver
float x = (float) hs.get(am, methodType(float.class, Void.class)).
@@ -360,7 +360,7 @@
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.set)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
// Incorrect argument types
checkNPE(() -> { // null receiver
hs.get(am, methodType(void.class, Void.class, float.class)).
@@ -509,7 +509,7 @@
static void testStaticFieldWrongMethodType(Handles hs) throws Throwable {
int i = 0;
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.get)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
// Incorrect return type
checkWMTE(() -> { // reference class
Void x = (Void) hs.get(am, methodType(Void.class)).
@@ -526,7 +526,7 @@
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.set)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
checkWMTE(() -> { // value reference class
hs.get(am, methodType(void.class, Class.class)).
invoke(Void.class);
@@ -780,7 +780,7 @@
float[] array = new float[10];
Arrays.fill(array, 1.0f);
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.get)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
// Incorrect argument types
checkNPE(() -> { // null array
float x = (float) hs.get(am, methodType(float.class, Void.class, int.class)).
@@ -818,7 +818,7 @@
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.set)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
// Incorrect argument types
checkNPE(() -> { // null array
hs.get(am, methodType(void.class, Void.class, int.class, float.class)).
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeInt.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeInt.java Wed Jul 05 21:35:27 2017 +0200
@@ -615,7 +615,7 @@
}
static void testInstanceFieldWrongMethodType(VarHandleTestMethodTypeInt recv, Handles hs) throws Throwable {
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.get)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
// Incorrect argument types
checkNPE(() -> { // null receiver
int x = (int) hs.get(am, methodType(int.class, Void.class)).
@@ -649,7 +649,7 @@
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.set)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
// Incorrect argument types
checkNPE(() -> { // null receiver
hs.get(am, methodType(void.class, Void.class, int.class)).
@@ -678,7 +678,7 @@
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
// Incorrect argument types
checkNPE(() -> { // null receiver
boolean r = (boolean) hs.get(am, methodType(boolean.class, Void.class, int.class, int.class)).
@@ -711,7 +711,7 @@
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndExchange)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
checkNPE(() -> { // null receiver
int x = (int) hs.get(am, methodType(int.class, Void.class, int.class, int.class)).
invoke(null, 1, 1);
@@ -752,7 +752,7 @@
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
checkNPE(() -> { // null receiver
int x = (int) hs.get(am, methodType(int.class, Void.class, int.class)).
invoke(null, 1);
@@ -789,7 +789,7 @@
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndAdd)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
checkNPE(() -> { // null receiver
int x = (int) hs.get(am, methodType(int.class, Void.class, int.class)).
invoke(null, 1);
@@ -1143,7 +1143,7 @@
static void testStaticFieldWrongMethodType(Handles hs) throws Throwable {
int i = 0;
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.get)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
// Incorrect return type
checkWMTE(() -> { // reference class
Void x = (Void) hs.get(am, methodType(Void.class)).
@@ -1160,7 +1160,7 @@
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.set)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
checkWMTE(() -> { // value reference class
hs.get(am, methodType(void.class, Class.class)).
invoke(Void.class);
@@ -1175,7 +1175,7 @@
invoke(1, Void.class);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
// Incorrect argument types
checkWMTE(() -> { // expected reference class
boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, int.class)).
@@ -1196,7 +1196,7 @@
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndExchange)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
// Incorrect argument types
checkWMTE(() -> { // expected reference class
int x = (int) hs.get(am, methodType(int.class, Class.class, int.class)).
@@ -1226,7 +1226,7 @@
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
// Incorrect argument types
checkWMTE(() -> { // value reference class
int x = (int) hs.get(am, methodType(int.class, Class.class)).
@@ -1252,7 +1252,7 @@
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndAdd)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
// Incorrect argument types
checkWMTE(() -> { // value reference class
int x = (int) hs.get(am, methodType(int.class, Class.class)).
@@ -1834,7 +1834,7 @@
int[] array = new int[10];
Arrays.fill(array, 1);
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.get)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
// Incorrect argument types
checkNPE(() -> { // null array
int x = (int) hs.get(am, methodType(int.class, Void.class, int.class)).
@@ -1872,7 +1872,7 @@
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.set)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
// Incorrect argument types
checkNPE(() -> { // null array
hs.get(am, methodType(void.class, Void.class, int.class, int.class)).
@@ -1904,7 +1904,7 @@
invoke(array, 0, 1, Void.class);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
// Incorrect argument types
checkNPE(() -> { // null receiver
boolean r = (boolean) hs.get(am, methodType(boolean.class, Void.class, int.class, int.class, int.class)).
@@ -1941,7 +1941,7 @@
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndExchange)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
// Incorrect argument types
checkNPE(() -> { // null receiver
int x = (int) hs.get(am, methodType(int.class, Void.class, int.class, int.class, int.class)).
@@ -1987,7 +1987,7 @@
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
// Incorrect argument types
checkNPE(() -> { // null array
int x = (int) hs.get(am, methodType(int.class, Void.class, int.class, int.class)).
@@ -2029,7 +2029,7 @@
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndAdd)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
// Incorrect argument types
checkNPE(() -> { // null array
int x = (int) hs.get(am, methodType(int.class, Void.class, int.class, int.class)).
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeLong.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeLong.java Wed Jul 05 21:35:27 2017 +0200
@@ -615,7 +615,7 @@
}
static void testInstanceFieldWrongMethodType(VarHandleTestMethodTypeLong recv, Handles hs) throws Throwable {
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.get)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
// Incorrect argument types
checkNPE(() -> { // null receiver
long x = (long) hs.get(am, methodType(long.class, Void.class)).
@@ -649,7 +649,7 @@
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.set)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
// Incorrect argument types
checkNPE(() -> { // null receiver
hs.get(am, methodType(void.class, Void.class, long.class)).
@@ -678,7 +678,7 @@
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
// Incorrect argument types
checkNPE(() -> { // null receiver
boolean r = (boolean) hs.get(am, methodType(boolean.class, Void.class, long.class, long.class)).
@@ -711,7 +711,7 @@
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndExchange)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
checkNPE(() -> { // null receiver
long x = (long) hs.get(am, methodType(long.class, Void.class, long.class, long.class)).
invoke(null, 1L, 1L);
@@ -752,7 +752,7 @@
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
checkNPE(() -> { // null receiver
long x = (long) hs.get(am, methodType(long.class, Void.class, long.class)).
invoke(null, 1L);
@@ -789,7 +789,7 @@
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndAdd)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
checkNPE(() -> { // null receiver
long x = (long) hs.get(am, methodType(long.class, Void.class, long.class)).
invoke(null, 1L);
@@ -1143,7 +1143,7 @@
static void testStaticFieldWrongMethodType(Handles hs) throws Throwable {
int i = 0;
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.get)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
// Incorrect return type
checkWMTE(() -> { // reference class
Void x = (Void) hs.get(am, methodType(Void.class)).
@@ -1160,7 +1160,7 @@
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.set)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
checkWMTE(() -> { // value reference class
hs.get(am, methodType(void.class, Class.class)).
invoke(Void.class);
@@ -1175,7 +1175,7 @@
invoke(1L, Void.class);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
// Incorrect argument types
checkWMTE(() -> { // expected reference class
boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, long.class)).
@@ -1196,7 +1196,7 @@
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndExchange)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
// Incorrect argument types
checkWMTE(() -> { // expected reference class
long x = (long) hs.get(am, methodType(long.class, Class.class, long.class)).
@@ -1226,7 +1226,7 @@
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
// Incorrect argument types
checkWMTE(() -> { // value reference class
long x = (long) hs.get(am, methodType(long.class, Class.class)).
@@ -1252,7 +1252,7 @@
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndAdd)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
// Incorrect argument types
checkWMTE(() -> { // value reference class
long x = (long) hs.get(am, methodType(long.class, Class.class)).
@@ -1834,7 +1834,7 @@
long[] array = new long[10];
Arrays.fill(array, 1L);
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.get)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
// Incorrect argument types
checkNPE(() -> { // null array
long x = (long) hs.get(am, methodType(long.class, Void.class, int.class)).
@@ -1872,7 +1872,7 @@
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.set)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
// Incorrect argument types
checkNPE(() -> { // null array
hs.get(am, methodType(void.class, Void.class, int.class, long.class)).
@@ -1904,7 +1904,7 @@
invoke(array, 0, 1L, Void.class);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
// Incorrect argument types
checkNPE(() -> { // null receiver
boolean r = (boolean) hs.get(am, methodType(boolean.class, Void.class, int.class, long.class, long.class)).
@@ -1941,7 +1941,7 @@
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndExchange)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
// Incorrect argument types
checkNPE(() -> { // null receiver
long x = (long) hs.get(am, methodType(long.class, Void.class, int.class, long.class, long.class)).
@@ -1987,7 +1987,7 @@
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
// Incorrect argument types
checkNPE(() -> { // null array
long x = (long) hs.get(am, methodType(long.class, Void.class, int.class, long.class)).
@@ -2029,7 +2029,7 @@
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndAdd)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
// Incorrect argument types
checkNPE(() -> { // null array
long x = (long) hs.get(am, methodType(long.class, Void.class, int.class, long.class)).
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeShort.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeShort.java Wed Jul 05 21:35:27 2017 +0200
@@ -326,7 +326,7 @@
}
static void testInstanceFieldWrongMethodType(VarHandleTestMethodTypeShort recv, Handles hs) throws Throwable {
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.get)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
// Incorrect argument types
checkNPE(() -> { // null receiver
short x = (short) hs.get(am, methodType(short.class, Void.class)).
@@ -360,7 +360,7 @@
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.set)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
// Incorrect argument types
checkNPE(() -> { // null receiver
hs.get(am, methodType(void.class, Void.class, short.class)).
@@ -509,7 +509,7 @@
static void testStaticFieldWrongMethodType(Handles hs) throws Throwable {
int i = 0;
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.get)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
// Incorrect return type
checkWMTE(() -> { // reference class
Void x = (Void) hs.get(am, methodType(Void.class)).
@@ -526,7 +526,7 @@
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.set)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
checkWMTE(() -> { // value reference class
hs.get(am, methodType(void.class, Class.class)).
invoke(Void.class);
@@ -780,7 +780,7 @@
short[] array = new short[10];
Arrays.fill(array, (short)1);
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.get)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
// Incorrect argument types
checkNPE(() -> { // null array
short x = (short) hs.get(am, methodType(short.class, Void.class, int.class)).
@@ -818,7 +818,7 @@
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.set)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
// Incorrect argument types
checkNPE(() -> { // null array
hs.get(am, methodType(void.class, Void.class, int.class, short.class)).
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeString.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeString.java Wed Jul 05 21:35:27 2017 +0200
@@ -557,7 +557,7 @@
}
static void testInstanceFieldWrongMethodType(VarHandleTestMethodTypeString recv, Handles hs) throws Throwable {
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.get)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
// Incorrect argument types
checkNPE(() -> { // null receiver
String x = (String) hs.get(am, methodType(String.class, Void.class)).
@@ -591,7 +591,7 @@
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.set)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
// Incorrect argument types
checkNPE(() -> { // null receiver
hs.get(am, methodType(void.class, Void.class, String.class)).
@@ -620,7 +620,7 @@
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
// Incorrect argument types
checkNPE(() -> { // null receiver
boolean r = (boolean) hs.get(am, methodType(boolean.class, Void.class, String.class, String.class)).
@@ -653,7 +653,7 @@
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndExchange)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
checkNPE(() -> { // null receiver
String x = (String) hs.get(am, methodType(String.class, Void.class, String.class, String.class)).
invoke(null, "foo", "foo");
@@ -694,7 +694,7 @@
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
checkNPE(() -> { // null receiver
String x = (String) hs.get(am, methodType(String.class, Void.class, String.class)).
invoke(null, "foo");
@@ -1009,7 +1009,7 @@
static void testStaticFieldWrongMethodType(Handles hs) throws Throwable {
int i = 0;
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.get)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
// Incorrect return type
checkCCE(() -> { // reference class
Void x = (Void) hs.get(am, methodType(Void.class)).
@@ -1026,7 +1026,7 @@
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.set)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
checkCCE(() -> { // value reference class
hs.get(am, methodType(void.class, Class.class)).
invoke(Void.class);
@@ -1041,7 +1041,7 @@
invoke("foo", Void.class);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
// Incorrect argument types
checkCCE(() -> { // expected reference class
boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, String.class)).
@@ -1062,7 +1062,7 @@
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndExchange)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
// Incorrect argument types
checkCCE(() -> { // expected reference class
String x = (String) hs.get(am, methodType(String.class, Class.class, String.class)).
@@ -1092,7 +1092,7 @@
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
// Incorrect argument types
checkCCE(() -> { // value reference class
String x = (String) hs.get(am, methodType(String.class, Class.class)).
@@ -1611,7 +1611,7 @@
String[] array = new String[10];
Arrays.fill(array, "foo");
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.get)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
// Incorrect argument types
checkNPE(() -> { // null array
String x = (String) hs.get(am, methodType(String.class, Void.class, int.class)).
@@ -1649,7 +1649,7 @@
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.set)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
// Incorrect argument types
checkNPE(() -> { // null array
hs.get(am, methodType(void.class, Void.class, int.class, String.class)).
@@ -1681,7 +1681,7 @@
invoke(array, 0, "foo", Void.class);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
// Incorrect argument types
checkNPE(() -> { // null receiver
boolean r = (boolean) hs.get(am, methodType(boolean.class, Void.class, int.class, String.class, String.class)).
@@ -1718,7 +1718,7 @@
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndExchange)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
// Incorrect argument types
checkNPE(() -> { // null receiver
String x = (String) hs.get(am, methodType(String.class, Void.class, int.class, String.class, String.class)).
@@ -1764,7 +1764,7 @@
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
// Incorrect argument types
checkNPE(() -> { // null array
String x = (String) hs.get(am, methodType(String.class, Void.class, int.class, String.class)).
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestReflection.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestReflection.java Wed Jul 05 21:35:27 2017 +0200
@@ -57,7 +57,7 @@
// Try a reflective invoke using a Method
- Method vhm = VarHandle.class.getMethod(accessMode.name(), Object[].class);
+ Method vhm = VarHandle.class.getMethod(accessMode.methodName(), Object[].class);
vhm.invoke(v, new Object[]{});
}
@@ -68,7 +68,7 @@
// Try a reflective invoke using a MethodHandle
MethodHandle mh = MethodHandles.lookup().unreflect(
- VarHandle.class.getMethod(accessMode.name(), Object[].class));
+ VarHandle.class.getMethod(accessMode.methodName(), Object[].class));
// Use invoke to avoid WrongMethodTypeException for
// non-signature-polymorphic return types
Object o = (Object) mh.invoke(v, new Object[]{});
@@ -82,7 +82,7 @@
// a MethodHandle
MethodHandle mh = MethodHandles.lookup().unreflect(
- VarHandle.class.getMethod(accessMode.name(), Object[].class));
+ VarHandle.class.getMethod(accessMode.methodName(), Object[].class));
MethodHandleInfo info = MethodHandles.lookup().revealDirect(mh);
Method im = info.reflectAs(Method.class, MethodHandles.lookup());
im.invoke(v, new Object[]{});
@@ -105,7 +105,7 @@
VarHandle v = handle();
MethodHandle mh = MethodHandles.publicLookup().findVirtual(
- VarHandle.class, accessMode.name(), v.accessModeType(accessMode));
+ VarHandle.class, accessMode.methodName(), v.accessModeType(accessMode));
MethodHandleInfo info = MethodHandles.lookup().revealDirect(mh);
--- a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestAccess.java.template Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestAccess.java.template Wed Jul 05 21:35:27 2017 +0200
@@ -90,43 +90,41 @@
@Test(dataProvider = "varHandlesProvider")
public void testIsAccessModeSupported(VarHandle vh) {
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.get));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.set));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getVolatile));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.setVolatile));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getAcquire));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.setRelease));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getOpaque));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.setOpaque));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_VOLATILE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_VOLATILE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_ACQUIRE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_RELEASE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_OPAQUE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_OPAQUE));
#if[CAS]
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndSet));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndExchangeVolatile));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndExchangeAcquire));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndExchangeRelease));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSet));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSetAcquire));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSetRelease));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSetRelease));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getAndSet));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_SET));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_VOLATILE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET));
#else[CAS]
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndSet));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndExchangeVolatile));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndExchangeAcquire));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndExchangeRelease));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSet));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSetAcquire));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSetRelease));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSetRelease));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.getAndSet));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_SET));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_VOLATILE));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET));
#end[CAS]
#if[AtomicAdd]
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getAndAdd));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.addAndGet));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET));
#else[AtomicAdd]
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.getAndAdd));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.addAndGet));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET));
#end[AtomicAdd]
}
--- a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestByteArrayView.java.template Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestByteArrayView.java.template Wed Jul 05 21:35:27 2017 +0200
@@ -76,44 +76,42 @@
public void testIsAccessModeSupported(VarHandleSource vhs) {
VarHandle vh = vhs.s;
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.get));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.set));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getVolatile));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.setVolatile));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getAcquire));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.setRelease));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getOpaque));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.setOpaque));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_VOLATILE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_VOLATILE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_ACQUIRE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_RELEASE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_OPAQUE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_OPAQUE));
#if[CAS]
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndSet));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndExchangeVolatile));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndExchangeAcquire));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndExchangeRelease));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSet));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSetAcquire));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSetRelease));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSetRelease));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getAndSet));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_SET));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_VOLATILE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET));
#else[CAS]
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndSet));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndExchangeVolatile));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndExchangeAcquire));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndExchangeRelease));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSet));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSetAcquire));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSetRelease));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSetRelease));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.getAndSet));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_SET));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_VOLATILE));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET));
#end[CAS]
#if[AtomicAdd]
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getAndAdd));
- assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.addAndGet));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET));
#else[AtomicAdd]
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.getAndAdd));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.addAndGet));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD));
+ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET));
#end[AtomicAdd]
}
--- a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodHandleAccess.java.template Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodHandleAccess.java.template Wed Jul 05 21:35:27 2017 +0200
@@ -121,131 +121,131 @@
static void testInstanceField(VarHandleTestMethodHandleAccess$Type$ recv, Handles hs) throws Throwable {
// Plain
{
- hs.get(TestAccessMode.set).invokeExact(recv, $value1$);
- $type$ x = ($type$) hs.get(TestAccessMode.get).invokeExact(recv);
+ hs.get(TestAccessMode.SET).invokeExact(recv, $value1$);
+ $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv);
assertEquals(x, $value1$, "set $type$ value");
}
// Volatile
{
- hs.get(TestAccessMode.setVolatile).invokeExact(recv, $value2$);
- $type$ x = ($type$) hs.get(TestAccessMode.getVolatile).invokeExact(recv);
+ hs.get(TestAccessMode.SET_VOLATILE).invokeExact(recv, $value2$);
+ $type$ x = ($type$) hs.get(TestAccessMode.GET_VOLATILE).invokeExact(recv);
assertEquals(x, $value2$, "setVolatile $type$ value");
}
// Lazy
{
- hs.get(TestAccessMode.setRelease).invokeExact(recv, $value1$);
- $type$ x = ($type$) hs.get(TestAccessMode.getAcquire).invokeExact(recv);
+ hs.get(TestAccessMode.SET_RELEASE).invokeExact(recv, $value1$);
+ $type$ x = ($type$) hs.get(TestAccessMode.GET_ACQUIRE).invokeExact(recv);
assertEquals(x, $value1$, "setRelease $type$ value");
}
// Opaque
{
- hs.get(TestAccessMode.setOpaque).invokeExact(recv, $value2$);
- $type$ x = ($type$) hs.get(TestAccessMode.getOpaque).invokeExact(recv);
+ hs.get(TestAccessMode.SET_OPAQUE).invokeExact(recv, $value2$);
+ $type$ x = ($type$) hs.get(TestAccessMode.GET_OPAQUE).invokeExact(recv);
assertEquals(x, $value2$, "setOpaque $type$ value");
}
#if[CAS]
- hs.get(TestAccessMode.set).invokeExact(recv, $value1$);
+ hs.get(TestAccessMode.SET).invokeExact(recv, $value1$);
// Compare
{
- boolean r = (boolean) hs.get(TestAccessMode.compareAndSet).invokeExact(recv, $value1$, $value2$);
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(recv, $value1$, $value2$);
assertEquals(r, true, "success compareAndSet $type$");
- $type$ x = ($type$) hs.get(TestAccessMode.get).invokeExact(recv);
+ $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv);
assertEquals(x, $value2$, "success compareAndSet $type$ value");
}
{
- boolean r = (boolean) hs.get(TestAccessMode.compareAndSet).invokeExact(recv, $value1$, $value3$);
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(recv, $value1$, $value3$);
assertEquals(r, false, "failing compareAndSet $type$");
- $type$ x = ($type$) hs.get(TestAccessMode.get).invokeExact(recv);
+ $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv);
assertEquals(x, $value2$, "failing compareAndSet $type$ value");
}
{
- $type$ r = ($type$) hs.get(TestAccessMode.compareAndExchangeVolatile).invokeExact(recv, $value2$, $value1$);
+ $type$ r = ($type$) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact(recv, $value2$, $value1$);
assertEquals(r, $value2$, "success compareAndExchangeVolatile $type$");
- $type$ x = ($type$) hs.get(TestAccessMode.get).invokeExact(recv);
+ $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv);
assertEquals(x, $value1$, "success compareAndExchangeVolatile $type$ value");
}
{
- $type$ r = ($type$) hs.get(TestAccessMode.compareAndExchangeVolatile).invokeExact(recv, $value2$, $value3$);
+ $type$ r = ($type$) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact(recv, $value2$, $value3$);
assertEquals(r, $value1$, "failing compareAndExchangeVolatile $type$");
- $type$ x = ($type$) hs.get(TestAccessMode.get).invokeExact(recv);
+ $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv);
assertEquals(x, $value1$, "failing compareAndExchangeVolatile $type$ value");
}
{
- $type$ r = ($type$) hs.get(TestAccessMode.compareAndExchangeAcquire).invokeExact(recv, $value1$, $value2$);
+ $type$ r = ($type$) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(recv, $value1$, $value2$);
assertEquals(r, $value1$, "success compareAndExchangeAcquire $type$");
- $type$ x = ($type$) hs.get(TestAccessMode.get).invokeExact(recv);
+ $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv);
assertEquals(x, $value2$, "success compareAndExchangeAcquire $type$ value");
}
{
- $type$ r = ($type$) hs.get(TestAccessMode.compareAndExchangeAcquire).invokeExact(recv, $value1$, $value3$);
+ $type$ r = ($type$) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(recv, $value1$, $value3$);
assertEquals(r, $value2$, "failing compareAndExchangeAcquire $type$");
- $type$ x = ($type$) hs.get(TestAccessMode.get).invokeExact(recv);
+ $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv);
assertEquals(x, $value2$, "failing compareAndExchangeAcquire $type$ value");
}
{
- $type$ r = ($type$) hs.get(TestAccessMode.compareAndExchangeRelease).invokeExact(recv, $value2$, $value1$);
+ $type$ r = ($type$) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(recv, $value2$, $value1$);
assertEquals(r, $value2$, "success compareAndExchangeRelease $type$");
- $type$ x = ($type$) hs.get(TestAccessMode.get).invokeExact(recv);
+ $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv);
assertEquals(x, $value1$, "success compareAndExchangeRelease $type$ value");
}
{
- $type$ r = ($type$) hs.get(TestAccessMode.compareAndExchangeRelease).invokeExact(recv, $value2$, $value3$);
+ $type$ r = ($type$) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(recv, $value2$, $value3$);
assertEquals(r, $value1$, "failing compareAndExchangeRelease $type$");
- $type$ x = ($type$) hs.get(TestAccessMode.get).invokeExact(recv);
+ $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv);
assertEquals(x, $value1$, "failing compareAndExchangeRelease $type$ value");
}
{
- boolean r = (boolean) hs.get(TestAccessMode.weakCompareAndSet).invokeExact(recv, $value1$, $value2$);
+ boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, $value1$, $value2$);
assertEquals(r, true, "weakCompareAndSet $type$");
- $type$ x = ($type$) hs.get(TestAccessMode.get).invokeExact(recv);
+ $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv);
assertEquals(x, $value2$, "weakCompareAndSet $type$ value");
}
{
- boolean r = (boolean) hs.get(TestAccessMode.weakCompareAndSetAcquire).invokeExact(recv, $value2$, $value1$);
+ boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(recv, $value2$, $value1$);
assertEquals(r, true, "weakCompareAndSetAcquire $type$");
- $type$ x = ($type$) hs.get(TestAccessMode.get).invokeExact(recv);
+ $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv);
assertEquals(x, $value1$, "weakCompareAndSetAcquire $type$");
}
{
- boolean r = (boolean) hs.get(TestAccessMode.weakCompareAndSetRelease).invokeExact(recv, $value1$, $value2$);
+ boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(recv, $value1$, $value2$);
assertEquals(r, true, "weakCompareAndSetRelease $type$");
- $type$ x = ($type$) hs.get(TestAccessMode.get).invokeExact(recv);
+ $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv);
assertEquals(x, $value2$, "weakCompareAndSetRelease $type$");
}
// Compare set and get
{
- $type$ o = ($type$) hs.get(TestAccessMode.getAndSet).invokeExact(recv, $value1$);
+ $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_SET).invokeExact(recv, $value1$);
assertEquals(o, $value2$, "getAndSet $type$");
- $type$ x = ($type$) hs.get(TestAccessMode.get).invokeExact(recv);
+ $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv);
assertEquals(x, $value1$, "getAndSet $type$ value");
}
#end[CAS]
#if[AtomicAdd]
- hs.get(TestAccessMode.set).invokeExact(recv, $value1$);
+ hs.get(TestAccessMode.SET).invokeExact(recv, $value1$);
// get and add, add and get
{
- $type$ o = ($type$) hs.get(TestAccessMode.getAndAdd).invokeExact(recv, $value3$);
+ $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(recv, $value3$);
assertEquals(o, $value1$, "getAndAdd $type$");
- $type$ c = ($type$) hs.get(TestAccessMode.addAndGet).invokeExact(recv, $value3$);
+ $type$ c = ($type$) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(recv, $value3$);
assertEquals(c, $value1$ + $value3$ + $value3$, "getAndAdd $type$ value");
}
#end[AtomicAdd]
@@ -253,19 +253,19 @@
static void testInstanceFieldUnsupported(VarHandleTestMethodHandleAccess$Type$ recv, Handles hs) throws Throwable {
#if[!CAS]
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
checkUOE(am, () -> {
boolean r = (boolean) hs.get(am).invokeExact(recv, $value1$, $value2$);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndExchange)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
checkUOE(am, () -> {
$type$ r = ($type$) hs.get(am).invokeExact(recv, $value1$, $value2$);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
checkUOE(am, () -> {
$type$ r = ($type$) hs.get(am).invokeExact(recv, $value1$);
});
@@ -273,7 +273,7 @@
#end[CAS]
#if[!AtomicAdd]
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndAdd)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
checkUOE(am, () -> {
$type$ r = ($type$) hs.get(am).invokeExact(recv, $value1$);
});
@@ -285,131 +285,131 @@
static void testStaticField(Handles hs) throws Throwable {
// Plain
{
- hs.get(TestAccessMode.set).invokeExact($value1$);
- $type$ x = ($type$) hs.get(TestAccessMode.get).invokeExact();
+ hs.get(TestAccessMode.SET).invokeExact($value1$);
+ $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact();
assertEquals(x, $value1$, "set $type$ value");
}
// Volatile
{
- hs.get(TestAccessMode.setVolatile).invokeExact($value2$);
- $type$ x = ($type$) hs.get(TestAccessMode.getVolatile).invokeExact();
+ hs.get(TestAccessMode.SET_VOLATILE).invokeExact($value2$);
+ $type$ x = ($type$) hs.get(TestAccessMode.GET_VOLATILE).invokeExact();
assertEquals(x, $value2$, "setVolatile $type$ value");
}
// Lazy
{
- hs.get(TestAccessMode.setRelease).invokeExact($value1$);
- $type$ x = ($type$) hs.get(TestAccessMode.getAcquire).invokeExact();
+ hs.get(TestAccessMode.SET_RELEASE).invokeExact($value1$);
+ $type$ x = ($type$) hs.get(TestAccessMode.GET_ACQUIRE).invokeExact();
assertEquals(x, $value1$, "setRelease $type$ value");
}
// Opaque
{
- hs.get(TestAccessMode.setOpaque).invokeExact($value2$);
- $type$ x = ($type$) hs.get(TestAccessMode.getOpaque).invokeExact();
+ hs.get(TestAccessMode.SET_OPAQUE).invokeExact($value2$);
+ $type$ x = ($type$) hs.get(TestAccessMode.GET_OPAQUE).invokeExact();
assertEquals(x, $value2$, "setOpaque $type$ value");
}
#if[CAS]
- hs.get(TestAccessMode.set).invokeExact($value1$);
+ hs.get(TestAccessMode.SET).invokeExact($value1$);
// Compare
{
- boolean r = (boolean) hs.get(TestAccessMode.compareAndSet).invokeExact($value1$, $value2$);
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact($value1$, $value2$);
assertEquals(r, true, "success compareAndSet $type$");
- $type$ x = ($type$) hs.get(TestAccessMode.get).invokeExact();
+ $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact();
assertEquals(x, $value2$, "success compareAndSet $type$ value");
}
{
- boolean r = (boolean) hs.get(TestAccessMode.compareAndSet).invokeExact($value1$, $value3$);
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact($value1$, $value3$);
assertEquals(r, false, "failing compareAndSet $type$");
- $type$ x = ($type$) hs.get(TestAccessMode.get).invokeExact();
+ $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact();
assertEquals(x, $value2$, "failing compareAndSet $type$ value");
}
{
- $type$ r = ($type$) hs.get(TestAccessMode.compareAndExchangeVolatile).invokeExact($value2$, $value1$);
+ $type$ r = ($type$) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact($value2$, $value1$);
assertEquals(r, $value2$, "success compareAndExchangeVolatile $type$");
- $type$ x = ($type$) hs.get(TestAccessMode.get).invokeExact();
+ $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact();
assertEquals(x, $value1$, "success compareAndExchangeVolatile $type$ value");
}
{
- $type$ r = ($type$) hs.get(TestAccessMode.compareAndExchangeVolatile).invokeExact($value2$, $value3$);
+ $type$ r = ($type$) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact($value2$, $value3$);
assertEquals(r, $value1$, "failing compareAndExchangeVolatile $type$");
- $type$ x = ($type$) hs.get(TestAccessMode.get).invokeExact();
+ $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact();
assertEquals(x, $value1$, "failing compareAndExchangeVolatile $type$ value");
}
{
- $type$ r = ($type$) hs.get(TestAccessMode.compareAndExchangeAcquire).invokeExact($value1$, $value2$);
+ $type$ r = ($type$) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact($value1$, $value2$);
assertEquals(r, $value1$, "success compareAndExchangeAcquire $type$");
- $type$ x = ($type$) hs.get(TestAccessMode.get).invokeExact();
+ $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact();
assertEquals(x, $value2$, "success compareAndExchangeAcquire $type$ value");
}
{
- $type$ r = ($type$) hs.get(TestAccessMode.compareAndExchangeAcquire).invokeExact($value1$, $value3$);
+ $type$ r = ($type$) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact($value1$, $value3$);
assertEquals(r, $value2$, "failing compareAndExchangeAcquire $type$");
- $type$ x = ($type$) hs.get(TestAccessMode.get).invokeExact();
+ $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact();
assertEquals(x, $value2$, "failing compareAndExchangeAcquire $type$ value");
}
{
- $type$ r = ($type$) hs.get(TestAccessMode.compareAndExchangeRelease).invokeExact($value2$, $value1$);
+ $type$ r = ($type$) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact($value2$, $value1$);
assertEquals(r, $value2$, "success compareAndExchangeRelease $type$");
- $type$ x = ($type$) hs.get(TestAccessMode.get).invokeExact();
+ $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact();
assertEquals(x, $value1$, "success compareAndExchangeRelease $type$ value");
}
{
- $type$ r = ($type$) hs.get(TestAccessMode.compareAndExchangeRelease).invokeExact($value2$, $value3$);
+ $type$ r = ($type$) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact($value2$, $value3$);
assertEquals(r, $value1$, "failing compareAndExchangeRelease $type$");
- $type$ x = ($type$) hs.get(TestAccessMode.get).invokeExact();
+ $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact();
assertEquals(x, $value1$, "failing compareAndExchangeRelease $type$ value");
}
{
- boolean r = (boolean) hs.get(TestAccessMode.weakCompareAndSet).invokeExact($value1$, $value2$);
+ boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact($value1$, $value2$);
assertEquals(r, true, "weakCompareAndSet $type$");
- $type$ x = ($type$) hs.get(TestAccessMode.get).invokeExact();
+ $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact();
assertEquals(x, $value2$, "weakCompareAndSet $type$ value");
}
{
- boolean r = (boolean) hs.get(TestAccessMode.weakCompareAndSetAcquire).invokeExact($value2$, $value1$);
+ boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact($value2$, $value1$);
assertEquals(r, true, "weakCompareAndSetAcquire $type$");
- $type$ x = ($type$) hs.get(TestAccessMode.get).invokeExact();
+ $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact();
assertEquals(x, $value1$, "weakCompareAndSetAcquire $type$");
}
{
- boolean r = (boolean) hs.get(TestAccessMode.weakCompareAndSetRelease).invokeExact( $value1$, $value2$);
+ boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact( $value1$, $value2$);
assertEquals(r, true, "weakCompareAndSetRelease $type$");
- $type$ x = ($type$) hs.get(TestAccessMode.get).invokeExact();
+ $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact();
assertEquals(x, $value2$, "weakCompareAndSetRelease $type$");
}
// Compare set and get
{
- $type$ o = ($type$) hs.get(TestAccessMode.getAndSet).invokeExact( $value1$);
+ $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_SET).invokeExact( $value1$);
assertEquals(o, $value2$, "getAndSet $type$");
- $type$ x = ($type$) hs.get(TestAccessMode.get).invokeExact();
+ $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact();
assertEquals(x, $value1$, "getAndSet $type$ value");
}
#end[CAS]
#if[AtomicAdd]
- hs.get(TestAccessMode.set).invokeExact($value1$);
+ hs.get(TestAccessMode.SET).invokeExact($value1$);
// get and add, add and get
{
- $type$ o = ($type$) hs.get(TestAccessMode.getAndAdd).invokeExact( $value3$);
+ $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_ADD).invokeExact( $value3$);
assertEquals(o, $value1$, "getAndAdd $type$");
- $type$ c = ($type$) hs.get(TestAccessMode.addAndGet).invokeExact($value3$);
+ $type$ c = ($type$) hs.get(TestAccessMode.ADD_AND_GET).invokeExact($value3$);
assertEquals(c, $value1$ + $value3$ + $value3$, "getAndAdd $type$ value");
}
#end[AtomicAdd]
@@ -417,19 +417,19 @@
static void testStaticFieldUnsupported(Handles hs) throws Throwable {
#if[!CAS]
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
checkUOE(am, () -> {
boolean r = (boolean) hs.get(am).invokeExact($value1$, $value2$);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndExchange)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
checkUOE(am, () -> {
$type$ r = ($type$) hs.get(am).invokeExact($value1$, $value2$);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
checkUOE(am, () -> {
$type$ r = ($type$) hs.get(am).invokeExact($value1$);
});
@@ -437,7 +437,7 @@
#end[CAS]
#if[!AtomicAdd]
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndAdd)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
checkUOE(am, () -> {
$type$ r = ($type$) hs.get(am).invokeExact($value1$);
});
@@ -452,131 +452,131 @@
for (int i = 0; i < array.length; i++) {
// Plain
{
- hs.get(TestAccessMode.set).invokeExact(array, i, $value1$);
- $type$ x = ($type$) hs.get(TestAccessMode.get).invokeExact(array, i);
+ hs.get(TestAccessMode.SET).invokeExact(array, i, $value1$);
+ $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i);
assertEquals(x, $value1$, "get $type$ value");
}
// Volatile
{
- hs.get(TestAccessMode.setVolatile).invokeExact(array, i, $value2$);
- $type$ x = ($type$) hs.get(TestAccessMode.getVolatile).invokeExact(array, i);
+ hs.get(TestAccessMode.SET_VOLATILE).invokeExact(array, i, $value2$);
+ $type$ x = ($type$) hs.get(TestAccessMode.GET_VOLATILE).invokeExact(array, i);
assertEquals(x, $value2$, "setVolatile $type$ value");
}
// Lazy
{
- hs.get(TestAccessMode.setRelease).invokeExact(array, i, $value1$);
- $type$ x = ($type$) hs.get(TestAccessMode.getAcquire).invokeExact(array, i);
+ hs.get(TestAccessMode.SET_RELEASE).invokeExact(array, i, $value1$);
+ $type$ x = ($type$) hs.get(TestAccessMode.GET_ACQUIRE).invokeExact(array, i);
assertEquals(x, $value1$, "setRelease $type$ value");
}
// Opaque
{
- hs.get(TestAccessMode.setOpaque).invokeExact(array, i, $value2$);
- $type$ x = ($type$) hs.get(TestAccessMode.getOpaque).invokeExact(array, i);
+ hs.get(TestAccessMode.SET_OPAQUE).invokeExact(array, i, $value2$);
+ $type$ x = ($type$) hs.get(TestAccessMode.GET_OPAQUE).invokeExact(array, i);
assertEquals(x, $value2$, "setOpaque $type$ value");
}
#if[CAS]
- hs.get(TestAccessMode.set).invokeExact(array, i, $value1$);
+ hs.get(TestAccessMode.SET).invokeExact(array, i, $value1$);
// Compare
{
- boolean r = (boolean) hs.get(TestAccessMode.compareAndSet).invokeExact(array, i, $value1$, $value2$);
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(array, i, $value1$, $value2$);
assertEquals(r, true, "success compareAndSet $type$");
- $type$ x = ($type$) hs.get(TestAccessMode.get).invokeExact(array, i);
+ $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i);
assertEquals(x, $value2$, "success compareAndSet $type$ value");
}
{
- boolean r = (boolean) hs.get(TestAccessMode.compareAndSet).invokeExact(array, i, $value1$, $value3$);
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(array, i, $value1$, $value3$);
assertEquals(r, false, "failing compareAndSet $type$");
- $type$ x = ($type$) hs.get(TestAccessMode.get).invokeExact(array, i);
+ $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i);
assertEquals(x, $value2$, "failing compareAndSet $type$ value");
}
{
- $type$ r = ($type$) hs.get(TestAccessMode.compareAndExchangeVolatile).invokeExact(array, i, $value2$, $value1$);
+ $type$ r = ($type$) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact(array, i, $value2$, $value1$);
assertEquals(r, $value2$, "success compareAndExchangeVolatile $type$");
- $type$ x = ($type$) hs.get(TestAccessMode.get).invokeExact(array, i);
+ $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i);
assertEquals(x, $value1$, "success compareAndExchangeVolatile $type$ value");
}
{
- $type$ r = ($type$) hs.get(TestAccessMode.compareAndExchangeVolatile).invokeExact(array, i, $value2$, $value3$);
+ $type$ r = ($type$) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact(array, i, $value2$, $value3$);
assertEquals(r, $value1$, "failing compareAndExchangeVolatile $type$");
- $type$ x = ($type$) hs.get(TestAccessMode.get).invokeExact(array, i);
+ $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i);
assertEquals(x, $value1$, "failing compareAndExchangeVolatile $type$ value");
}
{
- $type$ r = ($type$) hs.get(TestAccessMode.compareAndExchangeAcquire).invokeExact(array, i, $value1$, $value2$);
+ $type$ r = ($type$) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(array, i, $value1$, $value2$);
assertEquals(r, $value1$, "success compareAndExchangeAcquire $type$");
- $type$ x = ($type$) hs.get(TestAccessMode.get).invokeExact(array, i);
+ $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i);
assertEquals(x, $value2$, "success compareAndExchangeAcquire $type$ value");
}
{
- $type$ r = ($type$) hs.get(TestAccessMode.compareAndExchangeAcquire).invokeExact(array, i, $value1$, $value3$);
+ $type$ r = ($type$) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(array, i, $value1$, $value3$);
assertEquals(r, $value2$, "failing compareAndExchangeAcquire $type$");
- $type$ x = ($type$) hs.get(TestAccessMode.get).invokeExact(array, i);
+ $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i);
assertEquals(x, $value2$, "failing compareAndExchangeAcquire $type$ value");
}
{
- $type$ r = ($type$) hs.get(TestAccessMode.compareAndExchangeRelease).invokeExact(array, i, $value2$, $value1$);
+ $type$ r = ($type$) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(array, i, $value2$, $value1$);
assertEquals(r, $value2$, "success compareAndExchangeRelease $type$");
- $type$ x = ($type$) hs.get(TestAccessMode.get).invokeExact(array, i);
+ $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i);
assertEquals(x, $value1$, "success compareAndExchangeRelease $type$ value");
}
{
- $type$ r = ($type$) hs.get(TestAccessMode.compareAndExchangeRelease).invokeExact(array, i, $value2$, $value3$);
+ $type$ r = ($type$) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(array, i, $value2$, $value3$);
assertEquals(r, $value1$, "failing compareAndExchangeRelease $type$");
- $type$ x = ($type$) hs.get(TestAccessMode.get).invokeExact(array, i);
+ $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i);
assertEquals(x, $value1$, "failing compareAndExchangeRelease $type$ value");
}
{
- boolean r = (boolean) hs.get(TestAccessMode.weakCompareAndSet).invokeExact(array, i, $value1$, $value2$);
+ boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, $value1$, $value2$);
assertEquals(r, true, "weakCompareAndSet $type$");
- $type$ x = ($type$) hs.get(TestAccessMode.get).invokeExact(array, i);
+ $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i);
assertEquals(x, $value2$, "weakCompareAndSet $type$ value");
}
{
- boolean r = (boolean) hs.get(TestAccessMode.weakCompareAndSetAcquire).invokeExact(array, i, $value2$, $value1$);
+ boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(array, i, $value2$, $value1$);
assertEquals(r, true, "weakCompareAndSetAcquire $type$");
- $type$ x = ($type$) hs.get(TestAccessMode.get).invokeExact(array, i);
+ $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i);
assertEquals(x, $value1$, "weakCompareAndSetAcquire $type$");
}
{
- boolean r = (boolean) hs.get(TestAccessMode.weakCompareAndSetRelease).invokeExact(array, i, $value1$, $value2$);
+ boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(array, i, $value1$, $value2$);
assertEquals(r, true, "weakCompareAndSetRelease $type$");
- $type$ x = ($type$) hs.get(TestAccessMode.get).invokeExact(array, i);
+ $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i);
assertEquals(x, $value2$, "weakCompareAndSetRelease $type$");
}
// Compare set and get
{
- $type$ o = ($type$) hs.get(TestAccessMode.getAndSet).invokeExact(array, i, $value1$);
+ $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_SET).invokeExact(array, i, $value1$);
assertEquals(o, $value2$, "getAndSet $type$");
- $type$ x = ($type$) hs.get(TestAccessMode.get).invokeExact(array, i);
+ $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i);
assertEquals(x, $value1$, "getAndSet $type$ value");
}
#end[CAS]
#if[AtomicAdd]
- hs.get(TestAccessMode.set).invokeExact(array, i, $value1$);
+ hs.get(TestAccessMode.SET).invokeExact(array, i, $value1$);
// get and add, add and get
{
- $type$ o = ($type$) hs.get(TestAccessMode.getAndAdd).invokeExact(array, i, $value3$);
+ $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(array, i, $value3$);
assertEquals(o, $value1$, "getAndAdd $type$");
- $type$ c = ($type$) hs.get(TestAccessMode.addAndGet).invokeExact(array, i, $value3$);
+ $type$ c = ($type$) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(array, i, $value3$);
assertEquals(c, $value1$ + $value3$ + $value3$, "getAndAdd $type$ value");
}
#end[AtomicAdd]
@@ -588,19 +588,19 @@
final int i = 0;
#if[!CAS]
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
checkUOE(am, () -> {
boolean r = (boolean) hs.get(am).invokeExact(array, i, $value1$, $value2$);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndExchange)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
checkUOE(am, () -> {
$type$ r = ($type$) hs.get(am).invokeExact(array, i, $value1$, $value2$);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
checkUOE(am, () -> {
$type$ r = ($type$) hs.get(am).invokeExact(array, i, $value1$);
});
@@ -608,7 +608,7 @@
#end[CAS]
#if[!AtomicAdd]
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndAdd)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
checkUOE(am, () -> {
$type$ o = ($type$) hs.get(am).invokeExact(array, i, $value1$);
});
@@ -622,32 +622,32 @@
for (int i : new int[]{-1, Integer.MIN_VALUE, 10, 11, Integer.MAX_VALUE}) {
final int ci = i;
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.get)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
checkIOOBE(am, () -> {
$type$ x = ($type$) hs.get(am).invokeExact(array, ci);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.set)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
checkIOOBE(am, () -> {
hs.get(am).invokeExact(array, ci, $value1$);
});
}
#if[CAS]
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
checkIOOBE(am, () -> {
boolean r = (boolean) hs.get(am).invokeExact(array, ci, $value1$, $value2$);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndExchange)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
checkIOOBE(am, () -> {
$type$ r = ($type$) hs.get(am).invokeExact(array, ci, $value2$, $value1$);
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
checkIOOBE(am, () -> {
$type$ o = ($type$) hs.get(am).invokeExact(array, ci, $value1$);
});
@@ -655,7 +655,7 @@
#end[CAS]
#if[AtomicAdd]
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndAdd)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
checkIOOBE(am, () -> {
$type$ o = ($type$) hs.get(am).invokeExact(array, ci, $value3$);
});
--- a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodType.java.template Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodType.java.template Wed Jul 05 21:35:27 2017 +0200
@@ -619,7 +619,7 @@
}
static void testInstanceFieldWrongMethodType(VarHandleTestMethodType$Type$ recv, Handles hs) throws Throwable {
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.get)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
// Incorrect argument types
checkNPE(() -> { // null receiver
$type$ x = ($type$) hs.get(am, methodType($type$.class, Void.class)).
@@ -653,7 +653,7 @@
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.set)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
// Incorrect argument types
checkNPE(() -> { // null receiver
hs.get(am, methodType(void.class, Void.class, $type$.class)).
@@ -683,7 +683,7 @@
}
#if[CAS]
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
// Incorrect argument types
checkNPE(() -> { // null receiver
boolean r = (boolean) hs.get(am, methodType(boolean.class, Void.class, $type$.class, $type$.class)).
@@ -716,7 +716,7 @@
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndExchange)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
checkNPE(() -> { // null receiver
$type$ x = ($type$) hs.get(am, methodType($type$.class, Void.class, $type$.class, $type$.class)).
invoke(null, $value1$, $value1$);
@@ -757,7 +757,7 @@
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
checkNPE(() -> { // null receiver
$type$ x = ($type$) hs.get(am, methodType($type$.class, Void.class, $type$.class)).
invoke(null, $value1$);
@@ -796,7 +796,7 @@
#end[CAS]
#if[AtomicAdd]
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndAdd)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
checkNPE(() -> { // null receiver
$type$ x = ($type$) hs.get(am, methodType($type$.class, Void.class, $type$.class)).
invoke(null, $value1$);
@@ -1155,7 +1155,7 @@
static void testStaticFieldWrongMethodType(Handles hs) throws Throwable {
int i = 0;
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.get)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
// Incorrect return type
check{#if[String]?CCE:WMTE}(() -> { // reference class
Void x = (Void) hs.get(am, methodType(Void.class)).
@@ -1172,7 +1172,7 @@
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.set)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
check{#if[String]?CCE:WMTE}(() -> { // value reference class
hs.get(am, methodType(void.class, Class.class)).
invoke(Void.class);
@@ -1188,7 +1188,7 @@
});
}
#if[CAS]
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
// Incorrect argument types
check{#if[String]?CCE:WMTE}(() -> { // expected reference class
boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, $type$.class)).
@@ -1209,7 +1209,7 @@
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndExchange)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
// Incorrect argument types
check{#if[String]?CCE:WMTE}(() -> { // expected reference class
$type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class, $type$.class)).
@@ -1239,7 +1239,7 @@
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
// Incorrect argument types
check{#if[String]?CCE:WMTE}(() -> { // value reference class
$type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class)).
@@ -1267,7 +1267,7 @@
#end[CAS]
#if[AtomicAdd]
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndAdd)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
// Incorrect argument types
check{#if[String]?CCE:WMTE}(() -> { // value reference class
$type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class)).
@@ -1854,7 +1854,7 @@
$type$[] array = new $type$[10];
Arrays.fill(array, $value1$);
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.get)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
// Incorrect argument types
checkNPE(() -> { // null array
$type$ x = ($type$) hs.get(am, methodType($type$.class, Void.class, int.class)).
@@ -1892,7 +1892,7 @@
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.set)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
// Incorrect argument types
checkNPE(() -> { // null array
hs.get(am, methodType(void.class, Void.class, int.class, $type$.class)).
@@ -1925,7 +1925,7 @@
});
}
#if[CAS]
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
// Incorrect argument types
checkNPE(() -> { // null receiver
boolean r = (boolean) hs.get(am, methodType(boolean.class, Void.class, int.class, $type$.class, $type$.class)).
@@ -1962,7 +1962,7 @@
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.compareAndExchange)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
// Incorrect argument types
checkNPE(() -> { // null receiver
$type$ x = ($type$) hs.get(am, methodType($type$.class, Void.class, int.class, $type$.class, $type$.class)).
@@ -2008,7 +2008,7 @@
});
}
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndSet)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
// Incorrect argument types
checkNPE(() -> { // null array
$type$ x = ($type$) hs.get(am, methodType($type$.class, Void.class, int.class, $type$.class)).
@@ -2052,7 +2052,7 @@
#end[CAS]
#if[AtomicAdd]
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.getAndAdd)) {
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
// Incorrect argument types
checkNPE(() -> { // null array
$type$ x = ($type$) hs.get(am, methodType($type$.class, Void.class, int.class, $type$.class)).
--- a/jdk/test/java/lang/management/ThreadMXBean/ThreadLists.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/java/lang/management/ThreadMXBean/ThreadLists.java Wed Jul 05 21:35:27 2017 +0200
@@ -35,6 +35,11 @@
public class ThreadLists {
public static void main(String args[]) {
+ // Bug id : JDK-8151797
+ // Use a lambda expression so that call-site cleaner thread is started
+ Runnable printLambda = () -> {System.out.println("Starting Test");};
+ printLambda.run();
+
// get top-level thread group
ThreadGroup top = Thread.currentThread().getThreadGroup();
ThreadGroup parent;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/net/URLClassLoader/definePackage/SplitPackage.java Wed Jul 05 21:35:27 2017 +0200
@@ -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.
+ */
+
+/*
+ * @test
+ * @bug 8153665
+ * @summary Test two URLClassLoader define Package object of the same name
+ * @library /lib/testlibrary
+ * @build CompilerUtils
+ * @run testng SplitPackage
+ */
+
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.StandardCopyOption;
+import java.util.jar.Manifest;
+
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+import static org.testng.Assert.*;
+
+public class SplitPackage {
+ private static final Path SRC_DIR = Paths.get(System.getProperty("test.src", "."));
+ private static final Path FOO_DIR = Paths.get("foo");
+ private static final Path BAR_DIR = Paths.get("bar");
+
+ @BeforeTest
+ private void setup() throws Exception {
+ Files.createDirectory(BAR_DIR);
+
+ Path pkgDir = Paths.get("p");
+ // compile classes in package p
+ assertTrue(CompilerUtils.compile(SRC_DIR.resolve(pkgDir), BAR_DIR));
+
+ // move p.Foo to a different directory
+ Path foo = pkgDir.resolve("Foo.class");
+ Files.createDirectories(FOO_DIR.resolve(pkgDir));
+ Files.move(BAR_DIR.resolve(foo), FOO_DIR.resolve(foo),
+ StandardCopyOption.REPLACE_EXISTING);
+ }
+
+ @Test
+ public void test() throws Exception {
+ URLClassLoader loader1 = new URLClassLoader(new URL[] {
+ FOO_DIR.toUri().toURL()
+ });
+ Loader loader2 = new Loader(new URL[] {
+ BAR_DIR.toUri().toURL()
+ }, loader1);
+
+ Class<?> foo = Class.forName("p.Foo", true, loader2);
+ Class<?> bar = Class.forName("p.Bar", true, loader2);
+ Class<?> baz = Class.forName("p.Baz", true, loader2);
+
+ Package pForFoo = loader1.getDefinedPackage("p");
+ Package pForBar = loader2.getDefinedPackage("p");
+
+ assertEquals(pForFoo.getName(), pForBar.getName());
+ assertTrue(pForFoo != pForBar);
+
+ try {
+ loader2.defineSplitPackage("p");
+ } catch (IllegalArgumentException e) {
+
+ }
+ }
+
+ static class Loader extends URLClassLoader {
+ Loader(URL[] urls, URLClassLoader parent) {
+ super(urls, parent);
+ }
+
+ public Package defineSplitPackage(String name) {
+ Manifest manifest = new Manifest();
+ return super.definePackage(name, manifest, null);
+ }
+ }
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/net/URLClassLoader/definePackage/p/Bar.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,27 @@
+/*
+ * 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 p;
+
+public class Bar { }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/net/URLClassLoader/definePackage/p/Baz.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,27 @@
+/*
+ * 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 p;
+
+public class Baz { }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/net/URLClassLoader/definePackage/p/Foo.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,27 @@
+/*
+ * 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 p;
+
+public class Foo { }
--- a/jdk/test/java/nio/channels/AsyncCloseAndInterrupt.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/java/nio/channels/AsyncCloseAndInterrupt.java Wed Jul 05 21:35:27 2017 +0200
@@ -23,7 +23,7 @@
/* @test
* @bug 4460583 4470470 4840199 6419424 6710579 6596323 6824135 6395224 7142919
- * 8151582
+ * 8151582 8068693 8153209
* @run main/othervm AsyncCloseAndInterrupt
* @summary Comprehensive test of asynchronous closing and interruption
* @author Mark Reinhold
@@ -557,7 +557,11 @@
}
// Test
- static void test(ChannelFactory cf, Op op, int test)
+ static void test(ChannelFactory cf, Op op, int test) throws Exception {
+ test(cf, op, test, true);
+ }
+
+ static void test(ChannelFactory cf, Op op, int test, boolean extraSleep)
throws Exception
{
log.println();
@@ -571,6 +575,10 @@
sleep(50);
} while (!t.ready);
+ if (extraSleep) {
+ sleep(100);
+ }
+
switch (test) {
case TEST_INTR:
@@ -603,15 +611,18 @@
break;
}
- t.finishAndThrow(500);
+ t.finishAndThrow(10000);
}
-
static void test(ChannelFactory cf, Op op) throws Exception {
+ test(cf, op, true);
+ }
+
+ static void test(ChannelFactory cf, Op op, boolean extraSleep) throws Exception {
// Test INTR cases before PREINTER cases since sometimes
// interrupted threads can't load classes
- test(cf, op, TEST_INTR);
- test(cf, op, TEST_PREINTR);
+ test(cf, op, TEST_INTR, extraSleep);
+ test(cf, op, TEST_PREINTR, extraSleep);
// Bugs, see FileChannelImpl for details
if (op == TRANSFER_FROM) {
@@ -623,7 +634,7 @@
return;
}
- test(cf, op, TEST_CLOSE);
+ test(cf, op, TEST_CLOSE, extraSleep);
}
static void test(ChannelFactory cf)
@@ -720,8 +731,8 @@
Future<Integer> pumpFuture = pumpRefuser(pumperExecutor);
waitPump("\nWait for initial Pump");
- test(socketChannelFactory, CONNECT);
- test(socketChannelFactory, FINISH_CONNECT);
+ test(socketChannelFactory, CONNECT, false);
+ test(socketChannelFactory, FINISH_CONNECT, false);
pumpDone = true;
Integer newConn = pumpFuture.get(30, TimeUnit.SECONDS);
--- a/jdk/test/java/security/testlibrary/SimpleOCSPServer.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/java/security/testlibrary/SimpleOCSPServer.java Wed Jul 05 21:35:27 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 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
@@ -86,6 +86,7 @@
private boolean logEnabled = false;
private ExecutorService threadPool;
private volatile boolean started = false;
+ private volatile boolean serverReady = false;
private volatile boolean receivedShutdown = false;
private long delayMsec = 0;
@@ -217,6 +218,9 @@
listenPort), 128);
log("Listening on " + servSocket.getLocalSocketAddress());
+ // Singal ready
+ serverReady = true;
+
// Update the listenPort with the new port number. If
// the server is restarted, it will bind to the same
// port rather than picking a new one.
@@ -242,11 +246,12 @@
threadPool.shutdown();
} catch (IOException ioe) {
err(ioe);
+ } finally {
+ // Reset state variables so the server can be restarted
+ receivedShutdown = false;
+ started = false;
+ serverReady = false;
}
-
- // Reset state variables so the server can be restarted
- receivedShutdown = false;
- started = false;
}
});
}
@@ -468,7 +473,7 @@
* server has not yet been bound to a port.
*/
public int getPort() {
- if (servSocket != null && started) {
+ if (serverReady) {
InetSocketAddress inetSock =
(InetSocketAddress)servSocket.getLocalSocketAddress();
return inetSock.getPort();
@@ -478,6 +483,15 @@
}
/**
+ * Use to check if OCSP server is ready to accept connection.
+ *
+ * @return true if server ready, false otherwise
+ */
+ public boolean isServerReady() {
+ return serverReady;
+ }
+
+ /**
* Set a delay between the reception of the request and production of
* the response.
*
--- a/jdk/test/java/time/tck/java/time/TCKDuration.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/java/time/tck/java/time/TCKDuration.java Wed Jul 05 21:35:27 2017 +0200
@@ -65,9 +65,11 @@
import static java.time.temporal.ChronoUnit.MICROS;
import static java.time.temporal.ChronoUnit.MILLIS;
import static java.time.temporal.ChronoUnit.MINUTES;
+import static java.time.temporal.ChronoUnit.MONTHS;
import static java.time.temporal.ChronoUnit.NANOS;
import static java.time.temporal.ChronoUnit.SECONDS;
import static java.time.temporal.ChronoUnit.WEEKS;
+import static java.time.temporal.ChronoUnit.YEARS;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
@@ -2287,6 +2289,133 @@
}
//-----------------------------------------------------------------------
+ // truncated(TemporalUnit)
+ //-----------------------------------------------------------------------
+ TemporalUnit NINETY_MINS = new TemporalUnit() {
+ @Override
+ public Duration getDuration() {
+ return Duration.ofMinutes(90);
+ }
+ @Override
+ public boolean isDurationEstimated() {
+ return false;
+ }
+ @Override
+ public boolean isDateBased() {
+ return false;
+ }
+ @Override
+ public boolean isTimeBased() {
+ return true;
+ }
+ @Override
+ public boolean isSupportedBy(Temporal temporal) {
+ return false;
+ }
+ @Override
+ public <R extends Temporal> R addTo(R temporal, long amount) {
+ throw new UnsupportedOperationException();
+ }
+ @Override
+ public long between(Temporal temporal1, Temporal temporal2) {
+ throw new UnsupportedOperationException();
+ }
+ @Override
+ public String toString() {
+ return "NinetyMins";
+ }
+ };
+
+ TemporalUnit NINETY_FIVE_MINS = new TemporalUnit() {
+ @Override
+ public Duration getDuration() {
+ return Duration.ofMinutes(95);
+ }
+ @Override
+ public boolean isDurationEstimated() {
+ return false;
+ }
+ @Override
+ public boolean isDateBased() {
+ return false;
+ }
+ @Override
+ public boolean isTimeBased() {
+ return false;
+ }
+ @Override
+ public boolean isSupportedBy(Temporal temporal) {
+ return false;
+ }
+ @Override
+ public <R extends Temporal> R addTo(R temporal, long amount) {
+ throw new UnsupportedOperationException();
+ }
+ @Override
+ public long between(Temporal temporal1, Temporal temporal2) {
+ throw new UnsupportedOperationException();
+ }
+ @Override
+ public String toString() {
+ return "NinetyFiveMins";
+ }
+ };
+
+ @DataProvider(name="truncatedToValid")
+ Object[][] data_truncatedToValid() {
+ return new Object[][] {
+ {Duration.ofSeconds(86400 + 3600 + 60 + 1, 123_456_789), NANOS, Duration.ofSeconds(86400 + 3600 + 60 + 1, 123_456_789)},
+ {Duration.ofSeconds(86400 + 3600 + 60 + 1, 123_456_789), MICROS, Duration.ofSeconds(86400 + 3600 + 60 + 1, 123_456_000)},
+ {Duration.ofSeconds(86400 + 3600 + 60 + 1, 123_456_789), MILLIS, Duration.ofSeconds(86400 + 3600 + 60 + 1, 1230_00_000)},
+ {Duration.ofSeconds(86400 + 3600 + 60 + 1, 123_456_789), SECONDS, Duration.ofSeconds(86400 + 3600 + 60 + 1, 0)},
+ {Duration.ofSeconds(86400 + 3600 + 60 + 1, 123_456_789), MINUTES, Duration.ofSeconds(86400 + 3600 + 60, 0)},
+ {Duration.ofSeconds(86400 + 3600 + 60 + 1, 123_456_789), HOURS, Duration.ofSeconds(86400 + 3600, 0)},
+ {Duration.ofSeconds(86400 + 3600 + 60 + 1, 123_456_789), DAYS, Duration.ofSeconds(86400, 0)},
+
+ {Duration.ofSeconds(86400 + 3600 + 60 + 1, 123_456_789), NINETY_MINS, Duration.ofSeconds(86400 + 0, 0)},
+ {Duration.ofSeconds(86400 + 7200 + 60 + 1, 123_456_789), NINETY_MINS, Duration.ofSeconds(86400 + 5400, 0)},
+ {Duration.ofSeconds(86400 + 10800 + 60 + 1, 123_456_789), NINETY_MINS, Duration.ofSeconds(86400 + 10800, 0)},
+
+ {Duration.ofSeconds(-86400 - 3600 - 60 - 1, 123_456_789), MINUTES, Duration.ofSeconds(-86400 - 3600 - 60, 0 )},
+ {Duration.ofSeconds(-86400 - 3600 - 60 - 1, 123_456_789), MICROS, Duration.ofSeconds(-86400 - 3600 - 60 - 1, 123_457_000)},
+
+ {Duration.ofSeconds(86400 + 3600 + 60 + 1, 0), SECONDS, Duration.ofSeconds(86400 + 3600 + 60 + 1, 0)},
+ {Duration.ofSeconds(-86400 - 3600 - 120, 0), MINUTES, Duration.ofSeconds(-86400 - 3600 - 120, 0)},
+
+ {Duration.ofSeconds(-1, 0), SECONDS, Duration.ofSeconds(-1, 0)},
+ {Duration.ofSeconds(-1, 123_456_789), SECONDS, Duration.ofSeconds(0, 0)},
+ {Duration.ofSeconds(-1, 123_456_789), NANOS, Duration.ofSeconds(0, -876_543_211)},
+ {Duration.ofSeconds(0, 123_456_789), SECONDS, Duration.ofSeconds(0, 0)},
+ {Duration.ofSeconds(0, 123_456_789), NANOS, Duration.ofSeconds(0, 123_456_789)},
+ };
+ }
+
+ @Test(dataProvider="truncatedToValid")
+ public void test_truncatedTo_valid(Duration input, TemporalUnit unit, Duration expected) {
+ assertEquals(input.truncatedTo(unit), expected);
+ }
+
+ @DataProvider(name="truncatedToInvalid")
+ Object[][] data_truncatedToInvalid() {
+ return new Object[][] {
+ {Duration.ofSeconds(1, 123_456_789), NINETY_FIVE_MINS},
+ {Duration.ofSeconds(1, 123_456_789), WEEKS},
+ {Duration.ofSeconds(1, 123_456_789), MONTHS},
+ {Duration.ofSeconds(1, 123_456_789), YEARS},
+ };
+ }
+
+ @Test(dataProvider="truncatedToInvalid", expectedExceptions=DateTimeException.class)
+ public void test_truncatedTo_invalid(Duration input, TemporalUnit unit) {
+ input.truncatedTo(unit);
+ }
+
+ @Test(expectedExceptions=NullPointerException.class)
+ public void test_truncatedTo_null() {
+ Duration.ofSeconds(1234).truncatedTo(null);
+ }
+
+ //-----------------------------------------------------------------------
// dividedBy()
//-----------------------------------------------------------------------
@DataProvider(name="DividedBy")
--- a/jdk/test/java/util/Currency/CurrencyTest.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/java/util/Currency/CurrencyTest.java Wed Jul 05 21:35:27 2017 +0200
@@ -23,7 +23,7 @@
/*
* @test
* @bug 4290801 4692419 4693631 5101540 5104960 6296410 6336600 6371531
- * 6488442 7036905 8008577 8039317 8074350 8074351
+ * 6488442 7036905 8008577 8039317 8074350 8074351 8150324
* @summary Basic tests for Currency class.
* @modules jdk.localedata
*/
@@ -32,12 +32,12 @@
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
-import java.util.Calendar;
-import java.util.Date;
+import java.time.LocalDate;
+import java.time.LocalTime;
+import java.time.ZoneId;
+import java.time.ZonedDateTime;
import java.util.Currency;
-import java.util.GregorianCalendar;
import java.util.Locale;
-import java.util.TimeZone;
public class CurrencyTest {
@@ -137,7 +137,7 @@
/*
* check currency changes
- * In current implementation, there is no data of old currency and transition date at jdk/src/share/classes/java/util/CurrencyData.properties.
+ * In current implementation, there is no data of old currency and transition date at jdk/make/data/currency/CurrencyData.properties.
* So, all the switch data arrays are empty. In the future, if data of old currency and transition date are necessary for any country, the
* arrays here can be updated so that the program can check the currency switch.
*/
@@ -146,15 +146,16 @@
String[] switchOverNew = {};
String[] switchOverTZ = {};
int[] switchOverYear = {};
- int[] switchOverMonth = {};
+ int[] switchOverMonth = {}; // java.time APIs accept month starting from 1 i.e. 01 for January
int[] switchOverDay = {};
for (int i = 0; i < switchOverCtry.length; i++) {
- TimeZone.setDefault(TimeZone.getTimeZone(switchOverTZ[i]));
- Calendar date = new GregorianCalendar(switchOverYear[i], switchOverMonth[i], switchOverDay[i]);
- long switchOver = date.getTime().getTime();
- boolean switchedOver = System.currentTimeMillis() >= switchOver;
- checkCountryCurrency(switchOverCtry[i], switchedOver ? switchOverNew[i] : switchOverOld[i]);
+ ZoneId zoneId = ZoneId.of(switchOverTZ[i]);
+ ZonedDateTime zonedDateAndTime = ZonedDateTime.of(LocalDate.of(switchOverYear[i], switchOverMonth[i], switchOverDay[i]),
+ LocalTime.MIDNIGHT, zoneId);
+ ZonedDateTime currentZonedDateAndTime = ZonedDateTime.now(zoneId);
+ checkCountryCurrency(switchOverCtry[i], (currentZonedDateAndTime.isAfter(zonedDateAndTime) ||
+ currentZonedDateAndTime.isEqual(zonedDateAndTime)) ? switchOverNew[i] : switchOverOld[i]);
}
// check a country code which doesn't have a currency
--- a/jdk/test/java/util/Objects/CheckIndex.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/java/util/Objects/CheckIndex.java Wed Jul 05 21:35:27 2017 +0200
@@ -43,22 +43,30 @@
public class CheckIndex {
static class AssertingOutOfBoundsException extends RuntimeException {
+ public AssertingOutOfBoundsException(String message) {
+ super(message);
+ }
}
- static BiFunction<Integer, Integer, AssertingOutOfBoundsException> assertingOutOfBounds(
- int expFromIndex, int expToIndexOrSizeOrLength) {
- return (fromIndex, toIndexOrSizeorLength) -> {
- assertEquals(fromIndex, Integer.valueOf(expFromIndex));
- assertEquals(toIndexOrSizeorLength, Integer.valueOf(expToIndexOrSizeOrLength));
- return new AssertingOutOfBoundsException();
+ static BiFunction<String, List<Integer>, AssertingOutOfBoundsException> assertingOutOfBounds(
+ String message, String expCheckKind, Integer... expArgs) {
+ return (checkKind, args) -> {
+ assertEquals(checkKind, expCheckKind);
+ assertEquals(args, List.of(expArgs));
+ try {
+ args.clear();
+ fail("Out of bounds List<Integer> argument should be unmodifiable");
+ } catch (Exception e) {
+ }
+ return new AssertingOutOfBoundsException(message);
};
}
- static BiFunction<Integer, Integer, AssertingOutOfBoundsException> assertingOutOfBoundsReturnNull(
- int expFromIndex, int expToIndexOrSizeOrLength) {
- return (fromIndex, toIndexOrSizeorLength) -> {
- assertEquals(fromIndex, Integer.valueOf(expFromIndex));
- assertEquals(toIndexOrSizeorLength, Integer.valueOf(expToIndexOrSizeOrLength));
+ static BiFunction<String, List<Integer>, AssertingOutOfBoundsException> assertingOutOfBoundsReturnNull(
+ String expCheckKind, Integer... expArgs) {
+ return (checkKind, args) -> {
+ assertEquals(checkKind, expCheckKind);
+ assertEquals(args, List.of(expArgs));
return null;
};
}
@@ -85,7 +93,12 @@
@Test(dataProvider = "checkIndexProvider")
public void testCheckIndex(int index, int length, boolean withinBounds) {
- BiConsumer<Class<? extends RuntimeException>, IntSupplier> check = (ec, s) -> {
+ String expectedMessage = withinBounds
+ ? null
+ : Objects.outOfBoundsExceptionFormatter(IndexOutOfBoundsException::new).
+ apply("checkIndex", List.of(index, length)).getMessage();
+
+ BiConsumer<Class<? extends RuntimeException>, IntSupplier> checker = (ec, s) -> {
try {
int rIndex = s.getAsInt();
if (!withinBounds)
@@ -98,17 +111,27 @@
if (withinBounds)
fail(String.format(
"Index %d is within bounds of [0, %d), but was reported to be out of bounds", index, length));
+ else
+ assertEquals(e.getMessage(), expectedMessage);
}
};
- check.accept(AssertingOutOfBoundsException.class,
- () -> Objects.checkIndex(index, length, assertingOutOfBounds(index, length)));
- check.accept(IndexOutOfBoundsException.class,
- () -> Objects.checkIndex(index, length, assertingOutOfBoundsReturnNull(index, length)));
- check.accept(IndexOutOfBoundsException.class,
+ checker.accept(AssertingOutOfBoundsException.class,
+ () -> Objects.checkIndex(index, length,
+ assertingOutOfBounds(expectedMessage, "checkIndex", index, length)));
+ checker.accept(IndexOutOfBoundsException.class,
+ () -> Objects.checkIndex(index, length,
+ assertingOutOfBoundsReturnNull("checkIndex", index, length)));
+ checker.accept(IndexOutOfBoundsException.class,
() -> Objects.checkIndex(index, length, null));
- check.accept(IndexOutOfBoundsException.class,
+ checker.accept(IndexOutOfBoundsException.class,
() -> Objects.checkIndex(index, length));
+ checker.accept(ArrayIndexOutOfBoundsException.class,
+ () -> Objects.checkIndex(index, length,
+ Objects.outOfBoundsExceptionFormatter(ArrayIndexOutOfBoundsException::new)));
+ checker.accept(StringIndexOutOfBoundsException.class,
+ () -> Objects.checkIndex(index, length,
+ Objects.outOfBoundsExceptionFormatter(StringIndexOutOfBoundsException::new)));
}
@@ -132,6 +155,11 @@
@Test(dataProvider = "checkFromToIndexProvider")
public void testCheckFromToIndex(int fromIndex, int toIndex, int length, boolean withinBounds) {
+ String expectedMessage = withinBounds
+ ? null
+ : Objects.outOfBoundsExceptionFormatter(IndexOutOfBoundsException::new).
+ apply("checkFromToIndex", List.of(fromIndex, toIndex, length)).getMessage();
+
BiConsumer<Class<? extends RuntimeException>, IntSupplier> check = (ec, s) -> {
try {
int rIndex = s.getAsInt();
@@ -145,17 +173,27 @@
if (withinBounds)
fail(String.format(
"Range [%d, %d) is within bounds of [0, %d), but was reported to be out of bounds", fromIndex, toIndex, length));
+ else
+ assertEquals(e.getMessage(), expectedMessage);
}
};
check.accept(AssertingOutOfBoundsException.class,
- () -> Objects.checkFromToIndex(fromIndex, toIndex, length, assertingOutOfBounds(fromIndex, toIndex)));
+ () -> Objects.checkFromToIndex(fromIndex, toIndex, length,
+ assertingOutOfBounds(expectedMessage, "checkFromToIndex", fromIndex, toIndex, length)));
check.accept(IndexOutOfBoundsException.class,
- () -> Objects.checkFromToIndex(fromIndex, toIndex, length, assertingOutOfBoundsReturnNull(fromIndex, toIndex)));
+ () -> Objects.checkFromToIndex(fromIndex, toIndex, length,
+ assertingOutOfBoundsReturnNull("checkFromToIndex", fromIndex, toIndex, length)));
check.accept(IndexOutOfBoundsException.class,
() -> Objects.checkFromToIndex(fromIndex, toIndex, length, null));
check.accept(IndexOutOfBoundsException.class,
() -> Objects.checkFromToIndex(fromIndex, toIndex, length));
+ check.accept(ArrayIndexOutOfBoundsException.class,
+ () -> Objects.checkFromToIndex(fromIndex, toIndex, length,
+ Objects.outOfBoundsExceptionFormatter(ArrayIndexOutOfBoundsException::new)));
+ check.accept(StringIndexOutOfBoundsException.class,
+ () -> Objects.checkFromToIndex(fromIndex, toIndex, length,
+ Objects.outOfBoundsExceptionFormatter(StringIndexOutOfBoundsException::new)));
}
@@ -186,6 +224,11 @@
@Test(dataProvider = "checkFromIndexSizeProvider")
public void testCheckFromIndexSize(int fromIndex, int size, int length, boolean withinBounds) {
+ String expectedMessage = withinBounds
+ ? null
+ : Objects.outOfBoundsExceptionFormatter(IndexOutOfBoundsException::new).
+ apply("checkFromIndexSize", List.of(fromIndex, size, length)).getMessage();
+
BiConsumer<Class<? extends RuntimeException>, IntSupplier> check = (ec, s) -> {
try {
int rIndex = s.getAsInt();
@@ -199,36 +242,54 @@
if (withinBounds)
fail(String.format(
"Range [%d, %d + %d) is within bounds of [0, %d), but was reported to be out of bounds", fromIndex, fromIndex, size, length));
+ else
+ assertEquals(e.getMessage(), expectedMessage);
}
};
check.accept(AssertingOutOfBoundsException.class,
- () -> Objects.checkFromIndexSize(fromIndex, size, length, assertingOutOfBounds(fromIndex, size)));
+ () -> Objects.checkFromIndexSize(fromIndex, size, length,
+ assertingOutOfBounds(expectedMessage, "checkFromIndexSize", fromIndex, size, length)));
check.accept(IndexOutOfBoundsException.class,
- () -> Objects.checkFromIndexSize(fromIndex, size, length, assertingOutOfBoundsReturnNull(fromIndex, size)));
+ () -> Objects.checkFromIndexSize(fromIndex, size, length,
+ assertingOutOfBoundsReturnNull("checkFromIndexSize", fromIndex, size, length)));
check.accept(IndexOutOfBoundsException.class,
() -> Objects.checkFromIndexSize(fromIndex, size, length, null));
check.accept(IndexOutOfBoundsException.class,
() -> Objects.checkFromIndexSize(fromIndex, size, length));
+ check.accept(ArrayIndexOutOfBoundsException.class,
+ () -> Objects.checkFromIndexSize(fromIndex, size, length,
+ Objects.outOfBoundsExceptionFormatter(ArrayIndexOutOfBoundsException::new)));
+ check.accept(StringIndexOutOfBoundsException.class,
+ () -> Objects.checkFromIndexSize(fromIndex, size, length,
+ Objects.outOfBoundsExceptionFormatter(StringIndexOutOfBoundsException::new)));
}
@Test
- public void checkIndexOutOfBoundsExceptionConstructors() {
- BiConsumer<Class<? extends RuntimeException>, IntSupplier> check = (ec, s) -> {
- try {
- s.getAsInt();
- fail("Runtime exception expected");
- }
- catch (RuntimeException e) {
- assertTrue(ec.isInstance(e));
- }
- };
+ public void uniqueMessagesForCheckKinds() {
+ BiFunction<String, List<Integer>, IndexOutOfBoundsException> f =
+ Objects.outOfBoundsExceptionFormatter(IndexOutOfBoundsException::new);
- check.accept(IndexOutOfBoundsException.class,
- () -> Objects.checkIndex(1, 0, IndexOutOfBoundsException::new));
- check.accept(StringIndexOutOfBoundsException.class,
- () -> Objects.checkIndex(1, 0, StringIndexOutOfBoundsException::new));
- check.accept(ArrayIndexOutOfBoundsException.class,
- () -> Objects.checkIndex(1, 0, ArrayIndexOutOfBoundsException::new));
+ List<String> messages = new ArrayList<>();
+ // Exact arguments
+ messages.add(f.apply("checkIndex", List.of(-1, 0)).getMessage());
+ messages.add(f.apply("checkFromToIndex", List.of(-1, 0, 0)).getMessage());
+ messages.add(f.apply("checkFromIndexSize", List.of(-1, 0, 0)).getMessage());
+ // Unknown check kind
+ messages.add(f.apply("checkUnknown", List.of(-1, 0, 0)).getMessage());
+ // Known check kind with more arguments
+ messages.add(f.apply("checkIndex", List.of(-1, 0, 0)).getMessage());
+ messages.add(f.apply("checkFromToIndex", List.of(-1, 0, 0, 0)).getMessage());
+ messages.add(f.apply("checkFromIndexSize", List.of(-1, 0, 0, 0)).getMessage());
+ // Known check kind with fewer arguments
+ messages.add(f.apply("checkIndex", List.of(-1)).getMessage());
+ messages.add(f.apply("checkFromToIndex", List.of(-1, 0)).getMessage());
+ messages.add(f.apply("checkFromIndexSize", List.of(-1, 0)).getMessage());
+ // Null arguments
+ messages.add(f.apply(null, null).getMessage());
+ messages.add(f.apply("checkNullArguments", null).getMessage());
+ messages.add(f.apply(null, List.of(-1)).getMessage());
+
+ assertEquals(messages.size(), messages.stream().distinct().count());
}
}
--- a/jdk/test/java/util/jar/JarFile/MultiReleaseJarAPI.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/java/util/jar/JarFile/MultiReleaseJarAPI.java Wed Jul 05 21:35:27 2017 +0200
@@ -54,6 +54,7 @@
static final int MAJOR_VERSION = Version.current().major();
String userdir = System.getProperty("user.dir",".");
+ CreateMultiReleaseTestJars creator = new CreateMultiReleaseTestJars();
File unversioned = new File(userdir, "unversioned.jar");
File multirelease = new File(userdir, "multi-release.jar");
File signedmultirelease = new File(userdir, "signed-multi-release.jar");
@@ -62,7 +63,6 @@
@BeforeClass
public void initialize() throws Exception {
- CreateMultiReleaseTestJars creator = new CreateMultiReleaseTestJars();
creator.compileEntries();
creator.buildUnversionedJar();
creator.buildMultiReleaseJar();
@@ -82,6 +82,10 @@
Assert.assertFalse(jf.isMultiRelease());
}
+ try (JarFile jf = new JarFile(unversioned, true, ZipFile.OPEN_READ, Release.RUNTIME)) {
+ Assert.assertFalse(jf.isMultiRelease());
+ }
+
try (JarFile jf = new JarFile(multirelease)) {
Assert.assertFalse(jf.isMultiRelease());
}
@@ -89,6 +93,28 @@
try (JarFile jf = new JarFile(multirelease, true, ZipFile.OPEN_READ, Release.RUNTIME)) {
Assert.assertTrue(jf.isMultiRelease());
}
+
+ testCustomMultiReleaseValue("true", true);
+ testCustomMultiReleaseValue("true\r\nOther: value", true);
+ testCustomMultiReleaseValue("true\nOther: value", true);
+ testCustomMultiReleaseValue("true\rOther: value", true);
+
+ testCustomMultiReleaseValue("false", false);
+ testCustomMultiReleaseValue(" true", false);
+ testCustomMultiReleaseValue("true ", false);
+ testCustomMultiReleaseValue("true\n ", false);
+ testCustomMultiReleaseValue("true\r ", false);
+ testCustomMultiReleaseValue("true\n true", false);
+ testCustomMultiReleaseValue("true\r\n true", false);
+ }
+
+ private void testCustomMultiReleaseValue(String value, boolean expected) throws Exception {
+ creator.buildCustomMultiReleaseJar("custom-mr.jar", value);
+ File custom = new File(userdir, "custom-mr.jar");
+ try (JarFile jf = new JarFile(custom, true, ZipFile.OPEN_READ, Release.RUNTIME)) {
+ Assert.assertEquals(jf.isMultiRelease(), expected);
+ }
+ Files.delete(custom.toPath());
}
@Test
--- a/jdk/test/javax/net/ssl/DTLS/CipherSuite.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/javax/net/ssl/DTLS/CipherSuite.java Wed Jul 05 21:35:27 2017 +0200
@@ -27,6 +27,7 @@
/*
* @test
* @bug 8043758
+ * @key intermittent
* @summary Datagram Transport Layer Security (DTLS)
* @modules java.base/sun.security.util
* @build DTLSOverDatagram
--- a/jdk/test/javax/net/ssl/Stapling/HttpsUrlConnClient.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/javax/net/ssl/Stapling/HttpsUrlConnClient.java Wed Jul 05 21:35:27 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 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
@@ -26,7 +26,7 @@
/*
* @test
- * @bug 8046321
+ * @bug 8046321 8153829
* @summary OCSP Stapling for TLS
* @library ../../../../java/security/testlibrary
* @build CertificateBuilder SimpleOCSPServer
@@ -298,12 +298,13 @@
*/
void doClientSide(ClientParameters cliParams) throws Exception {
- /*
- * Wait for server to get started.
- */
- while (!serverReady) {
+ // Wait 5 seconds for server ready
+ for (int i = 0; (i < 100 && !serverReady); i++) {
Thread.sleep(50);
}
+ if (!serverReady) {
+ throw new RuntimeException("Server not ready yet");
+ }
// Selectively enable or disable the feature
System.setProperty("jdk.tls.client.enableStatusRequestExtension",
@@ -532,7 +533,15 @@
rootOcsp.enableLog(debug);
rootOcsp.setNextUpdateInterval(3600);
rootOcsp.start();
- Thread.sleep(1000); // Give the server a second to start up
+
+ // Wait 5 seconds for server ready
+ for (int i = 0; (i < 100 && !rootOcsp.isServerReady()); i++) {
+ Thread.sleep(50);
+ }
+ if (!rootOcsp.isServerReady()) {
+ throw new RuntimeException("Server not ready yet");
+ }
+
rootOcspPort = rootOcsp.getPort();
String rootRespURI = "http://localhost:" + rootOcspPort;
log("Root OCSP Responder URI is " + rootRespURI);
@@ -577,7 +586,15 @@
intOcsp.enableLog(debug);
intOcsp.setNextUpdateInterval(3600);
intOcsp.start();
- Thread.sleep(1000);
+
+ // Wait 5 seconds for server ready
+ for (int i = 0; (i < 100 && !intOcsp.isServerReady()); i++) {
+ Thread.sleep(50);
+ }
+ if (!intOcsp.isServerReady()) {
+ throw new RuntimeException("Server not ready yet");
+ }
+
intOcspPort = intOcsp.getPort();
String intCaRespURI = "http://localhost:" + intOcspPort;
log("Intermediate CA OCSP Responder URI is " + intCaRespURI);
--- a/jdk/test/javax/net/ssl/Stapling/SSLEngineWithStapling.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/javax/net/ssl/Stapling/SSLEngineWithStapling.java Wed Jul 05 21:35:27 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 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
@@ -26,7 +26,7 @@
/*
* @test
- * @bug 8046321
+ * @bug 8046321 8153829
* @summary OCSP Stapling for TLS
* @library ../../../../java/security/testlibrary
* @build CertificateBuilder SimpleOCSPServer
@@ -487,7 +487,15 @@
rootOcsp.enableLog(logging);
rootOcsp.setNextUpdateInterval(3600);
rootOcsp.start();
- Thread.sleep(1000); // Give the server a second to start up
+
+ // Wait 5 seconds for server ready
+ for (int i = 0; (i < 100 && !rootOcsp.isServerReady()); i++) {
+ Thread.sleep(50);
+ }
+ if (!rootOcsp.isServerReady()) {
+ throw new RuntimeException("Server not ready yet");
+ }
+
rootOcspPort = rootOcsp.getPort();
String rootRespURI = "http://localhost:" + rootOcspPort;
log("Root OCSP Responder URI is " + rootRespURI);
@@ -532,7 +540,15 @@
intOcsp.enableLog(logging);
intOcsp.setNextUpdateInterval(3600);
intOcsp.start();
- Thread.sleep(1000);
+
+ // Wait 5 seconds for server ready
+ for (int i = 0; (i < 100 && !intOcsp.isServerReady()); i++) {
+ Thread.sleep(50);
+ }
+ if (!intOcsp.isServerReady()) {
+ throw new RuntimeException("Server not ready yet");
+ }
+
intOcspPort = intOcsp.getPort();
String intCaRespURI = "http://localhost:" + intOcspPort;
log("Intermediate CA OCSP Responder URI is " + intCaRespURI);
--- a/jdk/test/javax/net/ssl/Stapling/SSLSocketWithStapling.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/javax/net/ssl/Stapling/SSLSocketWithStapling.java Wed Jul 05 21:35:27 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 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
@@ -26,7 +26,7 @@
/*
* @test
- * @bug 8046321
+ * @bug 8046321 8153829
* @summary OCSP Stapling for TLS
* @library ../../../../java/security/testlibrary
* @build CertificateBuilder SimpleOCSPServer
@@ -318,6 +318,14 @@
// Start the OCSP responders up again
intOcsp.start();
rootOcsp.start();
+
+ // Wait 5 seconds for server ready
+ for (int i = 0; (i < 100 && (!intOcsp.isServerReady() || !rootOcsp.isServerReady())); i++) {
+ Thread.sleep(50);
+ }
+ if (!intOcsp.isServerReady() || !rootOcsp.isServerReady()) {
+ throw new RuntimeException("Server not ready yet");
+ }
}
/**
@@ -367,6 +375,14 @@
// Start the OCSP responders up again
intOcsp.start();
rootOcsp.start();
+
+ // Wait 5 seconds for server ready
+ for (int i = 0; (i < 100 && (!intOcsp.isServerReady() || !rootOcsp.isServerReady())); i++) {
+ Thread.sleep(50);
+ }
+ if (!intOcsp.isServerReady() || !rootOcsp.isServerReady()) {
+ throw new RuntimeException("Server not ready yet");
+ }
}
/**
@@ -394,7 +410,14 @@
rootOcsp.setDelay(3000);
rootOcsp.start();
intOcsp.start();
- Thread.sleep(1000);
+
+ // Wait 5 seconds for server ready
+ for (int i = 0; (i < 100 && (!intOcsp.isServerReady() || !rootOcsp.isServerReady())); i++) {
+ Thread.sleep(50);
+ }
+ if (!intOcsp.isServerReady() || !rootOcsp.isServerReady()) {
+ throw new RuntimeException("Server not ready yet");
+ }
System.out.println("========================================");
System.out.println("Stapling enbled in client. Server does");
@@ -442,6 +465,14 @@
rootOcsp.setDelay(0);
rootOcsp.start();
intOcsp.start();
+
+ // Wait 5 seconds for server ready
+ for (int i = 0; (i < 100 && (!intOcsp.isServerReady() || !rootOcsp.isServerReady())); i++) {
+ Thread.sleep(50);
+ }
+ if (!intOcsp.isServerReady() || !rootOcsp.isServerReady()) {
+ throw new RuntimeException("Server not ready yet");
+ }
}
/*
@@ -509,12 +540,13 @@
*/
void doClientSide(ClientParameters cliParams) throws Exception {
- /*
- * Wait for server to get started.
- */
- while (!serverReady) {
+ // Wait 5 seconds for server ready
+ for (int i = 0; (i < 100 && !serverReady); i++) {
Thread.sleep(50);
}
+ if (!serverReady) {
+ throw new RuntimeException("Server not ready yet");
+ }
// Selectively enable or disable the feature
System.setProperty("jdk.tls.client.enableStatusRequestExtension",
@@ -732,7 +764,15 @@
rootOcsp.enableLog(debug);
rootOcsp.setNextUpdateInterval(3600);
rootOcsp.start();
- Thread.sleep(1000); // Give the server a second to start up
+
+ // Wait 5 seconds for server ready
+ for (int i = 0; (i < 100 && !rootOcsp.isServerReady()); i++) {
+ Thread.sleep(50);
+ }
+ if (!rootOcsp.isServerReady()) {
+ throw new RuntimeException("Server not ready yet");
+ }
+
rootOcspPort = rootOcsp.getPort();
String rootRespURI = "http://localhost:" + rootOcspPort;
log("Root OCSP Responder URI is " + rootRespURI);
@@ -777,7 +817,15 @@
intOcsp.enableLog(debug);
intOcsp.setNextUpdateInterval(3600);
intOcsp.start();
- Thread.sleep(1000);
+
+ // Wait 5 seconds for server ready
+ for (int i = 0; (i < 100 && !intOcsp.isServerReady()); i++) {
+ Thread.sleep(50);
+ }
+ if (!intOcsp.isServerReady()) {
+ throw new RuntimeException("Server not ready yet");
+ }
+
intOcspPort = intOcsp.getPort();
String intCaRespURI = "http://localhost:" + intOcspPort;
log("Intermediate CA OCSP Responder URI is " + intCaRespURI);
--- a/jdk/test/javax/net/ssl/Stapling/StapleEnableProps.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/javax/net/ssl/Stapling/StapleEnableProps.java Wed Jul 05 21:35:27 2017 +0200
@@ -26,7 +26,7 @@
/*
* @test
- * @bug 8145854
+ * @bug 8145854 8153829
* @summary SSLContextImpl.statusResponseManager should be generated if required
* @library ../../../../java/security/testlibrary
* @build CertificateBuilder SimpleOCSPServer
@@ -588,7 +588,15 @@
rootOcsp.enableLog(logging);
rootOcsp.setNextUpdateInterval(3600);
rootOcsp.start();
- Thread.sleep(1000); // Give the server a second to start up
+
+ // Wait 5 seconds for server ready
+ for (int i = 0; (i < 100 && !rootOcsp.isServerReady()); i++) {
+ Thread.sleep(50);
+ }
+ if (!rootOcsp.isServerReady()) {
+ throw new RuntimeException("Server not ready yet");
+ }
+
rootOcspPort = rootOcsp.getPort();
String rootRespURI = "http://localhost:" + rootOcspPort;
log("Root OCSP Responder URI is " + rootRespURI);
@@ -633,7 +641,15 @@
intOcsp.enableLog(logging);
intOcsp.setNextUpdateInterval(3600);
intOcsp.start();
- Thread.sleep(1000);
+
+ // Wait 5 seconds for server ready
+ for (int i = 0; (i < 100 && !intOcsp.isServerReady()); i++) {
+ Thread.sleep(50);
+ }
+ if (!intOcsp.isServerReady()) {
+ throw new RuntimeException("Server not ready yet");
+ }
+
intOcspPort = intOcsp.getPort();
String intCaRespURI = "http://localhost:" + intOcspPort;
log("Intermediate CA OCSP Responder URI is " + intCaRespURI);
--- a/jdk/test/jdk/internal/jrtfs/PathOps.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/jdk/internal/jrtfs/PathOps.java Wed Jul 05 21:35:27 2017 +0200
@@ -43,15 +43,15 @@
private Path path;
private Exception exc;
- private PathOps(String s) {
+ private PathOps(String first, String... more) {
out.println();
- input = s;
+ input = first;
try {
- path = fs.getPath(s);
- out.format("%s -> %s", s, path);
+ path = fs.getPath(first, more);
+ out.format("%s -> %s", first, path);
} catch (Exception x) {
exc = x;
- out.format("%s -> %s", s, x);
+ out.format("%s -> %s", first, x);
}
out.println();
}
@@ -175,6 +175,13 @@
return this;
}
+ PathOps resolveSibling(String other, String expected) {
+ out.format("test resolveSibling %s\n", other);
+ checkPath();
+ check(path.resolveSibling(other), expected);
+ return this;
+ }
+
PathOps relativize(String other, String expected) {
out.format("test relativize %s\n", other);
checkPath();
@@ -220,6 +227,10 @@
return new PathOps(s);
}
+ static PathOps test(String first, String... more) {
+ return new PathOps(first, more);
+ }
+
// -- PathOpss --
static void header(String s) {
@@ -231,6 +242,26 @@
static void doPathOpTests() {
header("Path operations");
+ // construction
+ test("/")
+ .string("/");
+ test("/", "")
+ .string("/");
+ test("/", "foo")
+ .string("/foo");
+ test("/", "/foo")
+ .string("/foo");
+ test("/", "foo/")
+ .string("/foo");
+ test("foo", "bar", "gus")
+ .string("foo/bar/gus");
+ test("")
+ .string("");
+ test("", "/")
+ .string("/");
+ test("", "foo", "", "bar", "", "/gus")
+ .string("foo/bar/gus");
+
// all components
test("/a/b/c")
.root("/")
@@ -254,6 +285,10 @@
.root(null)
.parent(null)
.name("foo");
+ test("")
+ .root(null)
+ .parent(null)
+ .name("");
// startsWith
test("")
@@ -261,6 +296,7 @@
.notStarts("/");
test("/")
.starts("/")
+ .notStarts("")
.notStarts("/foo");
test("/foo")
.starts("/")
@@ -278,6 +314,7 @@
.notStarts("");
test("foo")
.starts("foo")
+ .notStarts("")
.notStarts("f");
test("foo/bar")
.starts("foo")
@@ -293,12 +330,14 @@
.notEnds("/");
test("/")
.ends("/")
+ .notEnds("")
.notEnds("foo")
.notEnds("/foo");
test("/foo")
.ends("foo")
.ends("/foo")
- .notEnds("/");
+ .notEnds("/")
+ .notEnds("fool");
test("/foo/bar")
.ends("bar")
.ends("foo/bar")
@@ -312,13 +351,31 @@
.ends("/foo/bar")
.notEnds("/bar");
test("foo")
- .ends("foo");
+ .ends("foo")
+ .notEnds("")
+ .notEnds("oo")
+ .notEnds("oola");
test("foo/bar")
.ends("bar")
.ends("bar/")
.ends("foo/bar/")
- .ends("foo/bar");
-
+ .ends("foo/bar")
+ .notEnds("r")
+ .notEnds("barmaid")
+ .notEnds("/bar")
+ .notEnds("ar")
+ .notEnds("barack")
+ .notEnds("/bar")
+ .notEnds("o/bar");
+ test("foo/bar/gus")
+ .ends("gus")
+ .ends("bar/gus")
+ .ends("foo/bar/gus")
+ .notEnds("g")
+ .notEnds("/gus")
+ .notEnds("r/gus")
+ .notEnds("barack/gus")
+ .notEnds("bar/gust");
// elements
test("a/b/c")
@@ -339,16 +396,54 @@
// resolve
test("/tmp")
.resolve("foo", "/tmp/foo")
- .resolve("/foo", "/foo");
+ .resolve("/foo", "/foo")
+ .resolve("", "/tmp");
test("tmp")
.resolve("foo", "tmp/foo")
+ .resolve("/foo", "/foo")
+ .resolve("", "tmp");
+ test("")
+ .resolve("", "")
+ .resolve("foo", "foo")
.resolve("/foo", "/foo");
+ // resolveSibling
+ test("foo")
+ .resolveSibling("bar", "bar")
+ .resolveSibling("/bar", "/bar")
+ .resolveSibling("", "");
+ test("foo/bar")
+ .resolveSibling("gus", "foo/gus")
+ .resolveSibling("/gus", "/gus")
+ .resolveSibling("", "foo");
+ test("/foo")
+ .resolveSibling("gus", "/gus")
+ .resolveSibling("/gus", "/gus")
+ .resolveSibling("", "/");
+ test("/foo/bar")
+ .resolveSibling("gus", "/foo/gus")
+ .resolveSibling("/gus", "/gus")
+ .resolveSibling("", "/foo");
+ test("")
+ .resolveSibling("foo", "foo")
+ .resolveSibling("/foo", "/foo")
+ .resolve("", "");
+
// relativize
test("/a/b/c")
.relativize("/a/b/c", "")
.relativize("/a/b/c/d/e", "d/e")
- .relativize("/a/x", "../../x");
+ .relativize("/a/x", "../../x")
+ .relativize("/x", "../../../x");
+ test("a/b/c")
+ .relativize("a/b/c/d", "d")
+ .relativize("a/x", "../../x")
+ .relativize("x", "../../../x")
+ .relativize("", "../../..");
+ test("")
+ .relativize("a", "a")
+ .relativize("a/b/c", "a/b/c")
+ .relativize("", "");
// normalize
test("/")
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/jdk/internal/reflect/AnonymousNewInstance/ManyNewInstanceAnonTest.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * 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 7194897
+ * @summary JSR 292: Cannot create more than 16 instances of an anonymous class
+ * @modules java.base/jdk.internal.misc
+ * java.management
+ * @library /lib/testlibrary
+ * @author Robert Field
+ * @compile -XDignore.symbol.file ManyNewInstanceAnonTest.java
+ * @build jdk.testlibrary.*
+ * @run main ClassFileInstaller ManyNewInstanceAnonTest
+ * @run main/othervm -Xbootclasspath/a:. -Xverify:all ManyNewInstanceAnonTest
+ * @run main/othervm -Xbootclasspath/a:. -Xverify:all -Dsun.reflection.noInflation=true ManyNewInstanceAnonTest
+ */
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import jdk.internal.misc.Unsafe;
+
+public class ManyNewInstanceAnonTest {
+
+ static final int REPS = 20;
+ static final Class<?> klass = ManyNewInstanceAnonTest.class;
+
+ public static void main(String[] args) throws Exception {
+ Class<?> c = Unsafe.getUnsafe().defineAnonymousClass(klass, readClassFile(), null);
+ for (int i = 0; i < REPS; ++i) {
+ System.out.printf("%d: %s\n", i, c.newInstance());
+ }
+ System.out.println("Passed.");
+ }
+
+ private static byte[] readClassFile() throws Exception {
+ try (InputStream in = klass.getResourceAsStream(klass.getSimpleName() + ".class");
+ ByteArrayOutputStream out = new ByteArrayOutputStream())
+ {
+ int b;
+ while ((b = in.read()) != -1) {
+ out.write(b);
+ }
+ return out.toByteArray();
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/jdk/internal/reflect/CallerSensitive/CallerSensitiveFinder.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,234 @@
+/*
+ * Copyright (c) 2013, 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 com.sun.tools.classfile.*;
+import com.sun.tools.jdeps.ClassFileReader;
+import static com.sun.tools.classfile.ConstantPool.*;
+import java.io.File;
+import java.io.IOException;
+import java.io.UncheckedIOException;
+import java.net.URI;
+import java.nio.file.FileSystem;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.FutureTask;
+import java.util.stream.Stream;
+
+/*
+ * @test
+ * @bug 8010117
+ * @summary Verify if CallerSensitive methods are annotated with
+ * CallerSensitive annotation
+ * @modules jdk.jdeps/com.sun.tools.classfile jdk.jdeps/com.sun.tools.jdeps
+ * @build CallerSensitiveFinder
+ * @run main/othervm/timeout=900 CallerSensitiveFinder
+ */
+public class CallerSensitiveFinder {
+ private static int numThreads = 3;
+ private static boolean verbose = false;
+ private final ExecutorService pool;
+
+ public static void main(String[] args) throws Exception {
+ Stream<Path> classes = null;
+ String testclasses = System.getProperty("test.classes", ".");
+ int i = 0;
+ while (i < args.length) {
+ String arg = args[i++];
+ if (arg.equals("-v")) {
+ verbose = true;
+ } else {
+ Path p = Paths.get(testclasses, arg);
+ if (!p.toFile().exists()) {
+ throw new IllegalArgumentException(arg + " does not exist");
+ }
+ classes = Stream.of(p);
+ }
+ }
+
+ if (classes == null) {
+ classes = getPlatformClasses();
+ }
+
+ CallerSensitiveFinder csfinder = new CallerSensitiveFinder();
+ List<String> errors = csfinder.run(classes);
+
+ if (!errors.isEmpty()) {
+ throw new RuntimeException(errors.size() +
+ " caller-sensitive methods are missing @CallerSensitive annotation");
+ }
+ }
+
+ private final List<String> csMethodsMissingAnnotation =
+ Collections.synchronizedList(new ArrayList<>());
+ private final ReferenceFinder finder;
+ public CallerSensitiveFinder() {
+ this.finder = new ReferenceFinder(getFilter(), getVisitor());
+ pool = Executors.newFixedThreadPool(numThreads);
+
+ }
+
+ private ReferenceFinder.Filter getFilter() {
+ final String classname = "jdk/internal/reflect/Reflection";
+ final String method = "getCallerClass";
+ return new ReferenceFinder.Filter() {
+ public boolean accept(ConstantPool cpool, CPRefInfo cpref) {
+ try {
+ CONSTANT_NameAndType_info nat = cpref.getNameAndTypeInfo();
+ return cpref.getClassName().equals(classname) && nat.getName().equals(method);
+ } catch (ConstantPoolException ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+ };
+ }
+
+ private ReferenceFinder.Visitor getVisitor() {
+ return new ReferenceFinder.Visitor() {
+ public void visit(ClassFile cf, Method m, List<CPRefInfo> refs) {
+ try {
+ // ignore jdk.unsupported/sun.reflect.Reflection.getCallerClass
+ // which is a "special" delegate to the internal getCallerClass
+ if (cf.getName().equals("sun/reflect/Reflection") &&
+ m.getName(cf.constant_pool).equals("getCallerClass"))
+ return;
+
+ String name = String.format("%s#%s %s", cf.getName(),
+ m.getName(cf.constant_pool),
+ m.descriptor.getValue(cf.constant_pool));
+ if (!CallerSensitiveFinder.isCallerSensitive(m, cf.constant_pool)) {
+ csMethodsMissingAnnotation.add(name);
+ System.err.println("Missing @CallerSensitive: " + name);
+ } else {
+ if (verbose) {
+ System.out.format("@CS %s%n", name);
+ }
+ }
+ } catch (ConstantPoolException ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+ };
+ }
+
+ public List<String> run(Stream<Path> classes)throws IOException, InterruptedException,
+ ExecutionException, ConstantPoolException
+ {
+ classes.forEach(this::processPath);
+ waitForCompletion();
+ pool.shutdown();
+ return csMethodsMissingAnnotation;
+ }
+
+ void processPath(Path path) {
+ try {
+ ClassFileReader reader = ClassFileReader.newInstance(path);
+ for (ClassFile cf : reader.getClassFiles()) {
+ String classFileName = cf.getName();
+ // for each ClassFile
+ // parse constant pool to find matching method refs
+ // parse each method (caller)
+ // - visit and find method references matching the given method name
+ pool.submit(getTask(cf));
+ }
+ } catch (IOException x) {
+ throw new UncheckedIOException(x);
+ } catch (ConstantPoolException x) {
+ throw new RuntimeException(x);
+ }
+ }
+
+ private static final String CALLER_SENSITIVE_ANNOTATION = "Ljdk/internal/reflect/CallerSensitive;";
+ private static boolean isCallerSensitive(Method m, ConstantPool cp)
+ throws ConstantPoolException
+ {
+ RuntimeAnnotations_attribute attr =
+ (RuntimeAnnotations_attribute)m.attributes.get(Attribute.RuntimeVisibleAnnotations);
+ int index = 0;
+ if (attr != null) {
+ for (int i = 0; i < attr.annotations.length; i++) {
+ Annotation ann = attr.annotations[i];
+ String annType = cp.getUTF8Value(ann.type_index);
+ if (CALLER_SENSITIVE_ANNOTATION.equals(annType)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ private final List<FutureTask<Void>> tasks = new ArrayList<FutureTask<Void>>();
+ private FutureTask<Void> getTask(final ClassFile cf) {
+ FutureTask<Void> task = new FutureTask<Void>(new Callable<Void>() {
+ public Void call() throws Exception {
+ finder.parse(cf);
+ return null;
+ }
+ });
+ tasks.add(task);
+ return task;
+ }
+
+ private void waitForCompletion() throws InterruptedException, ExecutionException {
+ for (FutureTask<Void> t : tasks) {
+ t.get();
+ }
+ if (tasks.isEmpty()) {
+ throw new RuntimeException("No classes found, or specified.");
+ }
+ System.out.println("Parsed " + tasks.size() + " classfiles");
+ }
+
+ static Stream<Path> getPlatformClasses() throws IOException {
+ Path home = Paths.get(System.getProperty("java.home"));
+
+ // Either an exploded build or an image.
+ File classes = home.resolve("modules").toFile();
+ if (classes.isDirectory()) {
+ return Stream.of(classes.toPath());
+ } else {
+ return jrtPaths();
+ }
+ }
+
+ static Stream<Path> jrtPaths() {
+ FileSystem jrt = FileSystems.getFileSystem(URI.create("jrt:/"));
+ Path root = jrt.getPath("/");
+
+ try {
+ return Files.walk(root)
+ .filter(p -> p.getNameCount() > 1)
+ .filter(p -> p.toString().endsWith(".class"));
+ } catch (IOException x) {
+ throw new UncheckedIOException(x);
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/jdk/internal/reflect/CallerSensitive/MissingCallerSensitive.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2013, 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 8010117
+ * @summary Test CallerSensitiveFinder to find missing annotation
+ * @modules java.base/jdk.internal.reflect
+ * jdk.jdeps/com.sun.tools.classfile
+ * jdk.jdeps/com.sun.tools.jdeps
+ * @compile -XDignore.symbol.file MissingCallerSensitive.java
+ * @build CallerSensitiveFinder
+ * @run main MissingCallerSensitive
+ */
+
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.*;
+import java.util.stream.Stream;
+import jdk.internal.reflect.CallerSensitive;
+import jdk.internal.reflect.Reflection;
+
+public class MissingCallerSensitive {
+ public static void main(String[] args) throws Exception {
+ String testclasses = System.getProperty("test.classes", ".");
+
+ Stream<Path> classes = Stream.of(Paths.get(testclasses, "MissingCallerSensitive.class"));
+
+ CallerSensitiveFinder csfinder = new CallerSensitiveFinder();
+ List<String> errors = csfinder.run(classes);
+ if (errors.size() != 1) {
+ throw new RuntimeException("Unexpected number of methods found: " + errors.size());
+ }
+ String m = errors.get(0);
+ if (!m.startsWith("MissingCallerSensitive#missingCallerSensitiveAnnotation")) {
+ throw new RuntimeException("Unexpected method missing annotation: " + m);
+ }
+ }
+
+ @CallerSensitive
+ public ClassLoader getCallerLoader() {
+ Class<?> c = Reflection.getCallerClass();
+ return c.getClassLoader();
+ }
+
+ public ClassLoader missingCallerSensitiveAnnotation() {
+ Class<?> c = Reflection.getCallerClass();
+ return c.getClassLoader();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/jdk/internal/reflect/Reflection/GetCallerClass.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2013, 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 boot;
+
+public class GetCallerClass {
+ @jdk.internal.reflect.CallerSensitive
+ public ClassLoader getCallerLoader() {
+ Class<?> c = jdk.internal.reflect.Reflection.getCallerClass();
+ return c.getClassLoader();
+ }
+
+ public ClassLoader missingCallerSensitiveAnnotation() {
+ Class<?> c = jdk.internal.reflect.Reflection.getCallerClass();
+ return c.getClassLoader();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/jdk/internal/reflect/Reflection/GetCallerClassTest.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2013, 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 boot.GetCallerClass;
+import java.lang.reflect.*;
+import jdk.internal.reflect.CallerSensitive;
+import jdk.internal.reflect.Reflection;
+
+public class GetCallerClassTest {
+ private final GetCallerClass gcc; // boot.GetCallerClass is in bootclasspath
+ GetCallerClassTest() {
+ this.gcc = new GetCallerClass();
+ }
+
+ public static void main(String[] args) throws Exception {
+ GetCallerClassTest gcct = new GetCallerClassTest();
+ // ensure methods are annotated with @CallerSensitive
+ ensureAnnotationPresent(boot.GetCallerClass.class, "getCallerLoader", true);
+ ensureAnnotationPresent(GetCallerClassTest.class, "testNonSystemMethod", false);
+ // call Reflection.getCallerClass from bootclasspath with and without @CS
+ gcct.testCallerSensitiveMethods();
+ // call Reflection.getCallerClass from classpath with @CS
+ gcct.testNonSystemMethod();
+ }
+
+ private static void ensureAnnotationPresent(Class<?> c, String name, boolean cs)
+ throws NoSuchMethodException
+ {
+ Method m = c.getDeclaredMethod(name);
+ if (!m.isAnnotationPresent(CallerSensitive.class)) {
+ throw new RuntimeException("@CallerSensitive not present in method " + m);
+ }
+ if (Reflection.isCallerSensitive(m) != cs) {
+ throw new RuntimeException("Unexpected: isCallerSensitive returns " +
+ Reflection.isCallerSensitive(m));
+ }
+ }
+
+ private void testCallerSensitiveMethods() {
+ try {
+ ClassLoader cl = gcc.getCallerLoader();
+ if (cl != GetCallerClassTest.class.getClassLoader()) {
+ throw new RuntimeException("mismatched class loader");
+ }
+ gcc.missingCallerSensitiveAnnotation();
+ throw new RuntimeException("getCallerLoader not marked with @CallerSensitive");
+ } catch (InternalError e) {
+ StackTraceElement[] stackTrace = e.getStackTrace();
+ checkStackTrace(stackTrace, e);
+ if (!stackTrace[1].getClassName().equals(GetCallerClass.class.getName()) ||
+ !stackTrace[1].getMethodName().equals("missingCallerSensitiveAnnotation")) {
+ throw new RuntimeException("Unexpected error: " + e.getMessage(), e);
+ }
+ if (!stackTrace[2].getClassName().equals(GetCallerClassTest.class.getName()) ||
+ !stackTrace[2].getMethodName().equals("testCallerSensitiveMethods")) {
+ throw new RuntimeException("Unexpected error: " + e.getMessage(), e);
+ }
+ System.out.println("Expected error: " + e.getMessage());
+ }
+ }
+
+ @CallerSensitive
+ private void testNonSystemMethod() {
+ try {
+ Class<?> c = Reflection.getCallerClass();
+ throw new RuntimeException("@CallerSensitive testNonSystemMethods not supported");
+ } catch (InternalError e) {
+ StackTraceElement[] stackTrace = e.getStackTrace();
+ checkStackTrace(stackTrace, e);
+ if (!stackTrace[1].getClassName().equals(GetCallerClassTest.class.getName()) ||
+ !stackTrace[1].getMethodName().equals("testNonSystemMethod")) {
+ throw new RuntimeException("Unexpected error: " + e.getMessage(), e);
+ }
+ if (!stackTrace[2].getClassName().equals(GetCallerClassTest.class.getName()) ||
+ !stackTrace[2].getMethodName().equals("main")) {
+ throw new RuntimeException("Unexpected error: " + e.getMessage(), e);
+ }
+ System.out.println("Expected error: " + e.getMessage());
+ }
+ }
+
+ private void checkStackTrace(StackTraceElement[] stackTrace, Error e) {
+ if (stackTrace.length < 3) {
+ throw new RuntimeException("Unexpected error: " + e.getMessage(), e);
+ }
+
+ if (!stackTrace[0].getClassName().equals("jdk.internal.reflect.Reflection") ||
+ !stackTrace[0].getMethodName().equals("getCallerClass")) {
+ throw new RuntimeException("Unexpected error: " + e.getMessage(), e);
+ }
+
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/jdk/internal/reflect/Reflection/GetCallerClassTest.sh Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,70 @@
+#
+# Copyright (c) 2013, 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 8010117
+# @summary Test if the VM enforces Reflection.getCallerClass
+# be called by methods annotated with CallerSensitive
+#
+# @run shell GetCallerClassTest.sh
+
+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
+
+BCP=${TESTCLASSES}/bcp
+rm -rf ${BCP}
+mkdir ${BCP}
+
+EXTRAOPTS="-XaddExports:java.base/jdk.internal.reflect=ALL-UNNAMED"
+
+# Compile GetCallerClass in bootclasspath
+${COMPILEJAVA}/bin/javac ${TESTTOOLVMOPTS} ${EXTRAOPTS} \
+ -XDignore.symbol.file \
+ -d ${BCP} ${TESTSRC}/GetCallerClass.java || exit 1
+
+${COMPILEJAVA}/bin/javac ${TESTTOOLVMOPTS} ${EXTRAOPTS} \
+ -XDignore.symbol.file -cp ${BCP} \
+ -d ${TESTCLASSES} ${TESTSRC}/GetCallerClassTest.java || exit 2
+
+${TESTJAVA}/bin/java ${TESTVMOPTS} ${EXTRAOPTS} -Xbootclasspath/a:${BCP} \
+ -cp ${TESTCLASSES} GetCallerClassTest || exit 3
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/jdk/internal/reflect/Reflection/GetCallerClassWithDepth.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2013, 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 8025799
+ * @summary Reflection.getCallerClass(int)
+ * @modules java.base/jdk.internal.reflect
+ * @run main GetCallerClassWithDepth
+ */
+
+import jdk.internal.reflect.Reflection;
+
+public class GetCallerClassWithDepth {
+ public static void main(String[] args) throws Exception {
+ Class<?> c = Test.test();
+ assertEquals(c, GetCallerClassWithDepth.class);
+ Class<?> caller = Test.caller();
+ assertEquals(caller, GetCallerClassWithDepth.class);
+ Test.selfTest();
+
+ try {
+ Reflection.getCallerClass(-1);
+ throw new RuntimeException("getCallerClass(-1) should fail");
+ } catch (Error e) {
+ System.out.println("Expected: " + e.getMessage());
+ }
+ }
+
+ public Class<?> getCallerClass() {
+ // 0: Reflection 1: getCallerClass 2: Test.test 3: main
+ return Reflection.getCallerClass(3);
+ }
+
+ static void assertEquals(Class<?> c, Class<?> expected) {
+ if (c != expected) {
+ throw new RuntimeException("Incorrect caller: " + c);
+ }
+ }
+
+ static class Test {
+ // Returns the caller of this method
+ public static Class<?> test() {
+ return new GetCallerClassWithDepth().getCallerClass();
+ }
+
+ // Returns the caller of this method
+ public static Class<?> caller() {
+ // 0: Reflection 1: Test.caller 2: main
+ return Reflection.getCallerClass(2);
+ }
+ public static void selfTest() {
+ // 0: Reflection 1: Test.selfTest
+ Class<?> c = Reflection.getCallerClass(1);
+ assertEquals(c, Test.class);
+ Inner1.deep();
+ }
+
+ static class Inner1 {
+ static void deep() {
+ deeper();
+ }
+ static void deeper() {
+ Inner2.deepest();
+ }
+ static class Inner2 {
+ static void deepest() {
+ // 0: Reflection 1: deepest 2: deeper 3: deep 4: Test.selfTest
+ Class<?> c = Reflection.getCallerClass(4);
+ assertEquals(c, Test.class);
+ }
+ }
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/jdk/internal/reflect/constantPool/ConstantPoolTest.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,171 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * 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 8141615
+ * @summary Tests new public methods at ConstantPool
+ * @modules java.base/jdk.internal.misc
+ * java.base/jdk.internal.reflect
+ * @library /lib/testlibrary
+ * @compile ConstantPoolTestDummy.jasm
+ * @run main jdk.internal.reflect.constantPool.ConstantPoolTest
+ */
+
+package jdk.internal.reflect.constantPool;
+
+import java.util.HashMap;
+import java.util.Map;
+import jdk.internal.misc.SharedSecrets;
+import jdk.testlibrary.Asserts;
+import jdk.internal.reflect.ConstantPool;
+
+public class ConstantPoolTest {
+
+ private static final Class<?> TEST_CLASS = ConstantPoolTestDummy.class;
+ private static final ConstantPool CP = SharedSecrets.getJavaLangAccess()
+ .getConstantPool(TEST_CLASS);
+
+ public static void main(String[] s) {
+ for (TestCase testCase : TestCase.values()) {
+ testCase.test();
+ }
+ }
+
+ public static enum TestCase {
+ GET_TAG_AT {
+ {
+ referenceMap.put(1, ConstantPool.Tag.METHODREF);
+ referenceMap.put(2, ConstantPool.Tag.CLASS);
+ referenceMap.put(4, ConstantPool.Tag.UTF8);
+ referenceMap.put(10, ConstantPool.Tag.NAMEANDTYPE);
+ referenceMap.put(13, ConstantPool.Tag.LONG);
+ referenceMap.put(15, ConstantPool.Tag.INTEGER);
+ referenceMap.put(16, ConstantPool.Tag.INTERFACEMETHODREF);
+ referenceMap.put(21, ConstantPool.Tag.DOUBLE);
+ referenceMap.put(23, ConstantPool.Tag.STRING);
+ referenceMap.put(25, ConstantPool.Tag.INVOKEDYNAMIC);
+ referenceMap.put(29, ConstantPool.Tag.METHODHANDLE);
+ referenceMap.put(30, ConstantPool.Tag.METHODTYPE);
+ referenceMap.put(48, ConstantPool.Tag.FIELDREF);
+ referenceMap.put(52, ConstantPool.Tag.FLOAT);
+ }
+ @Override
+ void testIndex(int cpi, Object reference) {
+ ConstantPool.Tag tagToVerify = CP.getTagAt(cpi);
+ ConstantPool.Tag tagToRefer = (ConstantPool.Tag) reference;
+ String msg = String.format("Method getTagAt works not as expected"
+ + "at CP entry #%d: got CP tag %s, but should be %s",
+ cpi, tagToVerify.name(), tagToRefer.name());
+ Asserts.assertEquals(tagToVerify, tagToRefer, msg);
+ }
+ },
+ GET_CLASS_REF_INDEX_AT {
+ {
+ referenceMap.put(1, 3);
+ referenceMap.put(16, 17);
+ referenceMap.put(32, 35);
+ referenceMap.put(34, 3);
+ referenceMap.put(48, 2);
+ }
+ @Override
+ void testIndex(int cpi, Object reference) {
+ int indexToVerify = CP.getClassRefIndexAt(cpi);
+ int indexToRefer = (int) reference;
+ String msg = String.format("Method getClassRefIndexAt works not"
+ + " as expected at CP entry #%d:"
+ + " got index %d, but should be %d",
+ cpi, indexToVerify, indexToRefer);
+ Asserts.assertEquals(indexToVerify, indexToRefer, msg);
+ }
+ },
+ GET_NAME_AND_TYPE_REF_INDEX_AT {
+ {
+ referenceMap.put(1, 10);
+ referenceMap.put(16, 18);
+ referenceMap.put(25, 26);
+ referenceMap.put(32, 36);
+ referenceMap.put(34, 37);
+ referenceMap.put(48, 49);
+ }
+ @Override
+ void testIndex(int cpi, Object reference) {
+ int indexToRefer = (int) reference;
+ int indexToVerify = CP.getNameAndTypeRefIndexAt(cpi);
+ String msg = String.format("Method getNameAndTypeRefIndexAt works"
+ + " not as expected at CP entry #%d:"
+ + " got index %d, but should be %d",
+ cpi, indexToVerify, indexToRefer);
+ Asserts.assertEquals(indexToVerify, indexToRefer, msg);
+ }
+ },
+ GET_NAME_AND_TYPE_REF_INFO_AT {
+ {
+ referenceMap.put(10, new String[]{"<init>", "()V"});
+ referenceMap.put(18, new String[]{"run", "()V"});
+ referenceMap.put(26, new String[]{"accept", "()Ljava/util/function/Consumer;"});
+ referenceMap.put(36, new String[]{"metafactory",
+ "(Ljava/lang/invoke/MethodHandles$Lookup;"
+ + "Ljava/lang/String;Ljava/lang/invoke/MethodType;"
+ + "Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;"
+ + "Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;"});
+ referenceMap.put(37, new String[]{"toString", "()Ljava/lang/String;"});
+ referenceMap.put(49, new String[]{"myField", "I"});
+ }
+ @Override
+ void testIndex(int cpi, Object reference) {
+ String[] natInfo = CP.getNameAndTypeRefInfoAt(cpi);
+ String msg = String.format("Method getNameAndTypeRefInfoAt"
+ + " works not as expected at CP entry #%d:"
+ + " returned value should not be null", cpi);
+ Asserts.assertNotNull(natInfo, msg);
+ String[] castedReference = (String[]) reference;
+ int natInfoLength = natInfo.length;
+ msg = String.format("Method getNameAndTypeRefInfoAt"
+ + " works not as expected at CP entry #%d:"
+ + " length of the returned string array is %d, but should be 2",
+ cpi, natInfoLength);
+ Asserts.assertEquals(natInfoLength, 2, msg);
+ String[] nameOrType = new String[]{"name", "type"};
+ for (int i = 0; i < 2; i++) {
+ String infoToVerify = natInfo[i];
+ String infoToRefer = castedReference[i];
+ msg = String.format("Method getNameAndTypeRefInfoAt"
+ + " works not as expected at CP entry #%d:"
+ + " got %s info %s, but should be %s",
+ cpi, nameOrType[i], infoToVerify, infoToRefer);
+ Asserts.assertEquals(infoToVerify, infoToRefer, msg);
+ }
+ }
+ };
+
+ protected final Map<Integer, Object> referenceMap;
+ TestCase() {
+ this.referenceMap = new HashMap<>();
+ }
+ abstract void testIndex(int cpi, Object reference);
+ public void test() {
+ referenceMap.forEach(this::testIndex);
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/jdk/internal/reflect/constantPool/ConstantPoolTestDummy.jasm Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * 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/internal/reflect/constantPool;
+
+super public #2; //class ConstantPoolTestDummy
+ version 52:0
+{
+
+// Actually, only first 13 constant pool entries are actually used by the class
+// and its methods. All the rest are added just for the testing of getTagAt method
+// and getNameAndTypeRefIndexAt method.
+
+const #1 = Method #3.#10; // java/lang/Object."<init>":"()V"
+const #2 = class #11; // ConstantPoolTestDummy
+const #3 = class #12; // java/lang/Object
+const #4 = Asciz "<init>";
+const #5 = Asciz "()V";
+const #6 = Asciz "Code";
+const #7 = Asciz "LineNumberTable";
+const #8 = Asciz "SourceFile";
+const #9 = Asciz "ConstantPoolTestDummy.java";
+const #10 = NameAndType #4:#5; // "<init>":"()V"
+const #11 = Asciz "jdk/internal/reflect/constantPool/ConstantPoolTestDummy";
+const #12 = Asciz "java/lang/Object";
+const #13 = long 6l;
+const #15 = int 1;
+const #16 = InterfaceMethod #17.#18; // java/lang/Runnable.run:"()V"
+const #17 = class #19; // java/lang/Runnable
+const #18 = NameAndType #20:#5; // run:"()V"
+const #19 = Asciz "java/lang/Runnable";
+const #20 = Asciz "run";
+const #21 = double 1.45d;
+const #23 = String #24; // "Hello"
+const #24 = Asciz "Hello";
+const #25 = InvokeDynamic 0:#26; // REF_invokeStatic:java/lang/invoke/LambdaMetafactory.metafactory:"(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;":accept:"()Ljava/util/function/Consumer;" MethodType "(Ljava/lang/Object;)V", MethodHandle REF_invokeVirtual:java/lang/Object.toString:"()Ljava/lang/String;", MethodType "(Ljava/lang/Object;)V"
+const #26 = NameAndType #27:#28; // accept:"()Ljava/util/function/Consumer;"
+const #27 = Asciz "accept";
+const #28 = Asciz "()Ljava/util/function/Consumer;";
+const #29 = MethodHandle 6:#32; // REF_invokeStatic:java/lang/invoke/LambdaMetafactory.metafactory:"(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;"
+const #30 = MethodType #33; // "(Ljava/lang/Object;)V"
+const #31 = MethodHandle 5:#34; // REF_invokeVirtual:java/lang/Object.toString:"()Ljava/lang/String;"
+const #32 = Method #35.#36; // java/lang/invoke/LambdaMetafactory.metafactory:"(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;"
+const #33 = Asciz "(Ljava/lang/Object;)V";
+const #34 = Method #3.#37; // java/lang/Object.toString:"()Ljava/lang/String;"
+const #35 = class #38; // java/lang/invoke/LambdaMetafactory
+const #36 = NameAndType #39:#40; // metafactory:"(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;"
+const #37 = NameAndType #41:#42; // toString:"()Ljava/lang/String;"
+const #38 = Asciz "java/lang/invoke/LambdaMetafactory";
+const #39 = Asciz "metafactory";
+const #40 = Asciz "(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;";
+const #41 = Asciz "toString";
+const #42 = Asciz "()Ljava/lang/String;";
+const #43 = class #46; // java/lang/invoke/MethodHandles$Lookup
+const #44 = Asciz "Lookup";
+const #45 = class #47; // java/lang/invoke/MethodHandles
+const #46 = Asciz "java/lang/invoke/MethodHandles$Lookup";
+const #47 = Asciz "java/lang/invoke/MethodHandles";
+const #48 = Field #2.#49; // jdk/internal/reflect/constantPool/ConstantPoolTestDummy.myField:"I"
+const #49 = NameAndType #50:#51; // myField:"I"
+const #50 = Asciz "myField";
+const #51 = Asciz "I";
+const #52 = float 1.34f;
+
+public Method #4:#5 // "<init>":"()V"
+
+ stack 1 locals 1
+{
+3 0: aload_0;
+ 1: invokespecial #1; // Method java/lang/Object."<init>":"()V";
+ 4: return;
+}
+
+public static final InnerClass #44= #43 of #45; //Lookup=class java/lang/invoke/MethodHandles$Lookup of class java/lang/invoke/MethodHandles
+
+BootstrapMethod #29 #30 #31 #30;
+
+} // end Class ConstantPoolTestDummy
--- a/jdk/test/lib/testlibrary/java/util/jar/CreateMultiReleaseTestJars.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/lib/testlibrary/java/util/jar/CreateMultiReleaseTestJars.java Wed Jul 05 21:35:27 2017 +0200
@@ -88,8 +88,12 @@
}
public void buildMultiReleaseJar() throws IOException {
- JarBuilder jb = new JarBuilder("multi-release.jar");
- jb.addAttribute("Multi-Release", "true");
+ buildCustomMultiReleaseJar("multi-release.jar", "true");
+ }
+
+ public void buildCustomMultiReleaseJar(String filename, String multiReleaseValue) throws IOException {
+ JarBuilder jb = new JarBuilder(filename);
+ jb.addAttribute("Multi-Release", multiReleaseValue);
jb.addEntry("README", readme8.getBytes());
jb.addEntry("version/Main.java", main.getBytes());
jb.addEntry("version/Main.class", rootClasses.get("version.Main"));
--- a/jdk/test/sun/management/jdp/JdpDefaultsTest.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/sun/management/jdp/JdpDefaultsTest.java Wed Jul 05 21:35:27 2017 +0200
@@ -57,7 +57,6 @@
"-Dcom.sun.management.jmxremote.autodiscovery=true",
"-Dcom.sun.management.jdp.pause=1",
"-Dcom.sun.management.jdp.name=" + jdpName,
- "-Dcom.sun.management.jdp.address=224.0.23.178",
"-Djava.util.logging.SimpleFormatter.format='%1$tF %1$tT %4$-7s %5$s %n'",
testName
};
--- a/jdk/test/sun/management/jdp/JdpTestCase.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/sun/management/jdp/JdpTestCase.java Wed Jul 05 21:35:27 2017 +0200
@@ -122,7 +122,7 @@
*/
private void jdpPacketReceived(Map<String, String> payload) throws Exception {
final String instanceName = payload.get("INSTANCE_NAME");
- if (instanceName.equals(connection.instanceName)) {
+ if (instanceName != null && instanceName.equals(connection.instanceName)) {
packetFromThisVMReceived(payload);
} else {
packetFromOtherVMReceived(payload);
--- a/jdk/test/sun/reflect/AnonymousNewInstance/ManyNewInstanceAnonTest.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,66 +0,0 @@
-/*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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 7194897
- * @summary JSR 292: Cannot create more than 16 instances of an anonymous class
- * @modules java.base/jdk.internal.misc
- * java.management
- * @library /lib/testlibrary
- * @author Robert Field
- * @compile -XDignore.symbol.file ManyNewInstanceAnonTest.java
- * @build jdk.testlibrary.*
- * @run main ClassFileInstaller ManyNewInstanceAnonTest
- * @run main/othervm -Xbootclasspath/a:. -Xverify:all ManyNewInstanceAnonTest
- * @run main/othervm -Xbootclasspath/a:. -Xverify:all -Dsun.reflection.noInflation=true ManyNewInstanceAnonTest
- */
-import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
-import jdk.internal.misc.Unsafe;
-
-public class ManyNewInstanceAnonTest {
-
- static final int REPS = 20;
- static final Class<?> klass = ManyNewInstanceAnonTest.class;
-
- public static void main(String[] args) throws Exception {
- Class<?> c = Unsafe.getUnsafe().defineAnonymousClass(klass, readClassFile(), null);
- for (int i = 0; i < REPS; ++i) {
- System.out.printf("%d: %s\n", i, c.newInstance());
- }
- System.out.println("Passed.");
- }
-
- private static byte[] readClassFile() throws Exception {
- try (InputStream in = klass.getResourceAsStream(klass.getSimpleName() + ".class");
- ByteArrayOutputStream out = new ByteArrayOutputStream())
- {
- int b;
- while ((b = in.read()) != -1) {
- out.write(b);
- }
- return out.toByteArray();
- }
- }
-}
--- a/jdk/test/sun/reflect/CallerSensitive/CallerSensitiveFinder.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,228 +0,0 @@
-/*
- * Copyright (c) 2013, 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 com.sun.tools.classfile.*;
-import com.sun.tools.jdeps.ClassFileReader;
-import static com.sun.tools.classfile.ConstantPool.*;
-import java.io.File;
-import java.io.IOException;
-import java.io.UncheckedIOException;
-import java.net.URI;
-import java.nio.file.FileSystem;
-import java.nio.file.FileSystems;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.FutureTask;
-import java.util.stream.Stream;
-
-/*
- * @test
- * @bug 8010117
- * @summary Verify if CallerSensitive methods are annotated with
- * sun.reflect.CallerSensitive annotation
- * @modules jdk.jdeps/com.sun.tools.classfile jdk.jdeps/com.sun.tools.jdeps
- * @build CallerSensitiveFinder
- * @run main/othervm/timeout=900 CallerSensitiveFinder
- */
-public class CallerSensitiveFinder {
- private static int numThreads = 3;
- private static boolean verbose = false;
- private final ExecutorService pool;
-
- public static void main(String[] args) throws Exception {
- Stream<Path> classes = null;
- String testclasses = System.getProperty("test.classes", ".");
- int i = 0;
- while (i < args.length) {
- String arg = args[i++];
- if (arg.equals("-v")) {
- verbose = true;
- } else {
- Path p = Paths.get(testclasses, arg);
- if (!p.toFile().exists()) {
- throw new IllegalArgumentException(arg + " does not exist");
- }
- classes = Stream.of(p);
- }
- }
-
- if (classes == null) {
- classes = getPlatformClasses();
- }
-
- CallerSensitiveFinder csfinder = new CallerSensitiveFinder();
- List<String> errors = csfinder.run(classes);
-
- if (!errors.isEmpty()) {
- throw new RuntimeException(errors.size() +
- " caller-sensitive methods are missing @CallerSensitive annotation");
- }
- }
-
- private final List<String> csMethodsMissingAnnotation =
- Collections.synchronizedList(new ArrayList<>());
- private final ReferenceFinder finder;
- public CallerSensitiveFinder() {
- this.finder = new ReferenceFinder(getFilter(), getVisitor());
- pool = Executors.newFixedThreadPool(numThreads);
-
- }
-
- private ReferenceFinder.Filter getFilter() {
- final String classname = "sun/reflect/Reflection";
- final String method = "getCallerClass";
- return new ReferenceFinder.Filter() {
- public boolean accept(ConstantPool cpool, CPRefInfo cpref) {
- try {
- CONSTANT_NameAndType_info nat = cpref.getNameAndTypeInfo();
- return cpref.getClassName().equals(classname) && nat.getName().equals(method);
- } catch (ConstantPoolException ex) {
- throw new RuntimeException(ex);
- }
- }
- };
- }
-
- private ReferenceFinder.Visitor getVisitor() {
- return new ReferenceFinder.Visitor() {
- public void visit(ClassFile cf, Method m, List<CPRefInfo> refs) {
- try {
- String name = String.format("%s#%s %s", cf.getName(),
- m.getName(cf.constant_pool),
- m.descriptor.getValue(cf.constant_pool));
- if (!CallerSensitiveFinder.isCallerSensitive(m, cf.constant_pool)) {
- csMethodsMissingAnnotation.add(name);
- System.err.println("Missing @CallerSensitive: " + name);
- } else {
- if (verbose) {
- System.out.format("@CS %s%n", name);
- }
- }
- } catch (ConstantPoolException ex) {
- throw new RuntimeException(ex);
- }
- }
- };
- }
-
- public List<String> run(Stream<Path> classes)throws IOException, InterruptedException,
- ExecutionException, ConstantPoolException
- {
- classes.forEach(this::processPath);
- waitForCompletion();
- pool.shutdown();
- return csMethodsMissingAnnotation;
- }
-
- void processPath(Path path) {
- try {
- ClassFileReader reader = ClassFileReader.newInstance(path);
- for (ClassFile cf : reader.getClassFiles()) {
- String classFileName = cf.getName();
- // for each ClassFile
- // parse constant pool to find matching method refs
- // parse each method (caller)
- // - visit and find method references matching the given method name
- pool.submit(getTask(cf));
- }
- } catch (IOException x) {
- throw new UncheckedIOException(x);
- } catch (ConstantPoolException x) {
- throw new RuntimeException(x);
- }
- }
-
- private static final String CALLER_SENSITIVE_ANNOTATION = "Lsun/reflect/CallerSensitive;";
- private static boolean isCallerSensitive(Method m, ConstantPool cp)
- throws ConstantPoolException
- {
- RuntimeAnnotations_attribute attr =
- (RuntimeAnnotations_attribute)m.attributes.get(Attribute.RuntimeVisibleAnnotations);
- int index = 0;
- if (attr != null) {
- for (int i = 0; i < attr.annotations.length; i++) {
- Annotation ann = attr.annotations[i];
- String annType = cp.getUTF8Value(ann.type_index);
- if (CALLER_SENSITIVE_ANNOTATION.equals(annType)) {
- return true;
- }
- }
- }
- return false;
- }
-
- private final List<FutureTask<Void>> tasks = new ArrayList<FutureTask<Void>>();
- private FutureTask<Void> getTask(final ClassFile cf) {
- FutureTask<Void> task = new FutureTask<Void>(new Callable<Void>() {
- public Void call() throws Exception {
- finder.parse(cf);
- return null;
- }
- });
- tasks.add(task);
- return task;
- }
-
- private void waitForCompletion() throws InterruptedException, ExecutionException {
- for (FutureTask<Void> t : tasks) {
- t.get();
- }
- if (tasks.isEmpty()) {
- throw new RuntimeException("No classes found, or specified.");
- }
- System.out.println("Parsed " + tasks.size() + " classfiles");
- }
-
- static Stream<Path> getPlatformClasses() throws IOException {
- Path home = Paths.get(System.getProperty("java.home"));
-
- // Either an exploded build or an image.
- File classes = home.resolve("modules").toFile();
- if (classes.isDirectory()) {
- return Stream.of(classes.toPath());
- } else {
- return jrtPaths();
- }
- }
-
- static Stream<Path> jrtPaths() {
- FileSystem jrt = FileSystems.getFileSystem(URI.create("jrt:/"));
- Path root = jrt.getPath("/");
-
- try {
- return Files.walk(root)
- .filter(p -> p.getNameCount() > 1)
- .filter(p -> p.toString().endsWith(".class"));
- } catch (IOException x) {
- throw new UncheckedIOException(x);
- }
- }
-}
--- a/jdk/test/sun/reflect/CallerSensitive/MissingCallerSensitive.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,69 +0,0 @@
-/*
- * Copyright (c) 2013, 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 8010117
- * @summary Test CallerSensitiveFinder to find missing annotation
- * @modules java.base/sun.reflect
- * jdk.jdeps/com.sun.tools.classfile
- * jdk.jdeps/com.sun.tools.jdeps
- * @compile -XDignore.symbol.file MissingCallerSensitive.java
- * @build CallerSensitiveFinder
- * @run main MissingCallerSensitive
- */
-
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.*;
-import java.util.stream.Stream;
-
-public class MissingCallerSensitive {
- public static void main(String[] args) throws Exception {
- String testclasses = System.getProperty("test.classes", ".");
-
- Stream<Path> classes = Stream.of(Paths.get(testclasses, "MissingCallerSensitive.class"));
-
- CallerSensitiveFinder csfinder = new CallerSensitiveFinder();
- List<String> errors = csfinder.run(classes);
- if (errors.size() != 1) {
- throw new RuntimeException("Unexpected number of methods found: " + errors.size());
- }
- String m = errors.get(0);
- if (!m.startsWith("MissingCallerSensitive#missingCallerSensitiveAnnotation")) {
- throw new RuntimeException("Unexpected method missing annotation: " + m);
- }
- }
-
- @sun.reflect.CallerSensitive
- public ClassLoader getCallerLoader() {
- Class<?> c = sun.reflect.Reflection.getCallerClass();
- return c.getClassLoader();
- }
-
- public ClassLoader missingCallerSensitiveAnnotation() {
- Class<?> c = sun.reflect.Reflection.getCallerClass();
- return c.getClassLoader();
- }
-}
--- a/jdk/test/sun/reflect/Reflection/GetCallerClass.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2013, 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 boot;
-
-public class GetCallerClass {
- @sun.reflect.CallerSensitive
- public ClassLoader getCallerLoader() {
- Class<?> c = sun.reflect.Reflection.getCallerClass();
- return c.getClassLoader();
- }
-
- public ClassLoader missingCallerSensitiveAnnotation() {
- Class<?> c = sun.reflect.Reflection.getCallerClass();
- return c.getClassLoader();
- }
-}
--- a/jdk/test/sun/reflect/Reflection/GetCallerClassTest.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,113 +0,0 @@
-/*
- * Copyright (c) 2013, 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 boot.GetCallerClass;
-import java.lang.reflect.*;
-import sun.reflect.CallerSensitive;
-import sun.reflect.Reflection;
-
-public class GetCallerClassTest {
- private final GetCallerClass gcc; // boot.GetCallerClass is in bootclasspath
- GetCallerClassTest() {
- this.gcc = new GetCallerClass();
- }
-
- public static void main(String[] args) throws Exception {
- GetCallerClassTest gcct = new GetCallerClassTest();
- // ensure methods are annotated with @CallerSensitive
- ensureAnnotationPresent(boot.GetCallerClass.class, "getCallerLoader", true);
- ensureAnnotationPresent(GetCallerClassTest.class, "testNonSystemMethod", false);
- // call Reflection.getCallerClass from bootclasspath with and without @CS
- gcct.testCallerSensitiveMethods();
- // call Reflection.getCallerClass from classpath with @CS
- gcct.testNonSystemMethod();
- }
-
- private static void ensureAnnotationPresent(Class<?> c, String name, boolean cs)
- throws NoSuchMethodException
- {
- Method m = c.getDeclaredMethod(name);
- if (!m.isAnnotationPresent(CallerSensitive.class)) {
- throw new RuntimeException("@CallerSensitive not present in method " + m);
- }
- if (Reflection.isCallerSensitive(m) != cs) {
- throw new RuntimeException("Unexpected: isCallerSensitive returns " +
- Reflection.isCallerSensitive(m));
- }
- }
-
- private void testCallerSensitiveMethods() {
- try {
- ClassLoader cl = gcc.getCallerLoader();
- if (cl != GetCallerClassTest.class.getClassLoader()) {
- throw new RuntimeException("mismatched class loader");
- }
- gcc.missingCallerSensitiveAnnotation();
- throw new RuntimeException("getCallerLoader not marked with @CallerSensitive");
- } catch (InternalError e) {
- StackTraceElement[] stackTrace = e.getStackTrace();
- checkStackTrace(stackTrace, e);
- if (!stackTrace[1].getClassName().equals(GetCallerClass.class.getName()) ||
- !stackTrace[1].getMethodName().equals("missingCallerSensitiveAnnotation")) {
- throw new RuntimeException("Unexpected error: " + e.getMessage(), e);
- }
- if (!stackTrace[2].getClassName().equals(GetCallerClassTest.class.getName()) ||
- !stackTrace[2].getMethodName().equals("testCallerSensitiveMethods")) {
- throw new RuntimeException("Unexpected error: " + e.getMessage(), e);
- }
- System.out.println("Expected error: " + e.getMessage());
- }
- }
-
- @CallerSensitive
- private void testNonSystemMethod() {
- try {
- Class<?> c = Reflection.getCallerClass();
- throw new RuntimeException("@CallerSensitive testNonSystemMethods not supported");
- } catch (InternalError e) {
- StackTraceElement[] stackTrace = e.getStackTrace();
- checkStackTrace(stackTrace, e);
- if (!stackTrace[1].getClassName().equals(GetCallerClassTest.class.getName()) ||
- !stackTrace[1].getMethodName().equals("testNonSystemMethod")) {
- throw new RuntimeException("Unexpected error: " + e.getMessage(), e);
- }
- if (!stackTrace[2].getClassName().equals(GetCallerClassTest.class.getName()) ||
- !stackTrace[2].getMethodName().equals("main")) {
- throw new RuntimeException("Unexpected error: " + e.getMessage(), e);
- }
- System.out.println("Expected error: " + e.getMessage());
- }
- }
-
- private void checkStackTrace(StackTraceElement[] stackTrace, Error e) {
- if (stackTrace.length < 3) {
- throw new RuntimeException("Unexpected error: " + e.getMessage(), e);
- }
-
- if (!stackTrace[0].getClassName().equals("sun.reflect.Reflection") ||
- !stackTrace[0].getMethodName().equals("getCallerClass")) {
- throw new RuntimeException("Unexpected error: " + e.getMessage(), e);
- }
-
- }
-}
--- a/jdk/test/sun/reflect/Reflection/GetCallerClassTest.sh Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,70 +0,0 @@
-#
-# Copyright (c) 2013, 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 8010117
-# @summary Test if the VM enforces sun.reflect.Reflection.getCallerClass
-# be called by methods annotated with sun.reflect.CallerSensitive
-#
-# @run shell GetCallerClassTest.sh
-
-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
-
-BCP=${TESTCLASSES}/bcp
-rm -rf ${BCP}
-mkdir ${BCP}
-
-EXTRAOPTS="-XaddExports:java.base/sun.reflect=ALL-UNNAMED"
-
-# Compile GetCallerClass in bootclasspath
-${COMPILEJAVA}/bin/javac ${TESTTOOLVMOPTS} ${EXTRAOPTS} \
- -XDignore.symbol.file \
- -d ${BCP} ${TESTSRC}/GetCallerClass.java || exit 1
-
-${COMPILEJAVA}/bin/javac ${TESTTOOLVMOPTS} ${EXTRAOPTS} \
- -XDignore.symbol.file -cp ${BCP} \
- -d ${TESTCLASSES} ${TESTSRC}/GetCallerClassTest.java || exit 2
-
-${TESTJAVA}/bin/java ${TESTVMOPTS} ${EXTRAOPTS} -Xbootclasspath/a:${BCP} \
- -cp ${TESTCLASSES} GetCallerClassTest || exit 3
--- a/jdk/test/sun/reflect/Reflection/GetCallerClassWithDepth.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/sun/reflect/Reflection/GetCallerClassWithDepth.java Wed Jul 05 21:35:27 2017 +0200
@@ -23,12 +23,13 @@
/*
* @test
- * @bug 8025799
- * @summary sun.reflect.Reflection.getCallerClass(int)
- * @modules java.base/sun.reflect
- * @run main GetCallerClassWithDepth
+ * @bug 8137058
+ * @summary Basic test for the unsupported Reflection.getCallerClass(int)
+ * @modules jdk.unsupported
*/
+import sun.reflect.Reflection;
+
public class GetCallerClassWithDepth {
public static void main(String[] args) throws Exception {
Class<?> c = Test.test();
@@ -38,7 +39,7 @@
Test.selfTest();
try {
- sun.reflect.Reflection.getCallerClass(-1);
+ Reflection.getCallerClass(-1);
throw new RuntimeException("getCallerClass(-1) should fail");
} catch (Error e) {
System.out.println("Expected: " + e.getMessage());
@@ -47,7 +48,7 @@
public Class<?> getCallerClass() {
// 0: Reflection 1: getCallerClass 2: Test.test 3: main
- return sun.reflect.Reflection.getCallerClass(3);
+ return Reflection.getCallerClass(3);
}
static void assertEquals(Class<?> c, Class<?> expected) {
@@ -65,11 +66,11 @@
// Returns the caller of this method
public static Class<?> caller() {
// 0: Reflection 1: Test.caller 2: main
- return sun.reflect.Reflection.getCallerClass(2);
+ return Reflection.getCallerClass(2);
}
public static void selfTest() {
// 0: Reflection 1: Test.selfTest
- Class<?> c = sun.reflect.Reflection.getCallerClass(1);
+ Class<?> c = Reflection.getCallerClass(1);
assertEquals(c, Test.class);
Inner1.deep();
}
@@ -84,7 +85,7 @@
static class Inner2 {
static void deepest() {
// 0: Reflection 1: deepest 2: deeper 3: deep 4: Test.selfTest
- Class<?> c = sun.reflect.Reflection.getCallerClass(4);
+ Class<?> c = Reflection.getCallerClass(4);
assertEquals(c, Test.class);
}
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/reflect/ReflectionFactory/NewConstructorForSerialization.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,61 @@
+/*
+ * 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 8137058
+ * @summary Basic test for the unsupported newConstructorForSerialization
+ * @modules jdk.unsupported
+ */
+
+import java.lang.reflect.Constructor;
+import sun.reflect.ReflectionFactory;
+
+public class NewConstructorForSerialization {
+
+ private static Constructor<?> getConstructor(Class<?> type)
+ throws NoSuchMethodException
+ {
+ ReflectionFactory factory = ReflectionFactory.getReflectionFactory();
+ Constructor<?> objectConstructor = type.getConstructor((Class[]) null);
+
+ @SuppressWarnings("unchecked")
+ Constructor<?> c = (Constructor<?>) factory
+ .newConstructorForSerialization(type, objectConstructor);
+ return c;
+ }
+
+ public static void main(String[] args) throws Exception {
+ System.out.println(getConstructor(Object.class).newInstance());
+ System.out.println(getConstructor(Foo.class).newInstance());
+ System.out.println(getConstructor(Bar.class).newInstance());
+ }
+
+ static class Foo {
+ public Foo() { }
+ }
+
+ static class Bar extends Foo {
+ public Bar() { }
+ }
+}
--- a/jdk/test/sun/reflect/constantPool/ConstantPoolTest.java Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,171 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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 8141615
- * @summary Tests new public methods at sun.reflect.ConstantPool
- * @modules java.base/jdk.internal.misc
- * java.base/sun.reflect
- * @library /lib/testlibrary
- * @compile ConstantPoolTestDummy.jasm
- * @run main sun.reflect.constantPool.ConstantPoolTest
- */
-
-package sun.reflect.constantPool;
-
-import java.util.HashMap;
-import java.util.Map;
-import jdk.internal.misc.SharedSecrets;
-import jdk.testlibrary.Asserts;
-import sun.reflect.ConstantPool;
-
-public class ConstantPoolTest {
-
- private static final Class<?> TEST_CLASS = ConstantPoolTestDummy.class;
- private static final ConstantPool CP = SharedSecrets.getJavaLangAccess()
- .getConstantPool(TEST_CLASS);
-
- public static void main(String[] s) {
- for (TestCase testCase : TestCase.values()) {
- testCase.test();
- }
- }
-
- public static enum TestCase {
- GET_TAG_AT {
- {
- referenceMap.put(1, ConstantPool.Tag.METHODREF);
- referenceMap.put(2, ConstantPool.Tag.CLASS);
- referenceMap.put(4, ConstantPool.Tag.UTF8);
- referenceMap.put(10, ConstantPool.Tag.NAMEANDTYPE);
- referenceMap.put(13, ConstantPool.Tag.LONG);
- referenceMap.put(15, ConstantPool.Tag.INTEGER);
- referenceMap.put(16, ConstantPool.Tag.INTERFACEMETHODREF);
- referenceMap.put(21, ConstantPool.Tag.DOUBLE);
- referenceMap.put(23, ConstantPool.Tag.STRING);
- referenceMap.put(25, ConstantPool.Tag.INVOKEDYNAMIC);
- referenceMap.put(29, ConstantPool.Tag.METHODHANDLE);
- referenceMap.put(30, ConstantPool.Tag.METHODTYPE);
- referenceMap.put(48, ConstantPool.Tag.FIELDREF);
- referenceMap.put(52, ConstantPool.Tag.FLOAT);
- }
- @Override
- void testIndex(int cpi, Object reference) {
- ConstantPool.Tag tagToVerify = CP.getTagAt(cpi);
- ConstantPool.Tag tagToRefer = (ConstantPool.Tag) reference;
- String msg = String.format("Method getTagAt works not as expected"
- + "at CP entry #%d: got CP tag %s, but should be %s",
- cpi, tagToVerify.name(), tagToRefer.name());
- Asserts.assertEquals(tagToVerify, tagToRefer, msg);
- }
- },
- GET_CLASS_REF_INDEX_AT {
- {
- referenceMap.put(1, 3);
- referenceMap.put(16, 17);
- referenceMap.put(32, 35);
- referenceMap.put(34, 3);
- referenceMap.put(48, 2);
- }
- @Override
- void testIndex(int cpi, Object reference) {
- int indexToVerify = CP.getClassRefIndexAt(cpi);
- int indexToRefer = (int) reference;
- String msg = String.format("Method getClassRefIndexAt works not"
- + " as expected at CP entry #%d:"
- + " got index %d, but should be %d",
- cpi, indexToVerify, indexToRefer);
- Asserts.assertEquals(indexToVerify, indexToRefer, msg);
- }
- },
- GET_NAME_AND_TYPE_REF_INDEX_AT {
- {
- referenceMap.put(1, 10);
- referenceMap.put(16, 18);
- referenceMap.put(25, 26);
- referenceMap.put(32, 36);
- referenceMap.put(34, 37);
- referenceMap.put(48, 49);
- }
- @Override
- void testIndex(int cpi, Object reference) {
- int indexToRefer = (int) reference;
- int indexToVerify = CP.getNameAndTypeRefIndexAt(cpi);
- String msg = String.format("Method getNameAndTypeRefIndexAt works"
- + " not as expected at CP entry #%d:"
- + " got index %d, but should be %d",
- cpi, indexToVerify, indexToRefer);
- Asserts.assertEquals(indexToVerify, indexToRefer, msg);
- }
- },
- GET_NAME_AND_TYPE_REF_INFO_AT {
- {
- referenceMap.put(10, new String[]{"<init>", "()V"});
- referenceMap.put(18, new String[]{"run", "()V"});
- referenceMap.put(26, new String[]{"accept", "()Ljava/util/function/Consumer;"});
- referenceMap.put(36, new String[]{"metafactory",
- "(Ljava/lang/invoke/MethodHandles$Lookup;"
- + "Ljava/lang/String;Ljava/lang/invoke/MethodType;"
- + "Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;"
- + "Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;"});
- referenceMap.put(37, new String[]{"toString", "()Ljava/lang/String;"});
- referenceMap.put(49, new String[]{"myField", "I"});
- }
- @Override
- void testIndex(int cpi, Object reference) {
- String[] natInfo = CP.getNameAndTypeRefInfoAt(cpi);
- String msg = String.format("Method getNameAndTypeRefInfoAt"
- + " works not as expected at CP entry #%d:"
- + " returned value should not be null", cpi);
- Asserts.assertNotNull(natInfo, msg);
- String[] castedReference = (String[]) reference;
- int natInfoLength = natInfo.length;
- msg = String.format("Method getNameAndTypeRefInfoAt"
- + " works not as expected at CP entry #%d:"
- + " length of the returned string array is %d, but should be 2",
- cpi, natInfoLength);
- Asserts.assertEquals(natInfoLength, 2, msg);
- String[] nameOrType = new String[]{"name", "type"};
- for (int i = 0; i < 2; i++) {
- String infoToVerify = natInfo[i];
- String infoToRefer = castedReference[i];
- msg = String.format("Method getNameAndTypeRefInfoAt"
- + " works not as expected at CP entry #%d:"
- + " got %s info %s, but should be %s",
- cpi, nameOrType[i], infoToVerify, infoToRefer);
- Asserts.assertEquals(infoToVerify, infoToRefer, msg);
- }
- }
- };
-
- protected final Map<Integer, Object> referenceMap;
- TestCase() {
- this.referenceMap = new HashMap<>();
- }
- abstract void testIndex(int cpi, Object reference);
- public void test() {
- referenceMap.forEach(this::testIndex);
- }
- }
-}
--- a/jdk/test/sun/reflect/constantPool/ConstantPoolTestDummy.jasm Wed Jul 05 21:35:07 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,98 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun/reflect/constantPool;
-
-super public #2; //class ConstantPoolTestDummy
- version 52:0
-{
-
-// Actually, only first 13 constant pool entries are actually used by the class
-// and its methods. All the rest are added just for the testing of getTagAt method
-// and getNameAndTypeRefIndexAt method.
-
-const #1 = Method #3.#10; // java/lang/Object."<init>":"()V"
-const #2 = class #11; // ConstantPoolTestDummy
-const #3 = class #12; // java/lang/Object
-const #4 = Asciz "<init>";
-const #5 = Asciz "()V";
-const #6 = Asciz "Code";
-const #7 = Asciz "LineNumberTable";
-const #8 = Asciz "SourceFile";
-const #9 = Asciz "ConstantPoolTestDummy.java";
-const #10 = NameAndType #4:#5; // "<init>":"()V"
-const #11 = Asciz "sun/reflect/constantPool/ConstantPoolTestDummy";
-const #12 = Asciz "java/lang/Object";
-const #13 = long 6l;
-const #15 = int 1;
-const #16 = InterfaceMethod #17.#18; // java/lang/Runnable.run:"()V"
-const #17 = class #19; // java/lang/Runnable
-const #18 = NameAndType #20:#5; // run:"()V"
-const #19 = Asciz "java/lang/Runnable";
-const #20 = Asciz "run";
-const #21 = double 1.45d;
-const #23 = String #24; // "Hello"
-const #24 = Asciz "Hello";
-const #25 = InvokeDynamic 0:#26; // REF_invokeStatic:java/lang/invoke/LambdaMetafactory.metafactory:"(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;":accept:"()Ljava/util/function/Consumer;" MethodType "(Ljava/lang/Object;)V", MethodHandle REF_invokeVirtual:java/lang/Object.toString:"()Ljava/lang/String;", MethodType "(Ljava/lang/Object;)V"
-const #26 = NameAndType #27:#28; // accept:"()Ljava/util/function/Consumer;"
-const #27 = Asciz "accept";
-const #28 = Asciz "()Ljava/util/function/Consumer;";
-const #29 = MethodHandle 6:#32; // REF_invokeStatic:java/lang/invoke/LambdaMetafactory.metafactory:"(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;"
-const #30 = MethodType #33; // "(Ljava/lang/Object;)V"
-const #31 = MethodHandle 5:#34; // REF_invokeVirtual:java/lang/Object.toString:"()Ljava/lang/String;"
-const #32 = Method #35.#36; // java/lang/invoke/LambdaMetafactory.metafactory:"(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;"
-const #33 = Asciz "(Ljava/lang/Object;)V";
-const #34 = Method #3.#37; // java/lang/Object.toString:"()Ljava/lang/String;"
-const #35 = class #38; // java/lang/invoke/LambdaMetafactory
-const #36 = NameAndType #39:#40; // metafactory:"(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;"
-const #37 = NameAndType #41:#42; // toString:"()Ljava/lang/String;"
-const #38 = Asciz "java/lang/invoke/LambdaMetafactory";
-const #39 = Asciz "metafactory";
-const #40 = Asciz "(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;";
-const #41 = Asciz "toString";
-const #42 = Asciz "()Ljava/lang/String;";
-const #43 = class #46; // java/lang/invoke/MethodHandles$Lookup
-const #44 = Asciz "Lookup";
-const #45 = class #47; // java/lang/invoke/MethodHandles
-const #46 = Asciz "java/lang/invoke/MethodHandles$Lookup";
-const #47 = Asciz "java/lang/invoke/MethodHandles";
-const #48 = Field #2.#49; // sun/reflect/constantPool/ConstantPoolTestDummy.myField:"I"
-const #49 = NameAndType #50:#51; // myField:"I"
-const #50 = Asciz "myField";
-const #51 = Asciz "I";
-const #52 = float 1.34f;
-
-public Method #4:#5 // "<init>":"()V"
-
- stack 1 locals 1
-{
-3 0: aload_0;
- 1: invokespecial #1; // Method java/lang/Object."<init>":"()V";
- 4: return;
-}
-
-public static final InnerClass #44= #43 of #45; //Lookup=class java/lang/invoke/MethodHandles$Lookup of class java/lang/invoke/MethodHandles
-
-BootstrapMethod #29 #30 #31 #30;
-
-} // end Class ConstantPoolTestDummy
--- a/jdk/test/sun/security/mscapi/SmallPrimeExponentP.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/sun/security/mscapi/SmallPrimeExponentP.java Wed Jul 05 21:35:27 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 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,6 +21,18 @@
* questions.
*/
+ /*
+ * @test
+ * @bug 8023546 8151834
+ * @modules java.base/sun.security.x509
+ * java.base/sun.security.tools.keytool
+ * @summary Test prime exponent (p) lengths 63 and 65 bytes with SunMSCAPI.
+ * The seed 76 has the fastest test execution now (only 5 rounds) and is
+ * hard-coded in run tag. This number might change if algorithms for
+ * RSA key pair generation or BigInteger prime searching gets updated.
+ * @requires os.family == "windows"
+ * @run main SmallPrimeExponentP 76
+ */
import sun.security.tools.keytool.CertAndKeyGen;
import sun.security.x509.X500Name;
@@ -28,50 +40,63 @@
import java.security.SecureRandom;
import java.security.cert.X509Certificate;
import java.security.interfaces.RSAPrivateCrtKey;
+import java.util.Random;
-/*
- * @test
- * @bug 8023546
- * @key intermittent
- * @modules java.base/sun.security.x509
- * java.base/sun.security.tools.keytool
- * @summary sun/security/mscapi/ShortRSAKey1024.sh fails intermittently
- * @requires os.family == "windows"
- */
public class SmallPrimeExponentP {
public static void main(String argv[]) throws Exception {
- String osName = System.getProperty("os.name");
- if (!osName.startsWith("Windows")) {
- System.out.println("Not windows");
- return;
- }
+ long seed = Long.parseLong(argv[0]);
+ System.out.println("Seed for SecureRandom = " + seed + "L");
+
KeyStore ks = KeyStore.getInstance("Windows-MY");
ks.load(null, null);
+
CertAndKeyGen ckg = new CertAndKeyGen("RSA", "SHA1withRSA");
- ckg.setRandom(new SecureRandom());
- boolean see63 = false, see65 = false;
+ ckg.setRandom(new MySecureRandom(seed));
+
+ boolean see63 = false;
+ boolean see65 = false;
while (!see63 || !see65) {
ckg.generate(1024);
RSAPrivateCrtKey k = (RSAPrivateCrtKey) ckg.getPrivateKey();
+
int len = k.getPrimeExponentP().toByteArray().length;
+ System.out.println("Length of P = " + len);
if (len == 63 || len == 65) {
if (len == 63) {
- if (see63) continue;
- else see63 = true;
+ if (see63) {
+ continue;
+ } else {
+ see63 = true;
+ }
}
if (len == 65) {
- if (see65) continue;
- else see65 = true;
+ if (see65) {
+ continue;
+ } else {
+ see65 = true;
+ }
}
- System.err.print(len);
ks.setKeyEntry("anything", k, null, new X509Certificate[]{
- ckg.getSelfCertificate(new X500Name("CN=Me"), 1000)
+ ckg.getSelfCertificate(new X500Name("CN=Me"), 1000)
});
}
- System.err.print('.');
}
ks.store(null, null);
}
+
+ static class MySecureRandom extends SecureRandom {
+
+ final Random random;
+
+ public MySecureRandom(long seed) {
+ random = new Random(seed);
+ }
+
+ @Override
+ public void nextBytes(byte[] bytes) {
+ random.nextBytes(bytes);
+ }
+ }
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/pkcs11/KeyAgreement/SupportedDHKeys.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,127 @@
+/*
+ * 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 8072452
+ * @summary Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
+ * @library ..
+ * @run main/othervm SupportedDHKeys
+ * @run main/othervm SupportedDHKeys sm
+ */
+
+import java.math.BigInteger;
+
+import java.security.*;
+import javax.crypto.*;
+import javax.crypto.interfaces.*;
+import javax.crypto.spec.*;
+
+public class SupportedDHKeys extends PKCS11Test {
+
+ /*
+ * Sizes and values for various lengths.
+ */
+ private enum SupportedKeySize {
+ dhp512(512), dhp768(768), dhp832(832),
+ dhp1024(1024), dhp1536(1536), dhp2048(2048);
+
+ // the underlying pkcs11 may not support the following sizes yet
+ //
+ // dhp3072(3072), dhp4096(4096), dhp6144(6144),
+ // dhp8192(8192);
+
+ final int primeSize;
+
+ SupportedKeySize(int primeSize) {
+ this.primeSize = primeSize;
+ }
+ }
+
+ @Override
+ public void main(Provider provider) throws Exception {
+ if (provider.getService("KeyPairGenerator", "DiffieHellman") == null) {
+ System.out.println("No support of DH KeyPairGenerator, skipping");
+ return;
+ }
+
+ for (SupportedKeySize keySize : SupportedKeySize.values()) {
+ System.out.println("Checking " + keySize.primeSize + " ...");
+ KeyPairGenerator kpg =
+ KeyPairGenerator.getInstance("DiffieHellman", provider);
+ kpg.initialize(keySize.primeSize);
+ KeyPair kp = kpg.generateKeyPair();
+ checkKeyPair(kp, keySize.primeSize);
+
+ DHPublicKey publicKey = (DHPublicKey)kp.getPublic();
+ BigInteger p = publicKey.getParams().getP();
+ BigInteger g = publicKey.getParams().getG();
+ kpg.initialize(new DHParameterSpec(p, g));
+ kp = kpg.generateKeyPair();
+ checkKeyPair(kp, keySize.primeSize);
+ }
+ }
+
+ private static void checkKeyPair(KeyPair kp, int pSize) throws Exception {
+
+ DHPrivateKey privateKey = (DHPrivateKey)kp.getPrivate();
+ BigInteger p = privateKey.getParams().getP();
+ if (p.bitLength() != pSize) {
+ throw new Exception(
+ "Invalid modulus size: " + p.bitLength() + "/" + pSize);
+ }
+
+ // System.out.println("P(" + pSize + "): " + p.toString());
+ if (!p.isProbablePrime(128)) {
+ throw new Exception("Good luck, the modulus is composite!");
+ }
+
+ DHPublicKey publicKey = (DHPublicKey)kp.getPublic();
+ p = publicKey.getParams().getP();
+ if (p.bitLength() != pSize) {
+ throw new Exception(
+ "Invalid modulus size: " + p.bitLength() + "/" + pSize);
+ }
+
+ BigInteger leftOpen = BigInteger.ONE;
+ BigInteger rightOpen = p.subtract(BigInteger.ONE);
+
+ BigInteger x = privateKey.getX();
+ if ((x.compareTo(leftOpen) <= 0) ||
+ (x.compareTo(rightOpen) >= 0)) {
+ throw new Exception(
+ "X outside range [2, p - 2]: x: " + x + " p: " + p);
+ }
+
+ BigInteger y = publicKey.getY();
+ if ((y.compareTo(leftOpen) <= 0) ||
+ (y.compareTo(rightOpen) >= 0)) {
+ throw new Exception(
+ "Y outside range [2, p - 2]: x: " + x + " p: " + p);
+ }
+ }
+
+ public static void main(String[] args) throws Exception {
+ main(new SupportedDHKeys(), args);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/pkcs11/KeyAgreement/UnsupportedDHKeys.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,86 @@
+/*
+ * 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 8072452
+ * @summary Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
+ * @library ..
+ * @run main/othervm UnsupportedDHKeys
+ * @run main/othervm UnsupportedDHKeys sm
+ */
+
+import java.math.BigInteger;
+
+import java.security.*;
+import javax.crypto.*;
+import javax.crypto.interfaces.*;
+import javax.crypto.spec.*;
+
+public class UnsupportedDHKeys extends PKCS11Test {
+
+ /*
+ * Sizes and values for various lengths.
+ */
+ private enum UnsupportedKeySize {
+ // not multiple of 64
+ dhp513(513), dhp769(769), dhp895(895),
+ dhp1023(1023), dhp1535(1535), dhp2047(2047),
+
+ // unsupported
+ dhp2176(2176), dhp3008(3008), dhp4032(4032),
+ dhp5120(5120), dhp6400(6400), dhp7680(7680),
+ dhp8191(8191), dhp8128(8128), dhp8260(8260);
+
+ final int primeSize;
+
+ UnsupportedKeySize(int primeSize) {
+ this.primeSize = primeSize;
+ }
+ }
+
+ @Override
+ public void main(Provider provider) throws Exception {
+ if (provider.getService("KeyPairGenerator", "DiffieHellman") == null) {
+ System.out.println("No supported of DH KeyPairGenerator, skipping");
+ return;
+ }
+
+ for (UnsupportedKeySize keySize : UnsupportedKeySize.values()) {
+ try {
+ System.out.println("Checking " + keySize.primeSize + " ...");
+ KeyPairGenerator kpg =
+ KeyPairGenerator.getInstance("DiffieHellman", provider);
+ kpg.initialize(keySize.primeSize);
+
+ throw new Exception("Should not support " + keySize.primeSize);
+ } catch (InvalidParameterException ipe) {
+ System.out.println("\tOk, unsupported");
+ }
+ }
+ }
+
+ public static void main(String[] args) throws Exception {
+ main(new UnsupportedDHKeys(), args);
+ }
+}
--- a/jdk/test/sun/security/pkcs11/KeyPairGenerator/TestDH2048.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/sun/security/pkcs11/KeyPairGenerator/TestDH2048.java Wed Jul 05 21:35:27 2017 +0200
@@ -23,8 +23,8 @@
/**
* @test
- * @bug 7196382
- * @summary Ensure that 2048-bit DH key pairs can be generated
+ * @bug 7196382 8072452
+ * @summary Ensure that DH key pairs can be generated for 512 - 8192 bits
* @author Valerie Peng
* @library ..
* @run main/othervm TestDH2048
@@ -54,11 +54,45 @@
return;
}
KeyPairGenerator kpg = KeyPairGenerator.getInstance("DH", p);
- kpg.initialize(2048);
+ kpg.initialize(512);
KeyPair kp1 = kpg.generateKeyPair();
- checkUnsupportedKeySize(kpg, 1536);
- checkUnsupportedKeySize(kpg, 2176);
- checkUnsupportedKeySize(kpg, 3072);
+
+ kpg.initialize(768);
+ kp1 = kpg.generateKeyPair();
+
+ kpg.initialize(1024);
+ kp1 = kpg.generateKeyPair();
+
+ kpg.initialize(1536);
+ kp1 = kpg.generateKeyPair();
+
+ kpg.initialize(2048);
+ kp1 = kpg.generateKeyPair();
+
+ try {
+ kpg.initialize(3072);
+ kp1 = kpg.generateKeyPair();
+
+ kpg.initialize(4096);
+ kp1 = kpg.generateKeyPair();
+
+ kpg.initialize(6144);
+ kp1 = kpg.generateKeyPair();
+
+ kpg.initialize(8192);
+ kp1 = kpg.generateKeyPair();
+ } catch (InvalidParameterException ipe) {
+ // NSS (as of version 3.13) has a hard coded maximum limit
+ // of 2236 or 3072 bits for DHE keys.
+ System.out.println("4096-bit DH key pair generation: " + ipe);
+ if (!p.getName().equals("SunPKCS11-NSS")) {
+ throw ipe;
+ }
+ }
+
+ // key size must be multiples of 64 though
+ checkUnsupportedKeySize(kpg, 2048 + 63);
+ checkUnsupportedKeySize(kpg, 3072 + 32);
}
public static void main(String[] args) throws Exception {
--- a/jdk/test/sun/security/pkcs11/KeyStore/Basic.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/sun/security/pkcs11/KeyStore/Basic.java Wed Jul 05 21:35:27 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2015, 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
@@ -103,7 +103,7 @@
}
public static void main(String[] args) throws Exception {
- main(new Basic());
+ main(new Basic(), args);
}
public void main(Provider p) throws Exception {
--- a/jdk/test/sun/security/pkcs11/KeyStore/Basic.policy Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/sun/security/pkcs11/KeyStore/Basic.policy Wed Jul 05 21:35:27 2017 +0200
@@ -7,6 +7,7 @@
permission java.lang.RuntimePermission "loadLibrary.*";
permission java.lang.RuntimePermission "accessClassInPackage.sun.*";
permission java.lang.RuntimePermission "getProtectionDomain";
+ permission java.lang.RuntimePermission "setSecurityManager";
permission java.security.SecurityPermission "putProviderProperty.*";
permission java.io.FilePermission "<<ALL FILES>>", "read";
--- a/jdk/test/sun/security/pkcs11/KeyStore/Basic.sh Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/sun/security/pkcs11/KeyStore/Basic.sh Wed Jul 05 21:35:27 2017 +0200
@@ -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
@@ -187,10 +187,8 @@
-DTEST=${TEST} \
-Dtest.src=${TESTSRC} \
-Dtest.classes=${TESTCLASSES} \
- -Djava.security.manager \
- -Djava.security.policy=${TESTSRC}${FS}Basic.policy \
-Djava.security.debug=${DEBUG} \
- Basic
+ Basic sm Basic.policy
# save error status
status=$?
--- a/jdk/test/sun/security/pkcs11/KeyStore/Solaris.sh Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/sun/security/pkcs11/KeyStore/Solaris.sh Wed Jul 05 21:35:27 2017 +0200
@@ -155,10 +155,8 @@
-DNO_DEIMOS=true \
-DTOKEN=solaris \
-DTEST=${TEST} \
- -Djava.security.manager \
- -Djava.security.policy=${TESTSRC}${FS}Basic.policy \
-Djava.security.debug=${DEBUG} \
- Basic
+ Basic sm Basic.policy
# clean up
--- a/jdk/test/sun/security/pkcs11/PKCS11Test.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/sun/security/pkcs11/PKCS11Test.java Wed Jul 05 21:35:27 2017 +0200
@@ -181,8 +181,13 @@
public static void main(PKCS11Test test, String[] args) throws Exception {
if (args != null) {
- if (args.length > 0 && "sm".equals(args[0])) {
- test.enableSM = true;
+ if (args.length > 0) {
+ if ("sm".equals(args[0])) {
+ test.enableSM = true;
+ } else {
+ throw new RuntimeException("Unknown Command, use 'sm' as "
+ + "first arguemtn to enable security manager");
+ }
}
if (test.enableSM) {
System.setProperty("java.security.policy",
--- a/jdk/test/sun/security/pkcs11/Provider/Login.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/sun/security/pkcs11/Provider/Login.java Wed Jul 05 21:35:27 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2015, 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
@@ -35,7 +35,7 @@
private static char[] password;
public static void main(String[] args) throws Exception {
- main(new Login());
+ main(new Login(), args);
}
public void main(Provider p) throws Exception {
--- a/jdk/test/sun/security/pkcs11/Provider/Login.policy Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/sun/security/pkcs11/Provider/Login.policy Wed Jul 05 21:35:27 2017 +0200
@@ -4,6 +4,7 @@
permission java.lang.RuntimePermission "accessClassInPackage.apple.*";
permission java.lang.RuntimePermission "accessClassInPackage.sun.*";
permission java.lang.RuntimePermission "getProtectionDomain";
+ permission java.lang.RuntimePermission "setSecurityManager";
permission java.security.SecurityPermission "putProviderProperty.*";
--- a/jdk/test/sun/security/pkcs11/Provider/Login.sh Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/sun/security/pkcs11/Provider/Login.sh Wed Jul 05 21:35:27 2017 +0200
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 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
@@ -127,10 +127,8 @@
-DNO_DEIMOS=true \
-Dtest.src=${TESTSRC} \
-Dtest.classes=${TESTCLASSES} \
- -Djava.security.manager \
- -Djava.security.policy=${TESTSRC}${FS}Login.policy \
-Djava.security.debug=${DEBUG} \
- Login
+ Login sm Login.policy
# save error status
status=$?
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/provider/DSA/SupportedDSAParamGen.java Wed Jul 05 21:35:27 2017 +0200
@@ -0,0 +1,82 @@
+/*
+ * 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 8072452
+ * @summary Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
+ * @run main/timeout=300 SupportedDSAParamGen 1024 160
+ * @run main/timeout=300 SupportedDSAParamGen 2048 224
+ * @run main/timeout=300 SupportedDSAParamGen 2048 256
+ * @run main/timeout=450 SupportedDSAParamGen 3072 256
+ */
+import java.security.*;
+import java.security.spec.*;
+import java.security.interfaces.*;
+
+public class SupportedDSAParamGen {
+
+ public static void main(String[] args) throws Exception {
+ AlgorithmParameterGenerator apg =
+ AlgorithmParameterGenerator.getInstance("DSA", "SUN");
+
+ DSAGenParameterSpec spec = new DSAGenParameterSpec(
+ Integer.valueOf(args[0]).intValue(),
+ Integer.valueOf(args[1]).intValue());
+
+ System.out.println("Generating (" + spec.getPrimePLength() +
+ ", " + spec.getSubprimeQLength() + ") DSA Parameters");
+ long start = System.currentTimeMillis();
+ apg.init(spec, null);
+ AlgorithmParameters param = apg.generateParameters();
+ long stop = System.currentTimeMillis();
+ System.out.println("Time: " + (stop - start) + " ms.");
+ checkParamStrength(param, spec);
+ }
+
+ private static void checkParamStrength(AlgorithmParameters param,
+ DSAGenParameterSpec genParam) throws Exception {
+
+ String algo = param.getAlgorithm();
+ if (!algo.equalsIgnoreCase("DSA")) {
+ throw new Exception("Unexpected type of parameters: " + algo);
+ }
+
+ DSAParameterSpec spec = param.getParameterSpec(DSAParameterSpec.class);
+ int valueL = spec.getP().bitLength();
+ int strength = genParam.getPrimePLength();
+ if (strength != valueL) {
+ System.out.println(
+ "P: Expected " + strength + " but actual " + valueL);
+ throw new Exception("Wrong P strength");
+ }
+
+ int valueN = spec.getQ().bitLength();
+ strength = genParam.getSubprimeQLength();
+ if (strength != valueN) {
+ System.out.println(
+ "Q: Expected " + strength + " but actual " + valueN);
+ throw new Exception("Wrong Q strength");
+ }
+ }
+}
--- a/jdk/test/sun/security/provider/DSA/TestAlgParameterGenerator.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/sun/security/provider/DSA/TestAlgParameterGenerator.java Wed Jul 05 21:35:27 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 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
@@ -21,58 +21,61 @@
* questions.
*/
-/*
+ /*
* @test
- * @bug 7044060
+ * @bug 7044060 8055351
* @summary verify that DSA parameter generation works
- * @run main/othervm/timeout=300 TestAlgParameterGenerator
+ * @run main/timeout=600 TestAlgParameterGenerator
*/
-import java.security.*;
-import java.security.spec.*;
-import java.security.interfaces.*;
+
+import java.security.AlgorithmParameterGenerator;
+import java.security.AlgorithmParameters;
+import java.security.spec.DSAGenParameterSpec;
+import java.security.spec.DSAParameterSpec;
public class TestAlgParameterGenerator {
private static void checkParamStrength(AlgorithmParameters param,
- int strength) throws Exception {
+ int strength) throws Exception {
String algo = param.getAlgorithm();
if (!algo.equalsIgnoreCase("DSA")) {
- throw new Exception("Unexpected type of parameters: " + algo);
+ throw new RuntimeException("Unexpected type of parameters: " + algo);
}
DSAParameterSpec spec = param.getParameterSpec(DSAParameterSpec.class);
int valueL = spec.getP().bitLength();
if (strength != valueL) {
System.out.println("Expected " + strength + " but actual " + valueL);
- throw new Exception("Wrong P strength");
+ throw new RuntimeException("Wrong P strength");
}
}
+
private static void checkParamStrength(AlgorithmParameters param,
- DSAGenParameterSpec genParam)
- throws Exception {
+ DSAGenParameterSpec genParam)
+ throws Exception {
String algo = param.getAlgorithm();
if (!algo.equalsIgnoreCase("DSA")) {
- throw new Exception("Unexpected type of parameters: " + algo);
+ throw new RuntimeException("Unexpected type of parameters: " + algo);
}
DSAParameterSpec spec = param.getParameterSpec(DSAParameterSpec.class);
int valueL = spec.getP().bitLength();
int strength = genParam.getPrimePLength();
if (strength != valueL) {
System.out.println("P: Expected " + strength + " but actual " + valueL);
- throw new Exception("Wrong P strength");
+ throw new RuntimeException("Wrong P strength");
}
int valueN = spec.getQ().bitLength();
strength = genParam.getSubprimeQLength();
if (strength != valueN) {
System.out.println("Q: Expected " + strength + " but actual " + valueN);
- throw new Exception("Wrong Q strength");
+ throw new RuntimeException("Wrong Q strength");
}
}
public static void main(String[] args) throws Exception {
- AlgorithmParameterGenerator apg =
- AlgorithmParameterGenerator.getInstance("DSA", "SUN");
+ AlgorithmParameterGenerator apg
+ = AlgorithmParameterGenerator.getInstance("DSA", "SUN");
+ long start, stop;
- long start, stop;
// make sure no-init still works
start = System.currentTimeMillis();
AlgorithmParameters param = apg.generateParameters();
@@ -81,9 +84,8 @@
checkParamStrength(param, 1024);
// make sure the old model works
- int[] strengths = { 512, 768, 1024 };
- for (int i = 0; i < strengths.length; i++) {
- int sizeP = strengths[i];
+ int[] strengths = {512, 768, 1024};
+ for (int sizeP : strengths) {
System.out.println("Generating " + sizeP + "-bit DSA Parameters");
start = System.currentTimeMillis();
apg.init(sizeP);
@@ -94,18 +96,17 @@
}
// now the newer model
- DSAGenParameterSpec spec1 = new DSAGenParameterSpec(1024, 160);
- DSAGenParameterSpec spec2 = new DSAGenParameterSpec(2048, 224);
- DSAGenParameterSpec spec3 = new DSAGenParameterSpec(2048, 256);
- //DSAGenParameterSpec spec4 = new DSAGenParameterSpec(3072, 256);
DSAGenParameterSpec[] specSet = {
- spec1, spec2, spec3//, spec4
+ new DSAGenParameterSpec(1024, 160),
+ new DSAGenParameterSpec(2048, 224),
+ new DSAGenParameterSpec(2048, 256)
+ // no support for prime size 3072
+ // ,new DSAGenParameterSpec(3072, 256)
};
- for (int i = 0; i < specSet.length; i++) {
- DSAGenParameterSpec genParam = specSet[i];
- System.out.println("Generating (" + genParam.getPrimePLength() +
- ", " + genParam.getSubprimeQLength() +
- ") DSA Parameters");
+
+ for (DSAGenParameterSpec genParam : specSet) {
+ System.out.println("Generating (" + genParam.getPrimePLength()
+ + ", " + genParam.getSubprimeQLength() + ") DSA Parameters");
start = System.currentTimeMillis();
apg.init(genParam, null);
param = apg.generateParameters();
--- a/jdk/test/sun/security/provider/DSA/TestKeyPairGenerator.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/sun/security/provider/DSA/TestKeyPairGenerator.java Wed Jul 05 21:35:27 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2012, 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
@@ -23,15 +23,18 @@
/*
* @test
- * @bug 4800108
- * @summary verify that precomputed DSA parameters are always used (512, 768, 1024, 2048 bit)
+ * @bug 4800108 8072452
+ * @summary verify that precomputed DSA parameters are always used (512, 768,
+ * 1024, 2048, 3072 bit)
* @run main/othervm/timeout=15 TestKeyPairGenerator
*/
-// this fix is really a performance fix, so this test is not foolproof
-// without it, it will take a minute or more (unless you have a very fast machine)
-// with the fix, the test should complete in <2 seconds
-// use 15 second timeout to leave some room
+//
+// This fix is really a performance fix, so this test is not foolproof.
+// Without the precomputed parameters, it will take a minute or more
+// (unless you have a very fast machine). With the fix, the test should
+// complete in less than 2 seconds. Use 15 second timeout to leave some room.
+//
import java.security.*;
import java.security.interfaces.*;
@@ -82,8 +85,11 @@
kp = kpg.generateKeyPair();
checkKeyLength(kp, 2048);
+ kpg.initialize(3072);
+ kp = kpg.generateKeyPair();
+ checkKeyLength(kp, 3072);
+
long stop = System.currentTimeMillis();
System.out.println("Time: " + (stop - start) + " ms.");
}
-
}
--- a/jdk/test/sun/security/ssl/StatusStapling/java.base/sun/security/ssl/StatusResponseManagerTests.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/sun/security/ssl/StatusStapling/java.base/sun/security/ssl/StatusResponseManagerTests.java Wed Jul 05 21:35:27 2017 +0200
@@ -300,7 +300,15 @@
rootOcsp.enableLog(ocspDebug);
rootOcsp.setNextUpdateInterval(3600);
rootOcsp.start();
- Thread.sleep(1000); // Give the server a second to start up
+
+ // Wait 5 seconds for server ready
+ for (int i = 0; (i < 100 && !rootOcsp.isServerReady()); i++) {
+ Thread.sleep(50);
+ }
+ if (!rootOcsp.isServerReady()) {
+ throw new RuntimeException("Server not ready yet");
+ }
+
rootOcspPort = rootOcsp.getPort();
String rootRespURI = "http://localhost:" + rootOcspPort;
log("Root OCSP Responder URI is " + rootRespURI);
@@ -345,7 +353,15 @@
intOcsp.enableLog(ocspDebug);
intOcsp.setNextUpdateInterval(3600);
intOcsp.start();
- Thread.sleep(1000);
+
+ // Wait 5 seconds for server ready
+ for (int i = 0; (i < 100 && !intOcsp.isServerReady()); i++) {
+ Thread.sleep(50);
+ }
+ if (!intOcsp.isServerReady()) {
+ throw new RuntimeException("Server not ready yet");
+ }
+
intOcspPort = intOcsp.getPort();
String intCaRespURI = "http://localhost:" + intOcspPort;
log("Intermediate CA OCSP Responder URI is " + intCaRespURI);
--- a/jdk/test/sun/tools/jhsdb/BasicLauncherTest.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/sun/tools/jhsdb/BasicLauncherTest.java Wed Jul 05 21:35:27 2017 +0200
@@ -143,6 +143,7 @@
launch("No deadlocks found", "jstack");
launch("compiler detected", "jmap");
launch("Java System Properties", "jinfo");
+ launch("java.threads", "jsnap");
// The test throws RuntimeException on error.
// IOException is thrown if LingeredApp can't start because of some bad
--- a/jdk/test/sun/tools/jhsdb/SAGetoptTest.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/sun/tools/jhsdb/SAGetoptTest.java Wed Jul 05 21:35:27 2017 +0200
@@ -153,5 +153,8 @@
String[] optionSet6 = {"--exe", "--core", "bla_core"};
badOptionsTest(6, optionSet6, "Argument is expected for 'exe'");
+
+ String[] optionSet7 = {"--exe"};
+ badOptionsTest(7, optionSet7, "Argument is expected for 'exe'");
}
}
--- a/jdk/test/tools/launcher/MiscTests.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/tools/launcher/MiscTests.java Wed Jul 05 21:35:27 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 6856415
+ * @bug 6856415 8154212
* @summary Miscellaneous tests, Exceptions
* @compile -XDignore.symbol.file MiscTests.java
* @run main MiscTests
@@ -33,7 +33,9 @@
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
public class MiscTests extends TestHelper {
@@ -103,11 +105,22 @@
}
}
+ static void testJLDEnvWithTool() {
+ final Map<String, String> envMap = new HashMap<>();
+ envMap.put("_JAVA_LAUNCHER_DEBUG", "true");
+ TestResult tr = doExec(envMap, javacCmd, "-version");
+ tr.checkPositive();
+ if (!tr.isOK()) {
+ System.out.println(tr);
+ }
+ }
+
public static void main(String... args) throws IOException {
testWithClassPathSetViaProperty();
test6856415();
+ testJLDEnvWithTool();
if (testExitValue != 0) {
throw new Error(testExitValue + " tests failed");
+ }
}
}
-}
--- a/jdk/test/tools/launcher/modules/addexports/AddExportsTest.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/tools/launcher/modules/addexports/AddExportsTest.java Wed Jul 05 21:35:27 2017 +0200
@@ -107,7 +107,7 @@
public void testSanity() throws Exception {
int exitValue
- = executeTestJava("-XaddExports:java.base/sun.reflect=ALL-UNNAMED",
+ = executeTestJava("-XaddExports:java.base/jdk.internal.reflect=ALL-UNNAMED",
"-version")
.outputTo(System.out)
.errorTo(System.out)
@@ -207,8 +207,8 @@
public void testWithDuplicateOption() throws Exception {
int exitValue
- = executeTestJava("-XaddExports:java.base/sun.reflect=ALL-UNNAMED",
- "-XaddExports:java.base/sun.reflect=ALL-UNNAMED",
+ = executeTestJava("-XaddExports:java.base/jdk.internal.reflect=ALL-UNNAMED",
+ "-XaddExports:java.base/jdk.internal.reflect=ALL-UNNAMED",
"-version")
.outputTo(System.out)
.errorTo(System.out)
--- a/jdk/test/tools/pack200/BandIntegrity.java Wed Jul 05 21:35:07 2017 +0200
+++ b/jdk/test/tools/pack200/BandIntegrity.java Wed Jul 05 21:35:27 2017 +0200
@@ -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
@@ -26,6 +26,7 @@
* @summary test ensures the proper sequencing of bands, dump bands as well.
* @compile -XDignore.symbol.file Utils.java BandIntegrity.java
* @run main BandIntegrity
+ * @key intermittent
* @author ksrini
*/
import java.io.File;