This commit is contained in:
Alejandro Murillo 2016-04-18 15:39:46 -07:00
commit ed18f94d21
447 changed files with 10236 additions and 6367 deletions

View file

@ -356,3 +356,4 @@ c870cb782aca71093d2584376f27f0cfbfec0e3a jdk-9+109
a6614ff7bf09da74be1d0ef3d9755090d244697a jdk-9+111
7359994942f8d8e723b584d66a3a92c2e9e95e5c jdk-9+112
6072af7a98be3922f26bdce71b53bb3646cb2ac9 jdk-9+113
c84d0cce090e161d736de69e941830adf8c2f87a jdk-9+114

View file

@ -356,3 +356,4 @@ c7be2a78c31b3b6132f2f5e9e4b3d3bb1c20245c jdk-9+108
f900d5afd9c83a0df8f36161c27c5e4c86a66f4c jdk-9+111
03543a758cd5890f2266e4b9678378a925dde22a jdk-9+112
55b6d550828d1223b364e6ead4a56e56411c56df jdk-9+113
1d992540870ff33fe6cc550443388588df9b9e4f jdk-9+114

View file

@ -305,7 +305,7 @@ AC_DEFUN_ONCE([BOOTJDK_SETUP_BOOT_JDK],
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 @@ AC_DEFUN([BOOTJDK_CHECK_BUILD_JDK],
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

View file

@ -454,7 +454,7 @@ AC_DEFUN_ONCE([BPERF_SETUP_SMART_JAVAC],
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"

View file

@ -227,6 +227,7 @@ LIB_SETUP_LIBRARIES
HOTSPOT_SETUP_BUILD_TWEAKS
JDKOPT_DETECT_INTREE_EC
JDKOPT_ENABLE_DISABLE_FAILURE_HANDLER
###############################################################################
#

View file

@ -650,6 +650,7 @@ TEST_JOBS
JOBS
MEMORY_SIZE
NUM_CORES
BUILD_FAILURE_HANDLER
ENABLE_INTREE_EC
HOTSPOT_MAKE_ARGS
LIBZIP_CAN_USE_MMAP
@ -1172,6 +1173,7 @@ with_lcms
with_dxsdk
with_dxsdk_lib
with_dxsdk_include
enable_jtreg_failure_handler
with_num_cores
with_memory_size
with_jobs
@ -1940,6 +1942,12 @@ Optional Features:
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 @@ pkgadd_help() {
#
################################################################################
#
# 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 @@ VS_SDK_PLATFORM_NAME_2013=
#CUSTOM_AUTOCONF_INCLUDE
# Do not change or remove the following line, it is needed for consistency checks:
DATE_WHEN_GENERATED=1458755892
DATE_WHEN_GENERATED=1460963400
###############################################################################
#
@ -29770,13 +29784,13 @@ $as_echo "$tool_specified" >&6; }
$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 @@ $as_echo "$as_me: (This might be a JRE instead of an JDK)" >&6;}
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 @@ $as_echo "no" >&6; }
# 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_n "checking whether to use javac server... " >&6; }
$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"

View file

@ -408,7 +408,7 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_STATIC_BUILD],
################################################################################
#
# jlink options.
# jlink options.
# We always keep packaged modules in JDK image.
#
AC_DEFUN_ONCE([JDKOPT_SETUP_JLINK_OPTIONS],
@ -433,3 +433,42 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_JLINK_OPTIONS],
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)
])

View file

@ -260,6 +260,8 @@ HOTSPOT_DIST=@HOTSPOT_DIST@
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@

View file

