--- a/.hgtags Thu Apr 21 20:49:11 2016 -0700
+++ b/.hgtags Fri Apr 22 01:04:00 2016 -0700
@@ -356,3 +356,4 @@
a6614ff7bf09da74be1d0ef3d9755090d244697a jdk-9+111
7359994942f8d8e723b584d66a3a92c2e9e95e5c jdk-9+112
6072af7a98be3922f26bdce71b53bb3646cb2ac9 jdk-9+113
+c84d0cce090e161d736de69e941830adf8c2f87a jdk-9+114
--- a/.hgtags-top-repo Thu Apr 21 20:49:11 2016 -0700
+++ b/.hgtags-top-repo Fri Apr 22 01:04:00 2016 -0700
@@ -356,3 +356,4 @@
f900d5afd9c83a0df8f36161c27c5e4c86a66f4c jdk-9+111
03543a758cd5890f2266e4b9678378a925dde22a jdk-9+112
55b6d550828d1223b364e6ead4a56e56411c56df jdk-9+113
+1d992540870ff33fe6cc550443388588df9b9e4f jdk-9+114
--- a/common/autoconf/boot-jdk.m4 Thu Apr 21 20:49:11 2016 -0700
+++ b/common/autoconf/boot-jdk.m4 Fri Apr 22 01:04:00 2016 -0700
@@ -305,7 +305,7 @@
BOOT_JDK_SOURCETARGET="-source 8 -target 8"
AC_SUBST(BOOT_JDK_SOURCETARGET)
- ADD_JVM_ARG_IF_OK([-Xpatch:], dummy, [$JAVA])
+ ADD_JVM_ARG_IF_OK([-Xpatch:foo=bar], dummy, [$JAVA])
AC_MSG_CHECKING([if Boot JDK supports modules])
if test "x$JVM_ARG_OK" = "xtrue"; then
AC_MSG_RESULT([yes])
@@ -444,9 +444,9 @@
BUILD_JDK_VERSION=`"$BUILD_JDK/bin/java" -version 2>&1 | head -n 1`
# Extra M4 quote needed to protect [] in grep expression.
- [FOUND_CORRECT_VERSION=`echo $BUILD_JDK_VERSION | grep '\"1\.[9]\.'`]
+ [FOUND_CORRECT_VERSION=`echo $BUILD_JDK_VERSION | $EGREP '\"9([\.+-].*)?\"'`]
if test "x$FOUND_CORRECT_VERSION" = x; then
- AC_MSG_NOTICE([Potential Boot JDK found at $BUILD_JDK is incorrect JDK version ($BUILD_JDK_VERSION); ignoring])
+ AC_MSG_NOTICE([Potential Build JDK found at $BUILD_JDK is incorrect JDK version ($BUILD_JDK_VERSION); ignoring])
AC_MSG_NOTICE([(Your Build JDK must be version 9)])
BUILD_JDK_FOUND=no
else
--- a/common/autoconf/build-performance.m4 Thu Apr 21 20:49:11 2016 -0700
+++ b/common/autoconf/build-performance.m4 Fri Apr 22 01:04:00 2016 -0700
@@ -454,7 +454,7 @@
AC_MSG_RESULT([$ENABLE_JAVAC_SERVER])
AC_SUBST(ENABLE_JAVAC_SERVER)
- if test "x$ENABLE_JAVAC_SERVER" = "xyes" || "x$ENABLE_SJAVAC" = "xyes"; then
+ if test "x$ENABLE_JAVAC_SERVER" = "xyes" || test "x$ENABLE_SJAVAC" = "xyes"; then
# When using a server javac, the small client instances do not need much
# resources.
JAVA_FLAGS_JAVAC="$JAVA_FLAGS_SMALL"
--- a/common/autoconf/configure.ac Thu Apr 21 20:49:11 2016 -0700
+++ b/common/autoconf/configure.ac Fri Apr 22 01:04:00 2016 -0700
@@ -227,6 +227,7 @@
HOTSPOT_SETUP_BUILD_TWEAKS
JDKOPT_DETECT_INTREE_EC
+JDKOPT_ENABLE_DISABLE_FAILURE_HANDLER
###############################################################################
#
--- a/common/autoconf/generated-configure.sh Thu Apr 21 20:49:11 2016 -0700
+++ b/common/autoconf/generated-configure.sh Fri Apr 22 01:04:00 2016 -0700
@@ -650,6 +650,7 @@
JOBS
MEMORY_SIZE
NUM_CORES
+BUILD_FAILURE_HANDLER
ENABLE_INTREE_EC
HOTSPOT_MAKE_ARGS
LIBZIP_CAN_USE_MMAP
@@ -1172,6 +1173,7 @@
with_dxsdk
with_dxsdk_lib
with_dxsdk_include
+enable_jtreg_failure_handler
with_num_cores
with_memory_size
with_jobs
@@ -1940,6 +1942,12 @@
disable bundling of the freetype library with the
build result [enabled on Windows or when using
--with-freetype, disabled otherwise]
+ --enable-jtreg-failure-handler
+ forces build of the jtreg failure handler to be
+ enabled, missing dependencies become fatal errors.
+ Default is auto, where the failure handler is built
+ if all dependencies are present and otherwise just
+ disabled.
--enable-sjavac use sjavac to do fast incremental compiles
[disabled]
--disable-javac-server disable javac server [enabled]
@@ -4274,6 +4282,12 @@
#
+################################################################################
+#
+# Check if building of the jtreg failure handler should be enabled.
+#
+
+
#
# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -4950,7 +4964,7 @@
#CUSTOM_AUTOCONF_INCLUDE
# Do not change or remove the following line, it is needed for consistency checks:
-DATE_WHEN_GENERATED=1458755892
+DATE_WHEN_GENERATED=1460963400
###############################################################################
#
@@ -29770,13 +29784,13 @@
- $ECHO "Check if jvm arg is ok: -Xpatch:" >&5
- $ECHO "Command: $JAVA -Xpatch: -version" >&5
- OUTPUT=`$JAVA -Xpatch: -version 2>&1`
+ $ECHO "Check if jvm arg is ok: -Xpatch:foo=bar" >&5
+ $ECHO "Command: $JAVA -Xpatch:foo=bar -version" >&5
+ OUTPUT=`$JAVA -Xpatch:foo=bar -version 2>&1`
FOUND_WARN=`$ECHO "$OUTPUT" | grep -i warn`
FOUND_VERSION=`$ECHO $OUTPUT | grep " version \""`
if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then
- dummy="$dummy -Xpatch:"
+ dummy="$dummy -Xpatch:foo=bar"
JVM_ARG_OK=true
else
$ECHO "Arg failed:" >&5
@@ -29856,10 +29870,10 @@
BUILD_JDK_VERSION=`"$BUILD_JDK/bin/java" -version 2>&1 | head -n 1`
# Extra M4 quote needed to protect [] in grep expression.
- FOUND_CORRECT_VERSION=`echo $BUILD_JDK_VERSION | grep '\"1\.[9]\.'`
+ FOUND_CORRECT_VERSION=`echo $BUILD_JDK_VERSION | $EGREP '\"9([\.+-].*)?\"'`
if test "x$FOUND_CORRECT_VERSION" = x; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BUILD_JDK is incorrect JDK version ($BUILD_JDK_VERSION); ignoring" >&5
-$as_echo "$as_me: Potential Boot JDK found at $BUILD_JDK is incorrect JDK version ($BUILD_JDK_VERSION); ignoring" >&6;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Build JDK found at $BUILD_JDK is incorrect JDK version ($BUILD_JDK_VERSION); ignoring" >&5
+$as_echo "$as_me: Potential Build JDK found at $BUILD_JDK is incorrect JDK version ($BUILD_JDK_VERSION); ignoring" >&6;}
{ $as_echo "$as_me:${as_lineno-$LINENO}: (Your Build JDK must be version 9)" >&5
$as_echo "$as_me: (Your Build JDK must be version 9)" >&6;}
BUILD_JDK_FOUND=no
@@ -62037,6 +62051,45 @@
+ # Check whether --enable-jtreg-failure-handler was given.
+if test "${enable_jtreg_failure_handler+set}" = set; then :
+ enableval=$enable_jtreg_failure_handler;
+fi
+
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if jtreg failure handler should be built" >&5
+$as_echo_n "checking if jtreg failure handler should be built... " >&6; }
+
+ if test "x$enable_jtreg_failure_handler" = "xyes"; then
+ if test "x$JT_HOME" = "x"; then
+ as_fn_error $? "Cannot enable jtreg failure handler without jtreg." "$LINENO" 5
+ else
+ BUILD_FAILURE_HANDLER=true
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes, forced" >&5
+$as_echo "yes, forced" >&6; }
+ fi
+ elif test "x$enable_jtreg_failure_handler" = "xno"; then
+ BUILD_FAILURE_HANDLER=false
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, forced" >&5
+$as_echo "no, forced" >&6; }
+ elif test "x$enable_jtreg_failure_handler" = "xauto" \
+ || test "x$enable_jtreg_failure_handler" = "x"; then
+ if test "x$JT_HOME" = "x"; then
+ BUILD_FAILURE_HANDLER=false
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, missing jtreg" >&5
+$as_echo "no, missing jtreg" >&6; }
+ else
+ BUILD_FAILURE_HANDLER=true
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes, jtreg present" >&5
+$as_echo "yes, jtreg present" >&6; }
+ fi
+ else
+ as_fn_error $? "Invalid value for --enable-jtreg-failure-handler: $enable_jtreg_failure_handler" "$LINENO" 5
+ fi
+
+
+
+
###############################################################################
#
# Configure parts of the build that only affect the build performance,
@@ -62510,7 +62563,7 @@
$as_echo "$ENABLE_JAVAC_SERVER" >&6; }
- if test "x$ENABLE_JAVAC_SERVER" = "xyes" || "x$ENABLE_SJAVAC" = "xyes"; then
+ if test "x$ENABLE_JAVAC_SERVER" = "xyes" || test "x$ENABLE_SJAVAC" = "xyes"; then
# When using a server javac, the small client instances do not need much
# resources.
JAVA_FLAGS_JAVAC="$JAVA_FLAGS_SMALL"
--- a/common/autoconf/jdk-options.m4 Thu Apr 21 20:49:11 2016 -0700
+++ b/common/autoconf/jdk-options.m4 Fri Apr 22 01:04:00 2016 -0700
@@ -408,7 +408,7 @@
################################################################################
#
-# jlink options.
+# jlink options.
# We always keep packaged modules in JDK image.
#
AC_DEFUN_ONCE([JDKOPT_SETUP_JLINK_OPTIONS],
@@ -433,3 +433,42 @@
AC_SUBST(JLINK_KEEP_PACKAGED_MODULES)
])
+
+################################################################################
+#
+# Check if building of the jtreg failure handler should be enabled.
+#
+AC_DEFUN_ONCE([JDKOPT_ENABLE_DISABLE_FAILURE_HANDLER],
+[
+ AC_ARG_ENABLE([jtreg-failure-handler], [AS_HELP_STRING([--enable-jtreg-failure-handler],
+ [forces build of the jtreg failure handler to be enabled, missing dependencies
+ become fatal errors. Default is auto, where the failure handler is built if all
+ dependencies are present and otherwise just disabled.])])
+
+ AC_MSG_CHECKING([if jtreg failure handler should be built])
+
+ if test "x$enable_jtreg_failure_handler" = "xyes"; then
+ if test "x$JT_HOME" = "x"; then
+ AC_MSG_ERROR([Cannot enable jtreg failure handler without jtreg.])
+ else
+ BUILD_FAILURE_HANDLER=true
+ AC_MSG_RESULT([yes, forced])
+ fi
+ elif test "x$enable_jtreg_failure_handler" = "xno"; then
+ BUILD_FAILURE_HANDLER=false
+ AC_MSG_RESULT([no, forced])
+ elif test "x$enable_jtreg_failure_handler" = "xauto" \
+ || test "x$enable_jtreg_failure_handler" = "x"; then
+ if test "x$JT_HOME" = "x"; then
+ BUILD_FAILURE_HANDLER=false
+ AC_MSG_RESULT([no, missing jtreg])
+ else
+ BUILD_FAILURE_HANDLER=true
+ AC_MSG_RESULT([yes, jtreg present])
+ fi
+ else
+ AC_MSG_ERROR([Invalid value for --enable-jtreg-failure-handler: $enable_jtreg_failure_handler])
+ fi
+
+ AC_SUBST(BUILD_FAILURE_HANDLER)
+])
--- a/common/autoconf/spec.gmk.in Thu Apr 21 20:49:11 2016 -0700
+++ b/common/autoconf/spec.gmk.in Fri Apr 22 01:04:00 2016 -0700
@@ -260,6 +260,8 @@
BUILD_HOTSPOT=@BUILD_HOTSPOT@
+BUILD_FAILURE_HANDLER := @BUILD_FAILURE_HANDLER@
+
# The boot jdk to use. This is overridden in bootcycle-spec.gmk. Make sure to keep
# it in sync.
BOOT_JDK:=@BOOT_JDK@
--- a/common/bin/compare.sh Thu Apr 21 20:49:11 2016 -0700
+++ b/common/bin/compare.sh Fri Apr 22 01:04:00 2016 -0700
@@ -41,7 +41,7 @@
STAT_PRINT_SIZE="-f %z"
elif [ "$OPENJDK_TARGET_OS" = "windows" ]; then
FULLDUMP_CMD="$DUMPBIN -all"
- LDD_CMD="$DUMPBIN -dependants | $GREP .dll"
+ LDD_CMD="$DUMPBIN -dependents"
DIS_CMD="$DUMPBIN -disasm:nobytes"
STAT_PRINT_SIZE="-c %s"
elif [ "$OPENJDK_TARGET_OS" = "aix" ]; then
@@ -824,12 +824,25 @@
# Check dependencies
if [ -n "$LDD_CMD" ]; then
- (cd $FILE_WORK_DIR && $CP $OTHER_FILE . && $LDD_CMD $NAME 2>/dev/null | $AWK '{ print $1;}' | $SORT | $TEE $WORK_FILE_BASE.deps.other | $UNIQ > $WORK_FILE_BASE.deps.other.uniq)
- (cd $FILE_WORK_DIR && $CP $THIS_FILE . && $LDD_CMD $NAME 2</dev/null | $AWK '{ print $1;}' | $SORT | $TEE $WORK_FILE_BASE.deps.this | $UNIQ > $WORK_FILE_BASE.deps.this.uniq)
+ if [ "$OPENJDK_TARGET_OS" = "windows" ]; then
+ LDD_FILTER="$GREP \.dll"
+ else
+ LDD_FILTER="$CAT"
+ fi
+ (cd $FILE_WORK_DIR && $CP $OTHER_FILE . && $LDD_CMD $NAME 2>/dev/null \
+ | $LDD_FILTER | $AWK '{ print $1;}' | $SORT \
+ | $TEE $WORK_FILE_BASE.deps.other \
+ | $UNIQ > $WORK_FILE_BASE.deps.other.uniq)
+ (cd $FILE_WORK_DIR && $CP $THIS_FILE . && $LDD_CMD $NAME 2</dev/null \
+ | $LDD_FILTER | $AWK '{ print $1;}' | $SORT \
+ | $TEE $WORK_FILE_BASE.deps.this \
+ | $UNIQ > $WORK_FILE_BASE.deps.this.uniq)
(cd $FILE_WORK_DIR && $RM -f $NAME)
- LC_ALL=C $DIFF $WORK_FILE_BASE.deps.other $WORK_FILE_BASE.deps.this > $WORK_FILE_BASE.deps.diff
- LC_ALL=C $DIFF $WORK_FILE_BASE.deps.other.uniq $WORK_FILE_BASE.deps.this.uniq > $WORK_FILE_BASE.deps.diff.uniq
+ LC_ALL=C $DIFF $WORK_FILE_BASE.deps.other $WORK_FILE_BASE.deps.this \
+ > $WORK_FILE_BASE.deps.diff
+ LC_ALL=C $DIFF $WORK_FILE_BASE.deps.other.uniq $WORK_FILE_BASE.deps.this.uniq \
+ > $WORK_FILE_BASE.deps.diff.uniq
if [ -s $WORK_FILE_BASE.deps.diff ]; then
if [ -s $WORK_FILE_BASE.deps.diff.uniq ]; then
--- a/common/conf/jib-profiles.js Thu Apr 21 20:49:11 2016 -0700
+++ b/common/conf/jib-profiles.js Fri Apr 22 01:04:00 2016 -0700
@@ -214,7 +214,7 @@
var getJibProfilesCommon = function (input) {
var common = {
dependencies: ["boot_jdk", "gnumake", "jtreg"],
- configure_args: ["--with-default-make-target=all"],
+ configure_args: ["--with-default-make-target=all", "--enable-jtreg-failure-handler"],
configure_args_32bit: ["--with-target-bits=32", "--with-jvm-variants=client,server"],
configure_args_debug: ["--enable-debug"],
configure_args_slowdebug: ["--with-debug-level=slowdebug"],
--- a/corba/.hgtags Thu Apr 21 20:49:11 2016 -0700
+++ b/corba/.hgtags Fri Apr 22 01:04:00 2016 -0700
@@ -356,3 +356,4 @@
2bb92dd44275679edb29fdbffc3b7cbebc9a6bf0 jdk-9+111
780d0620add32bf545471cf65038c9ac6d9c036d jdk-9+112
cc30faa2da498c478e89ab062ff160653ca1b170 jdk-9+113
+10d175b0368c30f54350fc648adc41b94ce357ee jdk-9+114
--- a/corba/src/java.corba/share/classes/sun/corba/Bridge.java Thu Apr 21 20:49:11 2016 -0700
+++ b/corba/src/java.corba/share/classes/sun/corba/Bridge.java Fri Apr 22 01:04:00 2016 -0700
@@ -37,7 +37,7 @@
import java.security.PrivilegedAction;
import jdk.internal.misc.Unsafe ;
-import sun.reflect.ReflectionFactory ;
+import jdk.internal.reflect.ReflectionFactory;
/** This class provides the methods for fundamental JVM operations
* needed in the ORB that are not part of the public Java API. This includes:
--- a/hotspot/.hgtags Thu Apr 21 20:49:11 2016 -0700
+++ b/hotspot/.hgtags Fri Apr 22 01:04:00 2016 -0700
@@ -517,3 +517,4 @@
76582e8dc9e6374e4f99ab797c8d364b6e9449b4 jdk-9+112
c569f8d89269fb6205b90f727581eb8cc04132f9 jdk-9+113
b64432bae5271735fd53300b2005b713e98ef411 jdk-9+114
+88dd08d7be0fe7fb9f1914b1628f0aae9bf56e25 jdk-9+115
--- a/hotspot/make/test/JtregNative.gmk Thu Apr 21 20:49:11 2016 -0700
+++ b/hotspot/make/test/JtregNative.gmk Fri Apr 22 01:04:00 2016 -0700
@@ -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
@@ -47,6 +47,7 @@
$(HOTSPOT_TOPDIR)/test/runtime/jni/ToStringInInterfaceTest \
$(HOTSPOT_TOPDIR)/test/runtime/modules/getModuleJNI \
$(HOTSPOT_TOPDIR)/test/runtime/SameObject \
+ $(HOTSPOT_TOPDIR)/test/runtime/BoolReturn \
$(HOTSPOT_TOPDIR)/test/compiler/floatingpoint/ \
$(HOTSPOT_TOPDIR)/test/compiler/calls \
$(HOTSPOT_TOPDIR)/test/compiler/native \
--- a/hotspot/src/cpu/sparc/vm/c1_LIRGenerator_sparc.cpp Thu Apr 21 20:49:11 2016 -0700
+++ b/hotspot/src/cpu/sparc/vm/c1_LIRGenerator_sparc.cpp Fri Apr 22 01:04:00 2016 -0700
@@ -344,7 +344,7 @@
length.set_instruction(x->length());
length.load_item();
}
- if (needs_store_check) {
+ if (needs_store_check || x->check_boolean()) {
value.load_item();
} else {
value.load_for_store(x->elt_type());
@@ -389,7 +389,8 @@
pre_barrier(LIR_OprFact::address(array_addr), LIR_OprFact::illegalOpr /* pre_val */,
true /* do_load */, false /* patch */, NULL);
}
- __ move(value.result(), array_addr, null_check_info);
+ LIR_Opr result = maybe_mask_boolean(x, array.result(), value.result(), null_check_info);
+ __ move(result, array_addr, null_check_info);
if (obj_store) {
// Precise card mark
post_barrier(LIR_OprFact::address(array_addr), value.result());
--- a/hotspot/src/cpu/sparc/vm/interp_masm_sparc.cpp Thu Apr 21 20:49:11 2016 -0700
+++ b/hotspot/src/cpu/sparc/vm/interp_masm_sparc.cpp Fri Apr 22 01:04:00 2016 -0700
@@ -208,6 +208,7 @@
case atos: ld_ptr(oop_addr, Otos_l);
st_ptr(G0, oop_addr); break;
case btos: // fall through
+ case ztos: // fall through
case ctos: // fall through
case stos: // fall through
case itos: ld(val_addr, Otos_l1); break;
@@ -452,9 +453,10 @@
interp_verify_oop(Otos_i, state, __FILE__, __LINE__);
switch (state) {
case atos: push_ptr(); break;
- case btos: push_i(); break;
- case ctos:
- case stos: push_i(); break;
+ case btos: // fall through
+ case ztos: // fall through
+ case ctos: // fall through
+ case stos: // fall through
case itos: push_i(); break;
case ltos: push_l(); break;
case ftos: push_f(); break;
@@ -468,9 +470,10 @@
void InterpreterMacroAssembler::pop(TosState state) {
switch (state) {
case atos: pop_ptr(); break;
- case btos: pop_i(); break;
- case ctos:
- case stos: pop_i(); break;
+ case btos: // fall through
+ case ztos: // fall through
+ case ctos: // fall through
+ case stos: // fall through
case itos: pop_i(); break;
case ltos: pop_l(); break;
case ftos: pop_f(); break;
@@ -1103,6 +1106,49 @@
interp_verify_oop(Otos_i, state, __FILE__, __LINE__);
}
+void InterpreterMacroAssembler::narrow(Register result) {
+
+ ld_ptr(Address(Lmethod, Method::const_offset()), G3_scratch);
+ ldub(G3_scratch, in_bytes(ConstMethod::result_type_offset()), G3_scratch);
+
+ Label notBool, notByte, notChar, done;
+
+ // common case first
+ cmp(G3_scratch, T_INT);
+ br(Assembler::equal, true, pn, done);
+ delayed()->nop();
+
+ cmp(G3_scratch, T_BOOLEAN);
+ br(Assembler::notEqual, true, pn, notBool);
+ delayed()->cmp(G3_scratch, T_BYTE);
+ and3(result, 1, result);
+ ba(done);
+ delayed()->nop();
+
+ bind(notBool);
+ // cmp(G3_scratch, T_BYTE);
+ br(Assembler::notEqual, true, pn, notByte);
+ delayed()->cmp(G3_scratch, T_CHAR);
+ sll(result, 24, result);
+ sra(result, 24, result);
+ ba(done);
+ delayed()->nop();
+
+ bind(notByte);
+ // cmp(G3_scratch, T_CHAR);
+ sll(result, 16, result);
+ br(Assembler::notEqual, true, pn, done);
+ delayed()->sra(result, 16, result);
+ // sll(result, 16, result);
+ srl(result, 16, result);
+
+ // bind(notChar);
+ // must be short, instructions already executed in delay slot
+ // sll(result, 16, result);
+ // sra(result, 16, result);
+
+ bind(done);
+}
// remove activation
//
@@ -1151,6 +1197,7 @@
case ltos: mov(Otos_l2, Otos_l2->after_save()); // fall through // O1 -> I1
#endif
case btos: // fall through
+ case ztos: // fall through
case ctos:
case stos: // fall through
case atos: // fall through
--- a/hotspot/src/cpu/sparc/vm/interp_masm_sparc.hpp Thu Apr 21 20:49:11 2016 -0700
+++ b/hotspot/src/cpu/sparc/vm/interp_masm_sparc.hpp Fri Apr 22 01:04:00 2016 -0700
@@ -103,6 +103,8 @@
void dispatch_via (TosState state, address* table);
+ void narrow(Register result);
+
// Removes the current activation (incl. unlocking of monitors).
// Additionally this code is used for earlyReturn in which case we
// want to skip throwing an exception and installing an exception.
--- a/hotspot/src/cpu/sparc/vm/templateTable_sparc.cpp Thu Apr 21 20:49:11 2016 -0700
+++ b/hotspot/src/cpu/sparc/vm/templateTable_sparc.cpp Fri Apr 22 01:04:00 2016 -0700
@@ -165,6 +165,7 @@
switch (bc) {
case Bytecodes::_fast_aputfield:
case Bytecodes::_fast_bputfield:
+ case Bytecodes::_fast_zputfield:
case Bytecodes::_fast_cputfield:
case Bytecodes::_fast_dputfield:
case Bytecodes::_fast_fputfield:
@@ -922,8 +923,20 @@
transition(itos, vtos);
__ pop_i(O2); // index
// Otos_i: val
+ // O2: index
// O3: array
__ index_check(O3, O2, 0, G3_scratch, O2);
+ // Need to check whether array is boolean or byte
+ // since both types share the bastore bytecode.
+ __ load_klass(O3, G4_scratch);
+ __ ld(G4_scratch, in_bytes(Klass::layout_helper_offset()), G4_scratch);
+ __ set(Klass::layout_helper_boolean_diffbit(), G3_scratch);
+ __ andcc(G3_scratch, G4_scratch, G0);
+ Label L_skip;
+ __ br(Assembler::zero, false, Assembler::pn, L_skip);
+ __ delayed()->nop();
+ __ and3(Otos_i, 1, Otos_i); // if it is a T_BOOLEAN array, mask the stored value to 0/1
+ __ bind(L_skip);
__ stb(Otos_i, O2, arrayOopDesc::base_offset_in_bytes(T_BYTE));
}
@@ -2008,6 +2021,12 @@
__ bind(skip_register_finalizer);
}
+ // Narrow result if state is itos but result type is smaller.
+ // Need to narrow in the return bytecode rather than in generate_return_entry
+ // since compiled code callers expect the result to already be narrowed.
+ if (state == itos) {
+ __ narrow(Otos_i);
+ }
__ remove_activation(state, /* throw_monitor_exception */ true);
// The caller's SP was adjusted upon method entry to accomodate
@@ -2218,7 +2237,7 @@
Label checkVolatile;
// compute field type
- Label notByte, notInt, notShort, notChar, notLong, notFloat, notObj;
+ Label notByte, notBool, notInt, notShort, notChar, notLong, notFloat, notObj;
__ srl(Rflags, ConstantPoolCacheEntry::tos_state_shift, Rflags);
// Make sure we don't need to mask Rflags after the above shift
ConstantPoolCacheEntry::verify_tos_state_shift();
@@ -2273,7 +2292,7 @@
// cmp(Rflags, btos);
__ br(Assembler::notEqual, false, Assembler::pt, notByte);
- __ delayed() ->cmp(Rflags, ctos);
+ __ delayed() ->cmp(Rflags, ztos);
// btos
__ ldsb(Rclass, Roffset, Otos_i);
@@ -2286,6 +2305,22 @@
__ bind(notByte);
+ // cmp(Rflags, ztos);
+ __ br(Assembler::notEqual, false, Assembler::pt, notBool);
+ __ delayed() ->cmp(Rflags, ctos);
+
+ // ztos
+ __ ldsb(Rclass, Roffset, Otos_i);
+ __ push(itos);
+ if (!is_static && rc == may_rewrite) {
+ // use btos rewriting, no truncating to t/f bit is needed for getfield.
+ patch_bytecode(Bytecodes::_fast_bgetfield, G3_scratch, G4_scratch);
+ }
+ __ ba(checkVolatile);
+ __ delayed()->tst(Lscratch);
+
+ __ bind(notBool);
+
// cmp(Rflags, ctos);
__ br(Assembler::notEqual, false, Assembler::pt, notChar);
__ delayed() ->cmp(Rflags, stos);
@@ -2449,6 +2484,7 @@
switch (bytecode()) { // save tos values before call_VM() clobbers them
case Bytecodes::_fast_aputfield: __ push_ptr(Otos_i); break;
case Bytecodes::_fast_bputfield: // fall through
+ case Bytecodes::_fast_zputfield: // fall through
case Bytecodes::_fast_sputfield: // fall through
case Bytecodes::_fast_cputfield: // fall through
case Bytecodes::_fast_iputfield: __ push_i(Otos_i); break;
@@ -2466,6 +2502,7 @@
switch (bytecode()) { // restore tos values
case Bytecodes::_fast_aputfield: __ pop_ptr(Otos_i); break;
case Bytecodes::_fast_bputfield: // fall through
+ case Bytecodes::_fast_zputfield: // fall through
case Bytecodes::_fast_sputfield: // fall through
case Bytecodes::_fast_cputfield: // fall through
case Bytecodes::_fast_iputfield: __ pop_i(Otos_i); break;
@@ -2581,7 +2618,7 @@
ConstantPoolCacheEntry::verify_tos_state_shift();
// compute field type
- Label notInt, notShort, notChar, notObj, notByte, notLong, notFloat;
+ Label notInt, notShort, notChar, notObj, notByte, notBool, notLong, notFloat;
if (is_static) {
// putstatic with object type most likely, check that first
@@ -2649,7 +2686,7 @@
// cmp(Rflags, btos);
__ br(Assembler::notEqual, false, Assembler::pt, notByte);
- __ delayed()->cmp(Rflags, ltos);
+ __ delayed()->cmp(Rflags, ztos);
// btos
{
@@ -2664,6 +2701,25 @@
}
__ bind(notByte);
+
+ // cmp(Rflags, btos);
+ __ br(Assembler::notEqual, false, Assembler::pt, notBool);
+ __ delayed()->cmp(Rflags, ltos);
+
+ // ztos
+ {
+ __ pop_i();
+ if (!is_static) pop_and_check_object(Rclass);
+ __ and3(Otos_i, 1, Otos_i);
+ __ stb(Otos_i, Rclass, Roffset);
+ if (!is_static && rc == may_rewrite) {
+ patch_bytecode(Bytecodes::_fast_zputfield, G3_scratch, G4_scratch, true, byte_no);
+ }
+ __ ba(checkVolatile);
+ __ delayed()->tst(Lscratch);
+ }
+
+ __ bind(notBool);
// cmp(Rflags, ltos);
__ br(Assembler::notEqual, false, Assembler::pt, notLong);
__ delayed()->cmp(Rflags, ctos);
@@ -2787,6 +2843,7 @@
pop_and_check_object(Rclass);
switch (bytecode()) {
+ case Bytecodes::_fast_zputfield: __ and3(Otos_i, 1, Otos_i); // fall through to bputfield
case Bytecodes::_fast_bputfield: __ stb(Otos_i, Rclass, Roffset); break;
case Bytecodes::_fast_cputfield: /* fall through */
case Bytecodes::_fast_sputfield: __ sth(Otos_i, Rclass, Roffset); break;
--- a/hotspot/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp Thu Apr 21 20:49:11 2016 -0700
+++ b/hotspot/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp Fri Apr 22 01:04:00 2016 -0700
@@ -284,7 +284,7 @@
length.load_item();
}
- if (needs_store_check) {
+ if (needs_store_check || x->check_boolean()) {
value.load_item();
} else {
value.load_for_store(x->elt_type());
@@ -332,7 +332,8 @@
// Seems to be a precise
post_barrier(LIR_OprFact::address(array_addr), value.result());
} else {
- __ move(value.result(), array_addr, null_check_info);
+ LIR_Opr result = maybe_mask_boolean(x, array.result(), value.result(), null_check_info);
+ __ move(result, array_addr, null_check_info);
}
}
--- a/hotspot/src/cpu/x86/vm/interp_masm_x86.cpp Thu Apr 21 20:49:11 2016 -0700
+++ b/hotspot/src/cpu/x86/vm/interp_masm_x86.cpp Fri Apr 22 01:04:00 2016 -0700
@@ -349,6 +349,7 @@
verify_oop(rax, state); break;
case ltos: movptr(rax, val_addr); break;
case btos: // fall through
+ case ztos: // fall through
case ctos: // fall through
case stos: // fall through
case itos: movl(rax, val_addr); break;
@@ -370,6 +371,7 @@
case ltos:
movl(rdx, val_addr1); // fall through
case btos: // fall through
+ case ztos: // fall through
case ctos: // fall through
case stos: // fall through
case itos: movl(rax, val_addr); break;
@@ -616,6 +618,7 @@
switch (state) {
case atos: pop_ptr(); break;
case btos:
+ case ztos:
case ctos:
case stos:
case itos: pop_i(); break;
@@ -633,6 +636,7 @@
switch (state) {
case atos: push_ptr(); break;
case btos:
+ case ztos:
case ctos:
case stos:
case itos: push_i(); break;
@@ -668,6 +672,7 @@
switch (state) {
case atos: pop_ptr(rax); break;
case btos: // fall through
+ case ztos: // fall through
case ctos: // fall through
case stos: // fall through
case itos: pop_i(rax); break;
@@ -716,6 +721,7 @@
switch (state) {
case atos: push_ptr(rax); break;
case btos: // fall through
+ case ztos: // fall through
case ctos: // fall through
case stos: // fall through
case itos: push_i(rax); break;
@@ -849,6 +855,51 @@
dispatch_base(state, table);
}
+void InterpreterMacroAssembler::narrow(Register result) {
+
+ // Get method->_constMethod->_result_type
+ movptr(rcx, Address(rbp, frame::interpreter_frame_method_offset * wordSize));
+ movptr(rcx, Address(rcx, Method::const_offset()));
+ load_unsigned_byte(rcx, Address(rcx, ConstMethod::result_type_offset()));
+
+ Label done, notBool, notByte, notChar;
+
+ // common case first
+ cmpl(rcx, T_INT);
+ jcc(Assembler::equal, done);
+
+ // mask integer result to narrower return type.
+ cmpl(rcx, T_BOOLEAN);
+ jcc(Assembler::notEqual, notBool);
+ andl(result, 0x1);
+ jmp(done);
+
+ bind(notBool);
+ cmpl(rcx, T_BYTE);
+ jcc(Assembler::notEqual, notByte);
+ LP64_ONLY(movsbl(result, result);)
+ NOT_LP64(shll(result, 24);) // truncate upper 24 bits
+ NOT_LP64(sarl(result, 24);) // and sign-extend byte
+ jmp(done);
+
+ bind(notByte);
+ cmpl(rcx, T_CHAR);
+ jcc(Assembler::notEqual, notChar);
+ LP64_ONLY(movzwl(result, result);)
+ NOT_LP64(andl(result, 0xFFFF);) // truncate upper 16 bits
+ jmp(done);
+
+ bind(notChar);
+ // cmpl(rcx, T_SHORT); // all that's left
+ // jcc(Assembler::notEqual, done);
+ LP64_ONLY(movswl(result, result);)
+ NOT_LP64(shll(result, 16);) // truncate upper 16 bits
+ NOT_LP64(sarl(result, 16);) // and sign-extend short
+
+ // Nothing to do for T_INT
+ bind(done);
+}
+
// remove activation
//
// Unlock the receiver if this is a synchronized method.
--- a/hotspot/src/cpu/x86/vm/interp_masm_x86.hpp Thu Apr 21 20:49:11 2016 -0700
+++ b/hotspot/src/cpu/x86/vm/interp_masm_x86.hpp Fri Apr 22 01:04:00 2016 -0700
@@ -192,6 +192,9 @@
void prepare_to_jump_from_interpreted();
void jump_from_interpreted(Register method, Register temp);
+ // narrow int return value
+ void narrow(Register result);
+
// Returning from interpreted functions
//
// Removes the current activation (incl. unlocking of monitors)
--- a/hotspot/src/cpu/x86/vm/templateTable_x86.cpp Thu Apr 21 20:49:11 2016 -0700
+++ b/hotspot/src/cpu/x86/vm/templateTable_x86.cpp Fri Apr 22 01:04:00 2016 -0700
@@ -243,6 +243,7 @@
switch (bc) {
case Bytecodes::_fast_aputfield:
case Bytecodes::_fast_bputfield:
+ case Bytecodes::_fast_zputfield:
case Bytecodes::_fast_cputfield:
case Bytecodes::_fast_dputfield:
case Bytecodes::_fast_fputfield:
@@ -1082,6 +1083,16 @@
// rbx: index
// rdx: array
index_check(rdx, rbx); // prefer index in rbx
+ // Need to check whether array is boolean or byte
+ // since both types share the bastore bytecode.
+ __ load_klass(rcx, rdx);
+ __ movl(rcx, Address(rcx, Klass::layout_helper_offset()));
+ int diffbit = Klass::layout_helper_boolean_diffbit();
+ __ testl(rcx, diffbit);
+ Label L_skip;
+ __ jccb(Assembler::zero, L_skip);
+ __ andl(rax, 1); // if it is a T_BOOLEAN array, mask the stored value to 0/1
+ __ bind(L_skip);
__ movb(Address(rdx, rbx,
Address::times_1,
arrayOopDesc::base_offset_in_bytes(T_BYTE)),
@@ -2540,13 +2551,12 @@
void TemplateTable::_return(TosState state) {
transition(state, state);
- Register robj = LP64_ONLY(c_rarg1) NOT_LP64(rax);
-
assert(_desc->calls_vm(),
"inconsistent calls_vm information"); // call in remove_activation
if (_desc->bytecode() == Bytecodes::_return_register_finalizer) {
assert(state == vtos, "only valid state");
+ Register robj = LP64_ONLY(c_rarg1) NOT_LP64(rax);
__ movptr(robj, aaddress(0));
__ load_klass(rdi, robj);
__ movl(rdi, Address(rdi, Klass::access_flags_offset()));
@@ -2559,7 +2569,14 @@
__ bind(skip_register_finalizer);
}
+ // Narrow result if state is itos but result type is smaller.
+ // Need to narrow in the return bytecode rather than in generate_return_entry
+ // since compiled code callers expect the result to already be narrowed.
+ if (state == itos) {
+ __ narrow(rax);
+ }
__ remove_activation(state, rbcp);
+
__ jmp(rbcp);
}
@@ -2754,7 +2771,7 @@
const Address field(obj, off, Address::times_1, 0*wordSize);
NOT_LP64(const Address hi(obj, off, Address::times_1, 1*wordSize));
- Label Done, notByte, notInt, notShort, notChar, notLong, notFloat, notObj, notDouble;
+ Label Done, notByte, notBool, notInt, notShort, notChar, notLong, notFloat, notObj, notDouble;
__ shrl(flags, ConstantPoolCacheEntry::tos_state_shift);
// Make sure we don't need to mask edx after the above shift
@@ -2773,6 +2790,20 @@
__ jmp(Done);
__ bind(notByte);
+ __ cmpl(flags, ztos);
+ __ jcc(Assembler::notEqual, notBool);
+
+ // ztos (same code as btos)
+ __ load_signed_byte(rax, field);
+ __ push(ztos);
+ // Rewrite bytecode to be faster
+ if (!is_static && rc == may_rewrite) {
+ // use btos rewriting, no truncating to t/f bit is needed for getfield.
+ patch_bytecode(Bytecodes::_fast_bgetfield, bc, rbx);
+ }
+ __ jmp(Done);
+
+ __ bind(notBool);
__ cmpl(flags, atos);
__ jcc(Assembler::notEqual, notObj);
// atos
@@ -3006,7 +3037,7 @@
const Address field(obj, off, Address::times_1, 0*wordSize);
NOT_LP64( const Address hi(obj, off, Address::times_1, 1*wordSize);)
- Label notByte, notInt, notShort, notChar,
+ Label notByte, notBool, notInt, notShort, notChar,
notLong, notFloat, notObj, notDouble;
__ shrl(flags, ConstantPoolCacheEntry::tos_state_shift);
@@ -3027,6 +3058,22 @@
}
__ bind(notByte);
+ __ cmpl(flags, ztos);
+ __ jcc(Assembler::notEqual, notBool);
+
+ // ztos
+ {
+ __ pop(ztos);
+ if (!is_static) pop_and_check_object(obj);
+ __ andl(rax, 0x1);
+ __ movb(field, rax);
+ if (!is_static && rc == may_rewrite) {
+ patch_bytecode(Bytecodes::_fast_zputfield, bc, rbx, true, byte_no);
+ }
+ __ jmp(Done);
+ }
+
+ __ bind(notBool);
__ cmpl(flags, atos);
__ jcc(Assembler::notEqual, notObj);
@@ -3214,6 +3261,7 @@
switch (bytecode()) { // load values into the jvalue object
case Bytecodes::_fast_aputfield: __ push_ptr(rax); break;
case Bytecodes::_fast_bputfield: // fall through
+ case Bytecodes::_fast_zputfield: // fall through
case Bytecodes::_fast_sputfield: // fall through
case Bytecodes::_fast_cputfield: // fall through
case Bytecodes::_fast_iputfield: __ push_i(rax); break;
@@ -3238,6 +3286,7 @@
switch (bytecode()) { // restore tos values
case Bytecodes::_fast_aputfield: __ pop_ptr(rax); break;
case Bytecodes::_fast_bputfield: // fall through
+ case Bytecodes::_fast_zputfield: // fall through
case Bytecodes::_fast_sputfield: // fall through
case Bytecodes::_fast_cputfield: // fall through
case Bytecodes::_fast_iputfield: __ pop_i(rax); break;
@@ -3297,6 +3346,9 @@
case Bytecodes::_fast_iputfield:
__ movl(field, rax);
break;
+ case Bytecodes::_fast_zputfield:
+ __ andl(rax, 0x1); // boolean is true if LSB is 1
+ // fall through to bputfield
case Bytecodes::_fast_bputfield:
__ movb(field, rax);
break;
--- a/hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp Thu Apr 21 20:49:11 2016 -0700
+++ b/hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp Fri Apr 22 01:04:00 2016 -0700
@@ -82,6 +82,30 @@
return 0;
}
+intptr_t narrow(BasicType type, intptr_t result) {
+ // mask integer result to narrower return type.
+ switch (type) {
+ case T_BOOLEAN:
+ return result&1;
+ case T_BYTE:
+ return (intptr_t)(jbyte)result;
+ case T_CHAR:
+ return (intptr_t)(uintptr_t)(jchar)result;
+ case T_SHORT:
+ return (intptr_t)(jshort)result;
+ case T_OBJECT: // nothing to do fall through
+ case T_ARRAY:
+ case T_LONG:
+ case T_INT:
+ case T_FLOAT:
+ case T_DOUBLE:
+ case T_VOID:
+ return result;
+ default : ShouldNotReachHere();
+ }
+}
+
+
void CppInterpreter::main_loop(int recurse, TRAPS) {
JavaThread *thread = (JavaThread *) THREAD;
ZeroStack *stack = thread->zero_stack();
@@ -161,7 +185,7 @@
}
else if (istate->msg() == BytecodeInterpreter::return_from_method) {
// Copy the result into the caller's frame
- result_slots = type2size[result_type_of(method)];
+ result_slots = type2size[method->result_type()];
assert(result_slots >= 0 && result_slots <= 2, "what?");
result = istate->stack() + result_slots;
break;
@@ -195,8 +219,14 @@
stack->set_sp(stack->sp() + method->max_locals());
// Push our result
- for (int i = 0; i < result_slots; i++)
- stack->push(result[-i]);
+ for (int i = 0; i < result_slots; i++) {
+ // Adjust result to smaller
+ intptr_t res = result[-i];
+ if (result_slots == 1) {
+ res = narrow(method->result_type(), res);
+ }
+ stack->push(res);
+ }
}
int CppInterpreter::native_entry(Method* method, intptr_t UNUSED, TRAPS) {
@@ -407,7 +437,7 @@
// Push our result
if (!HAS_PENDING_EXCEPTION) {
- BasicType type = result_type_of(method);
+ BasicType type = method->result_type();
stack->set_sp(stack->sp() - type2size[type]);
switch (type) {
@@ -532,6 +562,7 @@
break;
case btos:
+ case ztos:
SET_LOCALS_INT(object->byte_field_acquire(entry->f2_as_index()), 0);
break;
@@ -570,6 +601,7 @@
break;
case btos:
+ case ztos:
SET_LOCALS_INT(object->byte_field(entry->f2_as_index()), 0);
break;
@@ -772,26 +804,6 @@
return (InterpreterFrame *) fp;
}
-BasicType CppInterpreter::result_type_of(Method* method) {
- BasicType t = T_ILLEGAL; // silence compiler warnings
- switch (method->result_index()) {
- case 0 : t = T_BOOLEAN; break;
- case 1 : t = T_CHAR; break;
- case 2 : t = T_BYTE; break;
- case 3 : t = T_SHORT; break;
- case 4 : t = T_INT; break;
- case 5 : t = T_LONG; break;
- case 6 : t = T_VOID; break;
- case 7 : t = T_FLOAT; break;
- case 8 : t = T_DOUBLE; break;
- case 9 : t = T_OBJECT; break;
- default: ShouldNotReachHere();
- }
- assert(AbstractInterpreter::BasicType_as_index(t) == method->result_index(),
- "out of step with AbstractInterpreter::BasicType_as_index");
- return t;
-}
-
address CppInterpreter::return_entry(TosState state, int length, Bytecodes::Code code) {
ShouldNotCallThis();
return NULL;
--- a/hotspot/src/cpu/zero/vm/cppInterpreter_zero.hpp Thu Apr 21 20:49:11 2016 -0700
+++ b/hotspot/src/cpu/zero/vm/cppInterpreter_zero.hpp Fri Apr 22 01:04:00 2016 -0700
@@ -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.
* Copyright 2007, 2008, 2010, 2011 Red Hat, Inc.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@@ -49,8 +49,4 @@
static intptr_t* calculate_unwind_sp(ZeroStack* stack, oop method_handle);
static void throw_exception(JavaThread* thread, Symbol* name,char *msg=NULL);
- private:
- // Fast result type determination
- static BasicType result_type_of(Method* method);
-
#endif // CPU_ZERO_VM_CPPINTERPRETER_ZERO_HPP
--- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/interpreter/Bytecodes.java Thu Apr 21 20:49:11 2016 -0700
+++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/interpreter/Bytecodes.java Fri Apr 22 01:04:00 2016 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -253,29 +253,30 @@
public static final int _fast_sgetfield = 210;
public static final int _fast_aputfield = 211;
public static final int _fast_bputfield = 212;
- public static final int _fast_cputfield = 213;
- public static final int _fast_dputfield = 214;
- public static final int _fast_fputfield = 215;
- public static final int _fast_iputfield = 216;
- public static final int _fast_lputfield = 217;
- public static final int _fast_sputfield = 218;
- public static final int _fast_aload_0 = 219;
- public static final int _fast_iaccess_0 = 220;
- public static final int _fast_aaccess_0 = 221;
- public static final int _fast_faccess_0 = 222;
- public static final int _fast_iload = 223;
- public static final int _fast_iload2 = 224;
- public static final int _fast_icaload = 225;
- public static final int _fast_invokevfinal = 226;
- public static final int _fast_linearswitch = 227;
- public static final int _fast_binaryswitch = 228;
- public static final int _fast_aldc = 229;
- public static final int _fast_aldc_w = 230;
- public static final int _return_register_finalizer = 231;
- public static final int _invokehandle = 232;
- public static final int _shouldnotreachhere = 233; // For debugging
+ public static final int _fast_zputfield = 213;
+ public static final int _fast_cputfield = 214;
+ public static final int _fast_dputfield = 215;
+ public static final int _fast_fputfield = 216;
+ public static final int _fast_iputfield = 217;
+ public static final int _fast_lputfield = 218;
+ public static final int _fast_sputfield = 219;
+ public static final int _fast_aload_0 = 220;
+ public static final int _fast_iaccess_0 = 221;
+ public static final int _fast_aaccess_0 = 222;
+ public static final int _fast_faccess_0 = 223;
+ public static final int _fast_iload = 224;
+ public static final int _fast_iload2 = 225;
+ public static final int _fast_icaload = 226;
+ public static final int _fast_invokevfinal = 227;
+ public static final int _fast_linearswitch = 228;
+ public static final int _fast_binaryswitch = 229;
+ public static final int _fast_aldc = 230;
+ public static final int _fast_aldc_w = 231;
+ public static final int _return_register_finalizer = 232;
+ public static final int _invokehandle = 233;
+ public static final int _shouldnotreachhere = 234; // For debugging
- public static final int number_of_codes = 234;
+ public static final int number_of_codes = 235;
// Flag bits derived from format strings, can_trap, can_rewrite, etc.:
// semantic flags:
@@ -776,6 +777,7 @@
def(_fast_aputfield , "fast_aputfield" , "bJJ" , null , BasicType.getTObject() , 0, true , _putfield );
def(_fast_bputfield , "fast_bputfield" , "bJJ" , null , BasicType.getTInt() , 0, true , _putfield );
+ def(_fast_zputfield , "fast_zputfield" , "bJJ" , null , BasicType.getTInt() , 0, true , _putfield );
def(_fast_cputfield , "fast_cputfield" , "bJJ" , null , BasicType.getTChar() , 0, true , _putfield );
def(_fast_dputfield , "fast_dputfield" , "bJJ" , null , BasicType.getTDouble() , 0, true , _putfield );
def(_fast_fputfield , "fast_fputfield" , "bJJ" , null , BasicType.getTFloat() , 0, true , _putfield );
--- a/hotspot/src/share/vm/c1/c1_Canonicalizer.cpp Thu Apr 21 20:49:11 2016 -0700
+++ b/hotspot/src/share/vm/c1/c1_Canonicalizer.cpp Fri Apr 22 01:04:00 2016 -0700
@@ -305,7 +305,8 @@
// limit this optimization to current block
if (value != NULL && in_current_block(conv)) {
set_canonical(new StoreIndexed(x->array(), x->index(), x->length(),
- x->elt_type(), value, x->state_before()));
+ x->elt_type(), value, x->state_before(),
+ x->check_boolean()));
return;
}
}
--- a/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp Thu Apr 21 20:49:11 2016 -0700
+++ b/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp Fri Apr 22 01:04:00 2016 -0700
@@ -976,7 +976,19 @@
(array->as_NewArray() && array->as_NewArray()->length() && array->as_NewArray()->length()->type()->is_constant())) {
length = append(new ArrayLength(array, state_before));
}
- StoreIndexed* result = new StoreIndexed(array, index, length, type, value, state_before);
+ ciType* array_type = array->declared_type();
+ bool check_boolean = false;
+ if (array_type != NULL) {
+ if (array_type->is_loaded() &&
+ array_type->as_array_klass()->element_type()->basic_type() == T_BOOLEAN) {
+ assert(type == T_BYTE, "boolean store uses bastore");
+ Value mask = append(new Constant(new IntConstant(1)));
+ value = append(new LogicOp(Bytecodes::_iand, value, mask));
+ }
+ } else if (type == T_BYTE) {
+ check_boolean = true;
+ }
+ StoreIndexed* result = new StoreIndexed(array, index, length, type, value, state_before, check_boolean);
append(result);
_memory->store_value(value);
@@ -1443,6 +1455,36 @@
need_mem_bar = true;
}
+ BasicType bt = method()->return_type()->basic_type();
+ switch (bt) {
+ case T_BYTE:
+ {
+ Value shift = append(new Constant(new IntConstant(24)));
+ x = append(new ShiftOp(Bytecodes::_ishl, x, shift));
+ x = append(new ShiftOp(Bytecodes::_ishr, x, shift));
+ break;
+ }
+ case T_SHORT:
+ {
+ Value shift = append(new Constant(new IntConstant(16)));
+ x = append(new ShiftOp(Bytecodes::_ishl, x, shift));
+ x = append(new ShiftOp(Bytecodes::_ishr, x, shift));
+ break;
+ }
+ case T_CHAR:
+ {
+ Value mask = append(new Constant(new IntConstant(0xFFFF)));
+ x = append(new LogicOp(Bytecodes::_iand, x, mask));
+ break;
+ }
+ case T_BOOLEAN:
+ {
+ Value mask = append(new Constant(new IntConstant(1)));
+ x = append(new LogicOp(Bytecodes::_iand, x, mask));
+ break;
+ }
+ }
+
// Check to see whether we are inlining. If so, Return
// instructions become Gotos to the continuation point.
if (continuation() != NULL) {
@@ -1612,6 +1654,10 @@
if (state_before == NULL) {
state_before = copy_state_for_exception();
}
+ if (field->type()->basic_type() == T_BOOLEAN) {
+ Value mask = append(new Constant(new IntConstant(1)));
+ val = append(new LogicOp(Bytecodes::_iand, val, mask));
+ }
append(new StoreField(append(obj), offset, field, val, true, state_before, needs_patching));
break;
}
@@ -1660,6 +1706,10 @@
if (state_before == NULL) {
state_before = copy_state_for_exception();
}
+ if (field->type()->basic_type() == T_BOOLEAN) {
+ Value mask = append(new Constant(new IntConstant(1)));
+ val = append(new LogicOp(Bytecodes::_iand, val, mask));
+ }
StoreField* store = new StoreField(obj, offset, field, val, false, state_before, needs_patching);
if (!needs_patching) store = _memory->store(store);
if (store != NULL) {
@@ -4122,7 +4172,12 @@
#ifndef _LP64
offset = append(new Convert(Bytecodes::_l2i, offset, as_ValueType(T_INT)));
#endif
- Instruction* op = append(new UnsafePutObject(t, args->at(1), offset, args->at(3), is_volatile));
+ Value val = args->at(3);
+ if (t == T_BOOLEAN) {
+ Value mask = append(new Constant(new IntConstant(1)));
+ val = append(new LogicOp(Bytecodes::_iand, val, mask));
+ }
+ Instruction* op = append(new UnsafePutObject(t, args->at(1), offset, val, is_volatile));
compilation()->set_has_unsafe_access(true);
kill_all();
}
@@ -4196,7 +4251,7 @@
Value index = args->at(1);
if (is_store) {
Value value = args->at(2);
- Instruction* store = append(new StoreIndexed(array, index, NULL, T_CHAR, value, state_before));
+ Instruction* store = append(new StoreIndexed(array, index, NULL, T_CHAR, value, state_before, false));
store->set_flag(Instruction::NeedsRangeCheckFlag, false);
_memory->store_value(value);
} else {
--- a/hotspot/src/share/vm/c1/c1_Instruction.hpp Thu Apr 21 20:49:11 2016 -0700
+++ b/hotspot/src/share/vm/c1/c1_Instruction.hpp Fri Apr 22 01:04:00 2016 -0700
@@ -970,11 +970,13 @@
ciMethod* _profiled_method;
int _profiled_bci;
+ bool _check_boolean;
+
public:
// creation
- StoreIndexed(Value array, Value index, Value length, BasicType elt_type, Value value, ValueStack* state_before)
+ StoreIndexed(Value array, Value index, Value length, BasicType elt_type, Value value, ValueStack* state_before, bool check_boolean)
: AccessIndexed(array, index, length, elt_type, state_before)
- , _value(value), _profiled_method(NULL), _profiled_bci(0)
+ , _value(value), _profiled_method(NULL), _profiled_bci(0), _check_boolean(check_boolean)
{
set_flag(NeedsWriteBarrierFlag, (as_ValueType(elt_type)->is_object()));
set_flag(NeedsStoreCheckFlag, (as_ValueType(elt_type)->is_object()));
@@ -986,6 +988,7 @@
Value value() const { return _value; }
bool needs_write_barrier() const { return check_flag(NeedsWriteBarrierFlag); }
bool needs_store_check() const { return check_flag(NeedsStoreCheckFlag); }
+ bool check_boolean() const { return _check_boolean; }
// Helpers for MethodData* profiling
void set_should_profile(bool value) { set_flag(ProfileMDOFlag, value); }
void set_profiled_method(ciMethod* method) { _profiled_method = method; }
--- a/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp Thu Apr 21 20:49:11 2016 -0700
+++ b/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp Fri Apr 22 01:04:00 2016 -0700
@@ -3682,3 +3682,26 @@
}
}
}
+
+LIR_Opr LIRGenerator::maybe_mask_boolean(StoreIndexed* x, LIR_Opr array, LIR_Opr value, CodeEmitInfo*& null_check_info) {
+ if (x->check_boolean()) {
+ LIR_Opr value_fixed = rlock_byte(T_BYTE);
+ if (TwoOperandLIRForm) {
+ __ move(value, value_fixed);
+ __ logical_and(value_fixed, LIR_OprFact::intConst(1), value_fixed);
+ } else {
+ __ logical_and(value, LIR_OprFact::intConst(1), value_fixed);
+ }
+ LIR_Opr klass = new_register(T_METADATA);
+ __ move(new LIR_Address(array, oopDesc::klass_offset_in_bytes(), T_ADDRESS), klass, null_check_info);
+ null_check_info = NULL;
+ LIR_Opr layout = new_register(T_INT);
+ __ move(new LIR_Address(klass, in_bytes(Klass::layout_helper_offset()), T_INT), layout);
+ int diffbit = Klass::layout_helper_boolean_diffbit();
+ __ logical_and(layout, LIR_OprFact::intConst(diffbit), layout);
+ __ cmp(lir_cond_notEqual, layout, LIR_OprFact::intConst(0));
+ __ cmove(lir_cond_notEqual, value_fixed, value, value_fixed, T_BYTE);
+ value = value_fixed;
+ }
+ return value;
+}
--- a/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp Thu Apr 21 20:49:11 2016 -0700
+++ b/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp Fri Apr 22 01:04:00 2016 -0700
@@ -444,6 +444,7 @@
void profile_arguments(ProfileCall* x);
void profile_parameters(Base* x);
void profile_parameters_at_call(ProfileCall* x);
+ LIR_Opr maybe_mask_boolean(StoreIndexed* x, LIR_Opr array, LIR_Opr value, CodeEmitInfo*& null_check_info);
public:
Compilation* compilation() const { return _compilation; }
--- a/hotspot/src/share/vm/classfile/classFileParser.cpp Thu Apr 21 20:49:11 2016 -0700
+++ b/hotspot/src/share/vm/classfile/classFileParser.cpp Fri Apr 22 01:04:00 2016 -0700
@@ -1967,7 +1967,7 @@
loader_data->is_platform_class_loader_data() ||
loader_data->is_anonymous();
switch (sid) {
- case vmSymbols::VM_SYMBOL_ENUM_NAME(sun_reflect_CallerSensitive_signature): {
+ case vmSymbols::VM_SYMBOL_ENUM_NAME(reflect_CallerSensitive_signature): {
if (_location != _in_method) break; // only allow for methods
if (!privileged) break; // only allow in privileged code
return _method_CallerSensitive;
@@ -2713,11 +2713,9 @@
m->set_constants(_cp);
m->set_name_index(name_index);
m->set_signature_index(signature_index);
-#ifdef CC_INTERP
- // hmm is there a gc issue here??
+
ResultTypeFinder rtf(cp->symbol_at(signature_index));
- m->set_result_index(rtf.type());
-#endif
+ m->constMethod()->set_result_type(rtf.type());
if (args_size >= 0) {
m->set_size_of_parameters(args_size);
--- a/hotspot/src/share/vm/classfile/defaultMethods.cpp Thu Apr 21 20:49:11 2016 -0700
+++ b/hotspot/src/share/vm/classfile/defaultMethods.cpp Fri Apr 22 01:04:00 2016 -0700
@@ -860,10 +860,8 @@
m->set_constants(NULL); // This will get filled in later
m->set_name_index(cp->utf8(name));
m->set_signature_index(cp->utf8(sig));
-#ifdef CC_INTERP
ResultTypeFinder rtf(sig);
- m->set_result_index(rtf.type());
-#endif
+ m->constMethod()->set_result_type(rtf.type());
m->set_size_of_parameters(params);
m->set_max_stack(max_stack);
m->set_max_locals(params);
--- a/hotspot/src/share/vm/classfile/javaClasses.cpp Thu Apr 21 20:49:11 2016 -0700
+++ b/hotspot/src/share/vm/classfile/javaClasses.cpp Fri Apr 22 01:04:00 2016 -0700
@@ -2698,7 +2698,7 @@
field->obj_field_put(type_annotations_offset, value);
}
-void sun_reflect_ConstantPool::compute_offsets() {
+void reflect_ConstantPool::compute_offsets() {
Klass* k = SystemDictionary::reflect_ConstantPool_klass();
// This null test can be removed post beta
if (k != NULL) {
@@ -2842,7 +2842,7 @@
module->address_field_put(_module_entry_offset, (address)module_entry);
}
-Handle sun_reflect_ConstantPool::create(TRAPS) {
+Handle reflect_ConstantPool::create(TRAPS) {
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
Klass* k = SystemDictionary::reflect_ConstantPool_klass();
instanceKlassHandle klass (THREAD, k);
@@ -2852,14 +2852,14 @@
}
-void sun_reflect_ConstantPool::set_cp(oop reflect, ConstantPool* value) {
+void reflect_ConstantPool::set_cp(oop reflect, ConstantPool* value) {
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
oop mirror = value->pool_holder()->java_mirror();
// Save the mirror to get back the constant pool.
reflect->obj_field_put(_oop_offset, mirror);
}
-ConstantPool* sun_reflect_ConstantPool::get_cp(oop reflect) {
+ConstantPool* reflect_ConstantPool::get_cp(oop reflect) {
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
oop mirror = reflect->obj_field(_oop_offset);
@@ -2874,7 +2874,7 @@
return InstanceKlass::cast(k)->constants();
}
-void sun_reflect_UnsafeStaticFieldAccessorImpl::compute_offsets() {
+void reflect_UnsafeStaticFieldAccessorImpl::compute_offsets() {
Klass* k = SystemDictionary::reflect_UnsafeStaticFieldAccessorImpl_klass();
// This null test can be removed post beta
if (k != NULL) {
@@ -3649,8 +3649,8 @@
int java_lang_AssertionStatusDirectives::deflt_offset;
int java_nio_Buffer::_limit_offset;
int java_util_concurrent_locks_AbstractOwnableSynchronizer::_owner_offset = 0;
-int sun_reflect_ConstantPool::_oop_offset;
-int sun_reflect_UnsafeStaticFieldAccessorImpl::_base_offset;
+int reflect_ConstantPool::_oop_offset;
+int reflect_UnsafeStaticFieldAccessorImpl::_base_offset;
// Support for java_lang_StackTraceElement
@@ -3835,8 +3835,8 @@
java_lang_reflect_Constructor::compute_offsets();
java_lang_reflect_Field::compute_offsets();
java_nio_Buffer::compute_offsets();
- sun_reflect_ConstantPool::compute_offsets();
- sun_reflect_UnsafeStaticFieldAccessorImpl::compute_offsets();
+ reflect_ConstantPool::compute_offsets();
+ reflect_UnsafeStaticFieldAccessorImpl::compute_offsets();
java_lang_reflect_Parameter::compute_offsets();
java_lang_reflect_Module::compute_offsets();
java_lang_StackFrameInfo::compute_offsets();
--- a/hotspot/src/share/vm/classfile/javaClasses.hpp Thu Apr 21 20:49:11 2016 -0700
+++ b/hotspot/src/share/vm/classfile/javaClasses.hpp Fri Apr 22 01:04:00 2016 -0700
@@ -799,8 +799,8 @@
friend class JavaClasses;
};
-// Interface to sun.reflect.ConstantPool objects
-class sun_reflect_ConstantPool {
+// Interface to jdk.internal.reflect.ConstantPool objects
+class reflect_ConstantPool {
private:
// Note that to reduce dependencies on the JDK we compute these
// offsets at run-time.
@@ -824,8 +824,8 @@
friend class JavaClasses;
};
-// Interface to sun.reflect.UnsafeStaticFieldAccessorImpl objects
-class sun_reflect_UnsafeStaticFieldAccessorImpl {
+// Interface to jdk.internal.reflect.UnsafeStaticFieldAccessorImpl objects
+class reflect_UnsafeStaticFieldAccessorImpl {
private:
static int _base_offset;
static void compute_offsets();
--- a/hotspot/src/share/vm/classfile/systemDictionary.hpp Thu Apr 21 20:49:11 2016 -0700
+++ b/hotspot/src/share/vm/classfile/systemDictionary.hpp Fri Apr 22 01:04:00 2016 -0700
@@ -142,13 +142,13 @@
\
/* NOTE: needed too early in bootstrapping process to have checks based on JDK version */ \
/* It's okay if this turns out to be NULL in non-1.4 JDKs. */ \
- do_klass(reflect_MagicAccessorImpl_klass, sun_reflect_MagicAccessorImpl, Opt ) \
- do_klass(reflect_MethodAccessorImpl_klass, sun_reflect_MethodAccessorImpl, Pre ) \
- do_klass(reflect_ConstructorAccessorImpl_klass, sun_reflect_ConstructorAccessorImpl, Pre ) \
- do_klass(reflect_DelegatingClassLoader_klass, sun_reflect_DelegatingClassLoader, Opt ) \
- do_klass(reflect_ConstantPool_klass, sun_reflect_ConstantPool, Opt ) \
- do_klass(reflect_UnsafeStaticFieldAccessorImpl_klass, sun_reflect_UnsafeStaticFieldAccessorImpl, Opt ) \
- do_klass(reflect_CallerSensitive_klass, sun_reflect_CallerSensitive, Opt ) \
+ do_klass(reflect_MagicAccessorImpl_klass, reflect_MagicAccessorImpl, Opt ) \
+ do_klass(reflect_MethodAccessorImpl_klass, reflect_MethodAccessorImpl, Pre ) \
+ do_klass(reflect_ConstructorAccessorImpl_klass, reflect_ConstructorAccessorImpl, Pre ) \
+ do_klass(reflect_DelegatingClassLoader_klass, reflect_DelegatingClassLoader, Opt ) \
+ do_klass(reflect_ConstantPool_klass, reflect_ConstantPool, Opt ) \
+ do_klass(reflect_UnsafeStaticFieldAccessorImpl_klass, reflect_UnsafeStaticFieldAccessorImpl, Opt ) \
+ do_klass(reflect_CallerSensitive_klass, reflect_CallerSensitive, Opt ) \
\
/* support for dynamic typing; it's OK if these are NULL in earlier JDKs */ \
do_klass(DirectMethodHandle_klass, java_lang_invoke_DirectMethodHandle, Opt ) \
--- a/hotspot/src/share/vm/classfile/verifier.cpp Thu Apr 21 20:49:11 2016 -0700
+++ b/hotspot/src/share/vm/classfile/verifier.cpp Fri Apr 22 01:04:00 2016 -0700
@@ -248,7 +248,7 @@
// As of the fix for 4486457 we disable verification for all of the
// dynamically-generated bytecodes associated with the 1.4
// reflection implementation, not just those associated with
- // sun/reflect/SerializationConstructorAccessor.
+ // jdk/internal/reflect/SerializationConstructorAccessor.
// NOTE: this is called too early in the bootstrapping process to be
// guarded by Universe::is_gte_jdk14x_version().
// Also for lambda generated code, gte jdk8
--- a/hotspot/src/share/vm/classfile/vmSymbols.hpp Thu Apr 21 20:49:11 2016 -0700
+++ b/hotspot/src/share/vm/classfile/vmSymbols.hpp Fri Apr 22 01:04:00 2016 -0700
@@ -227,26 +227,20 @@
\
/* Support for reflection based on dynamic bytecode generation (JDK 1.4 and above) */ \
\
- template(sun_reflect_FieldInfo, "sun/reflect/FieldInfo") \
- template(sun_reflect_MethodInfo, "sun/reflect/MethodInfo") \
- template(sun_reflect_MagicAccessorImpl, "sun/reflect/MagicAccessorImpl") \
- template(sun_reflect_MethodAccessorImpl, "sun/reflect/MethodAccessorImpl") \
- template(sun_reflect_ConstructorAccessorImpl, "sun/reflect/ConstructorAccessorImpl") \
- template(sun_reflect_SerializationConstructorAccessorImpl, "sun/reflect/SerializationConstructorAccessorImpl") \
- template(sun_reflect_DelegatingClassLoader, "sun/reflect/DelegatingClassLoader") \
- template(sun_reflect_Reflection, "sun/reflect/Reflection") \
- template(sun_reflect_CallerSensitive, "sun/reflect/CallerSensitive") \
- template(sun_reflect_CallerSensitive_signature, "Lsun/reflect/CallerSensitive;") \
+ template(reflect_MagicAccessorImpl, "jdk/internal/reflect/MagicAccessorImpl") \
+ template(reflect_MethodAccessorImpl, "jdk/internal/reflect/MethodAccessorImpl") \
+ template(reflect_ConstructorAccessorImpl, "jdk/internal/reflect/ConstructorAccessorImpl") \
+ template(reflect_DelegatingClassLoader, "jdk/internal/reflect/DelegatingClassLoader") \
+ template(reflect_Reflection, "jdk/internal/reflect/Reflection") \
+ template(reflect_CallerSensitive, "jdk/internal/reflect/CallerSensitive") \
+ template(reflect_CallerSensitive_signature, "Ljdk/internal/reflect/CallerSensitive;") \
template(checkedExceptions_name, "checkedExceptions") \
template(clazz_name, "clazz") \
template(exceptionTypes_name, "exceptionTypes") \
template(modifiers_name, "modifiers") \
template(newConstructor_name, "newConstructor") \
- template(newConstructor_signature, "(Lsun/reflect/MethodInfo;)Ljava/lang/reflect/Constructor;") \
template(newField_name, "newField") \
- template(newField_signature, "(Lsun/reflect/FieldInfo;)Ljava/lang/reflect/Field;") \
template(newMethod_name, "newMethod") \
- template(newMethod_signature, "(Lsun/reflect/MethodInfo;)Ljava/lang/reflect/Method;") \
template(invokeBasic_name, "invokeBasic") \
template(linkToVirtual_name, "linkToVirtual") \
template(linkToStatic_name, "linkToStatic") \
@@ -268,9 +262,9 @@
template(executable_name, "executable") \
template(parameter_annotations_name, "parameterAnnotations") \
template(annotation_default_name, "annotationDefault") \
- template(sun_reflect_ConstantPool, "sun/reflect/ConstantPool") \
+ template(reflect_ConstantPool, "jdk/internal/reflect/ConstantPool") \
template(ConstantPool_name, "constantPoolOop") \
- template(sun_reflect_UnsafeStaticFieldAccessorImpl, "sun/reflect/UnsafeStaticFieldAccessorImpl")\
+ template(reflect_UnsafeStaticFieldAccessorImpl, "jdk/internal/reflect/UnsafeStaticFieldAccessorImpl")\
template(base_name, "base") \
/* Type Annotations (JDK 8 and above) */ \
template(type_annotations_name, "typeAnnotations") \
@@ -870,12 +864,12 @@
do_intrinsic(_Class_cast, java_lang_Class, Class_cast_name, object_object_signature, F_R) \
do_name( Class_cast_name, "cast") \
\
- do_intrinsic(_getClassAccessFlags, sun_reflect_Reflection, getClassAccessFlags_name, class_int_signature, F_SN) \
+ do_intrinsic(_getClassAccessFlags, reflect_Reflection, getClassAccessFlags_name, class_int_signature, F_SN) \
do_name( getClassAccessFlags_name, "getClassAccessFlags") \
do_intrinsic(_getLength, java_lang_reflect_Array, getLength_name, object_int_signature, F_SN) \
do_name( getLength_name, "getLength") \
\
- do_intrinsic(_getCallerClass, sun_reflect_Reflection, getCallerClass_name, void_class_signature, F_SN) \
+ do_intrinsic(_getCallerClass, reflect_Reflection, getCallerClass_name, void_class_signature, F_SN) \
do_name( getCallerClass_name, "getCallerClass") \
\
do_intrinsic(_newArray, java_lang_reflect_Array, newArray_name, newArray_signature, F_SN) \
--- a/hotspot/src/share/vm/interpreter/bytecodeInterpreter.cpp Thu Apr 21 20:49:11 2016 -0700
+++ b/hotspot/src/share/vm/interpreter/bytecodeInterpreter.cpp Fri Apr 22 01:04:00 2016 -0700
@@ -1767,8 +1767,19 @@
((objArrayOop) arrObj)->obj_at_put(index, rhsObject);
UPDATE_PC_AND_TOS_AND_CONTINUE(1, -3);
}
- CASE(_bastore):
- ARRAY_STOREFROM32(T_BYTE, jbyte, "%d", STACK_INT, 0);
+ CASE(_bastore): {
+ ARRAY_INTRO(-3);
+ int item = STACK_INT(-1);
+ // if it is a T_BOOLEAN array, mask the stored value to 0/1
+ if (arrObj->klass() == Universe::boolArrayKlassObj()) {
+ item &= 1;
+ } else {
+ assert(arrObj->klass() == Universe::byteArrayKlassObj(),
+ "should be byte array otherwise");
+ }
+ ((typeArrayOop)arrObj)->byte_at_put(index, item);
+ UPDATE_PC_AND_TOS_AND_CONTINUE(1, -3);
+ }
CASE(_castore):
ARRAY_STOREFROM32(T_CHAR, jchar, "%d", STACK_INT, 0);
CASE(_sastore):
@@ -1999,7 +2010,7 @@
} else if (tos_type == ltos) {
SET_STACK_LONG(obj->long_field_acquire(field_offset), 0);
MORE_STACK(1);
- } else if (tos_type == btos) {
+ } else if (tos_type == btos || tos_type == ztos) {
SET_STACK_INT(obj->byte_field_acquire(field_offset), -1);
} else if (tos_type == ctos) {
SET_STACK_INT(obj->char_field_acquire(field_offset), -1);
@@ -2020,7 +2031,7 @@
} else if (tos_type == ltos) {
SET_STACK_LONG(obj->long_field(field_offset), 0);
MORE_STACK(1);
- } else if (tos_type == btos) {
+ } else if (tos_type == btos || tos_type == ztos) {
SET_STACK_INT(obj->byte_field(field_offset), -1);
} else if (tos_type == ctos) {
SET_STACK_INT(obj->char_field(field_offset), -1);
@@ -2109,6 +2120,9 @@
obj->release_obj_field_put(field_offset, STACK_OBJECT(-1));
} else if (tos_type == btos) {
obj->release_byte_field_put(field_offset, STACK_INT(-1));
+ } else if (tos_type == ztos) {
+ int bool_field = STACK_INT(-1); // only store LSB
+ obj->release_byte_field_put(field_offset, (bool_field & 1));
} else if (tos_type == ltos) {
obj->release_long_field_put(field_offset, STACK_LONG(-1));
} else if (tos_type == ctos) {
@@ -2129,6 +2143,9 @@
obj->obj_field_put(field_offset, STACK_OBJECT(-1));
} else if (tos_type == btos) {
obj->byte_field_put(field_offset, STACK_INT(-1));
+ } else if (tos_type == ztos) {
+ int bool_field = STACK_INT(-1); // only store LSB
+ obj->byte_field_put(field_offset, (bool_field & 1));
} else if (tos_type == ltos) {
obj->long_field_put(field_offset, STACK_LONG(-1));
} else if (tos_type == ctos) {
--- a/hotspot/src/share/vm/interpreter/bytecodes.cpp Thu Apr 21 20:49:11 2016 -0700
+++ b/hotspot/src/share/vm/interpreter/bytecodes.cpp Fri Apr 22 01:04:00 2016 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -496,6 +496,7 @@
def(_fast_aputfield , "fast_aputfield" , "bJJ" , NULL , T_OBJECT , 0, true , _putfield );
def(_fast_bputfield , "fast_bputfield" , "bJJ" , NULL , T_INT , 0, true , _putfield );
+ def(_fast_zputfield , "fast_zputfield" , "bJJ" , NULL , T_INT , 0, true , _putfield );
def(_fast_cputfield , "fast_cputfield" , "bJJ" , NULL , T_CHAR , 0, true , _putfield );
def(_fast_dputfield , "fast_dputfield" , "bJJ" , NULL , T_DOUBLE , 0, true , _putfield );
def(_fast_fputfield , "fast_fputfield" , "bJJ" , NULL , T_FLOAT , 0, true , _putfield );
--- a/hotspot/src/share/vm/interpreter/bytecodes.hpp Thu Apr 21 20:49:11 2016 -0700
+++ b/hotspot/src/share/vm/interpreter/bytecodes.hpp Fri Apr 22 01:04:00 2016 -0700
@@ -257,6 +257,7 @@
_fast_aputfield ,
_fast_bputfield ,
+ _fast_zputfield ,
_fast_cputfield ,
_fast_dputfield ,
_fast_fputfield ,
--- a/hotspot/src/share/vm/interpreter/interpreterRuntime.cpp Thu Apr 21 20:49:11 2016 -0700
+++ b/hotspot/src/share/vm/interpreter/interpreterRuntime.cpp Fri Apr 22 01:04:00 2016 -0700
@@ -1077,7 +1077,8 @@
char sig_type = '\0';
switch(cp_entry->flag_state()) {
- case btos: sig_type = 'Z'; break;
+ case btos: sig_type = 'B'; break;
+ case ztos: sig_type = 'Z'; break;
case ctos: sig_type = 'C'; break;
case stos: sig_type = 'S'; break;
case itos: sig_type = 'I'; break;
--- a/hotspot/src/share/vm/interpreter/templateInterpreter.cpp Thu Apr 21 20:49:11 2016 -0700
+++ b/hotspot/src/share/vm/interpreter/templateInterpreter.cpp Fri Apr 22 01:04:00 2016 -0700
@@ -89,8 +89,9 @@
// Implementation of EntryPoint
EntryPoint::EntryPoint() {
- assert(number_of_states == 9, "check the code below");
+ assert(number_of_states == 10, "check the code below");
_entry[btos] = NULL;
+ _entry[ztos] = NULL;
_entry[ctos] = NULL;
_entry[stos] = NULL;
_entry[atos] = NULL;
@@ -102,9 +103,10 @@
}
-EntryPoint::EntryPoint(address bentry, address centry, address sentry, address aentry, address ientry, address lentry, address fentry, address dentry, address ventry) {
- assert(number_of_states == 9, "check the code below");
+EntryPoint::EntryPoint(address bentry, address zentry, address centry, address sentry, address aentry, address ientry, address lentry, address fentry, address dentry, address ventry) {
+ assert(number_of_states == 10, "check the code below");
_entry[btos] = bentry;
+ _entry[ztos] = zentry;
_entry[ctos] = centry;
_entry[stos] = sentry;
_entry[atos] = aentry;
@@ -155,6 +157,7 @@
return
EntryPoint(
_table[btos][i],
+ _table[ztos][i],
_table[ctos][i],
_table[stos][i],
_table[atos][i],
@@ -169,8 +172,9 @@
void DispatchTable::set_entry(int i, EntryPoint& entry) {
assert(0 <= i && i < length, "index out of bounds");
- assert(number_of_states == 9, "check the code below");
+ assert(number_of_states == 10, "check the code below");
_table[btos][i] = entry.entry(btos);
+ _table[ztos][i] = entry.entry(ztos);
_table[ctos][i] = entry.entry(ctos);
_table[stos][i] = entry.entry(stos);
_table[atos][i] = entry.entry(atos);
--- a/hotspot/src/share/vm/interpreter/templateInterpreter.hpp Thu Apr 21 20:49:11 2016 -0700
+++ b/hotspot/src/share/vm/interpreter/templateInterpreter.hpp Fri Apr 22 01:04:00 2016 -0700
@@ -47,7 +47,7 @@
public:
// Construction
EntryPoint();
- EntryPoint(address bentry, address centry, address sentry, address aentry, address ientry, address lentry, address fentry, address dentry, address ventry);
+ EntryPoint(address bentry, address zentry, address centry, address sentry, address aentry, address ientry, address lentry, address fentry, address dentry, address ventry);
// Attributes
address entry(TosState state) const; // return target address for a given tosca state
--- a/hotspot/src/share/vm/interpreter/templateInterpreterGenerator.cpp Thu Apr 21 20:49:11 2016 -0700
+++ b/hotspot/src/share/vm/interpreter/templateInterpreterGenerator.cpp Fri Apr 22 01:04:00 2016 -0700
@@ -74,6 +74,7 @@
Interpreter::_trace_code =
EntryPoint(
generate_trace_code(btos),
+ generate_trace_code(ztos),
generate_trace_code(ctos),
generate_trace_code(stos),
generate_trace_code(atos),
@@ -94,6 +95,7 @@
generate_return_entry_for(itos, i, index_size),
generate_return_entry_for(itos, i, index_size),
generate_return_entry_for(itos, i, index_size),
+ generate_return_entry_for(itos, i, index_size),
generate_return_entry_for(atos, i, index_size),
generate_return_entry_for(itos, i, index_size),
generate_return_entry_for(ltos, i, index_size),
@@ -105,13 +107,16 @@
}
{ CodeletMark cm(_masm, "invoke return entry points");
- const TosState states[] = {itos, itos, itos, itos, ltos, ftos, dtos, atos, vtos};
+ // These states are in order specified in TosState, except btos/ztos/ctos/stos are
+ // really the same as itos since there is no top of stack optimization for these types
+ const TosState states[] = {itos, itos, itos, itos, itos, ltos, ftos, dtos, atos, vtos, ilgl};
const int invoke_length = Bytecodes::length_for(Bytecodes::_invokestatic);
const int invokeinterface_length = Bytecodes::length_for(Bytecodes::_invokeinterface);
const int invokedynamic_length = Bytecodes::length_for(Bytecodes::_invokedynamic);
for (int i = 0; i < Interpreter::number_of_return_addrs; i++) {
TosState state = states[i];
+ assert(state != ilgl, "states array is wrong above");
Interpreter::_invoke_return_entry[i] = generate_return_entry_for(state, invoke_length, sizeof(u2));
Interpreter::_invokeinterface_return_entry[i] = generate_return_entry_for(state, invokeinterface_length, sizeof(u2));
Interpreter::_invokedynamic_return_entry[i] = generate_return_entry_for(state, invokedynamic_length, sizeof(u4));
@@ -122,6 +127,7 @@
Interpreter::_earlyret_entry =
EntryPoint(
generate_earlyret_entry_for(btos),
+ generate_earlyret_entry_for(ztos),
generate_earlyret_entry_for(ctos),
generate_earlyret_entry_for(stos),
generate_earlyret_entry_for(atos),
@@ -140,6 +146,7 @@
generate_deopt_entry_for(itos, i),
generate_deopt_entry_for(itos, i),
generate_deopt_entry_for(itos, i),
+ generate_deopt_entry_for(itos, i),
generate_deopt_entry_for(atos, i),
generate_deopt_entry_for(itos, i),
generate_deopt_entry_for(ltos, i),
@@ -167,6 +174,7 @@
Interpreter::_continuation_entry =
EntryPoint(
generate_continuation_for(btos),
+ generate_continuation_for(ztos),
generate_continuation_for(ctos),
generate_continuation_for(stos),
generate_continuation_for(atos),
@@ -182,6 +190,7 @@
Interpreter::_safept_entry =
EntryPoint(
generate_safept_entry_for(btos, CAST_FROM_FN_PTR(address, InterpreterRuntime::at_safepoint)),
+ generate_safept_entry_for(ztos, CAST_FROM_FN_PTR(address, InterpreterRuntime::at_safepoint)),
generate_safept_entry_for(ctos, CAST_FROM_FN_PTR(address, InterpreterRuntime::at_safepoint)),
generate_safept_entry_for(stos, CAST_FROM_FN_PTR(address, InterpreterRuntime::at_safepoint)),
generate_safept_entry_for(atos, CAST_FROM_FN_PTR(address, InterpreterRuntime::at_safepoint)),
@@ -301,7 +310,7 @@
void TemplateInterpreterGenerator::set_unimplemented(int i) {
address e = _unimplemented_bytecode;
- EntryPoint entry(e, e, e, e, e, e, e, e, e);
+ EntryPoint entry(e, e, e, e, e, e, e, e, e, e);
Interpreter::_normal_table.set_entry(i, entry);
Interpreter::_wentry_point[i] = _unimplemented_bytecode;
}
@@ -316,6 +325,7 @@
assert(_unimplemented_bytecode != NULL, "should have been generated before");
assert(_illegal_bytecode_sequence != NULL, "should have been generated before");
address bep = _illegal_bytecode_sequence;
+ address zep = _illegal_bytecode_sequence;
address cep = _illegal_bytecode_sequence;
address sep = _illegal_bytecode_sequence;
address aep = _illegal_bytecode_sequence;
@@ -337,7 +347,7 @@
set_wide_entry_point(t, wep);
}
// set entry points
- EntryPoint entry(bep, cep, sep, aep, iep, lep, fep, dep, vep);
+ EntryPoint entry(bep, zep, cep, sep, aep, iep, lep, fep, dep, vep);
Interpreter::_normal_table.set_entry(code, entry);
Interpreter::_wentry_point[code] = wep;
CodeCacheExtensions::completed_template_interpreter_entries(_masm, code);
@@ -355,6 +365,7 @@
assert(t->is_valid(), "template must exist");
switch (t->tos_in()) {
case btos:
+ case ztos:
case ctos:
case stos:
ShouldNotReachHere(); // btos/ctos/stos should use itos.
--- a/hotspot/src/share/vm/interpreter/templateTable.cpp Thu Apr 21 20:49:11 2016 -0700
+++ b/hotspot/src/share/vm/interpreter/templateTable.cpp Fri Apr 22 01:04:00 2016 -0700
@@ -488,6 +488,7 @@
def(Bytecodes::_fast_aputfield , ubcp|____|____|____, atos, vtos, fast_storefield , atos );
def(Bytecodes::_fast_bputfield , ubcp|____|____|____, itos, vtos, fast_storefield , itos );
+ def(Bytecodes::_fast_zputfield , ubcp|____|____|____, itos, vtos, fast_storefield , itos );
def(Bytecodes::_fast_cputfield , ubcp|____|____|____, itos, vtos, fast_storefield , itos );
def(Bytecodes::_fast_dputfield , ubcp|____|____|____, dtos, vtos, fast_storefield , dtos );
def(Bytecodes::_fast_fputfield , ubcp|____|____|____, ftos, vtos, fast_storefield , ftos );
--- a/hotspot/src/share/vm/oops/constMethod.cpp Thu Apr 21 20:49:11 2016 -0700
+++ b/hotspot/src/share/vm/oops/constMethod.cpp Fri Apr 22 01:04:00 2016 -0700
@@ -66,6 +66,7 @@
set_max_locals(0);
set_method_idnum(0);
set_size_of_parameters(0);
+ set_result_type(T_VOID);
}
// Accessor that copies to metadata.
--- a/hotspot/src/share/vm/oops/constMethod.hpp Thu Apr 21 20:49:11 2016 -0700
+++ b/hotspot/src/share/vm/oops/constMethod.hpp Fri Apr 22 01:04:00 2016 -0700
@@ -210,6 +210,7 @@
int _constMethod_size;
u2 _flags;
+ u1 _result_type; // BasicType of result
// Size of Java bytecodes allocated immediately after Method*.
u2 _code_size;
@@ -494,6 +495,8 @@
static ByteSize size_of_parameters_offset()
{ return byte_offset_of(ConstMethod, _size_of_parameters); }
+ static ByteSize result_type_offset()
+ { return byte_offset_of(ConstMethod, _result_type); }
// Unique id for the method
static const u2 MAX_IDNUM;
@@ -516,6 +519,8 @@
int size_of_parameters() const { return _size_of_parameters; }
void set_size_of_parameters(int size) { _size_of_parameters = size; }
+ void set_result_type(BasicType rt) { assert(rt < 16, "result type too large");
+ _result_type = (u1)rt; }
// Deallocation for RedefineClasses
void deallocate_contents(ClassLoaderData* loader_data);
bool is_klass() const { return false; }
--- a/hotspot/src/share/vm/oops/cpCache.hpp Thu Apr 21 20:49:11 2016 -0700
+++ b/hotspot/src/share/vm/oops/cpCache.hpp Fri Apr 22 01:04:00 2016 -0700
@@ -77,18 +77,19 @@
// f2 flag true if f2 contains an oop (e.g., virtual final method)
// fv flag true if invokeinterface used for method in class Object
//
-// The flags 31, 30, 29, 28 together build a 4 bit number 0 to 8 with the
+// The flags 31, 30, 29, 28 together build a 4 bit number 0 to 16 with the
// following mapping to the TosState states:
//
// btos: 0
-// ctos: 1
-// stos: 2
-// itos: 3
-// ltos: 4
-// ftos: 5
-// dtos: 6
-// atos: 7
-// vtos: 8
+// ztos: 1
+// ctos: 2
+// stos: 3
+// itos: 4
+// ltos: 5
+// ftos: 6
+// dtos: 7
+// atos: 8
+// vtos: 9
//
// Entry specific: field entries:
// _indices = get (b1 section) and put (b2 section) bytecodes, original constant pool index
@@ -352,14 +353,8 @@
bool has_method_type() const { return (!is_f1_null()) && (_flags & (1 << has_method_type_shift)) != 0; }
bool is_method_entry() const { return (_flags & (1 << is_field_entry_shift)) == 0; }
bool is_field_entry() const { return (_flags & (1 << is_field_entry_shift)) != 0; }
- bool is_byte() const { return flag_state() == btos; }
- bool is_char() const { return flag_state() == ctos; }
- bool is_short() const { return flag_state() == stos; }
- bool is_int() const { return flag_state() == itos; }
bool is_long() const { return flag_state() == ltos; }
- bool is_float() const { return flag_state() == ftos; }
bool is_double() const { return flag_state() == dtos; }
- bool is_object() const { return flag_state() == atos; }
TosState flag_state() const { assert((uint)number_of_states <= (uint)tos_state_mask+1, "");
return (TosState)((_flags >> tos_state_shift) & tos_state_mask); }
--- a/hotspot/src/share/vm/oops/klass.hpp Thu Apr 21 20:49:11 2016 -0700
+++ b/hotspot/src/share/vm/oops/klass.hpp Fri Apr 22 01:04:00 2016 -0700
@@ -342,6 +342,21 @@
assert(btvalue >= T_BOOLEAN && btvalue <= T_OBJECT, "sanity");
return (BasicType) btvalue;
}
+
+ // Want a pattern to quickly diff against layout header in register
+ // find something less clever!
+ static int layout_helper_boolean_diffbit() {
+ jint zlh = array_layout_helper(T_BOOLEAN);
+ jint blh = array_layout_helper(T_BYTE);
+ assert(zlh != blh, "array layout helpers must differ");
+ int diffbit = 1;
+ while ((diffbit & (zlh ^ blh)) == 0 && (diffbit & zlh) == 0) {
+ diffbit <<= 1;
+ assert(diffbit != 0, "make sure T_BOOLEAN has a different bit than T_BYTE");
+ }
+ return diffbit;
+ }
+
static int layout_helper_log2_element_size(jint lh) {
assert(lh < (jint)_lh_neutral_value, "must be array");
int l2esz = (lh >> _lh_log2_element_size_shift) & _lh_log2_element_size_mask;
--- a/hotspot/src/share/vm/oops/method.cpp Thu Apr 21 20:49:11 2016 -0700
+++ b/hotspot/src/share/vm/oops/method.cpp Fri Apr 22 01:04:00 2016 -0700
@@ -84,9 +84,6 @@
NoSafepointVerifier no_safepoint;
set_constMethod(xconst);
set_access_flags(access_flags);
-#ifdef CC_INTERP
- set_result_index(T_VOID);
-#endif
set_intrinsic_id(vmIntrinsics::_none);
set_jfr_towrite(false);
set_force_inline(false);
@@ -445,12 +442,6 @@
set_size_of_parameters(asc.size() + (is_static() ? 0 : 1));
}
-#ifdef CC_INTERP
-void Method::set_result_index(BasicType type) {
- _result_index = Interpreter::BasicType_as_index(type);
-}
-#endif
-
BasicType Method::result_type() const {
ResultTypeFinder rtf(signature());
return rtf.type();
@@ -1220,10 +1211,8 @@
m->set_signature_index(_imcp_invoke_signature);
assert(MethodHandles::is_signature_polymorphic_name(m->name()), "");
assert(m->signature() == signature, "");
-#ifdef CC_INTERP
ResultTypeFinder rtf(signature);
- m->set_result_index(rtf.type());
-#endif
+ m->constMethod()->set_result_type(rtf.type());
m->compute_size_of_parameters(THREAD);
m->init_intrinsic_id();
assert(m->is_method_handle_intrinsic(), "");
--- a/hotspot/src/share/vm/oops/method.hpp Thu Apr 21 20:49:11 2016 -0700
+++ b/hotspot/src/share/vm/oops/method.hpp Fri Apr 22 01:04:00 2016 -0700
@@ -69,9 +69,6 @@
AccessFlags _access_flags; // Access flags
int _vtable_index; // vtable index of this method (see VtableIndexFlag)
// note: can have vtables with >2**16 elements (because of inheritance)
-#ifdef CC_INTERP
- int _result_index; // C++ interpreter needs for converting results to/from stack
-#endif
u2 _intrinsic_id; // vmSymbols::intrinsic_id (0 == _none)
// Flags
@@ -171,11 +168,6 @@
return constMethod()->type_annotations();
}
-#ifdef CC_INTERP
- void set_result_index(BasicType type);
- int result_index() { return _result_index; }
-#endif
-
// Helper routine: get klass name + "." + method name + signature as
// C string, for the purpose of providing more useful NoSuchMethodErrors
// and fatal error handling. The string is allocated in resource
@@ -563,7 +555,6 @@
void compute_size_of_parameters(Thread *thread); // word size of parameters (receiver if any + arguments)
Symbol* klass_name() const; // returns the name of the method holder
BasicType result_type() const; // type of the method result
- int result_type_index() const; // type index of the method result
bool is_returning_oop() const { BasicType r = result_type(); return (r == T_OBJECT || r == T_ARRAY); }
bool is_returning_fp() const { BasicType r = result_type(); return (r == T_FLOAT || r == T_DOUBLE); }
@@ -664,9 +655,6 @@
// interpreter support
static ByteSize const_offset() { return byte_offset_of(Method, _constMethod ); }
static ByteSize access_flags_offset() { return byte_offset_of(Method, _access_flags ); }
-#ifdef CC_INTERP
- static ByteSize result_index_offset() { return byte_offset_of(Method, _result_index ); }
-#endif /* CC_INTERP */
static ByteSize from_compiled_offset() { return byte_offset_of(Method, _from_compiled_entry); }
static ByteSize code_offset() { return byte_offset_of(Method, _code); }
static ByteSize method_data_offset() {
--- a/hotspot/src/share/vm/oops/oop.inline.hpp Thu Apr 21 20:49:11 2016 -0700
+++ b/hotspot/src/share/vm/oops/oop.inline.hpp Fri Apr 22 01:04:00 2016 -0700
@@ -443,7 +443,7 @@
void oopDesc::char_field_put(int offset, jchar contents) { *char_field_addr(offset) = (jint) contents; }
jboolean oopDesc::bool_field(int offset) const { return (jboolean) *bool_field_addr(offset); }
-void oopDesc::bool_field_put(int offset, jboolean contents) { *bool_field_addr(offset) = (jint) contents; }
+void oopDesc::bool_field_put(int offset, jboolean contents) { *bool_field_addr(offset) = (((jint) contents) & 1); }
jint oopDesc::int_field(int offset) const { return *int_field_addr(offset); }
void oopDesc::int_field_put(int offset, jint contents) { *int_field_addr(offset) = contents; }
@@ -483,7 +483,7 @@
void oopDesc::release_char_field_put(int offset, jchar contents) { OrderAccess::release_store(char_field_addr(offset), contents); }
jboolean oopDesc::bool_field_acquire(int offset) const { return OrderAccess::load_acquire(bool_field_addr(offset)); }
-void oopDesc::release_bool_field_put(int offset, jboolean contents) { OrderAccess::release_store(bool_field_addr(offset), contents); }
+void oopDesc::release_bool_field_put(int offset, jboolean contents) { OrderAccess::release_store(bool_field_addr(offset), (contents & 1)); }
jint oopDesc::int_field_acquire(int offset) const { return OrderAccess::load_acquire(int_field_addr(offset)); }
void oopDesc::release_int_field_put(int offset, jint contents) { OrderAccess::release_store(int_field_addr(offset), contents); }
--- a/hotspot/src/share/vm/oops/typeArrayOop.hpp Thu Apr 21 20:49:11 2016 -0700
+++ b/hotspot/src/share/vm/oops/typeArrayOop.hpp Fri Apr 22 01:04:00 2016 -0700
@@ -96,7 +96,7 @@
void byte_at_put(int which, jbyte contents) { *byte_at_addr(which) = contents; }
jboolean bool_at(int which) const { return *bool_at_addr(which); }
- void bool_at_put(int which, jboolean contents) { *bool_at_addr(which) = contents; }
+ void bool_at_put(int which, jboolean contents) { *bool_at_addr(which) = (((jint)contents) & 1); }
jchar char_at(int which) const { return *char_at_addr(which); }
void char_at_put(int which, jchar contents) { *char_at_addr(which) = contents; }
--- a/hotspot/src/share/vm/opto/memnode.cpp Thu Apr 21 20:49:11 2016 -0700
+++ b/hotspot/src/share/vm/opto/memnode.cpp Fri Apr 22 01:04:00 2016 -0700
@@ -2309,7 +2309,7 @@
ctl != NULL, "raw memory operations should have control edge");
switch (bt) {
- case T_BOOLEAN:
+ case T_BOOLEAN: val = gvn.transform(new AndINode(val, gvn.intcon(0x1))); // Fall through to T_BYTE case
case T_BYTE: return new StoreBNode(ctl, mem, adr, adr_type, val, mo);
case T_INT: return new StoreINode(ctl, mem, adr, adr_type, val, mo);
case T_CHAR:
--- a/hotspot/src/share/vm/opto/parse1.cpp Thu Apr 21 20:49:11 2016 -0700
+++ b/hotspot/src/share/vm/opto/parse1.cpp Fri Apr 22 01:04:00 2016 -0700
@@ -730,6 +730,26 @@
#endif
}
+static Node* mask_int_value(Node* v, BasicType bt, PhaseGVN* gvn) {
+ switch (bt) {
+ case T_BYTE:
+ v = gvn->transform(new LShiftINode(v, gvn->intcon(24)));
+ v = gvn->transform(new RShiftINode(v, gvn->intcon(24)));
+ break;
+ case T_SHORT:
+ v = gvn->transform(new LShiftINode(v, gvn->intcon(16)));
+ v = gvn->transform(new RShiftINode(v, gvn->intcon(16)));
+ break;
+ case T_CHAR:
+ v = gvn->transform(new AndINode(v, gvn->intcon(0xFFFF)));
+ break;
+ case T_BOOLEAN:
+ v = gvn->transform(new AndINode(v, gvn->intcon(0x1)));
+ break;
+ }
+ return v;
+}
+
//-------------------------------build_exits----------------------------------
// Build normal and exceptional exit merge points.
void Parse::build_exits() {
@@ -754,6 +774,16 @@
// Add a return value to the exit state. (Do not push it yet.)
if (tf()->range()->cnt() > TypeFunc::Parms) {
const Type* ret_type = tf()->range()->field_at(TypeFunc::Parms);
+ if (ret_type->isa_int()) {
+ BasicType ret_bt = method()->return_type()->basic_type();
+ if (ret_bt == T_BOOLEAN ||
+ ret_bt == T_CHAR ||
+ ret_bt == T_BYTE ||
+ ret_bt == T_SHORT) {
+ ret_type = TypeInt::INT;
+ }
+ }
+
// Don't "bind" an unloaded return klass to the ret_phi. If the klass
// becomes loaded during the subsequent parsing, the loaded and unloaded
// types will not join when we transform and push in do_exits().
@@ -1014,6 +1044,10 @@
}
return;
}
+ if (ret_type->isa_int()) {
+ BasicType ret_bt = method()->return_type()->basic_type();
+ ret_phi = mask_int_value(ret_phi, ret_bt, &_gvn);
+ }
_exits.push_node(ret_type->basic_type(), ret_phi);
}
--- a/hotspot/src/share/vm/opto/parse2.cpp Thu Apr 21 20:49:11 2016 -0700
+++ b/hotspot/src/share/vm/opto/parse2.cpp Fri Apr 22 01:04:00 2016 -0700
@@ -64,11 +64,15 @@
//--------------------------------array_store----------------------------------
void Parse::array_store(BasicType elem_type) {
- Node* adr = array_addressing(elem_type, 1);
+ const Type* elem = Type::TOP;
+ Node* adr = array_addressing(elem_type, 1, &elem);
if (stopped()) return; // guaranteed null or range check
Node* val = pop();
dec_sp(2); // Pop array and index
const TypeAryPtr* adr_type = TypeAryPtr::get_array_body_type(elem_type);
+ if (elem == TypeInt::BOOL) {
+ elem_type = T_BOOLEAN;
+ }
store_to_memory(control(), adr, val, elem_type, adr_type, StoreNode::release_if_reference(elem_type));
}
--- a/hotspot/src/share/vm/opto/type.cpp Thu Apr 21 20:49:11 2016 -0700
+++ b/hotspot/src/share/vm/opto/type.cpp Fri Apr 22 01:04:00 2016 -0700
@@ -1902,13 +1902,15 @@
break;
case T_OBJECT:
case T_ARRAY:
+ case T_FLOAT:
+ case T_INT:
+ field_array[pos++] = get_const_type(type);
+ break;
case T_BOOLEAN:
case T_CHAR:
- case T_FLOAT:
case T_BYTE:
case T_SHORT:
- case T_INT:
- field_array[pos++] = get_const_type(type);
+ field_array[pos++] = TypeInt::INT;
break;
default:
ShouldNotReachHere();
--- a/hotspot/src/share/vm/prims/jni.cpp Thu Apr 21 20:49:11 2016 -0700
+++ b/hotspot/src/share/vm/prims/jni.cpp Fri Apr 22 01:04:00 2016 -0700
@@ -919,7 +919,14 @@
protected:
va_list _ap;
- inline void get_bool() { _arguments->push_int(va_arg(_ap, jint)); } // bool is coerced to int when using va_arg
+ inline void get_bool() {
+ // Normalize boolean arguments from native code by converting 1-255 to JNI_TRUE and
+ // 0 to JNI_FALSE. Boolean return values from native are normalized the same in
+ // TemplateInterpreterGenerator::generate_result_handler_for and
+ // SharedRuntime::generate_native_wrapper.
+ jboolean b = va_arg(_ap, jint);
+ _arguments->push_int((jint)(b == 0 ? JNI_FALSE : JNI_TRUE));
+ }
inline void get_char() { _arguments->push_int(va_arg(_ap, jint)); } // char is coerced to int when using va_arg
inline void get_short() { _arguments->push_int(va_arg(_ap, jint)); } // short is coerced to int when using va_arg
inline void get_byte() { _arguments->push_int(va_arg(_ap, jint)); } // byte is coerced to int when using va_arg
@@ -960,9 +967,17 @@
while ( 1 ) {
switch ( fingerprint & parameter_feature_mask ) {
case bool_parm:
+ get_bool();
+ break;
case char_parm:
+ get_char();
+ break;
case short_parm:
+ get_short();
+ break;
case byte_parm:
+ get_byte();
+ break;
case int_parm:
get_int();
break;
@@ -996,7 +1011,14 @@
protected:
const jvalue *_ap;
- inline void get_bool() { _arguments->push_int((jint)(_ap++)->z); }
+ inline void get_bool() {
+ // Normalize boolean arguments from native code by converting 1-255 to JNI_TRUE and
+ // 0 to JNI_FALSE. Boolean return values from native are normalized the same in
+ // TemplateInterpreterGenerator::generate_result_handler_for and
+ // SharedRuntime::generate_native_wrapper.
+ jboolean b = (_ap++)->z;
+ _arguments->push_int((jint)(b == 0 ? JNI_FALSE : JNI_TRUE));
+ }
inline void get_char() { _arguments->push_int((jint)(_ap++)->c); }
inline void get_short() { _arguments->push_int((jint)(_ap++)->s); }
inline void get_byte() { _arguments->push_int((jint)(_ap++)->b); }
@@ -2188,6 +2210,7 @@
field_value.unionType = value; \
o = JvmtiExport::jni_SetField_probe_nh(thread, obj, o, k, fieldID, false, SigType, (jvalue *)&field_value); \
} \
+ if (SigType == 'Z') { value = ((jboolean)value) & 1; } \
o->Fieldname##_field_put(offset, value); \
ReturnProbe; \
JNI_END
@@ -2387,6 +2410,7 @@
field_value.unionType = value; \
JvmtiExport::jni_SetField_probe(thread, NULL, NULL, id->holder(), fieldID, true, SigType, (jvalue *)&field_value); \
} \
+ if (SigType == 'Z') { value = ((jboolean)value) & 1; } \
id->holder()->java_mirror()-> Fieldname##_field_put (id->offset(), value); \
ReturnProbe;\
JNI_END
--- a/hotspot/src/share/vm/prims/jvm.cpp Thu Apr 21 20:49:11 2016 -0700
+++ b/hotspot/src/share/vm/prims/jvm.cpp Fri Apr 22 01:04:00 2016 -0700
@@ -1940,8 +1940,8 @@
Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls));
if (k->is_instance_klass()) {
instanceKlassHandle k_h(THREAD, k);
- Handle jcp = sun_reflect_ConstantPool::create(CHECK_NULL);
- sun_reflect_ConstantPool::set_cp(jcp(), k_h->constants());
+ Handle jcp = reflect_ConstantPool::create(CHECK_NULL);
+ reflect_ConstantPool::set_cp(jcp(), k_h->constants());
return JNIHandles::make_local(jcp());
}
}
@@ -1953,7 +1953,7 @@
JVM_ENTRY(jint, JVM_ConstantPoolGetSize(JNIEnv *env, jobject obj, jobject unused))
{
JVMWrapper("JVM_ConstantPoolGetSize");
- constantPoolHandle cp = constantPoolHandle(THREAD, sun_reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj)));
+ constantPoolHandle cp = constantPoolHandle(THREAD, reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj)));
return cp->length();
}
JVM_END
@@ -1962,7 +1962,7 @@
JVM_ENTRY(jclass, JVM_ConstantPoolGetClassAt(JNIEnv *env, jobject obj, jobject unused, jint index))
{
JVMWrapper("JVM_ConstantPoolGetClassAt");
- constantPoolHandle cp = constantPoolHandle(THREAD, sun_reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj)));
+ constantPoolHandle cp = constantPoolHandle(THREAD, reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj)));
bounds_check(cp, index, CHECK_NULL);
constantTag tag = cp->tag_at(index);
if (!tag.is_klass() && !tag.is_unresolved_klass()) {
@@ -1976,7 +1976,7 @@
JVM_ENTRY(jclass, JVM_ConstantPoolGetClassAtIfLoaded(JNIEnv *env, jobject obj, jobject unused, jint index))
{
JVMWrapper("JVM_ConstantPoolGetClassAtIfLoaded");
- constantPoolHandle cp = constantPoolHandle(THREAD, sun_reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj)));
+ constantPoolHandle cp = constantPoolHandle(THREAD, reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj)));
bounds_check(cp, index, CHECK_NULL);
constantTag tag = cp->tag_at(index);
if (!tag.is_klass() && !tag.is_unresolved_klass()) {
@@ -2021,7 +2021,7 @@
{
JVMWrapper("JVM_ConstantPoolGetMethodAt");
JvmtiVMObjectAllocEventCollector oam;
- constantPoolHandle cp = constantPoolHandle(THREAD, sun_reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj)));
+ constantPoolHandle cp = constantPoolHandle(THREAD, reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj)));
bounds_check(cp, index, CHECK_NULL);
jobject res = get_method_at_helper(cp, index, true, CHECK_NULL);
return res;
@@ -2032,7 +2032,7 @@
{
JVMWrapper("JVM_ConstantPoolGetMethodAtIfLoaded");
JvmtiVMObjectAllocEventCollector oam;
- constantPoolHandle cp = constantPoolHandle(THREAD, sun_reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj)));
+ constantPoolHandle cp = constantPoolHandle(THREAD, reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj)));
bounds_check(cp, index, CHECK_NULL);
jobject res = get_method_at_helper(cp, index, false, CHECK_NULL);
return res;
@@ -2068,7 +2068,7 @@
{
JVMWrapper("JVM_ConstantPoolGetFieldAt");
JvmtiVMObjectAllocEventCollector oam;
- constantPoolHandle cp = constantPoolHandle(THREAD, sun_reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj)));
+ constantPoolHandle cp = constantPoolHandle(THREAD, reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj)));
bounds_check(cp, index, CHECK_NULL);
jobject res = get_field_at_helper(cp, index, true, CHECK_NULL);
return res;
@@ -2079,7 +2079,7 @@
{
JVMWrapper("JVM_ConstantPoolGetFieldAtIfLoaded");
JvmtiVMObjectAllocEventCollector oam;
- constantPoolHandle cp = constantPoolHandle(THREAD, sun_reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj)));
+ constantPoolHandle cp = constantPoolHandle(THREAD, reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj)));
bounds_check(cp, index, CHECK_NULL);
jobject res = get_field_at_helper(cp, index, false, CHECK_NULL);
return res;
@@ -2090,7 +2090,7 @@
{
JVMWrapper("JVM_ConstantPoolGetMemberRefInfoAt");
JvmtiVMObjectAllocEventCollector oam;
- constantPoolHandle cp = constantPoolHandle(THREAD, sun_reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj)));
+ constantPoolHandle cp = constantPoolHandle(THREAD, reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj)));
bounds_check(cp, index, CHECK_NULL);
constantTag tag = cp->tag_at(index);
if (!tag.is_field_or_method()) {
@@ -2116,7 +2116,7 @@
{
JVMWrapper("JVM_ConstantPoolGetClassRefIndexAt");
JvmtiVMObjectAllocEventCollector oam;
- constantPoolHandle cp(THREAD, sun_reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj)));
+ constantPoolHandle cp(THREAD, reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj)));
bounds_check(cp, index, CHECK_0);
constantTag tag = cp->tag_at(index);
if (!tag.is_field_or_method()) {
@@ -2130,7 +2130,7 @@
{
JVMWrapper("JVM_ConstantPoolGetNameAndTypeRefIndexAt");
JvmtiVMObjectAllocEventCollector oam;
- constantPoolHandle cp(THREAD, sun_reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj)));
+ constantPoolHandle cp(THREAD, reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj)));
bounds_check(cp, index, CHECK_0);
constantTag tag = cp->tag_at(index);
if (!tag.is_invoke_dynamic() && !tag.is_field_or_method()) {
@@ -2144,7 +2144,7 @@
{
JVMWrapper("JVM_ConstantPoolGetNameAndTypeRefInfoAt");
JvmtiVMObjectAllocEventCollector oam;
- constantPoolHandle cp(THREAD, sun_reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj)));
+ constantPoolHandle cp(THREAD, reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj)));
bounds_check(cp, index, CHECK_NULL);
constantTag tag = cp->tag_at(index);
if (!tag.is_name_and_type()) {
@@ -2165,7 +2165,7 @@
JVM_ENTRY(jint, JVM_ConstantPoolGetIntAt(JNIEnv *env, jobject obj, jobject unused, jint index))
{
JVMWrapper("JVM_ConstantPoolGetIntAt");
- constantPoolHandle cp = constantPoolHandle(THREAD, sun_reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj)));
+ constantPoolHandle cp = constantPoolHandle(THREAD, reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj)));
bounds_check(cp, index, CHECK_0);
constantTag tag = cp->tag_at(index);
if (!tag.is_int()) {
@@ -2178,7 +2178,7 @@
JVM_ENTRY(jlong, JVM_ConstantPoolGetLongAt(JNIEnv *env, jobject obj, jobject unused, jint index))
{
JVMWrapper("JVM_ConstantPoolGetLongAt");
- constantPoolHandle cp = constantPoolHandle(THREAD, sun_reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj)));
+ constantPoolHandle cp = constantPoolHandle(THREAD, reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj)));
bounds_check(cp, index, CHECK_(0L));
constantTag tag = cp->tag_at(index);
if (!tag.is_long()) {
@@ -2191,7 +2191,7 @@
JVM_ENTRY(jfloat, JVM_ConstantPoolGetFloatAt(JNIEnv *env, jobject obj, jobject unused, jint index))
{
JVMWrapper("JVM_ConstantPoolGetFloatAt");
- constantPoolHandle cp = constantPoolHandle(THREAD, sun_reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj)));
+ constantPoolHandle cp = constantPoolHandle(THREAD, reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj)));
bounds_check(cp, index, CHECK_(0.0f));
constantTag tag = cp->tag_at(index);
if (!tag.is_float()) {
@@ -2204,7 +2204,7 @@
JVM_ENTRY(jdouble, JVM_ConstantPoolGetDoubleAt(JNIEnv *env, jobject obj, jobject unused, jint index))
{
JVMWrapper("JVM_ConstantPoolGetDoubleAt");
- constantPoolHandle cp = constantPoolHandle(THREAD, sun_reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj)));
+ constantPoolHandle cp = constantPoolHandle(THREAD, reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj)));
bounds_check(cp, index, CHECK_(0.0));
constantTag tag = cp->tag_at(index);
if (!tag.is_double()) {
@@ -2217,7 +2217,7 @@
JVM_ENTRY(jstring, JVM_ConstantPoolGetStringAt(JNIEnv *env, jobject obj, jobject unused, jint index))
{
JVMWrapper("JVM_ConstantPoolGetStringAt");
- constantPoolHandle cp = constantPoolHandle(THREAD, sun_reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj)));
+ constantPoolHandle cp = constantPoolHandle(THREAD, reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj)));
bounds_check(cp, index, CHECK_NULL);
constantTag tag = cp->tag_at(index);
if (!tag.is_string()) {
@@ -2232,7 +2232,7 @@
{
JVMWrapper("JVM_ConstantPoolGetUTF8At");
JvmtiVMObjectAllocEventCollector oam;
- constantPoolHandle cp = constantPoolHandle(THREAD, sun_reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj)));
+ constantPoolHandle cp = constantPoolHandle(THREAD, reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj)));
bounds_check(cp, index, CHECK_NULL);
constantTag tag = cp->tag_at(index);
if (!tag.is_symbol()) {
@@ -2247,7 +2247,7 @@
JVM_ENTRY(jbyte, JVM_ConstantPoolGetTagAt(JNIEnv *env, jobject obj, jobject unused, jint index))
{
JVMWrapper("JVM_ConstantPoolGetTagAt");
- constantPoolHandle cp = constantPoolHandle(THREAD, sun_reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj)));
+ constantPoolHandle cp = constantPoolHandle(THREAD, reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj)));
bounds_check(cp, index, CHECK_0);
constantTag tag = cp->tag_at(index);
jbyte result = tag.value();
--- a/hotspot/src/share/vm/prims/jvmtiEnvBase.cpp Thu Apr 21 20:49:11 2016 -0700
+++ b/hotspot/src/share/vm/prims/jvmtiEnvBase.cpp Fri Apr 22 01:04:00 2016 -0700
@@ -1354,7 +1354,7 @@
ResultTypeFinder rtf(signature);
TosState fr_tos = as_TosState(rtf.type());
if (fr_tos != tos) {
- if (tos != itos || (fr_tos != btos && fr_tos != ctos && fr_tos != stos)) {
+ if (tos != itos || (fr_tos != btos && fr_tos != ztos && fr_tos != ctos && fr_tos != stos)) {
return JVMTI_ERROR_TYPE_MISMATCH;
}
}
--- a/hotspot/src/share/vm/prims/jvmtiExport.cpp Thu Apr 21 20:49:11 2016 -0700
+++ b/hotspot/src/share/vm/prims/jvmtiExport.cpp Fri Apr 22 01:04:00 2016 -0700
@@ -1699,7 +1699,7 @@
address location, KlassHandle field_klass, Handle object, jfieldID field,
char sig_type, jvalue *value) {
- if (sig_type == 'I' || sig_type == 'Z' || sig_type == 'C' || sig_type == 'S') {
+ if (sig_type == 'I' || sig_type == 'Z' || sig_type == 'B' || sig_type == 'C' || sig_type == 'S') {
// 'I' instructions are used for byte, char, short and int.
// determine which it really is, and convert
fieldDescriptor fd;
--- a/hotspot/src/share/vm/prims/unsafe.cpp Thu Apr 21 20:49:11 2016 -0700
+++ b/hotspot/src/share/vm/prims/unsafe.cpp Fri Apr 22 01:04:00 2016 -0700
@@ -133,13 +133,22 @@
///// Data in the Java heap.
+#define truncate_jboolean(x) ((x) & 1)
+#define truncate_jbyte(x) (x)
+#define truncate_jshort(x) (x)
+#define truncate_jchar(x) (x)
+#define truncate_jint(x) (x)
+#define truncate_jlong(x) (x)
+#define truncate_jfloat(x) (x)
+#define truncate_jdouble(x) (x)
+
#define GET_FIELD(obj, offset, type_name, v) \
oop p = JNIHandles::resolve(obj); \
type_name v = *(type_name*)index_oop_from_field_offset_long(p, offset)
#define SET_FIELD(obj, offset, type_name, x) \
oop p = JNIHandles::resolve(obj); \
- *(type_name*)index_oop_from_field_offset_long(p, offset) = x
+ *(type_name*)index_oop_from_field_offset_long(p, offset) = truncate_##type_name(x)
#define GET_FIELD_VOLATILE(obj, offset, type_name, v) \
oop p = JNIHandles::resolve(obj); \
@@ -150,7 +159,7 @@
#define SET_FIELD_VOLATILE(obj, offset, type_name, x) \
oop p = JNIHandles::resolve(obj); \
- OrderAccess::release_store_fence((volatile type_name*)index_oop_from_field_offset_long(p, offset), x);
+ OrderAccess::release_store_fence((volatile type_name*)index_oop_from_field_offset_long(p, offset), truncate_##type_name(x));
// Get/SetObject must be special-cased, since it works with handles.
--- a/hotspot/src/share/vm/runtime/deoptimization.cpp Thu Apr 21 20:49:11 2016 -0700
+++ b/hotspot/src/share/vm/runtime/deoptimization.cpp Fri Apr 22 01:04:00 2016 -0700
@@ -896,13 +896,25 @@
break;
}
- case T_SHORT: case T_CHAR: // 2 bytes
+ case T_SHORT:
assert(value->type() == T_INT, "Agreement.");
val = value->get_int();
obj->short_at_put(index, (jshort)*((jint*)&val));
break;
- case T_BOOLEAN: case T_BYTE: // 1 byte
+ case T_CHAR:
+ assert(value->type() == T_INT, "Agreement.");
+ val = value->get_int();
+ obj->char_at_put(index, (jchar)*((jint*)&val));
+ break;
+
+ case T_BYTE:
+ assert(value->type() == T_INT, "Agreement.");
+ val = value->get_int();
+ obj->byte_at_put(index, (jbyte)*((jint*)&val));
+ break;
+
+ case T_BOOLEAN:
assert(value->type() == T_INT, "Agreement.");
val = value->get_int();
obj->bool_at_put(index, (jboolean)*((jint*)&val));
@@ -1017,13 +1029,25 @@
break;
}
- case T_SHORT: case T_CHAR: // 2 bytes
+ case T_SHORT:
assert(value->type() == T_INT, "Agreement.");
val = value->get_int();
obj->short_field_put(offset, (jshort)*((jint*)&val));
break;
- case T_BOOLEAN: case T_BYTE: // 1 byte
+ case T_CHAR:
+ assert(value->type() == T_INT, "Agreement.");
+ val = value->get_int();
+ obj->char_field_put(offset, (jchar)*((jint*)&val));
+ break;
+
+ case T_BYTE:
+ assert(value->type() == T_INT, "Agreement.");
+ val = value->get_int();
+ obj->byte_field_put(offset, (jbyte)*((jint*)&val));
+ break;
+
+ case T_BOOLEAN:
assert(value->type() == T_INT, "Agreement.");
val = value->get_int();
obj->bool_field_put(offset, (jboolean)*((jint*)&val));
--- a/hotspot/src/share/vm/runtime/reflection.cpp Thu Apr 21 20:49:11 2016 -0700
+++ b/hotspot/src/share/vm/runtime/reflection.cpp Fri Apr 22 01:04:00 2016 -0700
@@ -487,7 +487,7 @@
is_same_class_package(current_class, new_class)) {
return ACCESS_OK;
}
- // Allow all accesses from sun/reflect/MagicAccessorImpl subclasses to
+ // Allow all accesses from jdk/internal/reflect/MagicAccessorImpl subclasses to
// succeed trivially.
if (current_class->is_subclass_of(SystemDictionary::reflect_MagicAccessorImpl_klass())) {
return ACCESS_OK;
@@ -698,7 +698,7 @@
return true;
}
- // Allow all accesses from sun/reflect/MagicAccessorImpl subclasses to
+ // Allow all accesses from jdk/internal/reflect/MagicAccessorImpl subclasses to
// succeed trivially.
if (current_class->is_subclass_of(SystemDictionary::reflect_MagicAccessorImpl_klass())) {
return true;
@@ -1025,7 +1025,7 @@
static void narrow(jvalue* value, BasicType narrow_type, TRAPS) {
switch (narrow_type) {
case T_BOOLEAN:
- value->z = (jboolean)value->i;
+ value->z = (jboolean) (value->i & 1);
return;
case T_BYTE:
value->b = (jbyte)value->i;
--- a/hotspot/src/share/vm/runtime/reflectionUtils.cpp Thu Apr 21 20:49:11 2016 -0700
+++ b/hotspot/src/share/vm/runtime/reflectionUtils.cpp Fri Apr 22 01:04:00 2016 -0700
@@ -76,9 +76,9 @@
int offset;
offset = java_lang_Throwable::get_backtrace_offset();
_filtered_fields->append(new FilteredField(SystemDictionary::Throwable_klass(), offset));
- offset = sun_reflect_ConstantPool::oop_offset();
+ offset = reflect_ConstantPool::oop_offset();
_filtered_fields->append(new FilteredField(SystemDictionary::reflect_ConstantPool_klass(), offset));
- offset = sun_reflect_UnsafeStaticFieldAccessorImpl::base_offset();
+ offset = reflect_UnsafeStaticFieldAccessorImpl::base_offset();
_filtered_fields->append(new FilteredField(SystemDictionary::reflect_UnsafeStaticFieldAccessorImpl_klass(), offset));
}
--- a/hotspot/src/share/vm/utilities/globalDefinitions.hpp Thu Apr 21 20:49:11 2016 -0700
+++ b/hotspot/src/share/vm/utilities/globalDefinitions.hpp Fri Apr 22 01:04:00 2016 -0700
@@ -851,14 +851,15 @@
enum TosState { // describes the tos cache contents
btos = 0, // byte, bool tos cached
- ctos = 1, // char tos cached
- stos = 2, // short tos cached
- itos = 3, // int tos cached
- ltos = 4, // long tos cached
- ftos = 5, // float tos cached
- dtos = 6, // double tos cached
- atos = 7, // object cached
- vtos = 8, // tos not cached
+ ztos = 1, // byte, bool tos cached
+ ctos = 2, // char tos cached
+ stos = 3, // short tos cached
+ itos = 4, // int tos cached
+ ltos = 5, // long tos cached
+ ftos = 6, // float tos cached
+ dtos = 7, // double tos cached
+ atos = 8, // object cached
+ vtos = 9, // tos not cached
number_of_states,
ilgl // illegal state: should not occur
};
@@ -867,7 +868,7 @@
inline TosState as_TosState(BasicType type) {
switch (type) {
case T_BYTE : return btos;
- case T_BOOLEAN: return btos; // FIXME: Add ztos
+ case T_BOOLEAN: return ztos;
case T_CHAR : return ctos;
case T_SHORT : return stos;
case T_INT : return itos;
@@ -883,8 +884,8 @@
inline BasicType as_BasicType(TosState state) {
switch (state) {
- //case ztos: return T_BOOLEAN;//FIXME
case btos : return T_BYTE;
+ case ztos : return T_BOOLEAN;
case ctos : return T_CHAR;
case stos : return T_SHORT;
case itos : return T_INT;
--- a/hotspot/test/compiler/jvmci/compilerToVM/ConstantPoolTestCase.java Thu Apr 21 20:49:11 2016 -0700
+++ b/hotspot/test/compiler/jvmci/compilerToVM/ConstantPoolTestCase.java Fri Apr 22 01:04:00 2016 -0700
@@ -28,8 +28,8 @@
import java.util.Map;
import jdk.vm.ci.hotspot.HotSpotResolvedObjectType;
import sun.hotspot.WhiteBox;
-import sun.reflect.ConstantPool;
-import sun.reflect.ConstantPool.Tag;
+import jdk.internal.reflect.ConstantPool;
+import jdk.internal.reflect.ConstantPool.Tag;
import compiler.jvmci.compilerToVM.ConstantPoolTestsHelper.DummyClasses;
import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.*;
--- a/hotspot/test/compiler/jvmci/compilerToVM/ConstantPoolTestsHelper.java Thu Apr 21 20:49:11 2016 -0700
+++ b/hotspot/test/compiler/jvmci/compilerToVM/ConstantPoolTestsHelper.java Fri Apr 22 01:04:00 2016 -0700
@@ -34,8 +34,8 @@
import jdk.internal.misc.SharedSecrets;
import jdk.internal.org.objectweb.asm.Opcodes;
import sun.hotspot.WhiteBox;
-import sun.reflect.ConstantPool;
-import sun.reflect.ConstantPool.Tag;
+import jdk.internal.reflect.ConstantPool;
+import jdk.internal.reflect.ConstantPool.Tag;
/**
* Class contains hard-coded constant pool tables for dummy classes used for
--- a/hotspot/test/compiler/jvmci/compilerToVM/LookupKlassInPoolTest.java Thu Apr 21 20:49:11 2016 -0700
+++ b/hotspot/test/compiler/jvmci/compilerToVM/LookupKlassInPoolTest.java Fri Apr 22 01:04:00 2016 -0700
@@ -30,6 +30,7 @@
* @library /testlibrary /test/lib /
* @library ../common/patches
* @modules java.base/jdk.internal.misc
+ * java.base/jdk.internal.reflect
* java.base/jdk.internal.org.objectweb.asm
* java.base/jdk.internal.org.objectweb.asm.tree
* jdk.vm.ci/jdk.vm.ci.hotspot
--- a/hotspot/test/compiler/jvmci/compilerToVM/LookupKlassRefIndexInPoolTest.java Thu Apr 21 20:49:11 2016 -0700
+++ b/hotspot/test/compiler/jvmci/compilerToVM/LookupKlassRefIndexInPoolTest.java Fri Apr 22 01:04:00 2016 -0700
@@ -29,6 +29,7 @@
* @library /testlibrary /test/lib /
* @library ../common/patches
* @modules java.base/jdk.internal.misc
+ * java.base/jdk.internal.reflect
* java.base/jdk.internal.org.objectweb.asm
* java.base/jdk.internal.org.objectweb.asm.tree
* jdk.vm.ci/jdk.vm.ci.hotspot
--- a/hotspot/test/compiler/jvmci/compilerToVM/LookupMethodInPoolTest.java Thu Apr 21 20:49:11 2016 -0700
+++ b/hotspot/test/compiler/jvmci/compilerToVM/LookupMethodInPoolTest.java Fri Apr 22 01:04:00 2016 -0700
@@ -29,6 +29,7 @@
* @library /testlibrary /test/lib /
* @library ../common/patches
* @modules java.base/jdk.internal.misc
+ * java.base/jdk.internal.reflect
* java.base/jdk.internal.org.objectweb.asm
* java.base/jdk.internal.org.objectweb.asm.tree
* jdk.vm.ci/jdk.vm.ci.hotspot
--- a/hotspot/test/compiler/jvmci/compilerToVM/LookupNameAndTypeRefIndexInPoolTest.java Thu Apr 21 20:49:11 2016 -0700
+++ b/hotspot/test/compiler/jvmci/compilerToVM/LookupNameAndTypeRefIndexInPoolTest.java Fri Apr 22 01:04:00 2016 -0700
@@ -29,6 +29,7 @@
* @library /testlibrary /test/lib /
* @library ../common/patches
* @modules java.base/jdk.internal.misc
+ * java.base/jdk.internal.reflect
* java.base/jdk.internal.org.objectweb.asm
* java.base/jdk.internal.org.objectweb.asm.tree
* jdk.vm.ci/jdk.vm.ci.hotspot
--- a/hotspot/test/compiler/jvmci/compilerToVM/LookupNameInPoolTest.java Thu Apr 21 20:49:11 2016 -0700
+++ b/hotspot/test/compiler/jvmci/compilerToVM/LookupNameInPoolTest.java Fri Apr 22 01:04:00 2016 -0700
@@ -29,6 +29,7 @@
* @library /testlibrary /test/lib /
* @library ../common/patches
* @modules java.base/jdk.internal.misc
+ * java.base/jdk.internal.reflect
* java.base/jdk.internal.org.objectweb.asm
* java.base/jdk.internal.org.objectweb.asm.tree
* jdk.vm.ci/jdk.vm.ci.hotspot
--- a/hotspot/test/compiler/jvmci/compilerToVM/LookupSignatureInPoolTest.java Thu Apr 21 20:49:11 2016 -0700
+++ b/hotspot/test/compiler/jvmci/compilerToVM/LookupSignatureInPoolTest.java Fri Apr 22 01:04:00 2016 -0700
@@ -29,6 +29,7 @@
* @library /testlibrary /test/lib /
* @library ../common/patches
* @modules java.base/jdk.internal.misc
+ * java.base/jdk.internal.reflect
* java.base/jdk.internal.org.objectweb.asm
* java.base/jdk.internal.org.objectweb.asm.tree
* jdk.vm.ci/jdk.vm.ci.hotspot
--- a/hotspot/test/compiler/jvmci/compilerToVM/MethodIsIgnoredBySecurityStackWalkTest.java Thu Apr 21 20:49:11 2016 -0700
+++ b/hotspot/test/compiler/jvmci/compilerToVM/MethodIsIgnoredBySecurityStackWalkTest.java Fri Apr 22 01:04:00 2016 -0700
@@ -28,7 +28,8 @@
* @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64")
* @library /testlibrary /test/lib /
* @library ../common/patches
- * @modules java.base/jdk.internal.org.objectweb.asm
+ * @modules java.base/jdk.internal.reflect
+ * java.base/jdk.internal.org.objectweb.asm
* java.base/jdk.internal.org.objectweb.asm.tree
* jdk.vm.ci/jdk.vm.ci.hotspot
* jdk.vm.ci/jdk.vm.ci.code
@@ -76,7 +77,7 @@
testCases.put(aClass.getMethod("invoke", Object.class,
Object[].class), true);
- aClass = Class.forName("sun.reflect.NativeMethodAccessorImpl");
+ aClass = Class.forName("jdk.internal.reflect.NativeMethodAccessorImpl");
testCases.put(aClass.getMethod("invoke", Object.class,
Object[].class), true);
testCases.put(aClass.getDeclaredMethod("invoke0", Method.class,
--- a/hotspot/test/compiler/jvmci/compilerToVM/ResolveConstantInPoolTest.java Thu Apr 21 20:49:11 2016 -0700
+++ b/hotspot/test/compiler/jvmci/compilerToVM/ResolveConstantInPoolTest.java Fri Apr 22 01:04:00 2016 -0700
@@ -29,6 +29,7 @@
* @library /testlibrary /test/lib /
* @library ../common/patches
* @modules java.base/jdk.internal.misc
+ * java.base/jdk.internal.reflect
* java.base/jdk.internal.org.objectweb.asm
* jdk.vm.ci/jdk.vm.ci.hotspot
* jdk.vm.ci/jdk.vm.ci.meta
--- a/hotspot/test/compiler/jvmci/compilerToVM/ResolveFieldInPoolTest.java Thu Apr 21 20:49:11 2016 -0700
+++ b/hotspot/test/compiler/jvmci/compilerToVM/ResolveFieldInPoolTest.java Fri Apr 22 01:04:00 2016 -0700
@@ -29,6 +29,7 @@
* @library /testlibrary /test/lib /
* @library ../common/patches
* @modules java.base/jdk.internal.misc
+ * java.base/jdk.internal.reflect
* java.base/jdk.internal.org.objectweb.asm
* java.base/jdk.internal.org.objectweb.asm.tree
* jdk.vm.ci/jdk.vm.ci.hotspot
--- a/hotspot/test/compiler/jvmci/compilerToVM/ResolvePossiblyCachedConstantInPoolTest.java Thu Apr 21 20:49:11 2016 -0700
+++ b/hotspot/test/compiler/jvmci/compilerToVM/ResolvePossiblyCachedConstantInPoolTest.java Fri Apr 22 01:04:00 2016 -0700
@@ -29,6 +29,7 @@
* @library /testlibrary /test/lib /
* @library ../common/patches
* @modules java.base/jdk.internal.misc
+ * java.base/jdk.internal.reflect
* java.base/jdk.internal.org.objectweb.asm
* java.base/jdk.internal.org.objectweb.asm.tree
* jdk.vm.ci/jdk.vm.ci.hotspot
--- a/hotspot/test/compiler/jvmci/compilerToVM/ResolveTypeInPoolTest.java Thu Apr 21 20:49:11 2016 -0700
+++ b/hotspot/test/compiler/jvmci/compilerToVM/ResolveTypeInPoolTest.java Fri Apr 22 01:04:00 2016 -0700
@@ -30,6 +30,7 @@
* @library /testlibrary /test/lib /
* @library ../common/patches
* @modules java.base/jdk.internal.misc
+ * java.base/jdk.internal.reflect
* java.base/jdk.internal.org.objectweb.asm
* jdk.vm.ci/jdk.vm.ci.hotspot
* jdk.vm.ci/jdk.vm.ci.meta
--- a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaType.java Thu Apr 21 20:49:11 2016 -0700
+++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaType.java Fri Apr 22 01:04:00 2016 -0700
@@ -25,7 +25,8 @@
* @test
* @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64")
* @library ../../../../../
- * @modules jdk.vm.ci/jdk.vm.ci.meta
+ * @modules java.base/jdk.internal.reflect
+ * jdk.vm.ci/jdk.vm.ci.meta
* jdk.vm.ci/jdk.vm.ci.runtime
* jdk.vm.ci/jdk.vm.ci.common
* @build jdk.vm.ci.runtime.test.TestResolvedJavaType
@@ -70,7 +71,7 @@
import org.junit.Test;
-import sun.reflect.ConstantPool;
+import jdk.internal.reflect.ConstantPool;
/**
* Tests for {@link ResolvedJavaType}.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/BoolReturn/BoolConstructor.java Fri Apr 22 01:04:00 2016 -0700
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import jdk.test.lib.Asserts;
+
+public class BoolConstructor {
+
+ boolean field;
+ BoolConstructor(boolean b, boolean expected) {
+ field = b;
+ // System.out.println("b is " + b + " field is " + field);
+ Asserts.assertTrue(field == b, "BoolConstructor argument not converted correctly");
+ Asserts.assertTrue(field == expected, "BoolConstructor argument not stored correctly");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/BoolReturn/NativeSmallIntCallsTest.java Fri Apr 22 01:04:00 2016 -0700
@@ -0,0 +1,60 @@
+/*
+ * 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 8149170
+ * @summary Test native functions return booleans as 0/1 but differently than java functions
+ * @library /testlibrary
+ * @compile BoolConstructor.java
+ * @run main/native NativeSmallIntCallsTest
+ */
+
+// This test shows that returns from native calls for boolean truncate to JNI_TRUE if value != 0
+// and JNI_FALSE if value returned is 0.
+
+import jdk.test.lib.Asserts;
+
+public class NativeSmallIntCallsTest {
+ static native boolean nativeCastToBoolCallTrue();
+ static native boolean nativeCastToBoolCallFalse();
+ static native boolean nativeCallBoolConstructor(int visible, boolean expected);
+ static {
+ System.loadLibrary("NativeSmallIntCalls");
+ }
+
+ public static void main(java.lang.String[] unused) throws Exception {
+ // Call through jni
+ // JNI makes all results != 0 true for compatibility
+ boolean nativeTrueVal = nativeCastToBoolCallTrue();
+ Asserts.assertTrue(nativeTrueVal, "trueval is false!");
+
+ boolean nativeFalseVal = nativeCastToBoolCallFalse();
+ Asserts.assertTrue(nativeFalseVal, "falseval is false in native!");
+
+ // Call a constructor or method that passes jboolean values into Java from native
+ nativeCallBoolConstructor(1, true);
+ nativeCallBoolConstructor(0x10, true);
+ nativeCallBoolConstructor(0x100, false);
+ nativeCallBoolConstructor(0x1000, false);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/BoolReturn/libNativeSmallIntCalls.c Fri Apr 22 01:04:00 2016 -0700
@@ -0,0 +1,57 @@
+/*
+ * 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.
+ */
+
+#include <jni.h>
+
+JNIEXPORT void JNICALL
+Java_NativeSmallIntCallsTest_nativeCallBoolConstructor(JNIEnv* env, jobject obj, int visible, int expected) {
+ jclass cls;
+ jmethodID ctor;
+
+ cls = (*env)->FindClass(env, "BoolConstructor");
+ if(NULL == cls) {
+ return;
+ }
+
+ ctor = (*env)->GetMethodID(env, cls, "<init>", "(ZZ)V");
+ if(NULL == ctor) {
+ return;
+ }
+
+ // printf("visible 0x%x expected %d\n", visible, expected);
+
+ (*env)->NewObject(env, cls, ctor, (jboolean) visible, expected);
+}
+
+JNIEXPORT jboolean JNICALL
+Java_NativeSmallIntCallsTest_nativeCastToBoolCallTrue(JNIEnv* env, jobject obj) {
+
+ return 55;
+}
+
+JNIEXPORT jboolean JNICALL
+Java_NativeSmallIntCallsTest_nativeCastToBoolCallFalse(JNIEnv* env, jobject obj) {
+
+ return 44;
+}
+
--- a/jaxp/.hgtags Thu Apr 21 20:49:11 2016 -0700
+++ b/jaxp/.hgtags Fri Apr 22 01:04:00 2016 -0700
@@ -356,3 +356,4 @@
27a3d65e1580386d060e0aa3a68ab52c1a9ab568 jdk-9+111
36326537f929d20cc5885b93939f90c0efcc4681 jdk-9+112
28626780e245fccbfb9bad8e3b05f62357958038 jdk-9+113
+147114dd0641cd7c9fe6e81642eb993a7b9c6f0b jdk-9+114
--- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogResolverImpl.java Thu Apr 21 20:49:11 2016 -0700
+++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogResolverImpl.java Fri Apr 22 01:04:00 2016 -0700
@@ -52,8 +52,8 @@
@Override
public InputSource resolveEntity(String publicId, String systemId) {
//Normalize publicId and systemId
- systemId = Normalizer.normalizeURI(systemId);
- publicId = Normalizer.normalizePublicId(Normalizer.decodeURN(publicId));
+ systemId = Normalizer.normalizeURI(Util.getNotNullOrEmpty(systemId));
+ publicId = Normalizer.normalizePublicId(Normalizer.decodeURN(Util.getNotNullOrEmpty(publicId)));
//check whether systemId is an urn
if (systemId != null && systemId.startsWith("urn:publicid:")) {
@@ -87,7 +87,17 @@
}
/**
- * Resolves the publicId or systemId to one specified in the catalog.
+ * Resolves the publicId or systemId using public or system entries in the catalog.
+ *
+ * The resolution follows the following rules determined by the prefer setting:
+ *
+ * prefer "system": attempts to resolve with a system entry;
+ * attempts to resolve with a public entry when only
+ * publicId is specified.
+ *
+ * prefer "public": attempts to resolve with a system entry;
+ * attempts to resolve with a public entry if no matching
+ * system entry is found.
* @param catalog the catalog
* @param publicId the publicId
* @param systemId the systemId
@@ -99,9 +109,14 @@
//search the current catalog
catalog.reset();
if (systemId != null) {
+ /*
+ If a system identifier is specified, it is used no matter how
+ prefer is set.
+ */
resolvedSystemId = catalog.matchSystem(systemId);
}
- if (resolvedSystemId == null) {
+
+ if (resolvedSystemId == null && publicId != null) {
resolvedSystemId = catalog.matchPublic(publicId);
}
--- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogUriResolverImpl.java Thu Apr 21 20:49:11 2016 -0700
+++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogUriResolverImpl.java Fri Apr 22 01:04:00 2016 -0700
@@ -60,6 +60,9 @@
@Override
public Source resolve(String href, String base) {
+ href = Util.getNotNullOrEmpty(href);
+ base = Util.getNotNullOrEmpty(base);
+
if (href == null) return null;
CatalogImpl c = (CatalogImpl)catalog;
--- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/GroupEntry.java Thu Apr 21 20:49:11 2016 -0700
+++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/GroupEntry.java Fri Apr 22 01:04:00 2016 -0700
@@ -82,6 +82,9 @@
//The length of the longest match of a suffix type
int longestSuffixMatch = 0;
+ //Indicate whether a system entry has been searched
+ boolean systemEntrySearched = false;
+
/**
* PreferType represents possible values of the prefer property
*/
@@ -156,6 +159,7 @@
longestRewriteMatch = 0;
suffixMatch = null;
longestSuffixMatch = 0;
+ systemEntrySearched = false;
}
/**
* Constructs a group entry.
@@ -212,6 +216,7 @@
* @return An URI string if a mapping is found, or null otherwise.
*/
public String matchSystem(String systemId) {
+ systemEntrySearched = true;
String match = null;
for (BaseEntry entry : entries) {
switch (entry.type) {
@@ -244,8 +249,10 @@
//use it if there is a match of the system type
return match;
} else if (grpEntry.longestRewriteMatch > longestRewriteMatch) {
+ longestRewriteMatch = grpEntry.longestRewriteMatch;
rewriteMatch = match;
} else if (grpEntry.longestSuffixMatch > longestSuffixMatch) {
+ longestSuffixMatch = grpEntry.longestSuffixMatch;
suffixMatch = match;
}
break;
@@ -277,11 +284,13 @@
* @return An URI string if a mapping is found, or null otherwise.
*/
public String matchPublic(String publicId) {
- //as the specification required
- if (!isPreferPublic) {
+ /*
+ When both public and system identifiers are specified, and prefer is
+ not public (that is, system), only system entry will be used.
+ */
+ if (!isPreferPublic && systemEntrySearched) {
return null;
}
-
//match public entries
String match = null;
for (BaseEntry entry : entries) {
--- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/Util.java Thu Apr 21 20:49:11 2016 -0700
+++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/Util.java Fri Apr 22 01:04:00 2016 -0700
@@ -122,4 +122,25 @@
}
return null;
}
+
+ /**
+ * Checks whether the specified string is null or empty, returns the original
+ * string with leading and trailing spaces removed if not.
+ * @param test the string to be tested
+ * @return the original string with leading and trailing spaces removed,
+ * or null if it is null or empty
+ *
+ */
+ static String getNotNullOrEmpty(String test) {
+ if (test == null) {
+ return test;
+ } else {
+ String temp = test.trim();
+ if (temp.length() == 0) {
+ return null;
+ } else {
+ return temp;
+ }
+ }
+ }
}
--- a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogTest.java Thu Apr 21 20:49:11 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogTest.java Fri Apr 22 01:04:00 2016 -0700
@@ -38,15 +38,71 @@
import org.testng.annotations.Test;
import org.xml.sax.Attributes;
import org.xml.sax.ErrorHandler;
+import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.ext.DefaultHandler2;
/*
- * @bug 8081248, 8144966, 8146606, 8146237, 8151154, 8150969
+ * @bug 8081248, 8144966, 8146606, 8146237, 8151154, 8150969, 8151162, 8152527
* @summary Tests basic Catalog functions.
*/
public class CatalogTest {
+ /*
+ * @bug 8152527
+ * This test is the same as the JDK test ResolveEntityTests:testMatch1.
+ * Verifies that the CatalogResolver resolves a publicId and/or systemId as
+ * expected.
+ */
+ @Test(dataProvider = "resolveEntity")
+ public void testMatch1(String cfile, String prefer, String sysId, String pubId, String expectedUri, String expectedFile, String msg) {
+ String catalogFile = getClass().getResource(cfile).getFile();
+ CatalogFeatures features = CatalogFeatures.builder().with(CatalogFeatures.Feature.PREFER, prefer).build();
+ CatalogResolver catalogResolver = CatalogManager.catalogResolver(features, catalogFile);
+ InputSource is = catalogResolver.resolveEntity(pubId, sysId);
+ Assert.assertNotNull(is, msg);
+ String expected = (expectedUri == null) ? expectedFile : expectedUri;
+ Assert.assertEquals(expected, is.getSystemId(), msg);
+ }
+
+ /*
+ * @bug 8151162
+ * Verifies that the Catalog matches specified publicId or systemId and returns
+ * results as expected.
+ */
+ @Test(dataProvider = "matchWithPrefer")
+ public void matchWithPrefer(String prefer, String cfile, String publicId, String systemId, String expected) {
+ String catalogFile = getClass().getResource(cfile).getFile();
+ Catalog c = CatalogManager.catalog(CatalogFeatures.builder().with(CatalogFeatures.Feature.PREFER, prefer).build(), catalogFile);
+ String result;
+ if (publicId != null && publicId.length() > 0) {
+ result = c.matchPublic(publicId);
+ } else {
+ result = c.matchSystem(systemId);
+ }
+ Assert.assertEquals(expected, result);
+ }
+
+ /*
+ * @bug 8151162
+ * Verifies that the CatalogResolver resolves specified publicId or systemId
+ * in accordance with the prefer setting.
+ * prefer "system": resolves with a system entry.
+ * Exception: use the public entry when the catalog contains
+ * only public entry and only publicId is specified.
+ * prefer "public": attempts to resolve with a system entry;
+ * attempts to resolve with a public entry if no matching
+ * system entry is found.
+ */
+ @Test(dataProvider = "resolveWithPrefer")
+ public void resolveWithPrefer(String prefer, String cfile, String publicId, String systemId, String expected) {
+ String catalogFile = getClass().getResource(cfile).getFile();
+ CatalogFeatures f = CatalogFeatures.builder().with(CatalogFeatures.Feature.PREFER, prefer).with(CatalogFeatures.Feature.RESOLVE, "ignore").build();
+ CatalogResolver catalogResolver = CatalogManager.catalogResolver(f, catalogFile);
+ String result = catalogResolver.resolveEntity(publicId, systemId).getSystemId();
+ Assert.assertEquals(expected, result);
+ }
+
/**
* @bug 8150969
* Verifies that the defer attribute set in the catalog file takes precedence
@@ -233,6 +289,72 @@
}
/*
+ DataProvider: used to verify CatalogResolver's resolveEntity function.
+ Data columns:
+ catalog, prefer, systemId, publicId, expectedUri, expectedFile, msg
+ */
+ @DataProvider(name = "resolveEntity")
+ Object[][] getDataForMatchingBothIds() {
+ String expected = "http://www.groupxmlbase.com/dtds/rewrite.dtd";
+ return new Object[][]{
+ {"rewriteSystem_id.xml", "system", "http://www.sys00test.com/rewrite.dtd", "PUB-404", expected, expected, "Relative rewriteSystem with xml:base at group level failed"},
+ };
+ }
+ static String id = "http://openjdk.java.net/xml/catalog/dtd/system.dtd";
+ /*
+ DataProvider: used to verify how prefer settings affect the result of the
+ Catalog's matching operation.
+ Data columns:
+ prefer, catalog, publicId, systemId, expected result
+ */
+ @DataProvider(name = "matchWithPrefer")
+ Object[][] getDataForMatch() {
+ return new Object[][]{
+ {"public", "pubOnly.xml", id, "", "http://local/base/dtd/public.dtd"},
+ {"public", "sysOnly.xml", id, "", null},
+ {"public", "sysAndPub.xml", id, "", "http://local/base/dtd/public.dtd"},
+ {"system", "pubOnly.xml", id, "", "http://local/base/dtd/public.dtd"},
+ {"system", "sysOnly.xml", id, "", null},
+ {"system", "sysAndPub.xml", id, "", "http://local/base/dtd/public.dtd"},
+ {"public", "pubOnly.xml", "", id, null},
+ {"public", "sysOnly.xml", "", id, "http://local/base/dtd/system.dtd"},
+ {"public", "sysAndPub.xml", "", id, "http://local/base/dtd/system.dtd"},
+ {"system", "pubOnly.xml", "", id, null},
+ {"system", "sysOnly.xml", "", id, "http://local/base/dtd/system.dtd"},
+ {"system", "sysAndPub.xml", "", id, "http://local/base/dtd/system.dtd"},
+ };
+ }
+
+ /*
+ DataProvider: used to verify how prefer settings affect the result of the
+ CatalogResolver's resolution operation.
+ Data columns:
+ prefer, catalog, publicId, systemId, expected result
+ */
+ @DataProvider(name = "resolveWithPrefer")
+ Object[][] getDataForResolve() {
+ return new Object[][]{
+ {"system", "pubOnly.xml", id, "", "http://local/base/dtd/public.dtd"},
+ {"system", "pubOnly.xml", "", id, null},
+ {"system", "pubOnly.xml", id, id, null},
+ {"public", "pubOnly.xml", id, "", "http://local/base/dtd/public.dtd"},
+ {"public", "pubOnly.xml", "", id, null},
+ {"public", "pubOnly.xml", id, id, "http://local/base/dtd/public.dtd"},
+ {"system", "sysOnly.xml", id, "", null},
+ {"system", "sysOnly.xml", "", id, "http://local/base/dtd/system.dtd"},
+ {"system", "sysOnly.xml", id, id, "http://local/base/dtd/system.dtd"},
+ {"public", "sysOnly.xml", id, "", null},
+ {"public", "sysOnly.xml", "", id, "http://local/base/dtd/system.dtd"},
+ {"public", "sysOnly.xml", id, id, "http://local/base/dtd/system.dtd"},
+ {"system", "sysAndPub.xml", id, "", "http://local/base/dtd/public.dtd"},
+ {"system", "sysAndPub.xml", "", id, "http://local/base/dtd/system.dtd"},
+ {"system", "sysAndPub.xml", id, id, "http://local/base/dtd/system.dtd"},
+ {"public", "sysAndPub.xml", id, "", "http://local/base/dtd/public.dtd"},
+ {"public", "sysAndPub.xml", "", id, "http://local/base/dtd/system.dtd"},
+ {"public", "sysAndPub.xml", id, id, "http://local/base/dtd/system.dtd"},
+ };
+ }
+ /*
DataProvider: catalogs that contain invalid next or delegate catalogs.
The defer attribute is set to false.
*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/pubOnly.xml Fri Apr 22 01:04:00 2016 -0700
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" xml:base="http://local/base/dtd/">
+
+ <public publicId="http://openjdk.java.net/xml/catalog/dtd/system.dtd" uri="public.dtd"/>
+
+</catalog>
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/rewriteSystem_id.xml Fri Apr 22 01:04:00 2016 -0700
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" xml:base="http://local/base/dtd/">
+ <rewriteSystem systemIdStartString="http://remote/dtd/alice/" rewritePrefix="http://local/dtd/alice/rs/" />
+
+ <rewriteSystem systemIdStartString="http://remote/dtd/bob/" rewritePrefix="bob/rs/" />
+
+ <rewriteSystem systemIdStartString="http://remote/dtd/carl/" rewritePrefix="carl/rs/"
+ xml:base="http://local/carlBase/dtd/" />
+
+ <rewriteSystem systemIdStartString="http://remote/dtd/david/" rewritePrefix="david1/rs/" />
+ <rewriteSystem systemIdStartString="http://remote/dtd/david/" rewritePrefix="david2/rs/" />
+
+ <rewriteSystem systemIdStartString="http://remote/dtd/" rewritePrefix="ella/" />
+ <rewriteSystem systemIdStartString="http://remote/dtd/ella/" rewritePrefix="ella/rs/" />
+
+ <rewriteSystem systemIdStartString="http://remote.com/"
+ rewritePrefix="file:///share/doctypes/dtd/fail/"/>
+ <rewriteSystem systemIdStartString="http://remote.com/dtd"
+ rewritePrefix="file:///share/docbook/docbook/pass"/>
+
+ <group xml:base="http://www.groupxmlbase.com/">
+ <rewriteSystem systemIdStartString="http://www.sys00test.com" rewritePrefix="dtds"/>
+ </group>
+</catalog>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/sysAndPub.xml Fri Apr 22 01:04:00 2016 -0700
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" xml:base="http://local/base/dtd/">
+
+ <system systemId="http://openjdk.java.net/xml/catalog/dtd/system.dtd" uri="system.dtd"/>
+ <public publicId="http://openjdk.java.net/xml/catalog/dtd/system.dtd" uri="public.dtd"/>
+
+</catalog>
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/sysOnly.xml Fri Apr 22 01:04:00 2016 -0700
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" xml:base="http://local/base/dtd/">
+
+ <system systemId="http://openjdk.java.net/xml/catalog/dtd/system.dtd" uri="system.dtd"/>
+
+</catalog>
\ No newline at end of file
--- a/jaxws/.hgtags Thu Apr 21 20:49:11 2016 -0700
+++ b/jaxws/.hgtags Fri Apr 22 01:04:00 2016 -0700
@@ -359,3 +359,4 @@
4d5296e0920afe7ef8d4db1939b76f0d407a3812 jdk-9+111
21274e7937bae291658d68143aca0e3ee9296db0 jdk-9+112
e980062475c10d21137051045bf95ee229db9b27 jdk-9+113
+b314bb02182b9ca94708a91f312c377f5435f740 jdk-9+114
--- a/jdk/.hgtags Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/.hgtags Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/make/launcher/Launcher-jdk.rmic.gmk Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/make/mapfiles/libjava/mapfile-vers Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/make/mapfiles/libjava/reorder-sparc Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/make/mapfiles/libjava/reorder-sparcv9 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/make/mapfiles/libjava/reorder-x86 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/make/mapfiles/libnio/mapfile-linux Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/make/mapfiles/libnio/mapfile-macosx Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/make/mapfiles/libnio/mapfile-solaris Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/com/sun/crypto/provider/AESCrypt.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/com/sun/crypto/provider/DHKeyPairGenerator.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/com/sun/crypto/provider/DHParameterGenerator.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/io/ObjectStreamClass.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/io/ObjectStreamField.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/lang/ArrayIndexOutOfBoundsException.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/lang/Class.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/lang/ClassLoader.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/lang/Deprecated.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/lang/IndexOutOfBoundsException.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/lang/Math.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/lang/Package.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/lang/ProcessHandleImpl.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/lang/Runtime.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/lang/SecurityManager.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/lang/StackStreamFactory.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/lang/StackTraceElement.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/lang/StackWalker.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/lang/StrictMath.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/lang/StringIndexOutOfBoundsException.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/lang/System.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/lang/Thread.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/lang/Throwable.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/Invokers.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MemberName.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandle.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleNatives.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleProxies.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/StringConcatFactory.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/VarForm.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/VarHandle.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/lang/reflect/AccessibleObject.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/lang/reflect/Constructor.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/lang/reflect/Field.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/lang/reflect/Method.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/lang/reflect/Modifier.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/lang/reflect/Module.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/lang/reflect/Proxy.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/lang/reflect/ReflectAccess.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/net/InetAddress.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/net/URLClassLoader.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/nio/file/Files.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/security/AccessController.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/security/AlgorithmParameterGenerator.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/security/AlgorithmParameters.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/security/KeyFactory.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/security/KeyPairGenerator.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/security/KeyStore.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/security/MessageDigest.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/security/Policy.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/security/SecureRandom.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/security/Signature.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/security/cert/CertPathBuilder.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/security/cert/CertPathValidator.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/security/cert/CertStore.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/security/cert/CertificateFactory.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/time/Duration.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/util/Objects.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/util/ResourceBundle.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/util/ServiceLoader.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongFieldUpdater.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/util/jar/JarFile.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/javax/crypto/Cipher.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/javax/crypto/ExemptionMechanism.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/javax/crypto/KeyAgreement.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/javax/crypto/KeyGenerator.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/javax/crypto/Mac.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/javax/crypto/SecretKeyFactory.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/javax/net/ssl/KeyManagerFactory.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/javax/net/ssl/SSLContext.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/javax/net/ssl/TrustManagerFactory.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/javax/security/auth/login/Configuration.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/jdk/internal/jimage/BasicImageReader.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/jdk/internal/jimage/ImageBufferCache.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/jdk/internal/jimage/ImageReader.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/jdk/internal/jrtfs/JrtDirectoryStream.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileAttributeView.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileAttributes.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileStore.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileSystem.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileSystemProvider.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/jdk/internal/jrtfs/JrtPath.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/jdk/internal/misc/JavaLangAccess.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/jdk/internal/misc/Unsafe.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/RemappingAnnotationAdapter.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/RemappingMethodAdapter.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/module-info.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/sun/invoke/util/VerifyAccess.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/sun/nio/fs/AbstractFileSystemProvider.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/sun/reflect/annotation/AnnotationParser.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/sun/reflect/annotation/AnnotationSupport.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/sun/reflect/annotation/TypeAnnotationParser.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/sun/reflect/misc/ReflectUtil.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/sun/security/provider/DSAKeyPairGenerator.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/sun/security/provider/DSAParameterGenerator.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/sun/security/provider/ParameterCache.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/DHCrypt.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/ServerHandshaker.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/classes/sun/security/util/ObjectIdentifier.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/conf/security/java.security Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/native/include/jvm.h Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/native/libjava/Class.c Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/native/libjava/ConstantPool.c Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/native/libjava/NativeAccessors.c Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/native/libjava/Reflection.c Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/native/libjava/Throwable.c Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/share/native/libjli/java.h Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/unix/classes/sun/nio/fs/UnixFileSystemProvider.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/unix/classes/sun/nio/fs/UnixNativeDispatcher.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/unix/classes/sun/nio/fs/UnixUriUtils.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/unix/native/libnio/fs/UnixNativeDispatcher.c Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/windows/classes/java/net/DefaultDatagramSocketImplFactory.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/windows/classes/java/net/PlainSocketImpl.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/windows/classes/sun/nio/ch/Iocp.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/windows/classes/sun/nio/ch/WindowsAsynchronousFileChannelImpl.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/windows/classes/sun/nio/ch/WindowsAsynchronousServerSocketChannelImpl.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/windows/classes/sun/nio/ch/WindowsAsynchronousSocketChannelImpl.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsFileAttributeViews.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsFileCopy.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsFileStore.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsFileSystem.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsFileSystemProvider.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsLinkSupport.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsNativeDispatcher.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsPath.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsUserDefinedFileAttributeView.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/windows/native/libnet/Inet4AddressImpl.c Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/windows/native/libnet/Inet6AddressImpl.c Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.base/windows/native/libnio/fs/WindowsNativeDispatcher.c Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.logging/share/classes/java/util/logging/Logger.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.management/share/classes/javax/management/remote/JMXServiceURL.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.management/share/classes/sun/management/jdp/JdpBroadcaster.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.naming/share/classes/com/sun/jndi/ldap/LdapReferralContext.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.security.sasl/share/classes/javax/security/sasl/Sasl.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.smartcardio/share/classes/javax/smartcardio/TerminalFactory.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.sql.rowset/share/classes/javax/sql/rowset/serial/SerialJavaObject.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.sql/share/classes/java/sql/DriverManager.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/TransformService.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/XMLSignatureFactory.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/keyinfo/KeyInfoFactory.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/jdk.crypto.pkcs11/share/classes/sun/security/pkcs11/P11KeyPairGenerator.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/jdk.rmic/share/classes/module-info.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/jdk.unsupported/share/classes/module-info.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/src/jdk.unsupported/share/classes/sun/misc/Unsafe.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/Makefile Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/ProblemList.txt Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/TEST.groups Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/com/sun/jdi/InterruptHangTest.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/com/sun/jdi/ShellScaffold.sh Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/com/sun/jdi/TestScaffold.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/java/lang/Math/Tests.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/java/lang/SecurityManager/RestrictedPackages.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/java/lang/StackWalker/DumpStackTest.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/java/lang/StackWalker/EmbeddedStackWalkTest.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/java/lang/StackWalker/HiddenFrames.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/java/lang/StackWalker/MultiThreadStackWalk.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/java/lang/StackWalker/StackWalkTest.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/java/lang/StackWalker/VerifyStackTrace.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/java/lang/invoke/JavaDocExamplesTest.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/java/lang/invoke/LoopCombinatorTest.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/java/lang/invoke/RevealDirectTest.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/java/lang/invoke/TryFinallyTest.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleBaseTest.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessBoolean.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessByte.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessChar.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessDouble.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessFloat.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessInt.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessLong.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessShort.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessString.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsChar.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsDouble.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsFloat.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsInt.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsLong.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsShort.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessBoolean.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessByte.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessChar.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessDouble.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessFloat.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessInt.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessLong.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessShort.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessString.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeBoolean.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeByte.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeChar.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeDouble.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeFloat.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeInt.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeLong.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeShort.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeString.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestReflection.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestAccess.java.template Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestByteArrayView.java.template Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodHandleAccess.java.template Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodType.java.template Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/java/lang/management/ThreadMXBean/ThreadLists.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/java/nio/channels/AsyncCloseAndInterrupt.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/java/security/testlibrary/SimpleOCSPServer.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/java/time/tck/java/time/TCKDuration.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/java/util/Currency/CurrencyTest.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/java/util/Objects/CheckIndex.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/java/util/jar/JarFile/MultiReleaseJarAPI.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/javax/net/ssl/DTLS/CipherSuite.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/javax/net/ssl/Stapling/HttpsUrlConnClient.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/javax/net/ssl/Stapling/SSLEngineWithStapling.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/javax/net/ssl/Stapling/SSLSocketWithStapling.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/javax/net/ssl/Stapling/StapleEnableProps.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/jdk/internal/jrtfs/PathOps.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/lib/testlibrary/java/util/jar/CreateMultiReleaseTestJars.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/sun/management/jdp/JdpDefaultsTest.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/sun/management/jdp/JdpTestCase.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/sun/reflect/Reflection/GetCallerClassWithDepth.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ /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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/sun/security/mscapi/SmallPrimeExponentP.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/sun/security/pkcs11/KeyPairGenerator/TestDH2048.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/sun/security/pkcs11/KeyStore/Basic.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/sun/security/pkcs11/KeyStore/Basic.policy Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/sun/security/pkcs11/KeyStore/Basic.sh Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/sun/security/pkcs11/KeyStore/Solaris.sh Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/sun/security/pkcs11/PKCS11Test.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/sun/security/pkcs11/Provider/Login.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/sun/security/pkcs11/Provider/Login.policy Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/sun/security/pkcs11/Provider/Login.sh Fri Apr 22 01:04:00 2016 -0700
@@ -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 Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/sun/security/provider/DSA/TestAlgParameterGenerator.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/sun/security/provider/DSA/TestKeyPairGenerator.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/sun/security/ssl/StatusStapling/java.base/sun/security/ssl/StatusResponseManagerTests.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/sun/tools/jhsdb/BasicLauncherTest.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/sun/tools/jhsdb/SAGetoptTest.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/tools/launcher/MiscTests.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/tools/launcher/modules/addexports/AddExportsTest.java Fri Apr 22 01:04:00 2016 -0700
@@ -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 Thu Apr 21 20:49:11 2016 -0700
+++ b/jdk/test/tools/pack200/BandIntegrity.java Fri Apr 22 01:04:00 2016 -0700
@@ -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;
--- a/langtools/.hgtags Thu Apr 21 20:49:11 2016 -0700
+++ b/langtools/.hgtags Fri Apr 22 01:04:00 2016 -0700
@@ -356,3 +356,4 @@
9adfb22ff08f2e82c7801b272607cd685976dbb1 jdk-9+111
3d4117c36559b344a73f786d39cc7626b4d8e2c0 jdk-9+112
4e87682893e662421af10a62d29ae822ce0fea04 jdk-9+113
+cba09a2e6ae969b029783eb59bb01017b78f8eef jdk-9+114
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTool.java Thu Apr 21 20:49:11 2016 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTool.java Fri Apr 22 01:04:00 2016 -0700
@@ -45,10 +45,13 @@
import com.sun.tools.javac.main.Arguments;
import com.sun.tools.javac.main.Option;
import com.sun.tools.javac.file.BaseFileManager;
+import com.sun.tools.javac.file.CacheFSInfo;
+import com.sun.tools.javac.jvm.Target;
import com.sun.tools.javac.util.ClientCodeException;
import com.sun.tools.javac.util.Context;
import com.sun.tools.javac.util.DefinedBy;
import com.sun.tools.javac.util.DefinedBy.Api;
+import com.sun.tools.javac.util.List;
import com.sun.tools.javac.util.Log;
import com.sun.tools.javac.util.PropagatedException;
@@ -95,6 +98,7 @@
? new PrintWriter(System.err, true)
: new PrintWriter(new OutputStreamWriter(System.err, charset), true);
context.put(Log.outKey, pw);
+ CacheFSInfo.preRegister(context);
return new JavacFileManager(context, true, charset);
}
@@ -173,6 +177,14 @@
Arguments args = Arguments.instance(context);
args.init("javac", options, classes, compilationUnits);
+
+ // init multi-release jar handling
+ if (fileManager.isSupportedOption(Option.MULTIRELEASE.text) == 1) {
+ Target target = Target.instance(context);
+ List<String> list = List.of(target.multiReleaseValue());
+ fileManager.handleOption(Option.MULTIRELEASE.text, list.iterator());
+ }
+
return new JavacTaskImpl(context);
} catch (PropagatedException ex) {
throw ex.getCause();
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/BaseFileManager.java Thu Apr 21 20:49:11 2016 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/BaseFileManager.java Fri Apr 22 01:04:00 2016 -0700
@@ -286,6 +286,8 @@
return -1;
}
+ protected String multiReleaseValue;
+
/**
* Common back end for OptionHelper handleFileManagerOption.
* @param option the option whose value to be set
@@ -298,6 +300,10 @@
encodingName = value;
return true;
+ case MULTIRELEASE:
+ multiReleaseValue = value;
+ return true;
+
default:
return locations.handleOption(option, value);
}
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/JavacFileManager.java Thu Apr 21 20:49:11 2016 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/JavacFileManager.java Fri Apr 22 01:04:00 2016 -0700
@@ -42,8 +42,10 @@
import java.nio.file.LinkOption;
import java.nio.file.Path;
import java.nio.file.Paths;
+import java.nio.file.ProviderNotFoundException;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;
+import java.nio.file.spi.FileSystemProvider;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -266,30 +268,137 @@
System.out.println(message);
}
- /**
- * Insert all files in a subdirectory of the platform image
- * which match fileKinds into resultList.
- */
- private void listJRTImage(RelativeDirectory subdirectory,
- Set<JavaFileObject.Kind> fileKinds,
- boolean recurse,
- ListBuffer<JavaFileObject> resultList) throws IOException {
- JRTIndex.Entry e = getJRTIndex().getEntry(subdirectory);
- if (symbolFileEnabled && e.ctSym.hidden)
- return;
- for (Path file: e.files.values()) {
- if (fileKinds.contains(getKind(file))) {
- JavaFileObject fe
- = PathFileObject.forJRTPath(JavacFileManager.this, file);
- resultList.append(fe);
+ private final Map<Path, Container> containers = new HashMap<>();
+
+ synchronized Container getContainer(Path path) throws IOException {
+ Container fs = containers.get(path);
+
+ if (fs != null) {
+ return fs;
+ }
+
+ if (fsInfo.isFile(path) && path.equals(Locations.thisSystemModules)) {
+ containers.put(path, fs = new JRTImageContainer());
+ return fs;
+ }
+
+ Path realPath = fsInfo.getCanonicalFile(path);
+
+ fs = containers.get(realPath);
+
+ if (fs != null) {
+ containers.put(path, fs);
+ return fs;
+ }
+
+ BasicFileAttributes attr = null;
+
+ try {
+ attr = Files.readAttributes(realPath, BasicFileAttributes.class);
+ } catch (IOException ex) {
+ //non-existing
+ fs = MISSING_CONTAINER;
+ }
+
+ if (attr != null) {
+ if (attr.isDirectory()) {
+ fs = new DirectoryContainer(realPath);
+ } else {
+ try {
+ fs = new ArchiveContainer(realPath);
+ } catch (ProviderNotFoundException | SecurityException ex) {
+ throw new IOException(ex);
+ }
}
}
- if (recurse) {
- for (RelativeDirectory rd: e.subdirs) {
- listJRTImage(rd, fileKinds, recurse, resultList);
+ containers.put(realPath, fs);
+ containers.put(path, fs);
+
+ return fs;
+ }
+
+ private interface Container {
+ /**
+ * Insert all files in subdirectory subdirectory of container which
+ * match fileKinds into resultList
+ */
+ public abstract void list(Path userPath,
+ RelativeDirectory subdirectory,
+ Set<JavaFileObject.Kind> fileKinds,
+ boolean recurse,
+ ListBuffer<JavaFileObject> resultList) throws IOException;
+ public abstract JavaFileObject getFileObject(Path userPath, RelativeFile name) throws IOException;
+ public abstract void close() throws IOException;
+ }
+
+ private static final Container MISSING_CONTAINER = new Container() {
+ @Override
+ public void list(Path userPath,
+ RelativeDirectory subdirectory,
+ Set<JavaFileObject.Kind> fileKinds,
+ boolean recurse,
+ ListBuffer<JavaFileObject> resultList) throws IOException {
+ }
+ @Override
+ public JavaFileObject getFileObject(Path userPath, RelativeFile name) throws IOException {
+ return null;
+ }
+ @Override
+ public void close() throws IOException {}
+ };
+
+ private final class JRTImageContainer implements Container {
+
+ /**
+ * Insert all files in a subdirectory of the platform image
+ * which match fileKinds into resultList.
+ */
+ @Override
+ public void list(Path userPath,
+ RelativeDirectory subdirectory,
+ Set<JavaFileObject.Kind> fileKinds,
+ boolean recurse,
+ ListBuffer<JavaFileObject> resultList) throws IOException {
+ try {
+ JRTIndex.Entry e = getJRTIndex().getEntry(subdirectory);
+ if (symbolFileEnabled && e.ctSym.hidden)
+ return;
+ for (Path file: e.files.values()) {
+ if (fileKinds.contains(getKind(file))) {
+ JavaFileObject fe
+ = PathFileObject.forJRTPath(JavacFileManager.this, file);
+ resultList.append(fe);
+ }
+ }
+
+ if (recurse) {
+ for (RelativeDirectory rd: e.subdirs) {
+ list(userPath, rd, fileKinds, recurse, resultList);
+ }
+ }
+ } catch (IOException ex) {
+ ex.printStackTrace(System.err);
+ log.error("error.reading.file", userPath, getMessage(ex));
}
}
+
+ @Override
+ public JavaFileObject getFileObject(Path userPath, RelativeFile name) throws IOException {
+ JRTIndex.Entry e = getJRTIndex().getEntry(name.dirname());
+ if (symbolFileEnabled && e.ctSym.hidden)
+ return null;
+ Path p = e.files.get(name.basename());
+ if (p != null) {
+ return PathFileObject.forJRTPath(JavacFileManager.this, p);
+ } else {
+ return null;
+ }
+ }
+
+ @Override
+ public void close() throws IOException {
+ }
}
private synchronized JRTIndex getJRTIndex() {
@@ -300,164 +409,199 @@
private JRTIndex jrtIndex;
+ private final class DirectoryContainer implements Container {
+ private final Path directory;
- /**
- * Insert all files in subdirectory subdirectory of directory directory
- * which match fileKinds into resultList
- */
- private void listDirectory(Path directory, Path realDirectory,
- RelativeDirectory subdirectory,
- Set<JavaFileObject.Kind> fileKinds,
- boolean recurse,
- ListBuffer<JavaFileObject> resultList) {
- Path d;
- try {
- d = subdirectory.resolveAgainst(directory);
- } catch (InvalidPathException ignore) {
- return;
- }
-
- if (!Files.exists(d)) {
- return;
- }
-
- if (!caseMapCheck(d, subdirectory)) {
- return;
+ public DirectoryContainer(Path directory) {
+ this.directory = directory;
}
- java.util.List<Path> files;
- try (Stream<Path> s = Files.list(d)) {
- files = (sortFiles == null ? s : s.sorted(sortFiles)).collect(Collectors.toList());
- } catch (IOException ignore) {
- return;
- }
+ /**
+ * Insert all files in subdirectory subdirectory of directory userPath
+ * which match fileKinds into resultList
+ */
+ @Override
+ public void list(Path userPath,
+ RelativeDirectory subdirectory,
+ Set<JavaFileObject.Kind> fileKinds,
+ boolean recurse,
+ ListBuffer<JavaFileObject> resultList) throws IOException {
+ Path d;
+ try {
+ d = subdirectory.resolveAgainst(userPath);
+ } catch (InvalidPathException ignore) {
+ return ;
+ }
- if (realDirectory == null)
- realDirectory = fsInfo.getCanonicalFile(directory);
+ if (!Files.exists(d)) {
+ return;
+ }
+
+ if (!caseMapCheck(d, subdirectory)) {
+ return;
+ }
- for (Path f: files) {
- String fname = f.getFileName().toString();
- if (fname.endsWith("/"))
- fname = fname.substring(0, fname.length() - 1);
- if (Files.isDirectory(f)) {
- if (recurse && SourceVersion.isIdentifier(fname)) {
- listDirectory(directory, realDirectory,
- new RelativeDirectory(subdirectory, fname),
- fileKinds,
- recurse,
- resultList);
- }
- } else {
- if (isValidFile(fname, fileKinds)) {
- RelativeFile file = new RelativeFile(subdirectory, fname);
- JavaFileObject fe = PathFileObject.forDirectoryPath(this,
- file.resolveAgainst(realDirectory), directory, file);
- resultList.append(fe);
+ java.util.List<Path> files;
+ try (Stream<Path> s = Files.list(d)) {
+ files = (sortFiles == null ? s : s.sorted(sortFiles)).collect(Collectors.toList());
+ } catch (IOException ignore) {
+ return;
+ }
+
+ for (Path f: files) {
+ String fname = f.getFileName().toString();
+ if (fname.endsWith("/"))
+ fname = fname.substring(0, fname.length() - 1);
+ if (Files.isDirectory(f)) {
+ if (recurse && SourceVersion.isIdentifier(fname)) {
+ list(userPath,
+ new RelativeDirectory(subdirectory, fname),
+ fileKinds,
+ recurse,
+ resultList);
+ }
+ } else {
+ if (isValidFile(fname, fileKinds)) {
+ RelativeFile file = new RelativeFile(subdirectory, fname);
+ JavaFileObject fe = PathFileObject.forDirectoryPath(JavacFileManager.this,
+ file.resolveAgainst(directory), userPath, file);
+ resultList.append(fe);
+ }
}
}
}
+
+ @Override
+ public JavaFileObject getFileObject(Path userPath, RelativeFile name) throws IOException {
+ try {
+ Path f = name.resolveAgainst(userPath);
+ if (Files.exists(f))
+ return PathFileObject.forSimplePath(JavacFileManager.this,
+ fsInfo.getCanonicalFile(f), f);
+ } catch (InvalidPathException ignore) {
+ }
+ return null;
+ }
+
+ @Override
+ public void close() throws IOException {
+ }
+ }
+
+ private final class ArchiveContainer implements Container {
+ private final Path archivePath;
+ private final FileSystem fileSystem;
+ private final Map<RelativePath, Path> pathCache = new HashMap<>();
+
+ public ArchiveContainer(Path archivePath) throws IOException, ProviderNotFoundException, SecurityException {
+ this.archivePath = archivePath;
+ if (multiReleaseValue != null && archivePath.toString().endsWith(".jar")) {
+ Map<String,String> env = Collections.singletonMap("multi-release", multiReleaseValue);
+ this.fileSystem = getJarFSProvider().newFileSystem(archivePath, env);
+ } else {
+ this.fileSystem = FileSystems.newFileSystem(archivePath, null);
+ }
+ }
+
+ /**
+ * Insert all files in subdirectory subdirectory of this archive
+ * which match fileKinds into resultList
+ */
+ @Override
+ public void list(Path userPath,
+ RelativeDirectory subdirectory,
+ Set<JavaFileObject.Kind> fileKinds,
+ boolean recurse,
+ ListBuffer<JavaFileObject> resultList) throws IOException {
+ Path resolvedSubdirectory = resolvePath(subdirectory);
+
+ if (resolvedSubdirectory == null)
+ return ;
+
+ int maxDepth = (recurse ? Integer.MAX_VALUE : 1);
+ Set<FileVisitOption> opts = EnumSet.of(FOLLOW_LINKS);
+ Files.walkFileTree(resolvedSubdirectory, opts, maxDepth,
+ new SimpleFileVisitor<Path>() {
+ @Override
+ public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) {
+ if (isValid(dir.getFileName())) {
+ return FileVisitResult.CONTINUE;
+ } else {
+ return FileVisitResult.SKIP_SUBTREE;
+ }
+ }
+
+ boolean isValid(Path fileName) {
+ if (fileName == null) {
+ return true;
+ } else {
+ String name = fileName.toString();
+ if (name.endsWith("/")) {
+ name = name.substring(0, name.length() - 1);
+ }
+ return SourceVersion.isIdentifier(name);
+ }
+ }
+
+ @Override
+ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
+ if (attrs.isRegularFile() && fileKinds.contains(getKind(file.getFileName().toString()))) {
+ JavaFileObject fe = PathFileObject.forJarPath(
+ JavacFileManager.this, file, archivePath);
+ resultList.append(fe);
+ }
+ return FileVisitResult.CONTINUE;
+ }
+ });
+
+ }
+
+ @Override
+ public JavaFileObject getFileObject(Path userPath, RelativeFile name) throws IOException {
+ Path p = resolvePath(name);
+ if (p != null)
+ return PathFileObject.forJarPath(JavacFileManager.this, p, userPath);
+
+ return null;
+ }
+
+ private synchronized Path resolvePath(RelativePath path) {
+ if (!pathCache.containsKey(path)) {
+ Path relativePath = path.resolveAgainst(fileSystem);
+
+ if (!Files.exists(relativePath)) {
+ relativePath = null;
+ }
+
+ pathCache.put(path, relativePath);
+ return relativePath;
+ }
+ return pathCache.get(path);
+ }
+
+ @Override
+ public void close() throws IOException {
+ fileSystem.close();
+ }
+ }
+
+ private FileSystemProvider jarFSProvider;
+
+ private FileSystemProvider getJarFSProvider() throws IOException {
+ if (jarFSProvider != null) {
+ return jarFSProvider;
+ }
+ for (FileSystemProvider provider: FileSystemProvider.installedProviders()) {
+ if (provider.getScheme().equals("jar")) {
+ return (jarFSProvider = provider);
+ }
+ }
+ throw new ProviderNotFoundException("no provider found for .jar files");
}
/**
- * Insert all files in subdirectory subdirectory of archive archivePath
- * which match fileKinds into resultList
+ * container is a directory, a zip file, or a non-existent path.
*/
- private void listArchive(Path archivePath,
- RelativeDirectory subdirectory,
- Set<JavaFileObject.Kind> fileKinds,
- boolean recurse,
- ListBuffer<JavaFileObject> resultList)
- throws IOException {
- FileSystem fs = getFileSystem(archivePath);
- if (fs == null) {
- return;
- }
-
- Path containerSubdir = subdirectory.resolveAgainst(fs);
- if (!Files.exists(containerSubdir)) {
- return;
- }
-
- int maxDepth = (recurse ? Integer.MAX_VALUE : 1);
- Set<FileVisitOption> opts = EnumSet.of(FOLLOW_LINKS);
- Files.walkFileTree(containerSubdir, opts, maxDepth,
- new SimpleFileVisitor<Path>() {
- @Override
- public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) {
- if (isValid(dir.getFileName())) {
- return FileVisitResult.CONTINUE;
- } else {
- return FileVisitResult.SKIP_SUBTREE;
- }
- }
-
- boolean isValid(Path fileName) {
- if (fileName == null) {
- return true;
- } else {
- String name = fileName.toString();
- if (name.endsWith("/")) {
- name = name.substring(0, name.length() - 1);
- }
- return SourceVersion.isIdentifier(name);
- }
- }
-
- @Override
- public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
- if (attrs.isRegularFile() && fileKinds.contains(getKind(file.getFileName().toString()))) {
- JavaFileObject fe = PathFileObject.forJarPath(
- JavacFileManager.this, file, archivePath);
- resultList.append(fe);
- }
- return FileVisitResult.CONTINUE;
- }
- });
-
- }
-
- /**
- * container is a directory, a zip file, or a non-existant path.
- * Insert all files in subdirectory subdirectory of container which
- * match fileKinds into resultList
- */
- private void listContainer(Path container,
- RelativeDirectory subdirectory,
- Set<JavaFileObject.Kind> fileKinds,
- boolean recurse,
- ListBuffer<JavaFileObject> resultList)
- throws IOException {
- if (Files.isRegularFile(container) && container.equals(Locations.thisSystemModules)) {
- try {
- listJRTImage(subdirectory,
- fileKinds,
- recurse,
- resultList);
- } catch (IOException ex) {
- ex.printStackTrace(System.err);
- log.error("error.reading.file", container, getMessage(ex));
- }
- return;
- }
-
- if (Files.isDirectory(container)) {
- listDirectory(container, null,
- subdirectory,
- fileKinds,
- recurse,
- resultList);
- return;
- }
-
- if (Files.isRegularFile(container)) {
- listArchive(container,
- subdirectory,
- fileKinds,
- recurse,
- resultList);
- }
- }
-
private boolean isValidFile(String s, Set<JavaFileObject.Kind> fileKinds) {
JavaFileObject.Kind kind = getKind(s);
return fileKinds.contains(kind);
@@ -498,18 +642,6 @@
return j < 0;
}
- private FileSystem getFileSystem(Path path) throws IOException {
- Path realPath = fsInfo.getCanonicalFile(path);
- FileSystem fs = fileSystems.get(realPath);
- if (fs == null) {
- fileSystems.put(realPath, fs = FileSystems.newFileSystem(realPath, null));
- }
- return fs;
- }
-
- private final Map<Path,FileSystem> fileSystems = new HashMap<>();
-
-
/** Flush any output resources.
*/
@Override @DefinedBy(Api.COMPILER)
@@ -528,10 +660,10 @@
}
locations.close();
- for (FileSystem fs: fileSystems.values()) {
- fs.close();
+ for (Container container: containers.values()) {
+ container.close();
}
- fileSystems.clear();
+ containers.clear();
contentCache.clear();
}
@@ -570,8 +702,12 @@
RelativeDirectory subdirectory = RelativeDirectory.forPackage(packageName);
ListBuffer<JavaFileObject> results = new ListBuffer<>();
- for (Path directory : path)
- listContainer(directory, subdirectory, kinds, recurse, results);
+ for (Path directory : path) {
+ Container container = getContainer(directory);
+
+ container.list(directory, subdirectory, kinds, recurse, results);
+ }
+
return results.toList();
}
@@ -644,29 +780,10 @@
return null;
for (Path file: path) {
- if (file.equals(Locations.thisSystemModules)) {
- JRTIndex.Entry e = getJRTIndex().getEntry(name.dirname());
- if (symbolFileEnabled && e.ctSym.hidden)
- continue;
- Path p = e.files.get(name.basename());
- if (p != null)
- return PathFileObject.forJRTPath(this, p);
- } else if (Files.isDirectory(file)) {
- try {
- Path f = name.resolveAgainst(file);
- if (Files.exists(f))
- return PathFileObject.forSimplePath(this,
- fsInfo.getCanonicalFile(f), f);
- } catch (InvalidPathException ignore) {
- }
- } else if (Files.isRegularFile(file)) {
- FileSystem fs = getFileSystem(file);
- if (fs != null) {
- Path fsRoot = fs.getRootDirectories().iterator().next();
- Path f = name.resolveAgainst(fsRoot);
- if (Files.exists(f))
- return PathFileObject.forJarPath(this, f, file);
- }
+ JavaFileObject fo = getContainer(file).getFileObject(file, name);
+
+ if (fo != null) {
+ return fo;
}
}
return null;
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Target.java Thu Apr 21 20:49:11 2016 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Target.java Fri Apr 22 01:04:00 2016 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 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
@@ -141,4 +141,10 @@
return compareTo(JDK1_9) >= 0;
}
+ /** Value of platform release used to access multi-release jar files
+ */
+ public String multiReleaseValue() {
+ return Integer.toString(this.ordinal() - Target.JDK1_1.ordinal() + 1);
+ }
+
}
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Main.java Thu Apr 21 20:49:11 2016 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Main.java Fri Apr 22 01:04:00 2016 -0700
@@ -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
@@ -42,6 +42,7 @@
import com.sun.tools.javac.file.CacheFSInfo;
import com.sun.tools.javac.file.BaseFileManager;
import com.sun.tools.javac.file.JavacFileManager;
+import com.sun.tools.javac.jvm.Target;
import com.sun.tools.javac.platform.PlatformDescription;
import com.sun.tools.javac.processing.AnnotationProcessingError;
import com.sun.tools.javac.util.*;
@@ -230,7 +231,7 @@
if (args.isEmpty())
return Result.OK;
- // init Depeendencies
+ // init Dependencies
if (options.isSet("completionDeps")) {
Dependencies.GraphDependencies.preRegister(context);
}
@@ -242,6 +243,13 @@
t.initPlugins(pluginOpts);
}
+ // init multi-release jar handling
+ if (fileManager.isSupportedOption(Option.MULTIRELEASE.text) == 1) {
+ Target target = Target.instance(context);
+ List<String> list = List.of(target.multiReleaseValue());
+ fileManager.handleOption(Option.MULTIRELEASE.text, list.iterator());
+ }
+
// init JavaCompiler
JavaCompiler comp = JavaCompiler.instance(context);
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Option.java Thu Apr 21 20:49:11 2016 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Option.java Fri Apr 22 01:04:00 2016 -0700
@@ -667,7 +667,9 @@
}
return false;
}
- };
+ },
+
+ MULTIRELEASE("-multi-release", "opt.arg.multi-release", "opt.multi-release", HIDDEN, FILEMANAGER);
/** The kind of an Option. This is used by the -help and -X options. */
public enum OptionKind {
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac.properties Thu Apr 21 20:49:11 2016 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac.properties Fri Apr 22 01:04:00 2016 -0700
@@ -99,6 +99,8 @@
Specify whether or not to generate class files for implicitly referenced files
javac.opt.pkginfo=\
Specify handling of package-info files
+javac.opt.multi-release=\
+ Specify which release to use in multi-release jars
javac.opt.arg.class=\
<class>
javac.opt.arg.class.list=\
@@ -133,6 +135,8 @@
Name and optional arguments for a plug-in to be run
javac.opt.arg.plugin=\
"name args"
+javac.opt.arg.multi-release=\
+ <release>
## extended options
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Start.java Thu Apr 21 20:49:11 2016 -0700
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Start.java Fri Apr 22 01:04:00 2016 -0700
@@ -52,6 +52,8 @@
import com.sun.tools.javac.file.BaseFileManager;
import com.sun.tools.javac.file.JavacFileManager;
import com.sun.tools.javac.main.CommandLine;
+import com.sun.tools.javac.main.OptionHelper;
+import com.sun.tools.javac.main.OptionHelper.GrumpyHelper;
import com.sun.tools.javac.platform.PlatformDescription;
import com.sun.tools.javac.platform.PlatformUtils;
import com.sun.tools.javac.util.ClientCodeException;
@@ -342,7 +344,7 @@
compOpts = Options.instance(context);
// Make sure no obsolete source/target messages are reported
- compOpts.put("-Xlint:-options", "-Xlint:-options");
+ com.sun.tools.javac.main.Option.XLINT.process(getOptionHelper(), "-Xlint:-options");
doclet.init(locale, messager);
parseArgs(argList, javaNames);
@@ -550,6 +552,8 @@
if (o.hasArg) {
oneArg(args, i++);
o.process(this, args.get(i));
+ } else if (o.hasSuffix) {
+ o.process(this, arg);
} else {
setOption(arg);
o.process(this);
@@ -690,4 +694,19 @@
}
return null;
}
+
+ @Override
+ OptionHelper getOptionHelper() {
+ return new GrumpyHelper(null) {
+ @Override
+ public String get(com.sun.tools.javac.main.Option option) {
+ return compOpts.get(option);
+ }
+
+ @Override
+ public void put(String name, String value) {
+ compOpts.put(name, value);
+ }
+ };
+ }
}
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ToolOption.java Thu Apr 21 20:49:11 2016 -0700
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ToolOption.java Fri Apr 22 01:04:00 2016 -0700
@@ -32,6 +32,7 @@
import java.util.StringTokenizer;
import com.sun.tools.javac.main.Option;
+import com.sun.tools.javac.main.OptionHelper;
import com.sun.tools.javac.util.Options;
/**
@@ -118,14 +119,14 @@
ADDMODS("-addmods", true) {
@Override
public void process(Helper helper, String arg) {
- helper.setCompilerOpt(opt, arg);
+ Option.ADDMODS.process(helper.getOptionHelper(), opt, arg);
}
},
LIMITMODS("-limitmods", true) {
@Override
public void process(Helper helper, String arg) {
- helper.setCompilerOpt(opt, arg);
+ Option.LIMITMODS.process(helper.getOptionHelper(), opt, arg);
}
},
@@ -133,35 +134,63 @@
@Override
public void process(Helper helper, String arg) {
helper.encoding = arg;
- helper.setCompilerOpt(opt, arg);
+ helper.setFileManagerOpt(Option.ENCODING, arg);
}
},
RELEASE("-release", true) {
@Override
public void process(Helper helper, String arg) {
- helper.setCompilerOpt(opt, arg);
+ Option.RELEASE.process(helper.getOptionHelper(), opt, arg);
}
},
SOURCE("-source", true) {
@Override
public void process(Helper helper, String arg) {
- helper.setCompilerOpt(opt, arg);
+ Option.SOURCE.process(helper.getOptionHelper(), opt, arg);
}
},
XMAXERRS("-Xmaxerrs", true) {
@Override
public void process(Helper helper, String arg) {
- helper.setCompilerOpt(opt, arg);
+ Option.XMAXERRS.process(helper.getOptionHelper(), opt, arg);
}
},
XMAXWARNS("-Xmaxwarns", true) {
@Override
public void process(Helper helper, String arg) {
- helper.setCompilerOpt(opt, arg);
+ Option.XMAXWARNS.process(helper.getOptionHelper(), opt, arg);
+ }
+ },
+
+ XADDREADS("-XaddReads:", false) {
+ @Override
+ public void process(Helper helper, String arg) {
+ Option.XADDREADS.process(helper.getOptionHelper(), arg);
+ }
+ },
+
+ XADDEXPORTS("-XaddExports:", false) {
+ @Override
+ public void process(Helper helper, String arg) {
+ Option.XADDEXPORTS.process(helper.getOptionHelper(), arg);
+ }
+ },
+
+ XMODULE("-Xmodule:", false) {
+ @Override
+ public void process(Helper helper, String arg) {
+ Option.XMODULE.process(helper.getOptionHelper(), arg);
+ }
+ },
+
+ XPATCH("-Xpatch:", false) {
+ @Override
+ public void process(Helper helper, String arg) {
+ Option.XMODULE.process(helper.getOptionHelper(), arg);
}
},
@@ -299,6 +328,7 @@
public final String opt;
public final boolean hasArg;
+ public final boolean hasSuffix; // ex: foo:bar or -foo=bar
ToolOption(String opt) {
this(opt, false);
@@ -307,6 +337,8 @@
ToolOption(String opt, boolean hasArg) {
this.opt = opt;
this.hasArg = hasArg;
+ char lastChar = opt.charAt(opt.length() - 1);
+ this.hasSuffix = lastChar == ':' || lastChar == '=';
}
void process(Helper helper, String arg) { }
@@ -314,9 +346,16 @@
void process(Helper helper) { }
static ToolOption get(String name) {
- for (ToolOption o: values()) {
- if (name.equals(o.opt))
+ String oname = name;
+ if (name.contains(":")) {
+ oname = name.substring(0, name.indexOf(':') + 1);
+ } else if (name.contains("=")) {
+ oname = name.substring(0, name.indexOf('=') + 1);
+ }
+ for (ToolOption o : values()) {
+ if (oname.equals(o.opt)) {
return o;
+ }
}
return null;
}
@@ -366,6 +405,7 @@
abstract void Xusage();
abstract void usageError(String msg, Object... args);
+ abstract OptionHelper getOptionHelper();
void addToList(List<String> list, String str){
StringTokenizer st = new StringTokenizer(str, ":");
@@ -388,13 +428,6 @@
}
}
- void setCompilerOpt(String opt, String arg) {
- if (compOpts.get(opt) != null) {
- usageError("main.option.already.seen", opt);
- }
- compOpts.put(opt, arg);
- }
-
void setFileManagerOpt(Option opt, String arg) {
fileManagerOpts.put(opt, arg);
}
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/resources/javadoc.properties Thu Apr 21 20:49:11 2016 -0700
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/resources/javadoc.properties Fri Apr 22 01:04:00 2016 -0700
@@ -37,6 +37,13 @@
\ -help Display command line options and exit\n\
\ -doclet <class> Generate output via alternate doclet\n\
\ -docletpath <path> Specify where to find doclet class files\n\
+\ -modulesourcepath <path> Specify where to find input source files for multiple modules\n\
+\ -upgrademodulepath <path> Override location of upgradeable modules\n\
+\ -modulepath <path> Specify where to find application modules\n\
+\ -mp <path> Specify where to find application modules\n\
+\ -addmods <module>(,<module>)* Root modules to resolve in addition to the initial modules,\n\
+\ or all modules on the module path if <module> is ALL-MODULE-PATH.\n\
+\ -limitmods <module>(,<module>)* Limit the universe of observable modules\n\
\ -sourcepath <pathlist> Specify where to find source files\n\
\ -classpath <pathlist> Specify where to find user class files\n\
\ -cp <pathlist> Specify where to find user class files\n\
@@ -56,14 +63,23 @@
main.Xusage=\
\ -Xmaxerrs <number> Set the maximum number of errors to print\n\
-\ -Xmaxwarns <number> Set the maximum number of warnings to print\n
+\ -Xmaxwarns <number> Set the maximum number of warnings to print\n\
+\ -XaddExports:<module>/<package>=<other-module>(,<other-module>)*\n\
+\ Specify a package to be considered as exported from its \n\
+\ defining module to additional modules, or to all unnamed \n\
+\ modules if <other-module> is ALL-UNNAMED.\n\
+\ -XaddReads:<module>=<other-module>(,<other-module>)*\n\
+\ Specify additional modules to be considered as required by a\n\
+\ given module. <other-module> may be ALL-UNNAMED to require\n\
+\ the unnamed module.\n\
+\ -Xmodule:<module-name> Specify a module to which the classes being compiled belong.\n\
+\ -Xpatch:<path> Specify location of module class files to patch\n
main.Xusage.foot=\
These options are non-standard and subject to change without notice.
main.doclet.usage.header=Provided by the {0} doclet:
-main.option.already.seen=The {0} option may be specified no more than once.
main.requires_argument=option {0} requires an argument.
main.invalid_flag=invalid flag: {0}
main.No_packages_or_classes_specified=No packages or classes specified.
--- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java Thu Apr 21 20:49:11 2016 -0700
+++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java Fri Apr 22 01:04:00 2016 -0700
@@ -1077,12 +1077,12 @@
ed.add(n);
}
editor = ed.toArray(new String[ed.size()]);
- fluffmsg("jshell.msg.set.editor.set", arg);
+ fluffmsg("jshell.msg.set.editor.set", prog);
return true;
}
}
case "start": {
- String init = readFile(at.next(), "'/set start'");
+ String init = readFile(at.next(), "/set start");
if (init == null) {
return false;
} else {
@@ -1351,7 +1351,7 @@
.filter(sn -> state.status(sn).isActive && sn instanceof PersistentSnippet)
.collect(toList());
if (snippets.isEmpty()) {
- errormsg("jshell.err.drop.active");
+ errormsg("jshell.err.drop.not.active");
return false;
}
if (snippets.size() > 1) {
@@ -1499,7 +1499,7 @@
}
private boolean cmdOpen(String filename) {
- return runFile(filename, "'/open'");
+ return runFile(filename, "/open");
}
private boolean runFile(String filename, String context) {
@@ -1533,7 +1533,7 @@
} catch (AccessDeniedException e) {
errormsg("jshell.err.file.not.accessible", context, filename, e.getMessage());
} catch (NoSuchFileException e) {
- errormsg("jshell.err.file.not.found", context, filename, e.getMessage());
+ errormsg("jshell.err.file.not.found", context, filename);
} catch (Exception e) {
errormsg("jshell.err.file.exception", context, filename, e);
}
--- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/resources/l10n.properties Thu Apr 21 20:49:11 2016 -0700
+++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/resources/l10n.properties Fri Apr 22 01:04:00 2016 -0700
@@ -42,7 +42,7 @@
jshell.msg.see = See {0} for help.
jshell.err.file.not.accessible = File ''{1}'' for ''{0}'' is not accessible: {2}
-jshell.err.file.not.found = File ''{1}'' for ''{0}'' is not found: {2}
+jshell.err.file.not.found = File ''{1}'' for ''{0}'' is not found.
jshell.err.file.exception = File ''{1}'' for ''{0}'' threw exception: {2}
jshell.err.file.filename = ''{0}'' requires a filename argument.
@@ -90,7 +90,7 @@
jshell.err.drop.arg =\
In the /drop argument, please specify an import, variable, method, or class to drop.\n\
Specify by id or name. Use /list to see ids. Use /reset to reset all state.
-jshell.msg.drop.not.active = The argument did not specify an active import, variable, method, or class to drop.
+jshell.err.drop.not.active = The argument did not specify an active import, variable, method, or class to drop.
jshell.err.drop.ambiguous = The argument references more than one import, variable, method, or class.
jshell.err.failed = Failed.
jshell.msg.native.method = Native Method
@@ -503,74 +503,86 @@
which are run when the jshell tool is started or reset.
startup.feedback = \
-/set newmode normal command \n\
-/set prompt normal '\\n-> ' '>> ' \n\
-/set format normal pre '| ' \n\
-/set format normal post '%n' \n\
-/set format normal errorpre '| ' \n\
-/set format normal errorpost '%n' \n\
- \n\
-/set format normal errorline '{post}{pre} {err}' \n\
- \n\
-/set format normal action 'Added' added-primary \n\
-/set format normal action 'Modified' modified-primary \n\
-/set format normal action 'Replaced' replaced-primary \n\
-/set format normal action 'Overwrote' overwrote-primary \n\
-/set format normal action 'Dropped' dropped-primary \n\
-/set format normal action ' Update added' added-update \n\
-/set format normal action ' Update modified' modified-update \n\
-/set format normal action ' Update replaced' replaced-update \n\
-/set format normal action ' Update overwrote' overwrote-update \n\
-/set format normal action ' Update dropped' dropped-update \n\
- \n\
-/set format normal until ', however, it cannot be instanciated or its methods invoked until' defined-class-primary \n\
-/set format normal until ', however, its methods cannot be invoked until' defined-interface-primary \n\
-/set format normal until ', however, it cannot be used until' defined-enum,annotation-primary \n\
-/set format normal until ', however, it cannot be invoked until' defined-method-primary \n\
-/set format normal until ', however, it cannot be referenced until' notdefined-primary \n\
-/set format normal until ' which cannot be instanciated or its methods invoked until' defined-class-update \n\
-/set format normal until ' whose methods cannot be invoked until' defined-interface-update \n\
-/set format normal until ' which cannot be invoked until' defined-method-update \n\
-/set format normal until ' which cannot be referenced until' notdefined-update \n\
- \n\
-/set format normal unrerr '{unresolved} is declared' unresolved1-error0 \n\
-/set format normal unrerr '{unresolved} are declared' unresolved2-error0 \n\
-/set format normal unrerr ' this error is corrected: {errors}' unresolved0-error1 \n\
-/set format normal unrerr '{unresolved} is declared and this error is corrected: {errors}' unresolved1-error1 \n\
-/set format normal unrerr '{unresolved} are declared and this error is corrected: {errors}' unresolved2-error1 \n\
-/set format normal unrerr ' these errors are corrected: {errors}' unresolved0-error2 \n\
-/set format normal unrerr '{unresolved} is declared and these errors are corrected: {errors}' unresolved1-error2 \n\
-/set format normal unrerr '{unresolved} are declared and these errors are corrected: {errors}' unresolved2-error2 \n\
- \n\
-/set format normal resolve '{until}{unrerr}' added,modified,replaced,used \n\
- \n\
-/set format normal typeKind 'class' class \n\
-/set format normal typeKind 'interface' interface \n\
-/set format normal typeKind 'enum' enum \n\
-/set format normal typeKind 'annotation interface' annotation \n\
- \n\
-/set format normal display '{pre}{action} {typeKind} {name}{resolve}{post}' class,interface,enum,annotation \n\
-/set format normal display '{pre}{action} method {name}({type}){resolve}{post}' method \n\
- \n\
-/set format normal display '{pre}{action} variable {name} of type {type}{resolve}{post}' vardecl \n\
-/set format normal display '{pre}{action} variable {name} of type {type} with initial value {value}{resolve}{post}' varinit \n\
+/set newmode verbose command \n\
+\n\
+/set prompt verbose '\\njshell> ' ' ...> ' \n\
+\n\
+/set format verbose pre '| ' \n\
+/set format verbose post '%n' \n\
+/set format verbose errorpre '| ' \n\
+/set format verbose errorpost '%n' \n\
+\n\
+/set format verbose errorline '{pre} {err}' \n\
+\n\
+/set format verbose action 'created' added-primary \n\
+/set format verbose action 'modified' modified-primary \n\
+/set format verbose action 'replaced' replaced-primary \n\
+/set format verbose action 'overwrote' overwrote-primary \n\
+/set format verbose action 'dropped' dropped-primary \n\
+/set format verbose action ' update created' added-update \n\
+/set format verbose action ' update modified' modified-update \n\
+/set format verbose action ' update replaced' replaced-update \n\
+/set format verbose action ' update overwrote' overwrote-update \n\
+/set format verbose action ' update dropped' dropped-update \n\
+\n\
+/set format verbose until ', however, it cannot be instanciated or its methods invoked until' defined-class-primary \n\
+/set format verbose until ', however, its methods cannot be invoked until' defined-interface-primary \n\
+/set format verbose until ', however, it cannot be used until' defined-enum,annotation-primary \n\
+/set format verbose until ', however, it cannot be invoked until' defined-method-primary \n\
+/set format verbose until ', however, it cannot be referenced until' notdefined-primary \n\
+/set format verbose until ' which cannot be instanciated or its methods invoked until' defined-class-update \n\
+/set format verbose until ' whose methods cannot be invoked until' defined-interface-update \n\
+/set format verbose until ' which cannot be invoked until' defined-method-update \n\
+/set format verbose until ' which cannot be referenced until' notdefined-update \n\
+\n\
+/set format verbose unrerr '{unresolved} is declared' unresolved1-error0 \n\
+/set format verbose unrerr '{unresolved} are declared' unresolved2-error0 \n\
+/set format verbose unrerr ' this error is corrected: {errors}' unresolved0-error1 \n\
+/set format verbose unrerr '{unresolved} is declared and this error is corrected: {errors}' unresolved1-error1 \n\
+/set format verbose unrerr '{unresolved} are declared and this error is corrected: {errors}' unresolved2-error1 \n\
+/set format verbose unrerr ' these errors are corrected: {errors}' unresolved0-error2 \n\
+/set format verbose unrerr '{unresolved} is declared and these errors are corrected: {errors}' unresolved1-error2 \n\
+/set format verbose unrerr '{unresolved} are declared and these errors are corrected: {errors}' unresolved2-error2 \n\
+\n\
+/set format verbose resolve '{until}{unrerr}' added,modified,replaced,used \n\
+\n\
+/set format verbose typeKind 'class' class \n\
+/set format verbose typeKind 'interface' interface \n\
+/set format verbose typeKind 'enum' enum \n\
+/set format verbose typeKind 'annotation interface' annotation \n\
+\n\
+/set format verbose result '{name} ==> {value}{post}' added,modified,replaced-ok-primary \n\
+\n\
+/set format verbose display '{result}{pre}created scratch variable {name} : {type}{post}' expression-primary \n\
+/set format verbose display '{result}{pre}value of {name} : {type}{post}' varvalue-primary \n\
+/set format verbose display '{result}{pre}assigned to {name} : {type}{post}' assignment-primary \n\
+/set format verbose display '{result}{pre}{action} variable {name} : {type}{resolve}{post}' varinit,vardecl \n\
+/set format verbose display '{pre}{action} variable {name}{resolve}{post}' vardecl,varinit-notdefined \n\
+/set format verbose display '{pre}{action} variable {name}{post}' dropped-vardecl,varinit \n\
+/set format verbose display '{pre}{action} variable {name}, reset to null{post}' replaced-vardecl,varinit-ok-update \n\
+\n\
+/set format verbose display '{pre}{action} {typeKind} {name}{resolve}{post}' class,interface,enum,annotation \n\
+/set format verbose display '{pre}{action} method {name}({type}){resolve}{post}' method \n\
+\n\
+/set format verbose display '{pre}attempted to use {typeKind} {name}{resolve}{post}' used-class,interface,enum,annotation \n\
+/set format verbose display '{pre}attempted to call method {name}({type}){resolve}{post}' used-method \n\
+\n\
+/set newmode normal command verbose \n\
+/set format normal display '' added,modified,replaced,overwrote,dropped-update \n\
/set format normal display '{pre}{action} variable {name}, reset to null{post}' replaced-vardecl,varinit-ok-update \n\
-/set format normal display '{pre}{action} variable {name}{resolve}{post}' vardecl,varinit-notdefined \n\
-/set format normal display '{pre}{action} variable {name}{post}' overwrote,dropped-vardecl,varinit \n\
- \n\
-/set format normal display '{pre}Expression value is: {value}{post}{pre} assigned to temporary variable {name} of type {type}{post}' expression \n\
-/set format normal display '{pre}Variable {name} of type {type} has value {value}{post}' varvalue \n\
-/set format normal display '{pre}Variable {name} has been assigned the value {value}{post}' assignment \n\
- \n\
-/set format normal display '{pre}Attempted to use {typeKind} {name}{resolve}{post}' used-class,interface,enum,annotation \n\
-/set format normal display '{pre}Attempted to call method {name}({type}){resolve}{post}' used-method \n\
- \n\
+/set format normal display '{result}' added,modified,replaced-expression,varvalue,assignment,varinit,vardecl-ok-primary \n\
+/set newmode concise quiet normal \n\
+\n\
+/set prompt concise 'jshell> ' ' ...> ' \n\
+\n\
+/set format concise display '' class,interface,enum,annotation,method,assignment,varinit,vardecl-ok \n\
+\n\
/set feedback normal \n\
- \n\
-/set newmode off quiet \n\
-/set prompt off '-> ' '>> ' \n\
-/set format off pre '| ' \n\
-/set format off post '%n' \n\
-/set format off errorpre '| ' \n\
-/set format off errorpost '%n' \n\
-/set format off display '' \n
+\n\
+/set newmode silent quiet \n\
+/set prompt silent '-> ' '>> ' \n\
+/set format silent pre '| ' \n\
+/set format silent post '%n' \n\
+/set format silent errorpre '| ' \n\
+/set format silent errorpost '%n' \n\
+/set format silent display '' \n
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/Eval.java Thu Apr 21 20:49:11 2016 -0700
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/Eval.java Fri Apr 22 01:04:00 2016 -0700
@@ -465,16 +465,40 @@
// If appropriate, execute the snippet
String value = null;
Exception exception = null;
- if (si.isExecutable() && si.status().isDefined) {
- try {
- value = state.executionControl().commandInvoke(state.maps.classFullName(si));
- value = si.subKind().hasValue()
- ? expunge(value)
- : "";
- } catch (EvalException ex) {
- exception = translateExecutionException(ex);
- } catch (UnresolvedReferenceException ex) {
- exception = ex;
+ if (si.status().isDefined) {
+ if (si.isExecutable()) {
+ try {
+ value = state.executionControl().commandInvoke(state.maps.classFullName(si));
+ value = si.subKind().hasValue()
+ ? expunge(value)
+ : "";
+ } catch (EvalException ex) {
+ exception = translateExecutionException(ex);
+ } catch (UnresolvedReferenceException ex) {
+ exception = ex;
+ }
+ } else if (si.subKind() == SubKind.VAR_DECLARATION_SUBKIND) {
+ switch (((VarSnippet) si).typeName()) {
+ case "byte":
+ case "short":
+ case "int":
+ case "long":
+ value = "0";
+ break;
+ case "float":
+ case "double":
+ value = "0.0";
+ break;
+ case "boolean":
+ value = "false";
+ break;
+ case "char":
+ value = "''";
+ break;
+ default:
+ value = "null";
+ break;
+ }
}
}
return events(c, outs, value, exception);
--- a/langtools/test/jdk/jshell/EditorPadTest.java Thu Apr 21 20:49:11 2016 -0700
+++ b/langtools/test/jdk/jshell/EditorPadTest.java Fri Apr 22 01:04:00 2016 -0700
@@ -25,6 +25,7 @@
* @test
* @summary Testing built-in editor.
* @ignore 8139872
+ * @modules jdk.jshell/jdk.internal.jshell.tool
* @build ReplToolTesting EditorTestBase
* @run testng EditorPadTest
*/
@@ -67,7 +68,7 @@
private static JButton exit = null;
@BeforeClass
- public static void setUp() {
+ public static void setUpEditorPadTest() {
try {
robot = new Robot();
robot.setAutoWaitForIdle(true);
--- a/langtools/test/jdk/jshell/EditorTestBase.java Thu Apr 21 20:49:11 2016 -0700
+++ b/langtools/test/jdk/jshell/EditorTestBase.java Fri Apr 22 01:04:00 2016 -0700
@@ -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
@@ -65,19 +65,19 @@
}
public void assertEditOutput(boolean after, String cmd, String output, Action action) {
- assertEditOutput(after, cmd, s -> assertEquals(s, output, "command"), action);
+ assertEditOutput(after, cmd, s -> assertEquals(s.trim(), output.trim(), "command"), action);
}
@Test
public void testEditNegative() {
- for (String edit : new String[] {"/e", "/edit"}) {
+ for (String edit : new String[] {"/ed", "/edit"}) {
test(new String[]{"-nostartup"},
- a -> assertCommand(a, edit + " 1",
- "| No definition or id named 1 found. See /classes, /methods, /vars, or /list\n"),
- a -> assertCommand(a, edit + " -1",
- "| No definition or id named -1 found. See /classes, /methods, /vars, or /list\n"),
- a -> assertCommand(a, edit + " unknown",
- "| No definition or id named unknown found. See /classes, /methods, /vars, or /list\n")
+ a -> assertCommandOutputStartsWith(a, edit + " 1",
+ "| No definition or id found named: 1"),
+ a -> assertCommandOutputStartsWith(a, edit + " -1",
+ "| No definition or id found named: -1"),
+ a -> assertCommandOutputStartsWith(a, edit + " unknown",
+ "| No definition or id found named: unknown")
);
}
}
@@ -86,7 +86,7 @@
public void testDoNothing() {
testEditor(
a -> assertVariable(a, "int", "a", "0", "0"),
- a -> assertEditOutput(a, "/e 1", "", this::exit),
+ a -> assertEditOutput(a, "/ed 1", "", this::exit),
a -> assertCommandCheckOutput(a, "/v", assertVariables())
);
}
@@ -95,12 +95,12 @@
public void testEditVariable1() {
testEditor(
a -> assertVariable(a, "int", "a", "0", "0"),
- a -> assertEditOutput(a, "/e 1", "| Modified variable a of type int with initial value 10\n", () -> {
+ a -> assertEditOutput(a, "/ed 1", "a ==> 10", () -> {
writeSource("\n\n\nint a = 10;\n\n\n");
exit();
loadVariable(true, "int", "a", "10", "10");
}),
- a -> assertEditOutput(a, "/e 1", "| Modified variable a of type int with initial value 15\n", () -> {
+ a -> assertEditOutput(a, "/ed 1", "a ==> 15", () -> {
writeSource("int a = 15;");
exit();
loadVariable(true, "int", "a", "15", "15");
@@ -113,12 +113,12 @@
public void testEditVariable2() {
testEditor(
a -> assertVariable(a, "int", "a", "0", "0"),
- a -> assertEditOutput(a, "/e 1", "| Added variable b of type int with initial value 10\n", () -> {
+ a -> assertEditOutput(a, "/ed 1", "b ==> 10", () -> {
writeSource("int b = 10;");
exit();
loadVariable(true, "int", "b", "10", "10");
}),
- a -> assertEditOutput(a, "/e 1", "| Modified variable a of type int with initial value 15\n", () -> {
+ a -> assertEditOutput(a, "/ed 1", "a ==> 15", () -> {
writeSource("int a = 15;");
exit();
loadVariable(true, "int", "a", "15", "15");
@@ -131,19 +131,18 @@
public void testEditClass1() {
testEditor(
a -> assertClass(a, "class A {}", "class", "A"),
- a -> assertEditOutput(a, "/e 1", "", () -> {
+ a -> assertEditOutput(a, "/ed 1", "", () -> {
writeSource("\n\n\nclass A {}\n\n\n");
exit();
loadClass(true, "class A {}", "class", "A");
}),
- a -> assertEditOutput(a, "/e 1",
- "| Replaced enum A\n" +
- "| Update overwrote class A\n", () -> {
+ a -> assertEditOutput(a, "/ed 1",
+ "| replaced enum A", () -> {
writeSource("enum A {}");
exit();
loadClass(true, "enum A {}", "enum", "A");
}),
- a -> assertCommandCheckOutput(a, "/c", assertClasses())
+ a -> assertCommandCheckOutput(a, "/classes", assertClasses())
);
}
@@ -151,19 +150,18 @@
public void testEditClass2() {
testEditor(
a -> assertClass(a, "class A {}", "class", "A"),
- a -> assertEditOutput(a, "/e 1", "| Added class B\n", () -> {
+ a -> assertEditOutput(a, "/ed 1", "| created class B", () -> {
writeSource("class B { }");
exit();
loadClass(true, "class B {}", "class", "B");
}),
- a -> assertEditOutput(a, "/e 1",
- "| Replaced enum A\n" +
- "| Update overwrote class A\n", () -> {
+ a -> assertEditOutput(a, "/ed 1",
+ "| replaced enum A", () -> {
writeSource("enum A {}");
exit();
loadClass(true, "enum A {}", "enum", "A");
}),
- a -> assertCommandCheckOutput(a, "/c", assertClasses())
+ a -> assertCommandCheckOutput(a, "/classes", assertClasses())
);
}
@@ -171,14 +169,13 @@
public void testEditMethod1() {
testEditor(
a -> assertMethod(a, "void f() {}", "()void", "f"),
- a -> assertEditOutput(a, "/e 1", "", () -> {
+ a -> assertEditOutput(a, "/ed 1", "", () -> {
writeSource("\n\n\nvoid f() {}\n\n\n");
exit();
loadMethod(true, "void f() {}", "()void", "f");
}),
- a -> assertEditOutput(a, "/e 1",
- "| Replaced method f()\n" +
- "| Update overwrote method f()\n", () -> {
+ a -> assertEditOutput(a, "/ed 1",
+ "| replaced method f()", () -> {
writeSource("double f() { return 0; }");
exit();
loadMethod(true, "double f() { return 0; }", "()double", "f");
@@ -191,14 +188,13 @@
public void testEditMethod2() {
testEditor(
a -> assertMethod(a, "void f() {}", "()void", "f"),
- a -> assertEditOutput(a, "/e 1", "| Added method g()\n", () -> {
+ a -> assertEditOutput(a, "/ed 1", "| created method g()", () -> {
writeSource("void g() {}");
exit();
loadMethod(true, "void g() {}", "()void", "g");
}),
- a -> assertEditOutput(a, "/e 1",
- "| Replaced method f()\n" +
- "| Update overwrote method f()\n", () -> {
+ a -> assertEditOutput(a, "/ed 1",
+ "| replaced method f()", () -> {
writeSource("double f() { return 0; }");
exit();
loadMethod(true, "double f() { return 0; }", "()double", "f");
@@ -213,7 +209,7 @@
a -> assertVariable(a, "int", "a"),
a -> assertMethod(a, "void f() {}", "()void", "f"),
a -> assertClass(a, "class A {}", "class", "A"),
- a -> assertEditInput(a, "/e", s -> {
+ a -> assertEditInput(a, "/ed", s -> {
String[] ss = s.split("\n");
assertEquals(ss.length, 3, "Expected 3 lines: " + s);
assertEquals(ss[0], "int a;");
@@ -226,15 +222,15 @@
@Test
public void testStartup() {
testEditor(true, new String[0],
- a -> assertEditInput(a, "/e", s -> assertTrue(s.isEmpty(), "Checking of startup: " + s), this::cancel),
- a -> assertEditInput(a, "/e printf", assertStartsWith("void printf"), this::cancel));
+ a -> assertEditInput(a, "/ed", s -> assertTrue(s.isEmpty(), "Checking of startup: " + s), this::cancel),
+ a -> assertEditInput(a, "/ed printf", assertStartsWith("void printf"), this::cancel));
}
@Test
public void testCancel() {
testEditor(
a -> assertVariable(a, "int", "a"),
- a -> assertEditOutput(a, "/e a", "", () -> {
+ a -> assertEditOutput(a, "/ed a", "", () -> {
writeSource("int b = 10");
cancel();
})
@@ -245,7 +241,7 @@
public void testAccept() {
testEditor(
a -> assertVariable(a, "int", "a"),
- a -> assertEditOutput(a, "/e a", "| Added variable b of type int with initial value 10\n", () -> {
+ a -> assertEditOutput(a, "/ed a", "b ==> 10", () -> {
writeSource("int b = 10");
accept();
exit();
--- a/langtools/test/jdk/jshell/ExternalEditorTest.java Thu Apr 21 20:49:11 2016 -0700
+++ b/langtools/test/jdk/jshell/ExternalEditorTest.java Fri Apr 22 01:04:00 2016 -0700
@@ -24,8 +24,9 @@
/*
* @test
* @summary Testing external editor.
- * @bug 8080843
+ * @bug 8080843 8143955
* @ignore 8080843
+ * @modules jdk.jshell/jdk.internal.jshell.tool
* @build ReplToolTesting CustomEditor EditorTestBase
* @run testng ExternalEditorTest
*/
@@ -124,7 +125,7 @@
}
@BeforeClass
- public static void setUp() throws IOException {
+ public static void setUpExternalEditorTest() throws IOException {
listener = new ServerSocket(0);
listener.setSoTimeout(30000);
int localPort = listener.getLocalPort();
@@ -193,11 +194,11 @@
@Test
public void setUnknownEditor() {
test(
- a -> assertCommand(a, "/set editor", "| /set editor requires a path argument\n"),
- a -> assertCommand(a, "/set editor UNKNOWN", "| Editor set to: UNKNOWN\n"),
+ a -> assertCommand(a, "/set editor", "| The '/set editor' command requires a path argument"),
+ a -> assertCommand(a, "/set editor UNKNOWN", "| Editor set to: UNKNOWN"),
a -> assertCommand(a, "int a;", null),
- a -> assertCommand(a, "/e 1",
- "| Edit Error: process IO failure: Cannot run program \"UNKNOWN\": error=2, No such file or directory\n")
+ a -> assertCommand(a, "/ed 1",
+ "| Edit Error: process IO failure: Cannot run program \"UNKNOWN\": error=2, No such file or directory")
);
}
--- a/langtools/test/jdk/jshell/ReplToolTesting.java Thu Apr 21 20:49:11 2016 -0700
+++ b/langtools/test/jdk/jshell/ReplToolTesting.java Fri Apr 22 01:04:00 2016 -0700
@@ -273,8 +273,7 @@
}
public void evaluateExpression(boolean after, String type, String expr, String value) {
- String output = String.format("\\| *Expression values is: %s\n|" +
- " *.*temporary variable (\\$\\d+) of type %s", value, type);
+ String output = String.format("(\\$\\d+) ==> %s", value);
Pattern outputPattern = Pattern.compile(output);
assertCommandCheckOutput(after, expr, s -> {
Matcher matcher = outputPattern.matcher(s);
@@ -558,14 +557,19 @@
@Override
public Consumer<String> checkOutput() {
- String pattern = String.format("\\| *\\w+ variable %s of type %s", name, type);
- if (initialValue != null) {
- pattern += " with initial value " + initialValue;
- }
- Predicate<String> checkOutput = Pattern.compile(pattern).asPredicate();
- final String finalPattern = pattern;
- return output -> assertTrue(checkOutput.test(output),
- "Output: " + output + " does not fit pattern: " + finalPattern);
+ String arrowPattern = String.format("%s ==> %s", name, value);
+ Predicate<String> arrowCheckOutput = Pattern.compile(arrowPattern).asPredicate();
+ String howeverPattern = String.format("\\| *\\w+ variable %s, however*.", name);
+ Predicate<String> howeverCheckOutput = Pattern.compile(howeverPattern).asPredicate();
+ return output -> {
+ if (output.startsWith("| ")) {
+ assertTrue(howeverCheckOutput.test(output),
+ "Output: " + output + " does not fit pattern: " + howeverPattern);
+ } else {
+ assertTrue(arrowCheckOutput.test(output),
+ "Output: " + output + " does not fit pattern: " + arrowPattern);
+ }
+ };
}
@Override
--- a/langtools/test/jdk/jshell/T8146368/JShellToolTest8146368.java Thu Apr 21 20:49:11 2016 -0700
+++ b/langtools/test/jdk/jshell/T8146368/JShellToolTest8146368.java Fri Apr 22 01:04:00 2016 -0700
@@ -37,8 +37,8 @@
public class JShellToolTest8146368 extends ReplToolTesting {
public void test() {
test(
- a -> assertCommand(a, "class A extends B {}", "| Added class A, however, it cannot be referenced until class B is declared\n"),
- a -> assertCommand(a, "und m() { return new und(); }", "| Added method m(), however, it cannot be referenced until class und is declared\n")
+ a -> assertCommand(a, "class A extends B {}", "| created class A, however, it cannot be referenced until class B is declared\n"),
+ a -> assertCommand(a, "und m() { return new und(); }", "| created method m(), however, it cannot be referenced until class und is declared\n")
);
}
}
--- a/langtools/test/jdk/jshell/ToolBasicTest.java Thu Apr 21 20:49:11 2016 -0700
+++ b/langtools/test/jdk/jshell/ToolBasicTest.java Fri Apr 22 01:04:00 2016 -0700
@@ -23,9 +23,13 @@
/*
* @test
- * @bug 8143037 8142447 8144095 8140265 8144906 8146138 8147887 8147886 8148316 8148317
+ * @bug 8143037 8142447 8144095 8140265 8144906 8146138 8147887 8147886 8148316 8148317 8143955
* @summary Tests for Basic tests for REPL tool
* @requires os.family != "solaris"
+ * @modules jdk.compiler/com.sun.tools.javac.api
+ * jdk.compiler/com.sun.tools.javac.main
+ * jdk.jdeps/com.sun.tools.javap
+ * jdk.jshell/jdk.internal.jshell.tool
* @library /tools/lib
* @ignore 8139873
* @build toolbox.ToolBox toolbox.JarTask toolbox.JavacTask
@@ -176,23 +180,23 @@
}
assertOutput(getCommandOutput(), "", "command");
assertOutput(getCommandErrorOutput(), "", "command error");
- assertOutput(getUserOutput(), output, "user");
+ assertOutput(getUserOutput().trim(), output, "user");
assertOutput(getUserErrorOutput(), "", "user error");
}
}
public void testStop() {
test(
- (a) -> assertStop(a, "while (true) {}", "Killed.\n"),
- (a) -> assertStop(a, "while (true) { try { Thread.sleep(100); } catch (InterruptedException ex) { } }", "Killed.\n")
+ (a) -> assertStop(a, "while (true) {}", "Killed."),
+ (a) -> assertStop(a, "while (true) { try { Thread.sleep(100); } catch (InterruptedException ex) { } }", "Killed.")
);
}
@Test(enabled = false) // TODO 8130450
public void testRerun() {
test(false, new String[] {"-nostartup"},
- (a) -> assertCommand(a, "/0", "| No such command or snippet id: /0\n| Type /help for help.\n"),
- (a) -> assertCommand(a, "/5", "| No such command or snippet id: /5\n| Type /help for help.\n")
+ (a) -> assertCommand(a, "/0", "| No such command or snippet id: /0\n| Type /help for help."),
+ (a) -> assertCommand(a, "/5", "| No such command or snippet id: /5\n| Type /help for help.")
);
String[] codes = new String[] {
"int a = 0;", // var
@@ -251,99 +255,9 @@
);
test(false, new String[] {"-nostartup"},
- (a) -> assertCommand(a, "/s1", "| No such command or snippet id: /s1\n| Type /help for help.\n"),
- (a) -> assertCommand(a, "/1", "| No such command or snippet id: /1\n| Type /help for help.\n"),
- (a) -> assertCommand(a, "/e1", "| No such command or snippet id: /e1\n| Type /help for help.\n")
- );
- }
-
- public void testRemaining() {
- test(
- (a) -> assertCommand(a, "int z; z =", "| Added variable z of type int\n"),
- (a) -> assertCommand(a, "5", "| Variable z has been assigned the value 5\n"),
- (a) -> assertCommand(a, "/*nada*/; int q =", ""),
- (a) -> assertCommand(a, "77", "| Added variable q of type int with initial value 77\n"),
- (a) -> assertCommand(a, "//comment;", ""),
- (a) -> assertCommand(a, "int v;", "| Added variable v of type int\n"),
- (a) -> assertCommand(a, "int v; int c", "| Added variable c of type int\n")
- );
- }
-
- public void oneLineOfError() {
- test(
- (a) -> assertCommand(a, "12+", null),
- (a) -> assertCommandCheckOutput(a, " true", (s) ->
- assertTrue(s.contains("12+") && !s.contains("true"), "Output: '" + s + "'"))
- );
- }
-
- public void defineVariables() {
- test(
- (a) -> assertCommandCheckOutput(a, "/list", assertList()),
- (a) -> assertCommandCheckOutput(a, "/vars", assertVariables()),
- (a) -> assertVariable(a, "int", "a"),
- (a) -> assertCommandCheckOutput(a, "/list", assertList()),
- (a) -> assertCommandCheckOutput(a, "/vars", assertVariables()),
- (a) -> assertVariable(a, "double", "a", "1", "1.0"),
- (a) -> assertCommandCheckOutput(a, "/list", assertList()),
- (a) -> assertCommandCheckOutput(a, "/vars", assertVariables()),
- (a) -> evaluateExpression(a, "double", "2 * a", "2.0"),
- (a) -> assertCommandCheckOutput(a, "/list", assertList()),
- (a) -> assertCommandCheckOutput(a, "/vars", assertVariables())
- );
- }
-
- public void defineMethods() {
- test(
- (a) -> assertCommandCheckOutput(a, "/list", assertList()),
- (a) -> assertCommandCheckOutput(a, "/methods", assertMethods()),
- (a) -> assertMethod(a, "int f() { return 0; }", "()int", "f"),
- (a) -> assertCommandCheckOutput(a, "/list", assertList()),
- (a) -> assertCommandCheckOutput(a, "/methods", assertMethods()),
- (a) -> assertMethod(a, "void f(int a) { g(); }", "(int)void", "f"),
- (a) -> assertCommandCheckOutput(a, "/list", assertList()),
- (a) -> assertCommandCheckOutput(a, "/methods", assertMethods()),
- (a) -> assertMethod(a, "void g() {}", "()void", "g"),
- (a) -> assertCommandCheckOutput(a, "/list", assertList()),
- (a) -> assertCommandCheckOutput(a, "/methods", assertMethods())
- );
- }
-
- public void defineClasses() {
- test(
- (a) -> assertCommandCheckOutput(a, "/list", assertList()),
- (a) -> assertCommandCheckOutput(a, "/classes", assertClasses()),
- (a) -> assertClass(a, "class A { }", "class", "A"),
- (a) -> assertCommandCheckOutput(a, "/list", assertList()),
- (a) -> assertCommandCheckOutput(a, "/classes", assertClasses()),
- (a) -> assertClass(a, "interface A { }", "interface", "A"),
- (a) -> assertCommandCheckOutput(a, "/list", assertList()),
- (a) -> assertCommandCheckOutput(a, "/classes", assertClasses()),
- (a) -> assertClass(a, "enum A { }", "enum", "A"),
- (a) -> assertCommandCheckOutput(a, "/list", assertList()),
- (a) -> assertCommandCheckOutput(a, "/classes", assertClasses()),
- (a) -> assertClass(a, "@interface A { }", "@interface", "A"),
- (a) -> assertCommandCheckOutput(a, "/list", assertList()),
- (a) -> assertCommandCheckOutput(a, "/classes", assertClasses())
- );
- }
-
- public void defineImports() {
- test(
- (a) -> assertCommandCheckOutput(a, "/list", assertList()),
- (a) -> assertCommandCheckOutput(a, "/imports", assertImports()),
- (a) -> assertImport(a, "import java.util.stream.Stream;", "", "java.util.stream.Stream"),
- (a) -> assertCommandCheckOutput(a, "/list", assertList()),
- (a) -> assertCommandCheckOutput(a, "/imports", assertImports()),
- (a) -> assertImport(a, "import java.util.stream.*;", "", "java.util.stream.*"),
- (a) -> assertCommandCheckOutput(a, "/list", assertList()),
- (a) -> assertCommandCheckOutput(a, "/imports", assertImports()),
- (a) -> assertImport(a, "import static java.lang.Math.PI;", "static", "java.lang.Math.PI"),
- (a) -> assertCommandCheckOutput(a, "/list", assertList()),
- (a) -> assertCommandCheckOutput(a, "/imports", assertImports()),
- (a) -> assertImport(a, "import static java.lang.Math.*;", "static", "java.lang.Math.*"),
- (a) -> assertCommandCheckOutput(a, "/list", assertList()),
- (a) -> assertCommandCheckOutput(a, "/imports", assertImports())
+ (a) -> assertCommand(a, "/s1", "| No such command or snippet id: /s1\n| Type /help for help."),
+ (a) -> assertCommand(a, "/1", "| No such command or snippet id: /1\n| Type /help for help."),
+ (a) -> assertCommand(a, "/e1", "| No such command or snippet id: /e1\n| Type /help for help.")
);
}
@@ -353,14 +267,14 @@
compiler.compile(outDir, "package pkg; public class A { public String toString() { return \"A\"; } }");
Path classpath = compiler.getPath(outDir);
test(
- (a) -> assertCommand(a, "/classpath " + classpath, String.format("| Path %s added to classpath\n", classpath)),
- (a) -> evaluateExpression(a, "pkg.A", "new pkg.A();", "\"A\"")
+ (a) -> assertCommand(a, "/classpath " + classpath, String.format("| Path '%s' added to classpath", classpath)),
+ (a) -> evaluateExpression(a, "pkg.A", "new pkg.A();", "A")
);
test(new String[] { "-cp", classpath.toString() },
- (a) -> evaluateExpression(a, "pkg.A", "new pkg.A();", "\"A\"")
+ (a) -> evaluateExpression(a, "pkg.A", "new pkg.A();", "A")
);
test(new String[] { "-classpath", classpath.toString() },
- (a) -> evaluateExpression(a, "pkg.A", "new pkg.A();", "\"A\"")
+ (a) -> evaluateExpression(a, "pkg.A", "new pkg.A();", "A")
);
}
@@ -372,14 +286,14 @@
compiler.jar(outDir, jarName, "pkg/A.class");
Path jarPath = compiler.getPath(outDir).resolve(jarName);
test(
- (a) -> assertCommand(a, "/classpath " + jarPath, String.format("| Path %s added to classpath\n", jarPath)),
- (a) -> evaluateExpression(a, "pkg.A", "new pkg.A();", "\"A\"")
+ (a) -> assertCommand(a, "/classpath " + jarPath, String.format("| Path '%s' added to classpath", jarPath)),
+ (a) -> evaluateExpression(a, "pkg.A", "new pkg.A();", "A")
);
test(new String[] { "-cp", jarPath.toString() },
- (a) -> evaluateExpression(a, "pkg.A", "new pkg.A();", "\"A\"")
+ (a) -> evaluateExpression(a, "pkg.A", "new pkg.A();", "A")
);
test(new String[] { "-classpath", jarPath.toString() },
- (a) -> evaluateExpression(a, "pkg.A", "new pkg.A();", "\"A\"")
+ (a) -> evaluateExpression(a, "pkg.A", "new pkg.A();", "A")
);
}
@@ -389,7 +303,7 @@
Path startup = compiler.getPath("StartupFileOption/startup.txt");
compiler.writeToFile(startup, "class A { public String toString() { return \"A\"; } }");
test(new String[]{"-startup", startup.toString()},
- (a) -> evaluateExpression(a, "A", "new A()", "\"A\"\n")
+ (a) -> evaluateExpression(a, "A", "new A()", "A")
);
test(new String[]{"-nostartup"},
(a) -> assertCommandCheckOutput(a, "printf(\"\")", assertStartsWith("| Error:\n| cannot find symbol"))
@@ -406,18 +320,18 @@
Path path = compiler.getPath("loading.repl");
compiler.writeToFile(path, "int a = 10; double x = 20; double a = 10;");
test(new String[] { path.toString() },
- (a) -> assertCommand(a, "x", "| Variable x of type double has value 20.0\n"),
- (a) -> assertCommand(a, "a", "| Variable a of type double has value 10.0\n")
+ (a) -> assertCommand(a, "x", "x ==> 20.0"),
+ (a) -> assertCommand(a, "a", "a ==> 10.0")
);
Path unknown = compiler.getPath("UNKNOWN.jar");
test(Locale.ROOT, true, new String[]{unknown.toString()},
"| File " + unknown
- + " is not found: " + unresolvableMessage(unknown) + "\n");
+ + " is not found: " + unresolvableMessage(unknown));
}
public void testReset() {
test(
- (a) -> assertReset(a, "/r"),
+ (a) -> assertReset(a, "/res"),
(a) -> assertCommandCheckOutput(a, "/methods", assertMethods()),
(a) -> assertVariable(a, "int", "x"),
(a) -> assertCommandCheckOutput(a, "/vars", assertVariables()),
@@ -444,8 +358,8 @@
for (String s : new String[]{"/o", "/open"}) {
test(
(a) -> assertCommand(a, s + " " + path.toString(), ""),
- (a) -> assertCommand(a, "a", "| Variable a of type double has value 10.0\n"),
- (a) -> evaluateExpression(a, "A", "new A();", "\"A\""),
+ (a) -> assertCommand(a, "a", "a ==> 10.0"),
+ (a) -> evaluateExpression(a, "A", "new A();", "A"),
(a) -> evaluateExpression(a, "long", "Stream.of(\"A\").count();", "1"),
(a) -> {
loadVariable(a, "double", "x", "20.0", "20.0");
@@ -464,8 +378,7 @@
Path unknown = compiler.getPath("UNKNOWN.repl");
test(
(a) -> assertCommand(a, s + " " + unknown,
- "| File '" + unknown
- + "' is not found: " + unresolvableMessage(unknown) + "\n")
+ "| File '" + unknown + "' for '/open' is not found.")
);
}
}
@@ -529,8 +442,8 @@
);
Path unknown = compiler.getPath("UNKNOWN");
test(
- (a) -> assertCommand(a, "/set start " + unknown.toString(),
- "| File '" + unknown + "' for /set start is not found.\n")
+ (a) -> assertCommandOutputStartsWith(a, "/set start " + unknown.toString(),
+ "| File '" + unknown + "' for '/set start' is not found.")
);
test(false, new String[0],
(a) -> {
@@ -556,28 +469,6 @@
}
}
- public void testUnknownCommand() {
- test((a) -> assertCommand(a, "/unknown",
- "| No such command or snippet id: /unknown\n" +
- "| Type /help for help.\n"));
- }
-
- public void testEmptyClassPath() {
- test(after -> assertCommand(after, "/classpath", "| /classpath requires a path argument\n"));
- }
-
- public void testNoArgument() {
- String[] commands = {"/save", "/open", "/set start"};
- test(Stream.of(commands)
- .map(cmd -> {
- String c = cmd;
- final String finalC = c;
- return (ReplTest) after -> assertCommand(after, cmd,
- "| The " + finalC + " command requires a filename argument.\n");
- })
- .toArray(ReplTest[]::new));
- }
-
public void testStartSave() throws IOException {
Compiler compiler = new Compiler();
Path startSave = compiler.getPath("startSave.txt");
@@ -614,8 +505,8 @@
assertStartsWith("| Does not match any current feedback mode")));
}
- public void testFeedbackOff() {
- for (String off : new String[]{"o", "off"}) {
+ public void testFeedbackSilent() {
+ for (String off : new String[]{"s", "silent"}) {
test(
a -> assertCommand(a, "/set feedback " + off, ""),
a -> assertCommand(a, "int a", ""),
@@ -632,16 +523,16 @@
String[] sources = new String[] {"int a", "void f() {}", "class A {}", "a = 10"};
String[] sources2 = new String[] {"int a //again", "void f() {int y = 4;}", "class A {} //again", "a = 10"};
String[] output = new String[] {
- "| Added variable a of type int\n",
- "| Added method f()\n",
- "| Added class A\n",
- "| Variable a has been assigned the value 10\n"
+ "a ==> 0",
+ "| created method f()",
+ "| created class A",
+ "a ==> 10"
};
compiler.writeToFile(testNormalFile, sources2);
- for (String feedback : new String[]{"/set f", "/set feedback"}) {
- for (String feedbackState : new String[]{"n", "normal", "o", "off"}) {
+ for (String feedback : new String[]{"/set fe", "/set feedback"}) {
+ for (String feedbackState : new String[]{"n", "normal"}) {
test(
- a -> assertCommand(a, feedback + " " + feedbackState, "| Feedback mode: normal\n"),
+ a -> assertCommand(a, feedback + " " + feedbackState, "| Feedback mode: normal"),
a -> assertCommand(a, sources[0], output[0]),
a -> assertCommand(a, sources[1], output[1]),
a -> assertCommand(a, sources[2], output[2]),
@@ -652,87 +543,21 @@
}
}
- public void testDrop() {
- test(false, new String[]{"-nostartup"},
- a -> assertVariable(a, "int", "a"),
- a -> dropVariable(a, "/drop 1", "int a = 0", "| Dropped variable a\n"),
- a -> assertMethod(a, "int b() { return 0; }", "()I", "b"),
- a -> dropMethod(a, "/drop 2", "b ()I", "| Dropped method b()\n"),
- a -> assertClass(a, "class A {}", "class", "A"),
- a -> dropClass(a, "/drop 3", "class A", "| Dropped class A\n"),
- a -> assertImport(a, "import java.util.stream.*;", "", "java.util.stream.*"),
- a -> dropImport(a, "/drop 4", "import java.util.stream.*", ""),
- a -> assertCommandCheckOutput(a, "/vars", assertVariables()),
- a -> assertCommandCheckOutput(a, "/methods", assertMethods()),
- a -> assertCommandCheckOutput(a, "/classes", assertClasses()),
- a -> assertCommandCheckOutput(a, "/imports", assertImports())
- );
- test(false, new String[]{"-nostartup"},
- a -> assertVariable(a, "int", "a"),
- a -> dropVariable(a, "/drop a", "int a = 0", "| Dropped variable a\n"),
- a -> assertMethod(a, "int b() { return 0; }", "()I", "b"),
- a -> dropMethod(a, "/drop b", "b ()I", "| Dropped method b()\n"),
- a -> assertClass(a, "class A {}", "class", "A"),
- a -> dropClass(a, "/drop A", "class A", "| Dropped class A\n"),
- a -> assertCommandCheckOutput(a, "/vars", assertVariables()),
- a -> assertCommandCheckOutput(a, "/methods", assertMethods()),
- a -> assertCommandCheckOutput(a, "/classes", assertClasses()),
- a -> assertCommandCheckOutput(a, "/imports", assertImports())
- );
- }
-
- public void testDropNegative() {
- test(false, new String[]{"-nostartup"},
- a -> assertCommand(a, "/drop 0", "| No definition or id named 0 found. See /classes, /methods, /vars, or /list\n"),
- a -> assertCommand(a, "/drop a", "| No definition or id named a found. See /classes, /methods, /vars, or /list\n"),
- a -> assertCommandCheckOutput(a, "/drop",
- assertStartsWith("| In the /drop argument, please specify an import, variable, method, or class to drop.")),
- a -> assertVariable(a, "int", "a"),
- a -> assertCommand(a, "a", "| Variable a of type int has value 0\n"),
- a -> assertCommand(a, "/drop 2", "| The argument did not specify an active import, variable, method, or class to drop.\n")
- );
- }
-
- public void testAmbiguousDrop() {
- Consumer<String> check = s -> {
- assertTrue(s.startsWith("| The argument references more than one import, variable, method, or class"), s);
- int lines = s.split("\n").length;
- assertEquals(lines, 5, "Expected 3 ambiguous keys, but found: " + (lines - 2) + "\n" + s);
- };
- test(
- a -> assertVariable(a, "int", "a"),
- a -> assertMethod(a, "int a() { return 0; }", "()int", "a"),
- a -> assertClass(a, "class a {}", "class", "a"),
- a -> assertCommandCheckOutput(a, "/drop a", check),
- a -> assertCommandCheckOutput(a, "/vars", assertVariables()),
- a -> assertCommandCheckOutput(a, "/methods", assertMethods()),
- a -> assertCommandCheckOutput(a, "/classes", assertClasses()),
- a -> assertCommandCheckOutput(a, "/imports", assertImports())
- );
- test(
- a -> assertMethod(a, "int a() { return 0; }", "()int", "a"),
- a -> assertMethod(a, "double a(int a) { return 0; }", "(int)double", "a"),
- a -> assertMethod(a, "double a(double a) { return 0; }", "(double)double", "a"),
- a -> assertCommandCheckOutput(a, "/drop a", check),
- a -> assertCommandCheckOutput(a, "/methods", assertMethods())
- );
- }
-
public void testHistoryReference() {
test(false, new String[]{"-nostartup"},
a -> assertCommand(a, "System.err.println(1)", "", "", null, "", "1\n"),
a -> assertCommand(a, "System.err.println(2)", "", "", null, "", "2\n"),
- a -> assertCommand(a, "/-2", "System.err.println(1)\n", "", null, "", "1\n"),
- a -> assertCommand(a, "/history", "\n" +
+ a -> assertCommand(a, "/-2", "System.err.println(1)", "", null, "", "1\n"),
+ a -> assertCommand(a, "/history",
"/debug 0\n" +
"System.err.println(1)\n" +
"System.err.println(2)\n" +
"System.err.println(1)\n" +
"/history\n"),
- a -> assertCommand(a, "/-2", "System.err.println(2)\n", "", null, "", "2\n"),
- a -> assertCommand(a, "/!", "System.err.println(2)\n", "", null, "", "2\n"),
- a -> assertCommand(a, "/2", "System.err.println(2)\n", "", null, "", "2\n"),
- a -> assertCommand(a, "/1", "System.err.println(1)\n", "", null, "", "1\n")
+ a -> assertCommand(a, "/-2", "System.err.println(2)", "", null, "", "2\n"),
+ a -> assertCommand(a, "/!", "System.err.println(2)", "", null, "", "2\n"),
+ a -> assertCommand(a, "/2", "System.err.println(2)", "", null, "", "2\n"),
+ a -> assertCommand(a, "/1", "System.err.println(1)", "", null, "", "1\n")
);
}
@@ -744,14 +569,4 @@
return ex.getMessage();
}
}
-
- public void testCommandPrefix() {
- test(a -> assertCommandCheckOutput(a, "/s",
- assertStartsWith("| Command: /s is ambiguous: /save, /set")),
- a -> assertCommand(a, "int var", "| Added variable var of type int\n"),
- a -> assertCommandCheckOutput(a, "/va",
- assertStartsWith("| int var = 0")),
- a -> assertCommandCheckOutput(a, "/save",
- assertStartsWith("| The /save command requires a filename argument.")));
- }
}
--- a/langtools/test/jdk/jshell/ToolReloadTest.java Thu Apr 21 20:49:11 2016 -0700
+++ b/langtools/test/jdk/jshell/ToolReloadTest.java Fri Apr 22 01:04:00 2016 -0700
@@ -24,7 +24,7 @@
/*
* @test
* @key intermittent
- * @bug 8081845 8147898
+ * @bug 8081845 8147898 8143955
* @summary Tests for /reload in JShell tool
* @modules jdk.compiler/com.sun.tools.javac.api
* jdk.compiler/com.sun.tools.javac.main
@@ -71,7 +71,7 @@
Path classpath = compiler.getPath(outDir);
test(
(a) -> assertCommand(a, "/classpath " + classpath,
- String.format("| Path '%s' added to classpath\n", classpath)),
+ String.format("| Path '%s' added to classpath", classpath)),
(a) -> assertMethod(a, "String foo() { return (new pkg.A()).toString(); }",
"()String", "foo"),
(a) -> assertVariable(a, "String", "v", "foo()", "\"A\""),
@@ -83,20 +83,20 @@
"-: String foo() { return (new pkg.A()).toString(); }\n" +
"-: String v = foo();\n");
},
- (a) -> assertCommand(a, "v", "| Variable v of type String has value \"Aprime\"\n"),
+ (a) -> assertCommand(a, "v", "v ==> \"Aprime\""),
(a) -> evaluateExpression(a, "String", "foo()", "\"Aprime\""),
- (a) -> evaluateExpression(a, "pkg.A", "new pkg.A();", "\"Aprime\"")
+ (a) -> evaluateExpression(a, "pkg.A", "new pkg.A();", "Aprime")
);
}
public void testReloadDrop() {
test(false, new String[]{"-nostartup"},
a -> assertVariable(a, "int", "a"),
- a -> dropVariable(a, "/dr 1", "int a = 0", "| Dropped variable a\n"),
+ a -> dropVariable(a, "/dr 1", "int a = 0", "| dropped variable a"),
a -> assertMethod(a, "int b() { return 0; }", "()I", "b"),
- a -> dropMethod(a, "/drop b", "b ()I", "| Dropped method b()\n"),
+ a -> dropMethod(a, "/drop b", "b ()I", "| dropped method b()"),
a -> assertClass(a, "class A {}", "class", "A"),
- a -> dropClass(a, "/dr A", "class A", "| Dropped class A\n"),
+ a -> dropClass(a, "/dr A", "class A", "| dropped class A"),
a -> assertCommand(a, "/reload",
"| Restarting and restoring state.\n" +
"-: int a;\n" +
@@ -115,13 +115,13 @@
public void testReloadQuiet() {
test(false, new String[]{"-nostartup"},
a -> assertVariable(a, "int", "a"),
- a -> dropVariable(a, "/dr 1", "int a = 0", "| Dropped variable a\n"),
+ a -> dropVariable(a, "/dr 1", "int a = 0", "| dropped variable a"),
a -> assertMethod(a, "int b() { return 0; }", "()I", "b"),
- a -> dropMethod(a, "/drop b", "b ()I", "| Dropped method b()\n"),
+ a -> dropMethod(a, "/drop b", "b ()I", "| dropped method b()"),
a -> assertClass(a, "class A {}", "class", "A"),
- a -> dropClass(a, "/dr A", "class A", "| Dropped class A\n"),
+ a -> dropClass(a, "/dr A", "class A", "| dropped class A"),
a -> assertCommand(a, "/reload quiet",
- "| Restarting and restoring state.\n"),
+ "| Restarting and restoring state."),
a -> assertCommandCheckOutput(a, "/vars", assertVariables()),
a -> assertCommandCheckOutput(a, "/methods", assertMethods()),
a -> assertCommandCheckOutput(a, "/classes", assertClasses()),
@@ -144,8 +144,8 @@
"-: ++c\n" +
"-: ++c\n"
),
- (a) -> assertCommand(a, "c", "| Variable c of type int has value 11\n"),
- (a) -> assertCommand(a, "$4", "| Variable $4 of type int has value 10\n")
+ (a) -> assertCommand(a, "c", "c ==> 11"),
+ (a) -> assertCommand(a, "$4", "$4 ==> 10")
);
}
@@ -158,7 +158,7 @@
(a) -> assertCommand(a, "/vars", null),
(a) -> assertCommand(a, "/save abcd", null),
(a) -> assertCommand(a, "/reload",
- "| Restarting and restoring state.\n")
+ "| Restarting and restoring state.")
);
}
@@ -168,7 +168,7 @@
(a) -> assertMethod(a, "int m(int z) { return z * z; }",
"(int)int", "m"),
(a) -> evaluateExpression(a, "int", "m(x)", "25"),
- (a) -> assertCommand(a, "/reset", "| Resetting state.\n"),
+ (a) -> assertCommand(a, "/reset", "| Resetting state."),
(a) -> assertCommand(a, "/reload restore",
"| Restarting and restoring from previous state.\n" +
"-: int x = 5;\n" +
@@ -188,7 +188,7 @@
(a) -> evaluateExpression(a, "int", "m(x)", "25"),
(a) -> assertCommand(a, "System.exit(1);",
"| State engine terminated.\n" +
- "| Restore definitions with: /reload restore\n"),
+ "| Restore definitions with: /reload restore"),
(a) -> assertCommand(a, "/reload restore",
"| Restarting and restoring from previous state.\n" +
"-: int x = 5;\n" +
--- a/langtools/test/jdk/jshell/ToolSimpleTest.java Thu Apr 21 20:49:11 2016 -0700
+++ b/langtools/test/jdk/jshell/ToolSimpleTest.java Fri Apr 22 01:04:00 2016 -0700
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 8153716
+ * @bug 8153716 8143955
* @summary Simple jshell tool tests
* @modules jdk.compiler/com.sun.tools.javac.api
* jdk.compiler/com.sun.tools.javac.main
@@ -47,10 +47,102 @@
@Test
public class ToolSimpleTest extends ReplToolTesting {
+ public void testRemaining() {
+ test(
+ (a) -> assertCommand(a, "int z; z =", "z ==> 0"),
+ (a) -> assertCommand(a, "5", "z ==> 5"),
+ (a) -> assertCommand(a, "/*nada*/; int q =", ""),
+ (a) -> assertCommand(a, "77", "q ==> 77"),
+ (a) -> assertCommand(a, "//comment;", ""),
+ (a) -> assertCommand(a, "int v;", "v ==> 0"),
+ (a) -> assertCommand(a, "int v; int c",
+ "v ==> 0\n" +
+ "c ==> 0")
+ );
+ }
+
+ public void oneLineOfError() {
+ test(
+ (a) -> assertCommand(a, "12+", null),
+ (a) -> assertCommandCheckOutput(a, " true", (s) ->
+ assertTrue(s.contains("12+") && !s.contains("true"), "Output: '" + s + "'"))
+ );
+ }
+
+ public void defineVariables() {
+ test(
+ (a) -> assertCommandCheckOutput(a, "/list", assertList()),
+ (a) -> assertCommandCheckOutput(a, "/vars", assertVariables()),
+ (a) -> assertVariable(a, "int", "a"),
+ (a) -> assertCommandCheckOutput(a, "/list", assertList()),
+ (a) -> assertCommandCheckOutput(a, "/vars", assertVariables()),
+ (a) -> assertVariable(a, "double", "a", "1", "1.0"),
+ (a) -> assertCommandCheckOutput(a, "/list", assertList()),
+ (a) -> assertCommandCheckOutput(a, "/vars", assertVariables()),
+ (a) -> evaluateExpression(a, "double", "2 * a", "2.0"),
+ (a) -> assertCommandCheckOutput(a, "/list", assertList()),
+ (a) -> assertCommandCheckOutput(a, "/vars", assertVariables())
+ );
+ }
+
+ public void defineMethods() {
+ test(
+ (a) -> assertCommandCheckOutput(a, "/list", assertList()),
+ (a) -> assertCommandCheckOutput(a, "/methods", assertMethods()),
+ (a) -> assertMethod(a, "int f() { return 0; }", "()int", "f"),
+ (a) -> assertCommandCheckOutput(a, "/list", assertList()),
+ (a) -> assertCommandCheckOutput(a, "/methods", assertMethods()),
+ (a) -> assertMethod(a, "void f(int a) { g(); }", "(int)void", "f"),
+ (a) -> assertCommandCheckOutput(a, "/list", assertList()),
+ (a) -> assertCommandCheckOutput(a, "/methods", assertMethods()),
+ (a) -> assertMethod(a, "void g() {}", "()void", "g"),
+ (a) -> assertCommandCheckOutput(a, "/list", assertList()),
+ (a) -> assertCommandCheckOutput(a, "/methods", assertMethods())
+ );
+ }
+
+ public void defineClasses() {
+ test(
+ (a) -> assertCommandCheckOutput(a, "/list", assertList()),
+ (a) -> assertCommandCheckOutput(a, "/classes", assertClasses()),
+ (a) -> assertClass(a, "class A { }", "class", "A"),
+ (a) -> assertCommandCheckOutput(a, "/list", assertList()),
+ (a) -> assertCommandCheckOutput(a, "/classes", assertClasses()),
+ (a) -> assertClass(a, "interface A { }", "interface", "A"),
+ (a) -> assertCommandCheckOutput(a, "/list", assertList()),
+ (a) -> assertCommandCheckOutput(a, "/classes", assertClasses()),
+ (a) -> assertClass(a, "enum A { }", "enum", "A"),
+ (a) -> assertCommandCheckOutput(a, "/list", assertList()),
+ (a) -> assertCommandCheckOutput(a, "/classes", assertClasses()),
+ (a) -> assertClass(a, "@interface A { }", "@interface", "A"),
+ (a) -> assertCommandCheckOutput(a, "/list", assertList()),
+ (a) -> assertCommandCheckOutput(a, "/classes", assertClasses())
+ );
+ }
+
+ public void defineImports() {
+ test(
+ (a) -> assertCommandCheckOutput(a, "/list", assertList()),
+ (a) -> assertCommandCheckOutput(a, "/imports", assertImports()),
+ (a) -> assertImport(a, "import java.util.stream.Stream;", "", "java.util.stream.Stream"),
+ (a) -> assertCommandCheckOutput(a, "/list", assertList()),
+ (a) -> assertCommandCheckOutput(a, "/imports", assertImports()),
+ (a) -> assertImport(a, "import java.util.stream.*;", "", "java.util.stream.*"),
+ (a) -> assertCommandCheckOutput(a, "/list", assertList()),
+ (a) -> assertCommandCheckOutput(a, "/imports", assertImports()),
+ (a) -> assertImport(a, "import static java.lang.Math.PI;", "static", "java.lang.Math.PI"),
+ (a) -> assertCommandCheckOutput(a, "/list", assertList()),
+ (a) -> assertCommandCheckOutput(a, "/imports", assertImports()),
+ (a) -> assertImport(a, "import static java.lang.Math.*;", "static", "java.lang.Math.*"),
+ (a) -> assertCommandCheckOutput(a, "/list", assertList()),
+ (a) -> assertCommandCheckOutput(a, "/imports", assertImports())
+ );
+ }
+
public void defineVar() {
test(
- (a) -> assertCommand(a, "int x = 72", "| Added variable x of type int with initial value 72"),
- (a) -> assertCommand(a, "x", "| Variable x of type int has value 72"),
+ (a) -> assertCommand(a, "int x = 72", "x ==> 72"),
+ (a) -> assertCommand(a, "x", "x ==> 72"),
(a) -> assertCommand(a, "/vars", "| int x = 72")
);
}
@@ -59,7 +151,7 @@
public void defineUnresolvedVar() {
test(
(a) -> assertCommand(a, "undefined x",
- "| Added variable x, however, it cannot be referenced until class undefined is declared"),
+ "| created variable x, however, it cannot be referenced until class undefined is declared"),
(a) -> assertCommand(a, "/vars", "| undefined x = (not-active)")
);
}
@@ -67,15 +159,37 @@
public void testUnresolved() {
test(
(a) -> assertCommand(a, "int f() { return g() + x + new A().a; }",
- "| Added method f(), however, it cannot be invoked until method g(), variable x, and class A are declared"),
+ "| created method f(), however, it cannot be invoked until method g(), variable x, and class A are declared"),
(a) -> assertCommand(a, "f()",
- "| Attempted to call method f() which cannot be invoked until method g(), variable x, and class A are declared"),
+ "| attempted to call method f() which cannot be invoked until method g(), variable x, and class A are declared"),
(a) -> assertCommandOutputStartsWith(a, "int g() { return x; }",
- "| Added method g(), however, it cannot be invoked until variable x is declared"),
- (a) -> assertCommand(a, "g()", "| Attempted to call method g() which cannot be invoked until variable x is declared")
+ "| created method g(), however, it cannot be invoked until variable x is declared"),
+ (a) -> assertCommand(a, "g()", "| attempted to call method g() which cannot be invoked until variable x is declared")
);
}
+ public void testUnknownCommand() {
+ test((a) -> assertCommand(a, "/unknown",
+ "| No such command or snippet id: /unknown\n" +
+ "| Type /help for help."));
+ }
+
+ public void testEmptyClassPath() {
+ test(after -> assertCommand(after, "/classpath", "| The /classpath command requires a path argument."));
+ }
+
+ public void testNoArgument() {
+ String[] commands = {"/save", "/open", "/set start"};
+ test(Stream.of(commands)
+ .map(cmd -> {
+ String c = cmd;
+ final String finalC = c;
+ return (ReplTest) after -> assertCommand(after, cmd,
+ "| '" + finalC + "' requires a filename argument.");
+ })
+ .toArray(ReplTest[]::new));
+ }
+
public void testDebug() {
test(
(a) -> assertCommand(a, "/deb", "| Debugging on"),
@@ -85,6 +199,72 @@
);
}
+ public void testDrop() {
+ test(false, new String[]{"-nostartup"},
+ a -> assertVariable(a, "int", "a"),
+ a -> dropVariable(a, "/drop 1", "int a = 0", "| dropped variable a"),
+ a -> assertMethod(a, "int b() { return 0; }", "()I", "b"),
+ a -> dropMethod(a, "/drop 2", "b ()I", "| dropped method b()"),
+ a -> assertClass(a, "class A {}", "class", "A"),
+ a -> dropClass(a, "/drop 3", "class A", "| dropped class A"),
+ a -> assertImport(a, "import java.util.stream.*;", "", "java.util.stream.*"),
+ a -> dropImport(a, "/drop 4", "import java.util.stream.*", ""),
+ a -> assertCommandCheckOutput(a, "/vars", assertVariables()),
+ a -> assertCommandCheckOutput(a, "/methods", assertMethods()),
+ a -> assertCommandCheckOutput(a, "/classes", assertClasses()),
+ a -> assertCommandCheckOutput(a, "/imports", assertImports())
+ );
+ test(false, new String[]{"-nostartup"},
+ a -> assertVariable(a, "int", "a"),
+ a -> dropVariable(a, "/drop a", "int a = 0", "| dropped variable a"),
+ a -> assertMethod(a, "int b() { return 0; }", "()I", "b"),
+ a -> dropMethod(a, "/drop b", "b ()I", "| dropped method b()"),
+ a -> assertClass(a, "class A {}", "class", "A"),
+ a -> dropClass(a, "/drop A", "class A", "| dropped class A"),
+ a -> assertCommandCheckOutput(a, "/vars", assertVariables()),
+ a -> assertCommandCheckOutput(a, "/methods", assertMethods()),
+ a -> assertCommandCheckOutput(a, "/classes", assertClasses()),
+ a -> assertCommandCheckOutput(a, "/imports", assertImports())
+ );
+ }
+
+ public void testDropNegative() {
+ test(false, new String[]{"-nostartup"},
+ a -> assertCommandOutputStartsWith(a, "/drop 0", "| No definition or id found named: 0"),
+ a -> assertCommandOutputStartsWith(a, "/drop a", "| No definition or id found named: a"),
+ a -> assertCommandCheckOutput(a, "/drop",
+ assertStartsWith("| In the /drop argument, please specify an import, variable, method, or class to drop.")),
+ a -> assertVariable(a, "int", "a"),
+ a -> assertCommand(a, "a", "a ==> 0"),
+ a -> assertCommand(a, "/drop 2", "| The argument did not specify an active import, variable, method, or class to drop.")
+ );
+ }
+
+ public void testAmbiguousDrop() {
+ Consumer<String> check = s -> {
+ assertTrue(s.startsWith("| The argument references more than one import, variable, method, or class"), s);
+ int lines = s.split("\n").length;
+ assertEquals(lines, 5, "Expected 3 ambiguous keys, but found: " + (lines - 2) + "\n" + s);
+ };
+ test(
+ a -> assertVariable(a, "int", "a"),
+ a -> assertMethod(a, "int a() { return 0; }", "()int", "a"),
+ a -> assertClass(a, "class a {}", "class", "a"),
+ a -> assertCommandCheckOutput(a, "/drop a", check),
+ a -> assertCommandCheckOutput(a, "/vars", assertVariables()),
+ a -> assertCommandCheckOutput(a, "/methods", assertMethods()),
+ a -> assertCommandCheckOutput(a, "/classes", assertClasses()),
+ a -> assertCommandCheckOutput(a, "/imports", assertImports())
+ );
+ test(
+ a -> assertMethod(a, "int a() { return 0; }", "()int", "a"),
+ a -> assertMethod(a, "double a(int a) { return 0; }", "(int)double", "a"),
+ a -> assertMethod(a, "double a(double a) { return 0; }", "(double)double", "a"),
+ a -> assertCommandCheckOutput(a, "/drop a", check),
+ a -> assertCommandCheckOutput(a, "/methods", assertMethods())
+ );
+ }
+
public void testHelpLength() {
Consumer<String> testOutput = (s) -> {
List<String> ss = Stream.of(s.split("\n"))
@@ -148,6 +328,16 @@
);
}
+ public void testCommandPrefix() {
+ test(a -> assertCommandCheckOutput(a, "/s",
+ assertStartsWith("| Command: '/s' is ambiguous: /save, /set")),
+ a -> assertCommand(a, "int var", "var ==> 0"),
+ a -> assertCommandCheckOutput(a, "/va",
+ assertStartsWith("| int var = 0")),
+ a -> assertCommandCheckOutput(a, "/save",
+ assertStartsWith("| '/save' requires a filename argument.")));
+ }
+
public void testHeadlessEditPad() {
String prevHeadless = System.getProperty("java.awt.headless");
try {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/file/MultiReleaseJar/MultiReleaseJarAwareSJFM.java Fri Apr 22 01:04:00 2016 -0700
@@ -0,0 +1,216 @@
+/*
+ * 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 8149757
+ * @summary Test that StandardJavaFileManager uses the correct version of a
+ * class from a multi-release jar on classpath
+ * @library /tools/lib
+ * @modules jdk.compiler/com.sun.tools.javac.api
+ * jdk.compiler/com.sun.tools.javac.main
+ * @build toolbox.ToolBox
+ * @run testng MultiReleaseJarAwareSJFM
+ */
+
+import org.testng.Assert;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+import javax.tools.FileObject;
+import javax.tools.JavaFileManager;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.ToolProvider;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.invoke.MethodHandle;
+import java.lang.invoke.MethodHandles;
+import java.lang.invoke.MethodType;
+import java.util.List;
+
+import toolbox.JarTask;
+import toolbox.JavacTask;
+import toolbox.ToolBox;
+
+public class MultiReleaseJarAwareSJFM {
+
+ private final String version8 =
+ "package version;\n" +
+ "\n" +
+ "public class Version {\n" +
+ " public int getVersion() {\n" +
+ " return 8;\n" +
+ " }\n" +
+ "}\n";
+
+ private final String version9 =
+ "package version;\n" +
+ "\n" +
+ "public class Version {\n" +
+ " public int getVersion() {\n" +
+ " int version = (new PackagePrivate()).getVersion();\n" +
+ " if (version == 9) return 9;\n" +
+ " return version;\n" +
+ " }\n" +
+ "}\n";
+
+ private final String packagePrivate =
+ "package version;\n" +
+ "\n" +
+ "class PackagePrivate {\n" +
+ " int getVersion() {\n" +
+ " return 9;\n" +
+ " }\n" +
+ "}\n";
+
+ private final String version10 =
+ "package version;\n" +
+ "\n" +
+ "public class Version {\n" +
+ " public int getVersion() {\n" +
+ " return 10;\n" +
+ " }\n" +
+ "}\n";
+
+ private final String manifest =
+ "Manifest-Version: 1.0\n" +
+ "Multi-Release: true\n";
+
+ private final ToolBox tb = new ToolBox();
+
+ private final JavaFileManager.Location jloc = new JavaFileManager.Location() {
+ @Override
+ public String getName() {
+ return "Multi-Release Jar";
+ }
+ @Override
+ public boolean isOutputLocation() {
+ return false;
+ }
+ };
+
+ @BeforeClass
+ public void setup() throws Exception {
+ tb.createDirectories("classes",
+ "classes/META-INF/versions/9",
+ "classes/META-INF/versions/10");
+ new JavacTask(tb)
+ .outdir("classes")
+ .sources(version8)
+ .run();
+ new JavacTask(tb)
+ .outdir("classes/META-INF/versions/9")
+ .sources(version9, packagePrivate)
+ .run();
+ new JavacTask(tb)
+ .outdir("classes/META-INF/versions/10")
+ .sources(version10)
+ .run();
+ new JarTask(tb, "multi-release.jar")
+ .manifest(manifest)
+ .baseDir("classes")
+ .files("version/Version.class",
+ "META-INF/versions/9/version/Version.class",
+ "META-INF/versions/9/version/PackagePrivate.class",
+ "META-INF/versions/10/version/Version.class")
+ .run();
+ }
+
+ @AfterClass
+ public void teardown() throws Exception {
+ tb.deleteFiles(
+ "classes/META-INF/versions/10/version/Version.class",
+ "classes/META-INF/versions/10/version",
+ "classes/META-INF/versions/10/",
+ "classes/META-INF/versions/9/version/Version.class",
+ "classes/META-INF/versions/9/version/PackagePrivate.class",
+ "classes/META-INF/versions/9/version",
+ "classes/META-INF/versions/9",
+ "classes/META-INF/versions",
+ "classes/META-INF",
+ "classes/version/Version.class",
+ "classes/version",
+ "classes",
+ "multi-release.jar"
+ );
+ }
+
+ @DataProvider(name = "versions")
+ public Object[][] data() {
+ return new Object[][] {
+ {"", 8},
+ {"8", 8},
+ {"9", 9},
+ {"runtime", jdk.Version.current().major()}
+ };
+ }
+
+ @Test(dataProvider = "versions")
+ public void test(String version, int expected) throws Throwable {
+ StandardJavaFileManager jfm = ToolProvider.getSystemJavaCompiler().getStandardFileManager(null, null, null);
+ jfm.setLocation(jloc, List.of(new File("multi-release.jar")));
+
+ if (version.length() > 0) {
+ jfm.handleOption("-multi-release", List.of(version).iterator());
+ }
+
+ CustomClassLoader cldr = new CustomClassLoader(jfm);
+ Class<?> versionClass = cldr.loadClass("version.Version");
+ MethodType mt = MethodType.methodType(int.class);
+ MethodHandle mh = MethodHandles.lookup().findVirtual(versionClass, "getVersion", mt);
+ int v = (int)mh.invoke(versionClass.newInstance());
+ Assert.assertEquals(v, expected);
+
+ jfm.close();
+ }
+
+ private class CustomClassLoader extends ClassLoader {
+ private final JavaFileManager jfm;
+
+ public CustomClassLoader(JavaFileManager jfm) {
+ super(null);
+ this.jfm = jfm;
+ }
+
+ @Override
+ protected Class<?> findClass(String name) throws ClassNotFoundException {
+ int n = name.lastIndexOf('.');
+ String pkg = n == -1 ? "" : name.substring(0, n);
+ String cls = name.substring(n + 1) + ".class";
+ byte[] b;
+ try {
+ FileObject obj = jfm.getFileForInput(jloc, pkg, cls);
+ try (InputStream is = obj.openInputStream()) {
+ b = is.readAllBytes();
+ }
+ } catch (IOException x) {
+ throw new ClassNotFoundException(x.getMessage(), x);
+ }
+ return defineClass(name, b, 0, b.length);
+ }
+ }
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/file/MultiReleaseJar/MultiReleaseJarTest.java Fri Apr 22 01:04:00 2016 -0700
@@ -0,0 +1,216 @@
+/*
+ * 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 8149757
+ * @summary Test that javac uses the correct version of a class from a
+ * multi-release jar on classpath
+ * @library /tools/lib
+ * @modules jdk.compiler/com.sun.tools.javac.api
+ * jdk.compiler/com.sun.tools.javac.main
+ * @build toolbox.ToolBox toolbox.JarTask toolbox.JavacTask
+ * @run testng MultiReleaseJarTest
+ */
+
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+import toolbox.JarTask;
+import toolbox.JavacTask;
+import toolbox.Task;
+import toolbox.ToolBox;
+
+
+public class MultiReleaseJarTest {
+
+ private final String main1 =
+ "class Main {\n" +
+ " Info info = new Info();\n" +
+ " \n" +
+ " void run() {\n" +
+ " System.out.println(info.get());\n" +
+ " }\n" +
+ "}\n";
+
+ private final String main2 =
+ "class Main {\n" +
+ " Info info = new Info();\n" +
+ " \n" +
+ " void run() {\n" +
+ " System.out.println(info.getInfo());\n" +
+ " }\n" +
+ "}\n";
+
+ private final String info1 =
+ "class Info {\n" +
+ " String get() {\n" +
+ " return \"some info\";\n" +
+ " }\n" +
+ "}\n";
+
+ private final String info2 =
+ "class Info {\n" +
+ " String getInfo() {\n" +
+ " return \"some info\";\n" +
+ " }\n" +
+ "}\n";
+
+ private final String manifest =
+ "Manifest-Version: 1.0\n" +
+ "Multi-Release: true\n";
+
+ private final ToolBox tb = new ToolBox();
+
+ @BeforeClass
+ public void setup() throws Exception {
+ tb.createDirectories("classes", "classes/META-INF/versions/9");
+ new JavacTask(tb)
+ .outdir("classes")
+ .sources(info1)
+ .run();
+ new JavacTask(tb)
+ .outdir("classes/META-INF/versions/9")
+ .sources(info2)
+ .run();
+ // This is a bogus multi-release jar file since the two Info classes
+ // do not have the same public interface
+ new JarTask(tb, "multi-release.jar")
+ .manifest(manifest)
+ .baseDir("classes")
+ .files("Info.class", "META-INF/versions/9/Info.class")
+ .run();
+ tb.deleteFiles(
+ "classes/META-INF/versions/9/Info.class",
+ "classes/META-INF/versions/9",
+ "classes/META-INF/versions",
+ "classes/META-INF",
+ "classes/Info.class"
+ );
+ }
+
+ @AfterClass
+ public void teardown() throws Exception {
+ tb.deleteFiles(
+ "multi-release.jar",
+ "classes/Main.class",
+ "classes"
+ );
+ }
+
+ @Test(dataProvider="modes")
+ // javac -d classes -cp multi-release.jar Main.java -> fails
+ public void main1Runtime(Task.Mode mode) throws Exception {
+ tb.writeFile("Main.java", main1);
+ Task.Result result = new JavacTask(tb, mode)
+ .outdir("classes")
+ .classpath("multi-release.jar")
+ .files("Main.java")
+ .run(Task.Expect.FAIL, 1);
+ result.writeAll();
+ tb.deleteFiles("Main.java");
+
+ }
+
+ @Test(dataProvider="modes")
+ // javac -d classes -release 8 -cp multi-release.jar Main.java -> succeeds
+ public void main1Release8(Task.Mode mode) throws Exception {
+ tb.writeFile("Main.java", main1);
+ Task.Result result = new JavacTask(tb, mode)
+ .outdir("classes")
+ .options("-release", "8")
+ .classpath("multi-release.jar")
+ .files("Main.java")
+ .run();
+ result.writeAll();
+ tb.deleteFiles("Main.java");
+ }
+
+ @Test(dataProvider="modes")
+ // javac -d classes -release 9 -cp multi-release.jar Main.java -> fails
+ public void main1Release9(Task.Mode mode) throws Exception {
+ tb.writeFile("Main.java", main1);
+ Task.Result result = new JavacTask(tb, mode)
+ .outdir("classes")
+ .options("-release", "9")
+ .classpath("multi-release.jar")
+ .files("Main.java")
+ .run(Task.Expect.FAIL, 1);
+ result.writeAll();
+ tb.deleteFiles("Main.java");
+ }
+
+ @Test(dataProvider="modes")
+ // javac -d classes -cp multi-release.jar Main.java -> succeeds
+ public void main2Runtime(Task.Mode mode) throws Exception {
+ tb.writeFile("Main.java", main2);
+ Task.Result result = new JavacTask(tb, mode)
+ .outdir("classes")
+ .classpath("multi-release.jar")
+ .files("Main.java")
+ .run();
+ result.writeAll();
+ tb.deleteFiles("Main.java");
+
+ }
+
+ @Test(dataProvider="modes")
+ // javac -d classes -release 8 -cp multi-release.jar Main.java -> fails
+ public void main2Release8(Task.Mode mode) throws Exception {
+ tb.writeFile("Main.java", main2);
+ Task.Result result = new JavacTask(tb, mode)
+ .outdir("classes")
+ .options("-release", "8")
+ .classpath("multi-release.jar")
+ .files("Main.java")
+ .run(Task.Expect.FAIL, 1);
+ result.writeAll();
+ tb.deleteFiles("Main.java");
+ }
+
+ @Test(dataProvider="modes")
+ // javac -d classes -release 9 -cp multi-release.jar Main.java -> succeeds
+ public void main2Release9(Task.Mode mode) throws Exception {
+ tb.writeFile("Main.java", main2);
+ Task.Result result = new JavacTask(tb, mode)
+ .outdir("classes")
+ .options("-release", "9")
+ .classpath("multi-release.jar")
+ .files("Main.java")
+ .run();
+ result.writeAll();
+ tb.deleteFiles("Main.java");
+ }
+
+ @DataProvider(name="modes")
+ public Object[][] createModes() {
+ return new Object[][] {
+ new Object[] {Task.Mode.API},
+ new Object[] {Task.Mode.CMDLINE},
+ new Object[] {Task.Mode.EXEC},
+ };
+ }
+}
+
--- a/langtools/test/tools/javac/unit/T6198196.java Thu Apr 21 20:49:11 2016 -0700
+++ b/langtools/test/tools/javac/unit/T6198196.java Fri Apr 22 01:04:00 2016 -0700
@@ -36,34 +36,31 @@
public class T6198196 {
static String pkginf = "package-info";
- static StandardJavaFileManager fm;
- static void test(String pathname, String filename, boolean result) {
- JavaFileObject fo;
- fo = fm.getJavaFileObjectsFromStrings(Arrays.asList(pathname)).iterator().next();
- if (result != fo.isNameCompatible(filename, JavaFileObject.Kind.SOURCE))
- throw new AssertionError("endsWith(" + pathname + ", "
- + filename + ") != " + result);
- System.out.format("OK: endsWith(%s, %s) = %s%n", pathname, filename, result);
+ static void test(String pathname, String filename, boolean result) throws IOException {
+ try (StandardJavaFileManager fm =
+ ToolProvider.getSystemJavaCompiler().getStandardFileManager(null, null, null)) {
+ JavaFileObject fo =
+ fm.getJavaFileObjectsFromStrings(Arrays.asList(pathname)).iterator().next();
+ if (result != fo.isNameCompatible(filename, JavaFileObject.Kind.SOURCE))
+ throw new AssertionError("endsWith(" + pathname + ", "
+ + filename + ") != " + result);
+ System.out.format("OK: endsWith(%s, %s) = %s%n", pathname, filename, result);
+ }
}
public static void main(String[] args) throws IOException {
- fm = ToolProvider.getSystemJavaCompiler().getStandardFileManager(null, null, null);
- try {
- boolean windows = System.getProperty("os.name").startsWith("Windows");
- test("/x/y/z/package-info.java", pkginf, true);
- if (windows) {
- test("\\x\\y\\z\\package-info.java", pkginf, true);
- test("..\\x\\y\\z\\package-info.java", pkginf, true);
- } else {
- test("\\x\\y\\z\\package-info.java", pkginf, false);
- test("..\\x\\y\\z\\package-info.java", pkginf, false);
- }
- test("Package-info.java", pkginf, false);
- test("../x/y/z/package-info.java", pkginf, true);
- test("/x/y/z/package-info.java", pkginf, true);
- test("x/y/z/package-info.java", pkginf, true);
- test("package-info.java", pkginf, true);
- } finally {
- fm.close();
+ boolean windows = System.getProperty("os.name").startsWith("Windows");
+ test("/x/y/z/package-info.java", pkginf, true);
+ if (windows) {
+ test("\\x\\y\\z\\package-info.java", pkginf, true);
+ test("..\\x\\y\\z\\package-info.java", pkginf, true);
+ } else {
+ test("\\x\\y\\z\\package-info.java", pkginf, false);
+ test("..\\x\\y\\z\\package-info.java", pkginf, false);
}
+ test("Package-info.java", pkginf, false);
+ test("../x/y/z/package-info.java", pkginf, true);
+ test("/x/y/z/package-info.java", pkginf, true);
+ test("x/y/z/package-info.java", pkginf, true);
+ test("package-info.java", pkginf, true);
}
}
--- a/make/CompileJavaModules.gmk Thu Apr 21 20:49:11 2016 -0700
+++ b/make/CompileJavaModules.gmk Fri Apr 22 01:04:00 2016 -0700
@@ -469,32 +469,7 @@
################################################################################
# Setup the compilation for the module
#
-# Order src dirs in order of override with the most important first. Generated
-# source before static source and platform specific source before shared.
-#
-GENERATED_SRC_DIRS += \
- $(SUPPORT_OUTPUTDIR)/gensrc \
- #
-
-TOP_SRC_DIRS += \
- $(HOTSPOT_TOPDIR)/src \
- $(CORBA_TOPDIR)/src \
- $(JDK_TOPDIR)/src \
- $(LANGTOOLS_TOPDIR)/src \
- $(JAXP_TOPDIR)/src \
- $(JAXWS_TOPDIR)/src \
- $(NASHORN_TOPDIR)/src \
- #
-
-SRC_SUBDIRS += $(OPENJDK_TARGET_OS)/classes
-ifneq ($(OPENJDK_TARGET_OS), $(OPENJDK_TARGET_OS_TYPE))
- SRC_SUBDIRS += $(OPENJDK_TARGET_OS_TYPE)/classes
-endif
-SRC_SUBDIRS += share/classes
-
-MODULE_SRC_DIRS := $(strip \
- $(addsuffix /$(MODULE), $(GENERATED_SRC_DIRS) $(IMPORT_MODULES_SRC)) \
- $(foreach sub, $(SRC_SUBDIRS), $(addsuffix /$(MODULE)/$(sub), $(TOP_SRC_DIRS))))
+MODULE_SRC_DIRS := $(call FindModuleSrcDirs, $(MODULE))
# The JDK_USER_DEFINED_FILTER is a poor man's incremental build: by specifying
# JDK_FILTER at the make command line, only a subset of the JDK java files will
@@ -502,27 +477,20 @@
# space separated list.
JDK_USER_DEFINED_FILTER := $(strip $(subst $(COMMA),$(SPACE), $(JDK_FILTER)))
-# Rewrite the MODULE_SRC_DIRS with a wildcard for the module so that all module
-# source dirs are available on the path.
-MODULESOURCEPATH := $(subst $(SPACE),$(PATH_SEP),$(subst $(MODULE),*,$(MODULE_SRC_DIRS)))
+# Get the complete module source path.
+MODULESOURCEPATH := $(call GetModuleSrcPath)
-# Add imported modules to the moduleclasspath
-MODULECLASSPATH := $(subst $(SPACE),$(PATH_SEP), $(IMPORT_MODULES_CLASSES))
+# Add imported modules to the modulepath
+MODULEPATH := $(call PathList, $(IMPORT_MODULES_CLASSES))
ifeq ($(MODULE), jdk.vm.ci)
## WORKAROUND jdk.vm.ci source structure issue
JVMCI_MODULESOURCEPATH := $(MODULESOURCEPATH) \
$(subst /$(MODULE)/,/*/, $(filter-out %processor/src, \
$(wildcard $(HOTSPOT_TOPDIR)/src/jdk.vm.ci/share/classes/*/src)))
- MODULESOURCEPATH := $(subst $(SPACE),$(PATH_SEP), $(JVMCI_MODULESOURCEPATH))
+ MODULESOURCEPATH := $(call PathList, $(JVMCI_MODULESOURCEPATH))
endif
-# Make sure the generated source base dirs exist. Not all modules have generated
-# source in all of these directories and because of timing, all of them might not
-# exist at the time this makefile gets called. Javac will complain if there are
-# missing directories in the moduleclasspath.
-$(call MakeDir, $(GENERATED_SRC_DIRS))
-
$(eval $(call SetupJavaCompilation, $(MODULE), \
SETUP := $(if $($(MODULE)_SETUP), $($(MODULE)_SETUP), GENERATE_JDKBYTECODE), \
MODULE := $(MODULE), \
@@ -532,8 +500,8 @@
HEADERS := $(SUPPORT_OUTPUTDIR)/headers, \
ADD_JAVAC_FLAGS := \
$($(MODULE)_ADD_JAVAC_FLAGS) \
- -modulesourcepath "$(MODULESOURCEPATH)" \
- $(if $(MODULECLASSPATH), -modulepath "$(MODULECLASSPATH)") \
+ -modulesourcepath $(MODULESOURCEPATH) \
+ -modulepath $(MODULEPATH) \
-system none, \
))
@@ -574,8 +542,9 @@
ifneq ($(wildcard $(IMPORT_MODULES_CLASSES)/$(MODULE)), )
$(JDK_OUTPUTDIR)/modules/$(MODULE)/_imported.marker: \
$(call CacheFind, $(IMPORT_MODULES_CLASSES)/$(MODULE))
- $(RM) -r $(@D)
- $(MKDIR) -p $(@D)
+ $(call MakeDir, $(@D))
+ # Do not delete marker and build meta data files
+ $(RM) -r $(filter-out $(@D)/_%, $(wildcard $(@D)/*))
$(CP) -R $(IMPORT_MODULES_CLASSES)/$(MODULE)/* $(@D)/
$(TOUCH) $@
--- a/make/GensrcModuleInfo.gmk Thu Apr 21 20:49:11 2016 -0700
+++ b/make/GensrcModuleInfo.gmk Fri Apr 22 01:04:00 2016 -0700
@@ -49,7 +49,6 @@
include $(SPEC)
include MakeBase.gmk
include Modules.gmk
-#include TextFileProcessing.gmk
################################################################################
# Define this here since jdk/make/Tools.gmk cannot be included from the top
@@ -64,25 +63,8 @@
# Name of data file. Keep module-info.java.ext until javafx has changed.
MOD_FILENAME := module-info.java.extra module-info.java.ext
-# List all the possible sub directories inside a module source directory where
-# data might be stored.
-CLASSES_SUBDIRS += $(OPENJDK_TARGET_OS)/classes
-ifneq ($(OPENJDK_TARGET_OS), $(OPENJDK_TARGET_OS_TYPE))
- CLASSES_SUBDIRS += $(OPENJDK_TARGET_OS_TYPE)/classes
-endif
-CLASSES_SUBDIRS += share/classes
-
-# TODO: When the deploy build is better integrated, this will get added globally
-# but for now need to add it here.
-ifeq ($(BUILD_DEPLOY), true)
- ALL_TOP_SRC_DIRS += $(DEPLOY_TOPDIR)/src
-endif
-
# Construct all possible src directories for the module.
-MODULE_CLASSES_DIRS := $(strip \
- $(foreach sub, $(CLASSES_SUBDIRS), \
- $(addsuffix /$(MODULE)/$(sub), $(ALL_TOP_SRC_DIRS))) \
- $(addsuffix /$(MODULE), $(IMPORT_MODULES_SRC)))
+MODULE_CLASSES_DIRS := $(call FindModuleSrcDirs, $(MODULE))
# Find all the .extra files in the src dirs.
MOD_FILES := $(wildcard $(foreach f, $(MOD_FILENAME), $(addsuffix /$(f), \
@@ -125,20 +107,6 @@
TARGETS += $(SUPPORT_OUTPUTDIR)/gensrc/$(MODULE)/module-info.java
endif
-# This doesn't work because javac only accepts one single exports line per
-# exported package.
- # Restore the modifications to separate lines with spaces
-# MODIFICATIONS := $(subst /,$(SPACE),$(MODIFICATIONS))
-
-# ifneq ($(MODIFICATIONS), )
-# $(eval $(call SetupTextFileProcessing, PROCESS_MODULE_INFO, \
-# SOURCE_FILES := $(firstword $(call FindAllModuleInfos, $(MODULE))), \
-# OUTPUT_FILE := $(SUPPORT_OUTPUTDIR)/gensrc/$(MODULE)/module-info.java, \
-# REPLACEMENTS := } => $(MODIFICATIONS) }, \
-# ))
-
-# TARGETS += $(PROCESS_MODULE_INFO)
-# endif
endif
# If no modifications are found for this module, remove any module-info.java
--- a/make/Javadoc.gmk Thu Apr 21 20:49:11 2016 -0700
+++ b/make/Javadoc.gmk Fri Apr 22 01:04:00 2016 -0700
@@ -235,6 +235,11 @@
JRE_API_DOCSDIR = $(DOCSDIR)/jre/api
PLATFORM_DOCSDIR = $(DOCSDIR)/platform
+JAVADOC_ARCHIVE_NAME := jdk-$(VERSION_STRING)-docs.zip
+JAVADOC_ARCHIVE_ASSEMBLY_DIR := $(DOCSTMPDIR)/zip-docs
+JAVADOC_ARCHIVE_DIR := $(OUTPUT_ROOT)/bundles
+JAVADOC_ARCHIVE := $(JAVADOC_ARCHIVE_DIR)/$(JAVADOC_ARCHIVE_NAME)
+
# The core api index file is the target for the core api javadocs rule
# and needs to be defined early so that all other javadoc rules may
# depend on it.
@@ -378,6 +383,13 @@
all: docs
docs: coredocs otherdocs
+#
+# Optional target which bundles all generated javadocs into a zip archive.
+# The dependency on docs is handled in Main.gmk.
+#
+
+zip-docs: $(JAVADOC_ARCHIVE)
+
#############################################################
#
# coredocs
@@ -1671,6 +1683,28 @@
otherdocs: $(ALL_OTHER_TARGETS)
+#
+# Add the core docs as prerequisite to the archive to trigger a rebuild
+# if the core docs were rebuilt. Ideally any doc rebuild should trigger
+# this, but the way prerequisites are currently setup in this file, that
+# is hard to achieve.
+#
+
+$(JAVADOC_ARCHIVE): $(COREAPI_INDEX_FILE)
+ $(call LogInfo, Compressing javadoc to single $(JAVADOC_ARCHIVE_NAME))
+ $(MKDIR) -p $(JAVADOC_ARCHIVE_DIR)
+ $(RM) -r $(JAVADOC_ARCHIVE_ASSEMBLY_DIR)
+ $(MKDIR) -p $(JAVADOC_ARCHIVE_ASSEMBLY_DIR)
+ all_roots=`$(FIND) $(DOCSDIR) | $(GREP) index.html | grep -v old/doclet`; \
+ pushd $(JAVADOC_ARCHIVE_ASSEMBLY_DIR); \
+ for index_file in $${all_roots} ; do \
+ target_dir=`dirname $${index_file}`; \
+ name=`$(ECHO) $${target_dir} | $(SED) "s;/spec;;" | $(SED) "s;.*/;;"`; \
+ $(LN) -s $${target_dir} $${name}; \
+ done; \
+ $(ZIP) -q -r $(JAVADOC_ARCHIVE) * ; \
+ popd ;
+
#############################################################
.PHONY: all docs coredocs otherdocs \
- $(ALL_OTHER_TARGETS)
+ $(ALL_OTHER_TARGETS) zip-docs
--- a/make/Main.gmk Thu Apr 21 20:49:11 2016 -0700
+++ b/make/Main.gmk Fri Apr 22 01:04:00 2016 -0700
@@ -333,6 +333,9 @@
docs-jvmtidoc:
+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Javadoc.gmk jvmtidocs)
+zip-docs: docs-javadoc docs-jvmtidoc
+ +($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Javadoc.gmk zip-docs)
+
ALL_TARGETS += docs-javadoc docs-jvmtidoc
################################################################################
@@ -385,9 +388,27 @@
build-test-lib:
+($(CD) $(TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) -f BuildTestLib.gmk)
+ifeq ($(BUILD_FAILURE_HANDLER), true)
+ # Builds the failure handler jtreg extension
+ build-test-failure-handler:
+ +($(CD) $(TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) \
+ -f BuildFailureHandler.gmk build)
+
+ # Runs the tests for the failure handler jtreg extension
+ test-failure-handler:
+ +($(CD) $(TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) \
+ -f BuildFailureHandler.gmk test)
+
+ # Copies the failure handler jtreg extension into the test image
+ test-image-failure-handler:
+ +($(CD) $(TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) \
+ -f BuildFailureHandler.gmk images)
+endif
+
ALL_TARGETS += prepare-test-image build-test-hotspot-jtreg-native \
test-image-hotspot-jtreg-native build-test-jdk-jtreg-native \
- test-image-jdk-jtreg-native build-test-lib
+ test-image-jdk-jtreg-native build-test-lib build-test-failure-handler \
+ test-failure-handler test-image-failure-handler
################################################################################
# Run tests
@@ -582,6 +603,12 @@
build-test-lib: java
+ build-test-failure-handler: interim-langtools
+
+ test-failure-handler: build-test-failure-handler
+
+ test-image-failure-handler: build-test-failure-handler
+
build-test-hotspot-jtreg-native: buildtools-jdk
build-test-jdk-jtreg-native: buildtools-jdk
@@ -667,11 +694,11 @@
endif
# This target builds the documentation image
-docs-image: docs-javadoc docs-jvmtidoc
+docs-image: zip-docs
# This target builds the test image
test-image: prepare-test-image test-image-hotspot-jtreg-native \
- test-image-jdk-jtreg-native
+ test-image-jdk-jtreg-native test-image-failure-handler
# all-images is the top-most target, it builds all our deliverables ("images").
all-images: product-images test-image docs-image
@@ -691,7 +718,7 @@
docs: docs-image
all: all-images
-ALL_TARGETS += default jdk images docs all
+ALL_TARGETS += default jdk images docs all zip-docs
################################################################################
################################################################################
--- a/make/MainSupport.gmk Thu Apr 21 20:49:11 2016 -0700
+++ b/make/MainSupport.gmk Fri Apr 22 01:04:00 2016 -0700
@@ -104,6 +104,7 @@
@$(PRINTF) "\n" $(LOG_DEBUG)
$(RM) -r $(SUPPORT_OUTPUTDIR)/docs
$(RM) -r $(IMAGES_OUTPUTDIR)/docs
+ $(RM) $(OUTPUT_ROOT)/bundles/jdk-*-docs.zip
@$(PRINTF) " done\n"
endef
--- a/make/common/MakeBase.gmk Thu Apr 21 20:49:11 2016 -0700
+++ b/make/common/MakeBase.gmk Fri Apr 22 01:04:00 2016 -0700
@@ -723,12 +723,13 @@
endif
################################################################################
-# Return a string suitable for use after a -classpath option. It will correct and safe to use
-# on all platforms. Arguments are given as space separate classpath entries.
+# Return a string suitable for use after a -classpath or -modulepath option. It
+# will be correct and safe to use on all platforms. Arguments are given as space
+# separate classpath entries. Safe for multiple nested calls.
# param 1 : A space separated list of classpath entries
# The surrounding strip is needed to keep additional whitespace out
PathList = \
- "$(subst $(SPACE),$(PATH_SEP),$(strip $1))"
+ "$(subst $(SPACE),$(PATH_SEP),$(strip $(subst $(DQUOTE),,$1)))"
################################################################################
--- a/make/common/Modules.gmk Thu Apr 21 20:49:11 2016 -0700
+++ b/make/common/Modules.gmk Fri Apr 22 01:04:00 2016 -0700
@@ -138,26 +138,35 @@
################################################################################
# Module list macros
-# Use append so that the custom extension may add to this variable
+# Use append so that the custom extension may add to these variables
-ALL_TOP_SRC_DIRS += \
+GENERATED_SRC_DIRS += \
+ $(SUPPORT_OUTPUTDIR)/gensrc \
+ #
+
+TOP_SRC_DIRS += \
+ $(CORBA_TOPDIR)/src \
$(HOTSPOT_TOPDIR)/src \
$(JDK_TOPDIR)/src \
$(LANGTOOLS_TOPDIR)/src \
- $(CORBA_TOPDIR)/src \
$(JAXP_TOPDIR)/src \
$(JAXWS_TOPDIR)/src \
$(NASHORN_TOPDIR)/src \
#
+SRC_SUBDIRS += $(OPENJDK_TARGET_OS)/classes
+ifneq ($(OPENJDK_TARGET_OS), $(OPENJDK_TARGET_OS_TYPE))
+ SRC_SUBDIRS += $(OPENJDK_TARGET_OS_TYPE)/classes
+endif
+SRC_SUBDIRS += share/classes
+
# Find all module-info.java files for the current build target platform and
# configuration.
# Param 1 - Module to find for, set to * for finding all
FindAllModuleInfos = \
$(wildcard \
- $(patsubst %,%/$(strip $1)/$(OPENJDK_TARGET_OS)/classes/module-info.java, $(ALL_TOP_SRC_DIRS)) \
- $(patsubst %,%/$(strip $1)/$(OPENJDK_TARGET_OS_TYPE)/classes/module-info.java, $(ALL_TOP_SRC_DIRS)) \
- $(patsubst %,%/$(strip $1)/share/classes/module-info.java, $(ALL_TOP_SRC_DIRS)) \
+ $(foreach sub, $(SRC_SUBDIRS), \
+ $(patsubst %,%/$(strip $1)/$(sub)/module-info.java, $(TOP_SRC_DIRS))) \
$(patsubst %,%/$(strip $1)/module-info.java, $(IMPORT_MODULES_SRC)))
# Extract the module names from the paths of module-info.java files. The
@@ -178,6 +187,19 @@
FindImportedModules = \
$(if $(IMPORT_MODULES_CLASSES), $(notdir $(wildcard $(IMPORT_MODULES_CLASSES)/*)))
+# Find all source dirs for a particular module
+# $1 - Module to find source dirs for
+FindModuleSrcDirs = \
+ $(strip $(wildcard \
+ $(addsuffix /$(strip $1), $(GENERATED_SRC_DIRS) $(IMPORT_MODULES_SRC)) \
+ $(foreach sub, $(SRC_SUBDIRS), $(addsuffix /$(strip $1)/$(sub), $(TOP_SRC_DIRS)))))
+
+# Construct the complete module source path
+GetModuleSrcPath = \
+ $(call PathList, \
+ $(addsuffix /*, $(GENERATED_SRC_DIRS) $(IMPORT_MODULES_SRC)) \
+ $(foreach sub, $(SRC_SUBDIRS), $(addsuffix /*/$(sub), $(TOP_SRC_DIRS))))
+
################################################################################
# Extract module dependencies from module-info.java files.
--- a/make/jprt.properties Thu Apr 21 20:49:11 2016 -0700
+++ b/make/jprt.properties Fri Apr 22 01:04:00 2016 -0700
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2006, 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
@@ -311,13 +311,13 @@
# Platforms built for hotspot push jobs
my.build.targets.hotspot= \
- solaris_sparcv9_5.11-{product|fastdebug}, \
+ solaris_sparcv9_5.11-{product|fastdebug}, \
solaris_x64_5.11-{product|fastdebug}, \
linux_i586_3.8-{product|fastdebug}, \
- linux_x64_3.8-{product|fastdebug}, \
+ linux_x64_3.8-{product|fastdebug}, \
macosx_x64_10.9-{product|fastdebug}, \
windows_i586_6.3-{product|fastdebug}, \
- windows_x64_6.3-{product|fastdebug}, \
+ windows_x64_6.3-{product|fastdebug}, \
solaris_x64_5.11-{fastdebugOpen}, \
linux_x64_3.8-{productOpen}, \
${my.additional.build.targets.hotspot}
@@ -346,18 +346,15 @@
solaris_x64_5.11-{product|fastdebug}-c2-GCBasher_G1
my.test.targets.hotspot.linux.i586= \
- linux_i586_3.8-{product|fastdebug}-{c1|c2}-jvm98, \
+ linux_i586_3.8-{product|fastdebug}-c2-jvm98, \
linux_i586_3.8-{product|fastdebug}-c2-jvm98_nontiered, \
- linux_i586_3.8-{product|fastdebug}-{c1|c2}-scimark, \
- linux_i586_3.8-product-c1-runThese8_Xcomp_lang, \
- linux_i586_3.8-product-c1-runThese8_Xcomp_vm, \
- linux_i586_3.8-fastdebug-c1-runThese8_Xshare, \
+ linux_i586_3.8-{product|fastdebug}-c2-scimark, \
linux_i586_3.8-fastdebug-c2-runThese8_Xcomp_lang, \
linux_i586_3.8-fastdebug-c2-runThese8_Xcomp_vm, \
- linux_i586_3.8-{product|fastdebug}-{c1|c2}-GCBasher_SerialGC, \
- linux_i586_3.8-{product|fastdebug}-{c1|c2}-GCBasher_ParallelGC, \
- linux_i586_3.8-{product|fastdebug}-{c1|c2}-GCBasher_CMS, \
- linux_i586_3.8-{product|fastdebug}-{c1|c2}-GCBasher_G1
+ linux_i586_3.8-{product|fastdebug}-c2-GCBasher_SerialGC, \
+ linux_i586_3.8-{product|fastdebug}-c2-GCBasher_ParallelGC, \
+ linux_i586_3.8-{product|fastdebug}-c2-GCBasher_CMS, \
+ linux_i586_3.8-{product|fastdebug}-c2-GCBasher_G1
my.test.targets.hotspot.linux.x64= \
linux_x64_3.8-{product|fastdebug}-c2-jvm98, \
@@ -378,17 +375,16 @@
macosx_x64_10.9-{product|fastdebug}-c2-GCBasher_G1
my.test.targets.hotspot.windows.i586= \
- windows_i586_6.3-{product|fastdebug}-{c1|c2}-jvm98, \
+ windows_i586_6.3-{product|fastdebug}-c2-jvm98, \
windows_i586_6.3-{product|fastdebug}-c2-jvm98_nontiered, \
- windows_i586_6.3-{product|fastdebug}-{c1|c2}-scimark, \
- windows_i586_6.3-product-{c1|c2}-runThese8, \
- windows_i586_6.3-product-{c1|c2}-runThese8_Xcomp_lang, \
- windows_i586_6.3-product-{c1|c2}-runThese8_Xcomp_vm, \
- windows_i586_6.3-fastdebug-c1-runThese8_Xshare, \
- windows_i586_6.3-{product|fastdebug}-{c1|c2}-GCBasher_SerialGC, \
- windows_i586_6.3-{product|fastdebug}-{c1|c2}-GCBasher_ParallelGC, \
- windows_i586_6.3-{product|fastdebug}-{c1|c2}-GCBasher_CMS, \
- windows_i586_6.3-{product|fastdebug}-{c1|c2}-GCBasher_G1
+ windows_i586_6.3-{product|fastdebug}-c2-scimark, \
+ windows_i586_6.3-product-c2-runThese8, \
+ windows_i586_6.3-product-c2-runThese8_Xcomp_lang, \
+ windows_i586_6.3-product-c2-runThese8_Xcomp_vm, \
+ windows_i586_6.3-{product|fastdebug}-c2-GCBasher_SerialGC, \
+ windows_i586_6.3-{product|fastdebug}-c2-GCBasher_ParallelGC, \
+ windows_i586_6.3-{product|fastdebug}-c2-GCBasher_CMS, \
+ windows_i586_6.3-{product|fastdebug}-c2-GCBasher_G1
my.test.targets.hotspot.windows.x64= \
windows_x64_6.3-{product|fastdebug}-c2-jvm98, \
@@ -443,22 +439,21 @@
linux_x64_3.8-fastdebug-c2-GROUP, \
macosx_x64_10.9-fastdebug-c2-GROUP, \
windows_i586_6.3-fastdebug-c2-GROUP, \
- windows_x64_6.3-fastdebug-c2-GROUP, \
- linux_i586_3.8-fastdebug-c1-GROUP, \
- windows_i586_6.3-fastdebug-c1-GROUP
+ windows_x64_6.3-fastdebug-c2-GROUP
# Hotspot jtreg tests
-my.make.rule.test.targets.hotspot.reg= \
- ${my.make.rule.test.targets.hotspot.reg.group:GROUP=hotspot_compiler_1}, \
- ${my.make.rule.test.targets.hotspot.reg.group:GROUP=hotspot_compiler_2}, \
- ${my.make.rule.test.targets.hotspot.reg.group:GROUP=hotspot_compiler_3}, \
- ${my.make.rule.test.targets.hotspot.reg.group:GROUP=hotspot_compiler_closed}, \
- ${my.make.rule.test.targets.hotspot.reg.group:GROUP=hotspot_gc}, \
- ${my.make.rule.test.targets.hotspot.reg.group:GROUP=hotspot_gc_closed}, \
- ${my.make.rule.test.targets.hotspot.reg.group:GROUP=hotspot_gc_gcold}, \
- ${my.make.rule.test.targets.hotspot.reg.group:GROUP=hotspot_runtime}, \
- ${my.make.rule.test.targets.hotspot.reg.group:GROUP=hotspot_serviceability}, \
- ${my.make.rule.test.targets.hotspot.reg.group:GROUP=jdk_svc_sanity}, \
+my.make.rule.test.targets.hotspot.reg= \
+ ${my.make.rule.test.targets.hotspot.reg.group:GROUP=hotspot_fast_compiler_1}, \
+ ${my.make.rule.test.targets.hotspot.reg.group:GROUP=hotspot_fast_compiler_2}, \
+ ${my.make.rule.test.targets.hotspot.reg.group:GROUP=hotspot_fast_compiler_3}, \
+ ${my.make.rule.test.targets.hotspot.reg.group:GROUP=hotspot_fast_compiler_closed}, \
+ ${my.make.rule.test.targets.hotspot.reg.group:GROUP=hotspot_fast_gc_1}, \
+ ${my.make.rule.test.targets.hotspot.reg.group:GROUP=hotspot_fast_gc_2}, \
+ ${my.make.rule.test.targets.hotspot.reg.group:GROUP=hotspot_fast_gc_closed}, \
+ ${my.make.rule.test.targets.hotspot.reg.group:GROUP=hotspot_fast_gc_gcold}, \
+ ${my.make.rule.test.targets.hotspot.reg.group:GROUP=hotspot_fast_runtime}, \
+ ${my.make.rule.test.targets.hotspot.reg.group:GROUP=hotspot_fast_serviceability}, \
+ ${my.make.rule.test.targets.hotspot.reg.group:GROUP=jdk_svc_sanity}, \
${my.additional.make.rule.test.targets.hotspot.reg}
# Other Makefile based Hotspot tests
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/make/test/BuildFailureHandler.gmk Fri Apr 22 01:04:00 2016 -0700
@@ -0,0 +1,128 @@
+#
+# 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.
+#
+
+default: build
+
+include $(SPEC)
+include MakeBase.gmk
+include JavaCompilation.gmk
+include SetupJavaCompilers.gmk
+include NativeCompilation.gmk
+
+TARGETS :=
+
+################################################################################
+
+FH_BASEDIR := $(SRC_ROOT)/test/failure_handler
+FH_SUPPORT := $(SUPPORT_OUTPUTDIR)/test/failure_handler
+FH_JAR := $(FH_SUPPORT)/jtregFailureHandler.jar
+
+JTREG_JAR := $(JT_HOME)/lib/jtreg.jar
+ifeq ($(wildcard $(JTREG_JAR)), )
+ $(error Cannot build failure handler without jtreg)
+endif
+# tools.jar is only needed if it exists in the boot jdk
+TOOLS_JAR := $(wildcard $(BOOT_JDK)/lib/tools.jar)
+
+FH_CLASSPATH := $(call PathList, $(JTREG_JAR) $(TOOLS_JAR))
+
+$(eval $(call SetupJavaCompilation, BUILD_FAILURE_HANDLER, \
+ SETUP := GENERATE_OLDBYTECODE, \
+ SRC := $(FH_BASEDIR)/src/share/classes $(FH_BASEDIR)/src/share/conf, \
+ BIN := $(FH_SUPPORT)/classes, \
+ COPY := .properties, \
+ CLASSPATH := $(JTREG_JAR) $(TOOLS_JAR), \
+ JAR := $(FH_JAR), \
+))
+
+TARGETS += $(BUILD_FAILURE_HANDLER)
+
+################################################################################
+
+ifeq ($(OPENJDK_TARGET_OS), windows)
+
+ $(eval $(call SetupNativeCompilation, BUILD_LIBTIMEOUT_HANDLER, \
+ LIBRARY := timeoutHandler, \
+ SRC := $(FH_BASEDIR)/src/windows/native/libtimeoutHandler, \
+ OBJECT_DIR := $(FH_SUPPORT)/libtimeoutHandler, \
+ OUTPUT_DIR := $(FH_SUPPORT), \
+ CFLAGS := $(CFLAGS_JDKLIB), \
+ LDFLAGS := $(LDFLAGS_JDKLIB), \
+ OPTIMIZATION := LOW, \
+ ))
+
+ TARGETS += $(BUILD_LIBTIMEOUT_HANDLER)
+
+endif
+
+################################################################################
+# Targets for building test-image.
+################################################################################
+
+# Copy to hotspot jtreg test image
+$(eval $(call SetupCopyFiles, COPY_FH, \
+ SRC := $(FH_SUPPORT), \
+ DEST := $(TEST_IMAGE_DIR)/failure_handler, \
+ FILES := $(FH_JAR) $(BUILD_LIBTIMEOUT_HANDLER), \
+))
+
+IMAGES_TARGETS += $(COPY_FH)
+
+################################################################################
+# Test the failure handler itself
+################################################################################
+#
+# Use JTREG_TEST_OPTS for test VM options
+# Use JTREG_TESTS for jtreg tests parameter
+#
+RUN_DIR := $(FH_SUPPORT)/test
+# Add the dir of the dll to the path on windows
+ifeq ($(OPENJDK_TARGET_OS), windows)
+ export PATH := $(PATH);$(FH_SUPPORT)
+endif
+
+test:
+ $(RM) -r $(RUN_DIR)
+ $(MKDIR) -p $(RUN_DIR)
+ $(CD) $(FH_BASEDIR)/test && JT_JAVA=$(BOOT_JDK) $(JTREGEXE) \
+ -jdk:$(BOOT_JDK) \
+ $(JTREG_TEST_OPTS) \
+ -timeout:0.1 -va -retain:all \
+ -noreport \
+ -agentvm \
+ -thd:$(FH_JAR) \
+ -th:jdk.test.failurehandler.jtreg.GatherProcessInfoTimeoutHandler \
+ -od:$(FH_JAR) \
+ -o:jdk.test.failurehandler.jtreg.GatherDiagnosticInfoObserver \
+ -w:$(RUN_DIR)/JTwork -r:$(RUN_DIR)/JTreport \
+ $(if $(JTREG_TESTS), $(JTREG_TESTS), .) \
+ || true
+
+################################################################################
+
+build: $(TARGETS)
+images: $(IMAGES_TARGETS)
+
+.PHONY: all images test
--- a/nashorn/.hgtags Thu Apr 21 20:49:11 2016 -0700
+++ b/nashorn/.hgtags Fri Apr 22 01:04:00 2016 -0700
@@ -347,3 +347,4 @@
133ea8746b37739a0510c80b42888bd85ace9477 jdk-9+111
c261f8440c5578b34596e6b0419a81aec431a884 jdk-9+112
a5d1990fd32d908da8154d79116fce8013ba4d40 jdk-9+113
+ba21793a0e4816283cc0ecdab5142a4959363529 jdk-9+114
--- a/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/AbstractJavaLinker.java Thu Apr 21 20:49:11 2016 -0700
+++ b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/AbstractJavaLinker.java Fri Apr 22 01:04:00 2016 -0700
@@ -111,7 +111,7 @@
import jdk.dynalink.linker.LinkerServices;
import jdk.dynalink.linker.support.Guards;
import jdk.dynalink.linker.support.Lookup;
-import sun.reflect.CallerSensitive;
+import jdk.internal.reflect.CallerSensitive;
/**
* A base class for both {@link StaticClassLinker} and {@link BeanLinker}. Deals with common aspects of property
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/JavaAdapterBytecodeGenerator.java Thu Apr 21 20:49:11 2016 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/JavaAdapterBytecodeGenerator.java Fri Apr 22 01:04:00 2016 -0700
@@ -72,7 +72,7 @@
import jdk.nashorn.internal.runtime.ScriptFunction;
import jdk.nashorn.internal.runtime.ScriptObject;
import jdk.nashorn.internal.runtime.linker.AdaptationResult.Outcome;
-import sun.reflect.CallerSensitive;
+import jdk.internal.reflect.CallerSensitive;
/**
* Generates bytecode for a Java adapter class. Used by the {@link JavaAdapterFactory}.
--- a/test/failure_handler/Makefile Thu Apr 21 20:49:11 2016 -0700
+++ b/test/failure_handler/Makefile Fri Apr 22 01:04:00 2016 -0700
@@ -29,7 +29,7 @@
CLASSES_DIR := ${BUILD_DIR}/classes
IMAGE_DIR := ${BUILD_DIR}/image
RUN_DIR := $(shell pwd)/run
-
+CLASSPATH := ${JTREG_HOME}/lib/jtreg.jar:${JAVA_HOME}/lib/tools.jar
SRC_DIR := src/share/classes/
SOURCES := ${SRC_DIR}/jdk/test/failurehandler/*.java \
${SRC_DIR}/jdk/test/failurehandler/action/*.java \
@@ -47,9 +47,12 @@
ifeq ("${OS_NAME}", "Cygwin")
BUILD_DIR := $(shell cygpath -m "${BUILD_DIR}")
CLASSES_DIR := $(shell cygpath -m "${CLASSES_DIR}")
-IMAGE_DIR := $(shell cygpath -m "${IMAGE_DIR}") RUN_DIR := $(shell cygpath -m "${RUN_DIR}")
+IMAGE_DIR := $(shell cygpath -m "${IMAGE_DIR}")
+RUN_DIR := $(shell cygpath -m "${RUN_DIR}")
SRC_DIR := $(shell cygpath -m "${SRC_DIR}")
+JAVA_HOME := $(shell cygpath -m "${JAVA_HOME}")
JTREG_HOME := $(shell cygpath -m "${JTREG_HOME}")
+CLASSPATH := $(shell cygpath -pm "${CLASSPATH}")
CC := "cl.exe"
endif
@@ -57,33 +60,33 @@
native: require_env
ifeq ("${OS_NAME}", "Cygwin")
- "${CC}" src/windows/native/jdk/test/failurehandler/jtreg/*.c \
- -I"$(shell cygpath -w ${JAVA_HOME}/include)" \
- -I"$(shell cygpath -w ${JAVA_HOME}/include/win32)" \
- /link /MACHINE:X64 /DLL /OUT:timeoutHandler.dll
+ "${CC}" src/windows/native/jdk/test/failurehandler/jtreg/*.c \
+ -I"$(shell cygpath -w "${JAVA_HOME}/include")" \
+ -I"$(shell cygpath -w "${JAVA_HOME}/include/win32")" \
+ /link /DLL /OUT:timeoutHandler.dll
endif
check_defined = $(foreach 1,$1,$(__check_defined))
__check_defined = $(if $(value $1),, $(error $1 is not set))
classes: require_env
- mkdir -p ${IMAGE_DIR}/bin ${IMAGE_DIR}/lib ${CLASSES_DIR}
- "${JAVA_HOME}"/bin/javac -target ${JAVA_RELEASE} -source ${JAVA_RELEASE} \
- -sourcepath $(shell pwd) \
- -classpath ${JTREG_HOME}/lib/jtreg.jar:${JAVA_HOME}/lib/tools.jar \
- -d ${CLASSES_DIR} \
+ mkdir -p ${IMAGE_DIR}/bin ${IMAGE_DIR}/lib ${CLASSES_DIR}
+ "${JAVA_HOME}"/bin/javac -target ${JAVA_RELEASE} -source ${JAVA_RELEASE} \
+ -sourcepath "$(shell pwd)" \
+ -cp "${CLASSPATH}" \
+ -d ${CLASSES_DIR} \
${SOURCES}
- "${JAVA_HOME}"/bin/jar cf ${TARGET_JAR} -C ${CLASSES_DIR} .
- "${JAVA_HOME}"/bin/jar uf ${TARGET_JAR} -C ${CONF_DIR} .
+ "${JAVA_HOME}"/bin/jar cf "${TARGET_JAR}" -C "${CLASSES_DIR}" .
+ "${JAVA_HOME}"/bin/jar uf "${TARGET_JAR}" -C "${CONF_DIR}" .
#
# Use JTREG_TEST_OPTS for test VM options
# Use JTREG_TESTS for jtreg tests parameter
#
test: require_env build
- rm -rf ${RUN_DIR}
- mkdir -p ${RUN_DIR}
- "${JTREG_HOME}"/bin/jtreg \
+ rm -rf "${RUN_DIR}"
+ mkdir -p "${RUN_DIR}"
+ "${JTREG_HOME}"/bin/jtreg \
-jdk:"${JAVA_HOME}" \
${JTREG_TEST_OPTS} \
-timeout:0.1 -va -retain:all \
@@ -93,7 +96,8 @@
-th:jdk.test.failurehandler.jtreg.GatherProcessInfoTimeoutHandler \
-od:"${TARGET_JAR}" \
-o:jdk.test.failurehandler.jtreg.GatherDiagnosticInfoObserver \
- -w:${RUN_DIR}/JTwork -r:${RUN_DIR}/JTreport \
+ -w:"${RUN_DIR}/JTwork" \
+ -r:"${RUN_DIR}/JTreport" \
$(if ${JTREG_TESTS}, ${JTREG_TESTS}, test) \
&& false || true
@@ -101,11 +105,11 @@
debug: test
require_env:
- $(call check_defined, JAVA_HOME)
- $(call check_defined, JTREG_HOME)
+ $(call check_defined, JAVA_HOME)
+ $(call check_defined, JTREG_HOME)
clean:
- rm -rf "${BUILD_DIR}" "${RUN_DIR}"
+ rm -rf "${BUILD_DIR}" "${RUN_DIR}"
build: classes native
--- a/test/failure_handler/README Thu Apr 21 20:49:11 2016 -0700
+++ b/test/failure_handler/README Fri Apr 22 01:04:00 2016 -0700
@@ -36,11 +36,9 @@
BUILDING
-To build a library, one should simply run make with 'JTREG_HOME' and
-'JAVA_HOME' environment variables set. 'JAVA_HOME' should contain path to JDK,
-'JTREG_HOME' -- path to jtreg.
-
-'image/lib/jtregFailureHandler.jar' is created on successful build.
+The library is built using the top level build-test-failure-handler target and
+is automatically included in the test image and picked up by hotspot and jdk
+test makefiles.
CONFIGURATION
--- a/test/failure_handler/src/share/classes/jdk/test/failurehandler/jtreg/GatherProcessInfoTimeoutHandler.java Thu Apr 21 20:49:11 2016 -0700
+++ b/test/failure_handler/src/share/classes/jdk/test/failurehandler/jtreg/GatherProcessInfoTimeoutHandler.java Fri Apr 22 01:04:00 2016 -0700
@@ -39,12 +39,16 @@
* process and its children.
*/
public class GatherProcessInfoTimeoutHandler extends TimeoutHandler {
+ private static final boolean HAS_NATIVE_LIBRARY;
static {
+ boolean value = true;
try {
System.loadLibrary("timeoutHandler");
} catch (UnsatisfiedLinkError ignore) {
// not all os need timeoutHandler native-library
+ value = false;
}
+ HAS_NATIVE_LIBRARY = value;
}
private static final String LOG_FILENAME = "processes.log";
private static final String OUTPUT_FILENAME = "processes.html";
@@ -105,7 +109,7 @@
if (result == 0L) {
/* jtreg didn't find pid, most probably we are on JDK < 9
there is no Process::getPid */
- if ("windows".equals(OS.current().family)) {
+ if (HAS_NATIVE_LIBRARY && "windows".equals(OS.current().family)) {
try {
Field field = process.getClass().getDeclaredField("handle");
boolean old = field.isAccessible();
--- a/test/failure_handler/src/windows/native/jdk/test/failurehandler/jtreg/GatherProcessInfoTimeoutHandler.c Thu Apr 21 20:49:11 2016 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,37 +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.
- */
-
-#include <jni.h>
-#include <windows.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-JNIEXPORT jlong JNICALL Java_jdk_test_failurehandler_jtreg_GatherProcessInfoTimeoutHandler_getWin32Pid
- (JNIEnv* env, jobject o, jlong handle) {
- return GetProcessId(handle);
-}
-#ifdef __cplusplus
-}
-#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/failure_handler/src/windows/native/libtimeoutHandler/GatherProcessInfoTimeoutHandler.c Fri Apr 22 01:04:00 2016 -0700
@@ -0,0 +1,37 @@
+/*
+ * 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.
+ */
+
+#include <jni.h>
+#include <windows.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+JNIEXPORT jlong JNICALL Java_jdk_test_failurehandler_jtreg_GatherProcessInfoTimeoutHandler_getWin32Pid
+ (JNIEnv* env, jobject o, jlong handle) {
+ return GetProcessId((HANDLE) handle);
+}
+#ifdef __cplusplus
+}
+#endif
--- a/test/failure_handler/test/sanity/Suicide.java Thu Apr 21 20:49:11 2016 -0700
+++ b/test/failure_handler/test/sanity/Suicide.java Fri Apr 22 01:04:00 2016 -0700
@@ -28,7 +28,7 @@
/*
* @test
* @summary Suicide test
- * @run main/othervm Crash
+ * @run main/othervm Suicide
*/
public class Suicide {
public static void main(String[] args) {
--- a/test/lib/sun/hotspot/WhiteBox.java Thu Apr 21 20:49:11 2016 -0700
+++ b/test/lib/sun/hotspot/WhiteBox.java Fri Apr 22 01:04:00 2016 -0700
@@ -344,7 +344,13 @@
}
public native Object[] getCodeBlob(long addr);
- public native void clearInlineCaches();
+ private native void clearInlineCaches0(boolean preserve_static_stubs);
+ public void clearInlineCaches() {
+ clearInlineCaches0(false);
+ }
+ public void clearInlineCaches(boolean preserve_static_stubs) {
+ clearInlineCaches0(preserve_static_stubs);
+ }
// Intered strings
public native boolean isInStringTable(String str);
--- a/test/make/TestMakeBase.gmk Thu Apr 21 20:49:11 2016 -0700
+++ b/test/make/TestMakeBase.gmk Fri Apr 22 01:04:00 2016 -0700
@@ -254,4 +254,14 @@
but was $(call sequence, 5, 15))
endif
+################################################################################
+# Test that PathList is safe when called multiple nested times.
+
+PATHLIST_INPUT := foo bar baz
+
+$(eval $(call assert-equals, \
+ $(call PathList, $(call PathList, $(PATHLIST_INPUT))), \
+ $(call PathList, $(PATHLIST_INPUT)), \
+ PathList call not safe for calling twice))
+
all: $(TEST_TARGETS)