@ -41,7 +41,7 @@ if [ "$OPENJDK_TARGET_OS" = "macosx" ]; then
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 @@ compare_bin_file() {
# 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

View file

@ -214,7 +214,7 @@ var getJibProfiles = function (input) {
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"],

View file

@ -356,3 +356,4 @@ b75afa17aefe480c23c616a6a2497063312f7189 jdk-9+109
2bb92dd44275679edb29fdbffc3b7cbebc9a6bf0 jdk-9+111
780d0620add32bf545471cf65038c9ac6d9c036d jdk-9+112
cc30faa2da498c478e89ab062ff160653ca1b170 jdk-9+113
10d175b0368c30f54350fc648adc41b94ce357ee jdk-9+114

View file

@ -37,7 +37,7 @@ import java.security.Permission;
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:

View file

@ -1967,7 +1967,7 @@ AnnotationCollector::annotation_index(const ClassLoaderData* loader_data,
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;

View file

@ -2697,7 +2697,7 @@ void java_lang_reflect_Field::set_type_annotations(oop field, oop value) {
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) {
@ -2841,7 +2841,7 @@ void java_lang_reflect_Module::set_module_entry(oop module, ModuleEntry* module_
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);
@ -2851,14 +2851,14 @@ Handle sun_reflect_ConstantPool::create(TRAPS) {
}
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);
@ -2873,7 +2873,7 @@ ConstantPool* sun_reflect_ConstantPool::get_cp(oop reflect) {
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) {
@ -3648,8 +3648,8 @@ int java_lang_AssertionStatusDirectives::packageEnabled_offset;
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
@ -3834,8 +3834,8 @@ void JavaClasses::compute_offsets() {
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();

View file

@ -799,8 +799,8 @@ class java_lang_reflect_Module {
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 @@ class sun_reflect_ConstantPool {
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();

View file

@ -142,13 +142,13 @@ class SymbolPropertyTable;
\
/* 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 ) \

View file

@ -248,7 +248,7 @@ bool Verifier::is_eligible_for_verification(instanceKlassHandle klass, bool shou
// 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

View file

@ -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) \

View file

@ -1940,8 +1940,8 @@ JVM_ENTRY(jobject, JVM_GetClassConstantPool(JNIEnv *env, jclass cls))
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_END
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_END
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_END
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 @@ JVM_ENTRY(jobject, JVM_ConstantPoolGetMethodAt(JNIEnv *env, jobject obj, jobject
{
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 @@ JVM_ENTRY(jobject, JVM_ConstantPoolGetMethodAtIfLoaded(JNIEnv *env, jobject obj,
{
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 @@ JVM_ENTRY(jobject, JVM_ConstantPoolGetFieldAt(JNIEnv *env, jobject obj, jobject
{
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 @@ JVM_ENTRY(jobject, JVM_ConstantPoolGetFieldAtIfLoaded(JNIEnv *env, jobject obj,
{
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 @@ JVM_ENTRY(jobjectArray, JVM_ConstantPoolGetMemberRefInfoAt(JNIEnv *env, jobject
{
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 @@ JVM_ENTRY(jint, JVM_ConstantPoolGetClassRefIndexAt(JNIEnv *env, jobject obj, job
{
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 @@ JVM_ENTRY(jint, JVM_ConstantPoolGetNameAndTypeRefIndexAt(JNIEnv *env, jobject ob
{
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 @@ JVM_ENTRY(jobjectArray, JVM_ConstantPoolGetNameAndTypeRefInfoAt(JNIEnv *env, job
{
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_END
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_END
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_END
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_END
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_END
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 @@ JVM_ENTRY(jstring, JVM_ConstantPoolGetUTF8At(JNIEnv *env, jobject obj, jobject u
{
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_END
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();

View file

@ -487,7 +487,7 @@ Reflection::VerifyClassAccessResults Reflection::verify_class_access(
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 @@ bool Reflection::verify_field_access(const Klass* current_class,
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;

View file

@ -76,9 +76,9 @@ void FilteredFieldsMap::initialize() {
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));
}

View file

@ -28,8 +28,8 @@ import java.util.HashMap;
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.*;

View file

@ -34,8 +34,8 @@ import java.util.Map;
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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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 @@ public class MethodIsIgnoredBySecurityStackWalkTest {
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,

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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 jdk.vm.ci.meta.TrustedInterface;
import org.junit.Test;
import sun.reflect.ConstantPool;
import jdk.internal.reflect.ConstantPool;
/**
* Tests for {@link ResolvedJavaType}.

View file

@ -356,3 +356,4 @@ bdbf2342b21bd8ecad1b4e6499a0dfb314952bd7 jdk-9+103
27a3d65e1580386d060e0aa3a68ab52c1a9ab568 jdk-9+111
36326537f929d20cc5885b93939f90c0efcc4681 jdk-9+112
28626780e245fccbfb9bad8e3b05f62357958038 jdk-9+113
147114dd0641cd7c9fe6e81642eb993a7b9c6f0b jdk-9+114

View file

@ -52,8 +52,8 @@ final class CatalogResolverImpl implements CatalogResolver {
@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 @@ final class CatalogResolverImpl implements CatalogResolver {
}
/**
* 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 @@ final class CatalogResolverImpl implements CatalogResolver {
//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);
}

View file

@ -60,6 +60,9 @@ final class CatalogUriResolverImpl implements CatalogUriResolver {
@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;

View file

@ -82,6 +82,9 @@ class GroupEntry extends BaseEntry {
//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 @@ class GroupEntry extends BaseEntry {
longestRewriteMatch = 0;
suffixMatch = null;
longestSuffixMatch = 0;
systemEntrySearched = false;
}
/**
* Constructs a group entry.
@ -212,6 +216,7 @@ class GroupEntry extends BaseEntry {
* @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 @@ class GroupEntry extends BaseEntry {
//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 @@ class GroupEntry extends BaseEntry {
* @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) {

View file

@ -122,4 +122,25 @@ class Util {
}
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;
}
}
}
}

View file

@ -38,15 +38,71 @@ import org.testng.annotations.DataProvider;
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
@ -232,6 +288,72 @@ public class CatalogTest {
}
}
/*
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.

View file

@ -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>

View file

@ -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>

View file

@ -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>

View file

@ -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>

View file

@ -359,3 +359,4 @@ fafd694e801f0f5a7c737fb08630ced3ca8f772c jdk-9+107
4d5296e0920afe7ef8d4db1939b76f0d407a3812 jdk-9+111
21274e7937bae291658d68143aca0e3ee9296db0 jdk-9+112
e980062475c10d21137051045bf95ee229db9b27 jdk-9+113
b314bb02182b9ca94708a91f312c377f5435f740 jdk-9+114

View file

@ -356,3 +356,4 @@ eee1ced1d8e78293f2a004af818ca474387dbebf jdk-9+103
b2a69d66dc65ad1d3aeb3bd362cf5bb0deba040e jdk-9+111
1565a0efe6f0ca411a6df277df1e069431c60988 jdk-9+112
68f8be44b6a6b33dfa841ec671c0ba6e4056b372 jdk-9+113
bb8379287f3736f38c52b2d1418784e2592461d1 jdk-9+114

View file

@ -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, \
))

View file

@ -224,8 +224,7 @@ SUNWprivate_1.1 {
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 @@ SUNWprivate_1.1 {
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;

View file

@ -78,8 +78,7 @@ text: .text%Java_java_security_AccessController_doPrivileged__Ljava_security_Pri
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

View file

@ -74,8 +74,7 @@ text: .text%Java_java_security_AccessController_doPrivileged__Ljava_security_Pri
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

View file

@ -78,8 +78,7 @@ text: .text%Java_java_io_UnixFileSystem_checkAccess;
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

View file

@ -161,7 +161,9 @@ SUNWprivate_1.1 {
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;

View file

@ -138,7 +138,9 @@ SUNWprivate_1.1 {
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;

View file

@ -138,7 +138,9 @@ SUNWprivate_1.1 {
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;

View file

@ -56,7 +56,7 @@ final class AESCrypt extends SymmetricCipher implements AESConstants
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 @@ final class AESCrypt extends SymmetricCipher implements AESConstants
}
// 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 @@ final class AESCrypt extends SymmetricCipher implements AESConstants
limit = ROUNDS*4;
// store the expanded sub keys into 'sessionK'
sessionK = new Object[] { expandedKe, expandedKd };
sessionK = new int[][] { expandedKe, expandedKd };
}

View file

@ -71,6 +71,17 @@ public final class DHKeyPairGenerator extends KeyPairGeneratorSpi {
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 @@ public final class DHKeyPairGenerator extends KeyPairGeneratorSpi {
* @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 @@ public final class DHKeyPairGenerator extends KeyPairGeneratorSpi {
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 @@ public final class DHKeyPairGenerator extends KeyPairGeneratorSpi {
}
BigInteger x;
BigInteger pMinus2 = p.subtract(BigInteger.valueOf(2));
BigInteger pMinus2 = p.subtract(BigInteger.TWO);
//
// PKCS#3 section 7.1 "Private-value generation"

View file

@ -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 @@ import javax.crypto.spec.DHGenParameterSpec;
* @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 @@ extends AlgorithmParameterGeneratorSpi {
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 @@ extends AlgorithmParameterGeneratorSpi {
* @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 @@ extends AlgorithmParameterGeneratorSpi {
* @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 @@ extends AlgorithmParameterGeneratorSpi {
*
* @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 @@ extends AlgorithmParameterGeneratorSpi {
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;
}
}

View file

@ -49,9 +49,9 @@ import java.util.Set;
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.*;

View file

@ -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;
/**

View file

@ -64,20 +64,4 @@ public class ArrayIndexOutOfBoundsException extends IndexOutOfBoundsException {
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);
}
}

View file

@ -66,10 +66,10 @@ import jdk.internal.loader.BootLoader;
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 @@ public final class Class<T> implements java.io.Serializable,
if (reflectionFactory == null) {
reflectionFactory =
java.security.AccessController.doPrivileged
(new sun.reflect.ReflectionFactory.GetReflectionFactoryAction());
(new ReflectionFactory.GetReflectionFactoryAction());
}
return reflectionFactory;
}

View file

@ -60,8 +60,8 @@ import jdk.internal.loader.ClassLoaders;
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;

View file

@ -29,14 +29,44 @@ import java.lang.annotation.*;
import static java.lang.annotation.ElementType.*;
/**
* A program element annotated &#64;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>Use of the &#64;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>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>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 @@ import static java.lang.annotation.ElementType.*;
@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 &#64;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;
}

View file

@ -67,21 +67,4 @@ public class IndexOutOfBoundsException extends RuntimeException {
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);
}
}

View file

@ -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;
@ -1449,6 +1450,199 @@ public final class Math {
return (a <= b) ? a : b;
}
/**
* 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>&nbsp;&times;&nbsp;<i>b</i>&nbsp;+&nbsp;<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>&nbsp;&times;&nbsp;<i>b</i>&nbsp;+&nbsp;<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

View file

@ -36,8 +36,8 @@ import java.security.PrivilegedAction;
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;
/**

View file

@ -51,6 +51,11 @@ import static java.security.AccessController.doPrivileged;
* @since 9
*/
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.
*/
@ -79,10 +84,12 @@ final class ProcessHandleImpl implements ProcessHandle {
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);

View file

@ -27,8 +27,8 @@ package java.lang;
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

View file

@ -38,7 +38,7 @@ import java.net.InetAddress;
import java.lang.reflect.*;
import java.net.URL;
import sun.reflect.CallerSensitive;
import jdk.internal.reflect.CallerSensitive;
import sun.security.util.SecurityConstants;
/**

View file

@ -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 @@ final class StackStreamFactory {
}
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");
}

View file

@ -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 @@ public final class StackTraceElement implements java.io.Serializable {
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

View file

@ -24,7 +24,7 @@
*/
package java.lang;
import sun.reflect.CallerSensitive;
import jdk.internal.reflect.CallerSensitive;
import java.util.*;
import java.util.function.Consumer;

View file

@ -1134,6 +1134,110 @@ public final class StrictMath {
return Math.min(a, b);
}
/**
* 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>&nbsp;&times;&nbsp;<i>b</i>&nbsp;+&nbsp;<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>&nbsp;&times;&nbsp;<i>b</i>&nbsp;+&nbsp;<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

View file

@ -67,20 +67,4 @@ public class StringIndexOutOfBoundsException extends IndexOutOfBoundsException {
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);
}
}

View file

@ -56,8 +56,8 @@ import java.util.Objects;
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 @@ public final class System {
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) {

View file

@ -37,8 +37,8 @@ import java.util.concurrent.ConcurrentHashMap;
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;

View file

@ -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 @@ public class Throwable implements Serializable {
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 @@ public class Throwable implements Serializable {
*/
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 @@ public class Throwable implements Serializable {
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 @@ public class Throwable implements Serializable {
}
/**
* 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

View file

@ -89,8 +89,7 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
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);
}

View file

@ -655,6 +655,8 @@ class InvokerBytecodeGenerator {
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.

View file

@ -131,11 +131,11 @@ class Invokers {
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 @@ class Invokers {
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);

View file

@ -374,7 +374,7 @@ import java.util.Objects;
}
public static boolean isVarHandleMethodInvokeName(String name) {
try {
VarHandle.AccessMode.valueOf(name);
VarHandle.AccessMode.valueFromMethodName(name);
return true;
} catch (IllegalArgumentException e) {
return false;

View file

@ -219,7 +219,8 @@ import static java.lang.invoke.MethodHandleStatics.*;
* 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 @@ assertEquals("[A, B, C]", (String) caToString2.invokeExact('A', "BC".toCharArray
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 @@ assertEquals("[A, B, C]", (String) caToString2.invokeExact('A', "BC".toCharArray
* 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 @@ assertEquals("[123]", (String) longsToString.invokeExact((long)123));
* <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 @@ assertEquals("[three, thee, tee]", Arrays.toString((Object[])ls.get(0)));
* 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 @@ assertEquals("[three, thee, tee]", asListFix.invoke((Object)argv).toString());
* @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 @@ assertEquals("[three, thee, tee]", asListFix.invoke((Object)argv).toString());
/*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*/

View file

@ -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.Iterator;
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 @@ import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP;
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;
@ -1753,6 +1753,18 @@ import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP;
return counter + 1;
}
/**
* 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}.
*
@ -1879,7 +1891,8 @@ import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP;
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 @@ import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP;
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);

View file

@ -423,7 +423,7 @@ class MethodHandleNatives {
// 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);
}

View file

@ -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.AccessController;
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 @@ public class MethodHandleProxies {
}
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());
}
/**

View file

@ -37,13 +37,12 @@ import java.security.PrivilegedAction;
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 java.util.stream.Stream;
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 @@ assertEquals("", (String) MH_newString.invokeExact());
}
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 @@ import static java.lang.invoke.MethodType.*;
...
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 @@ assert((int)twice.invokeExact(21) == 42);
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 @@ assertEquals("yz", (String) d0.invokeExact(123, "x", "y", "z"));
* 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 @@ assertEquals("xz", (String) d12.invokeExact("x", 12, true, "z"));
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 @@ assertEquals("boojum", (String) catTrace.invokeExact("boo", "jum"));
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 @@ assertEquals("boojum", (String) catTrace.invokeExact("boo", "jum"));
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 @@ assertEquals("boojum", (String) catTrace.invokeExact("boo", "jum"));
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 @@ assertEquals("boojum", (String) catTrace.invokeExact("boo", "jum"));
* @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 @@ assertEquals("boojum", (String) catTrace.invokeExact("boo", "jum"));
* @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 @@ assertEquals("boojum", (String) catTrace.invokeExact("boo", "jum"));
* <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 @@ assertEquals("boojum", (String) catTrace.invokeExact("boo", "jum"));
* @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 @@ assertEquals("boojum", (String) catTrace.invokeExact("boo", "jum"));
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 @@ assertEquals("boojum", (String) catTrace.invokeExact("boo", "jum"));
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 @@ assertEquals("boojum", (String) catTrace.invokeExact("boo", "jum"));
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) {

View file

@ -34,11 +34,11 @@ import jdk.internal.misc.Unsafe;
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 @@ public final class StringConcatFactory {
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;

View file

@ -69,13 +69,10 @@ class VarForm {
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
}
}
}

View file

@ -31,8 +31,12 @@ import jdk.internal.vm.annotation.ForceInline;
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 @@ import static java.lang.invoke.MethodHandleStatics.newInternalError;
* 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 @@ import static java.lang.invoke.MethodHandleStatics.newInternalError;
* 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 @@ import static java.lang.invoke.MethodHandleStatics.newInternalError;
* <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 @@ public abstract class VarHandle {
* , 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 @@ public abstract class VarHandle {
* 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 @@ public abstract class VarHandle {
* 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 @@ public abstract class VarHandle {
* 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 @@ public abstract class VarHandle {
* 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 @@ public abstract class VarHandle {
* 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 @@ public abstract class VarHandle {
* 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 @@ public abstract class VarHandle {
* 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 @@ public abstract class VarHandle {
* 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 @@ public abstract class VarHandle {
* 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 @@ public abstract class VarHandle {
* 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 @@ public abstract class VarHandle {
* 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 @@ public abstract class VarHandle {
* 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 @@ public abstract class VarHandle {
* 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 @@ public abstract class VarHandle {
* 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 @@ public abstract class VarHandle {
* 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 @@ public abstract class VarHandle {
* 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 @@ public abstract class VarHandle {
* 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 @@ public abstract class VarHandle {
* 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 @@ public abstract class VarHandle {
* 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 @@ public abstract class VarHandle {
* 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 @@ public abstract class VarHandle {
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 @@ public abstract class VarHandle {
* 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 @@ public abstract class VarHandle {
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;

View file

@ -27,9 +27,9 @@ package java.lang.reflect;
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 @@ public class AccessibleObject implements AnnotatedElement {
// very early in the bootstrapping process.
static final ReflectionFactory reflectionFactory =
AccessController.doPrivileged(
new sun.reflect.ReflectionFactory.GetReflectionFactoryAction());
new ReflectionFactory.GetReflectionFactoryAction());
/**
* @throws NullPointerException {@inheritDoc}

View file

@ -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;

View file

@ -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;

View file

@ -27,9 +27,9 @@ package java.lang.reflect;
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;

View file

@ -27,8 +27,8 @@ package java.lang.reflect;
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 @@ public class Modifier {
* packages
*/
static {
sun.reflect.ReflectionFactory factory =
AccessController.doPrivileged(
ReflectionFactory factory = AccessController.doPrivileged(
new ReflectionFactory.GetReflectionFactoryAction());
factory.setLangReflectAccess(new java.lang.reflect.ReflectAccess());
}

View file

@ -56,8 +56,8 @@ import jdk.internal.loader.BootLoader;
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;
/**

View file

@ -47,8 +47,8 @@ import jdk.internal.loader.BootLoader;
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 @@ public class Proxy implements java.io.Serializable {
}
/*
* 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 @@ public class Proxy implements java.io.Serializable {
// 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;
}

View file

@ -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,

View file

@ -894,19 +894,17 @@ class InetAddress implements java.io.Serializable {
*/
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 @@ class InetAddress implements java.io.Serializable {
return host;
}
/**
* <p>Lookup a host mapping by name. Retrieve the IP addresses
* associated with a host.
@ -1004,7 +1001,6 @@ class InetAddress implements java.io.Serializable {
* @throws UnknownHostException
* if no IP address for the {@code host} could be found
*/
public InetAddress[] lookupAllHostAddr(String host)
throws UnknownHostException {
String hostEntry;

View file

@ -465,23 +465,21 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
}
/**
* 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;

Some files were not shown because too many files have changed in this diff Show more