--- a/.hgtags Wed Nov 09 15:20:30 2016 +0300
+++ b/.hgtags Wed Nov 09 10:04:43 2016 -0800
@@ -384,3 +384,5 @@
65477538bec32963dc41153d89c4417eb46c45fc jdk-9+139
0875007901f7d364a08220b052f0c81003e9c8c5 jdk-9+140
9aadd2163b568d76f8969ad2fb404a63733da359 jdk-9+141
+df0e03e3ca0ed1307793017dfc1a054c8726131c jdk-9+142
+d62173b931bf5b6bffc6e80a9060bb2e8b8efc75 jdk-9+143
--- a/.hgtags-top-repo Wed Nov 09 15:20:30 2016 +0300
+++ b/.hgtags-top-repo Wed Nov 09 10:04:43 2016 -0800
@@ -384,3 +384,5 @@
7dcf453eacae79ee86a6bcc75fd0b546fc99b48a jdk-9+139
a5815c6098a241d3a1df64d22b84b3524e4a77df jdk-9+140
f64afae7f1a5608e438585bbf0bc23785e69cba0 jdk-9+141
+2b3e5caafe3594ea507c37675c4d3086f415dc64 jdk-9+142
+1fc62b1c629fb80fdaa639d3b59452a184f0d705 jdk-9+143
--- a/common/autoconf/flags.m4 Wed Nov 09 15:20:30 2016 +0300
+++ b/common/autoconf/flags.m4 Wed Nov 09 10:04:43 2016 -0800
@@ -280,7 +280,7 @@
else
# Default works for linux, might work on other platforms as well.
SHARED_LIBRARY_FLAGS='-shared'
- SET_EXECUTABLE_ORIGIN='-Wl,-rpath,\$$$$ORIGIN[$]1'
+ SET_EXECUTABLE_ORIGIN='-Wl,-rpath,\$$ORIGIN[$]1'
SET_SHARED_LIBRARY_ORIGIN="-Wl,-z,origin $SET_EXECUTABLE_ORIGIN"
SET_SHARED_LIBRARY_NAME='-Wl,-soname=[$]1'
SET_SHARED_LIBRARY_MAPFILE='-Wl,-version-script=[$]1'
@@ -305,7 +305,7 @@
# Default works for linux, might work on other platforms as well.
PICFLAG='-fPIC'
SHARED_LIBRARY_FLAGS='-shared'
- SET_EXECUTABLE_ORIGIN='-Wl,-rpath,\$$$$ORIGIN[$]1'
+ SET_EXECUTABLE_ORIGIN='-Wl,-rpath,\$$ORIGIN[$]1'
SET_SHARED_LIBRARY_ORIGIN="-Wl,-z,origin $SET_EXECUTABLE_ORIGIN"
SET_SHARED_LIBRARY_NAME='-Wl,-soname=[$]1'
SET_SHARED_LIBRARY_MAPFILE='-Wl,-version-script=[$]1'
@@ -315,7 +315,7 @@
C_FLAG_REORDER='-xF'
CXX_FLAG_REORDER='-xF'
SHARED_LIBRARY_FLAGS="-G"
- SET_EXECUTABLE_ORIGIN='-R\$$$$ORIGIN[$]1'
+ SET_EXECUTABLE_ORIGIN='-R\$$ORIGIN[$]1'
SET_SHARED_LIBRARY_ORIGIN="$SET_EXECUTABLE_ORIGIN"
SET_SHARED_LIBRARY_NAME='-h [$]1'
SET_SHARED_LIBRARY_MAPFILE='-M[$]1'
@@ -759,6 +759,10 @@
# on ppc we don't prevent gcc to omit frame pointer but do prevent strict aliasing
$2CFLAGS_JDK="${$2CFLAGS_JDK} -fno-strict-aliasing"
;;
+ s390 )
+ $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK -fno-omit-frame-pointer -mbackchain -march=z10"
+ $2CFLAGS_JDK="${$2CFLAGS_JDK} -fno-strict-aliasing"
+ ;;
* )
$2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK -fno-omit-frame-pointer"
$2CFLAGS_JDK="${$2CFLAGS_JDK} -fno-strict-aliasing"
@@ -940,6 +944,10 @@
# Use Power8, this is the first CPU to support PPC64 LE with ELFv2 ABI.
$2JVM_CFLAGS="[$]$2JVM_CFLAGS -mcpu=power7 -mtune=power8"
fi
+ elif test "x$OPENJDK_$1_CPU" = xs390x; then
+ if test "x$OPENJDK_$1_OS" = xlinux; then
+ $2JVM_CFLAGS="[$]$2JVM_CFLAGS -mbackchain -march=z10"
+ fi
fi
if test "x$OPENJDK_$1_CPU_ENDIAN" = xlittle; then
@@ -999,6 +1007,7 @@
# Setup some hard coded includes
$2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK \
+ -I\$(SUPPORT_OUTPUTDIR)/modules_include/java.base \
-I${JDK_TOPDIR}/src/java.base/share/native/include \
-I${JDK_TOPDIR}/src/java.base/$OPENJDK_$1_OS/native/include \
-I${JDK_TOPDIR}/src/java.base/$OPENJDK_$1_OS_TYPE/native/include \
--- a/common/autoconf/generated-configure.sh Wed Nov 09 15:20:30 2016 +0300
+++ b/common/autoconf/generated-configure.sh Wed Nov 09 10:04:43 2016 -0800
@@ -5093,7 +5093,7 @@
#CUSTOM_AUTOCONF_INCLUDE
# Do not change or remove the following line, it is needed for consistency checks:
-DATE_WHEN_GENERATED=1477108079
+DATE_WHEN_GENERATED=1478524503
###############################################################################
#
@@ -49070,7 +49070,7 @@
else
# Default works for linux, might work on other platforms as well.
SHARED_LIBRARY_FLAGS='-shared'
- SET_EXECUTABLE_ORIGIN='-Wl,-rpath,\$$$$ORIGIN$1'
+ SET_EXECUTABLE_ORIGIN='-Wl,-rpath,\$$ORIGIN$1'
SET_SHARED_LIBRARY_ORIGIN="-Wl,-z,origin $SET_EXECUTABLE_ORIGIN"
SET_SHARED_LIBRARY_NAME='-Wl,-soname=$1'
SET_SHARED_LIBRARY_MAPFILE='-Wl,-version-script=$1'
@@ -49095,7 +49095,7 @@
# Default works for linux, might work on other platforms as well.
PICFLAG='-fPIC'
SHARED_LIBRARY_FLAGS='-shared'
- SET_EXECUTABLE_ORIGIN='-Wl,-rpath,\$$$$ORIGIN$1'
+ SET_EXECUTABLE_ORIGIN='-Wl,-rpath,\$$ORIGIN$1'
SET_SHARED_LIBRARY_ORIGIN="-Wl,-z,origin $SET_EXECUTABLE_ORIGIN"
SET_SHARED_LIBRARY_NAME='-Wl,-soname=$1'
SET_SHARED_LIBRARY_MAPFILE='-Wl,-version-script=$1'
@@ -49105,7 +49105,7 @@
C_FLAG_REORDER='-xF'
CXX_FLAG_REORDER='-xF'
SHARED_LIBRARY_FLAGS="-G"
- SET_EXECUTABLE_ORIGIN='-R\$$$$ORIGIN$1'
+ SET_EXECUTABLE_ORIGIN='-R\$$ORIGIN$1'
SET_SHARED_LIBRARY_ORIGIN="$SET_EXECUTABLE_ORIGIN"
SET_SHARED_LIBRARY_NAME='-h $1'
SET_SHARED_LIBRARY_MAPFILE='-M$1'
@@ -49840,6 +49840,10 @@
# on ppc we don't prevent gcc to omit frame pointer but do prevent strict aliasing
CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing"
;;
+ s390 )
+ COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -fno-omit-frame-pointer -mbackchain -march=z10"
+ CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing"
+ ;;
* )
COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -fno-omit-frame-pointer"
CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing"
@@ -50122,6 +50126,10 @@
# Use Power8, this is the first CPU to support PPC64 LE with ELFv2 ABI.
JVM_CFLAGS="$JVM_CFLAGS -mcpu=power7 -mtune=power8"
fi
+ elif test "x$OPENJDK_TARGET_CPU" = xs390x; then
+ if test "x$OPENJDK_TARGET_OS" = xlinux; then
+ JVM_CFLAGS="$JVM_CFLAGS -mbackchain -march=z10"
+ fi
fi
if test "x$OPENJDK_TARGET_CPU_ENDIAN" = xlittle; then
@@ -50270,6 +50278,7 @@
# Setup some hard coded includes
COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK \
+ -I\$(SUPPORT_OUTPUTDIR)/modules_include/java.base \
-I${JDK_TOPDIR}/src/java.base/share/native/include \
-I${JDK_TOPDIR}/src/java.base/$OPENJDK_TARGET_OS/native/include \
-I${JDK_TOPDIR}/src/java.base/$OPENJDK_TARGET_OS_TYPE/native/include \
@@ -50655,6 +50664,10 @@
# on ppc we don't prevent gcc to omit frame pointer but do prevent strict aliasing
OPENJDK_BUILD_CFLAGS_JDK="${OPENJDK_BUILD_CFLAGS_JDK} -fno-strict-aliasing"
;;
+ s390 )
+ OPENJDK_BUILD_COMMON_CCXXFLAGS_JDK="$OPENJDK_BUILD_COMMON_CCXXFLAGS_JDK -fno-omit-frame-pointer -mbackchain -march=z10"
+ OPENJDK_BUILD_CFLAGS_JDK="${OPENJDK_BUILD_CFLAGS_JDK} -fno-strict-aliasing"
+ ;;
* )
OPENJDK_BUILD_COMMON_CCXXFLAGS_JDK="$OPENJDK_BUILD_COMMON_CCXXFLAGS_JDK -fno-omit-frame-pointer"
OPENJDK_BUILD_CFLAGS_JDK="${OPENJDK_BUILD_CFLAGS_JDK} -fno-strict-aliasing"
@@ -50937,6 +50950,10 @@
# Use Power8, this is the first CPU to support PPC64 LE with ELFv2 ABI.
OPENJDK_BUILD_JVM_CFLAGS="$OPENJDK_BUILD_JVM_CFLAGS -mcpu=power7 -mtune=power8"
fi
+ elif test "x$OPENJDK_BUILD_CPU" = xs390x; then
+ if test "x$OPENJDK_BUILD_OS" = xlinux; then
+ OPENJDK_BUILD_JVM_CFLAGS="$OPENJDK_BUILD_JVM_CFLAGS -mbackchain -march=z10"
+ fi
fi
if test "x$OPENJDK_BUILD_CPU_ENDIAN" = xlittle; then
@@ -51085,6 +51102,7 @@
# Setup some hard coded includes
OPENJDK_BUILD_COMMON_CCXXFLAGS_JDK="$OPENJDK_BUILD_COMMON_CCXXFLAGS_JDK \
+ -I\$(SUPPORT_OUTPUTDIR)/modules_include/java.base \
-I${JDK_TOPDIR}/src/java.base/share/native/include \
-I${JDK_TOPDIR}/src/java.base/$OPENJDK_BUILD_OS/native/include \
-I${JDK_TOPDIR}/src/java.base/$OPENJDK_BUILD_OS_TYPE/native/include \
--- a/common/autoconf/spec.gmk.in Wed Nov 09 15:20:30 2016 +0300
+++ b/common/autoconf/spec.gmk.in Wed Nov 09 10:04:43 2016 -0800
@@ -265,6 +265,10 @@
BUNDLES_OUTPUTDIR=$(BUILD_OUTPUT)/bundles
TESTMAKE_OUTPUTDIR=$(BUILD_OUTPUT)/test-make
MAKESUPPORT_OUTPUTDIR=$(BUILD_OUTPUT)/make-support
+
+# By default, output javadoc directly into image
+JAVADOC_OUTPUTDIR = $(DOCS_IMAGE_DIR)
+
# This does not get overridden in a bootcycle build
CONFIGURESUPPORT_OUTPUTDIR:=@CONFIGURESUPPORT_OUTPUTDIR@
BUILDJDK_OUTPUTDIR=$(BUILD_OUTPUT)/buildjdk
@@ -784,11 +788,12 @@
SYMBOLS_IMAGE_DIR=$(IMAGES_OUTPUTDIR)/$(SYMBOLS_IMAGE_SUBDIR)
# Interim image
+INTERIM_JMODS_DIR := $(SUPPORT_OUTPUTDIR)/interim-jmods
INTERIM_IMAGE_DIR := $(SUPPORT_OUTPUTDIR)/interim-image
# Docs image
DOCS_IMAGE_SUBDIR := docs
-DOCS_IMAGE_DIR := $(IMAGES_OUTPUTDIR)/$(DOCS_IMAGE_SUBDIR)
+DOCS_IMAGE_DIR = $(IMAGES_OUTPUTDIR)/$(DOCS_IMAGE_SUBDIR)
# Macosx bundles directory definitions
JDK_MACOSX_BUNDLE_SUBDIR=jdk-bundle
--- a/corba/.hgtags Wed Nov 09 15:20:30 2016 +0300
+++ b/corba/.hgtags Wed Nov 09 10:04:43 2016 -0800
@@ -384,3 +384,5 @@
8c9da7fc5b07c606afd571c7012441b77dda83b2 jdk-9+139
9f3fc931bc230f44f2a58d75f7f6360af98bb113 jdk-9+140
b32f998da32b488ec7c4e9dbb3c750841b48e74d jdk-9+141
+408c9c621938ca028e20bced0459f815de47eba8 jdk-9+142
+6211236ef15ec796806357608b1dd1b70c258ece jdk-9+143
--- a/hotspot/.hgtags Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/.hgtags Wed Nov 09 10:04:43 2016 -0800
@@ -544,3 +544,5 @@
08492e67bf3226784dab3bf9ae967382ddbc1af5 jdk-9+139
fec31089c2ef5a12dd64f401b0bf2e00f56ee0d0 jdk-9+140
160a00bc6ed0af1fdf8418fc65e6bddbbc0c536d jdk-9+141
+7b48d63dfd6b8e2657288de3d7b1f153dee02d7e jdk-9+142
+d87d5d430c42342f0320ca7f5cbe0cbd1f9d62ba jdk-9+143
--- a/hotspot/make/gensrc/GensrcJvmti.gmk Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/make/gensrc/GensrcJvmti.gmk Wed Nov 09 10:04:43 2016 -0800
@@ -135,14 +135,14 @@
# Copy jvmti.h to include dir
# The file is the same regardless of jvm variant. Only let one do the copy.
-#ifeq ($(JVM_VARIANT), $(firstword $(JVM_VARIANTS)))
-# $(eval $(call SetupCopyFiles, COPY_JVMTI_H, \
-# DEST := $(SUPPORT_OUTPUTDIR)/modules_include/java.base, \
-# FILES := $(JVMTI_OUTPUTDIR)/jvmti.h, \
-# ))
+ifeq ($(JVM_VARIANT), $(firstword $(JVM_VARIANTS)))
+ $(eval $(call SetupCopyFiles, COPY_JVMTI_H, \
+ DEST := $(SUPPORT_OUTPUTDIR)/modules_include/java.base, \
+ FILES := $(JVMTI_OUTPUTDIR)/jvmti.h, \
+ ))
-# TARGETS += $(COPY_JVMTI_H)
-#endif
+ TARGETS += $(COPY_JVMTI_H)
+endif
################################################################################
# Create trace files in gensrc/tracefiles
--- a/hotspot/make/lib/CompileJvm.gmk Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/make/lib/CompileJvm.gmk Wed Nov 09 10:04:43 2016 -0800
@@ -176,6 +176,11 @@
JVM_OPTIMIZATION ?= HIGHEST_JVM
+# Need to set JVM_STRIPFLAGS to the default value from SPEC since the STRIPFLAGS
+# parameter to SetupNativeCompilation allows an empty value to override the
+# default.
+JVM_STRIPFLAGS ?= $(STRIPFLAGS)
+
################################################################################
# Now set up the actual compilation of the main hotspot native library
@@ -204,6 +209,7 @@
OBJECT_DIR := $(JVM_OUTPUTDIR)/objs, \
MAPFILE := $(JVM_MAPFILE), \
USE_MAPFILE_FOR_SYMBOLS := true, \
+ STRIPFLAGS := $(JVM_STRIPFLAGS), \
EMBED_MANIFEST := true, \
RC_FLAGS := $(JVM_RCFLAGS), \
VERSIONINFO_RESOURCE := $(HOTSPOT_TOPDIR)/src/os/windows/vm/version.rc, \
--- a/hotspot/make/lib/JvmFeatures.gmk Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/make/lib/JvmFeatures.gmk Wed Nov 09 10:04:43 2016 -0800
@@ -59,6 +59,10 @@
ifeq ($(call check-jvm-feature, minimal), true)
JVM_CFLAGS_FEATURES += -DMINIMAL_JVM -DVMTYPE=\"Minimal\"
+ ifeq ($(OPENJDK_TARGET_OS), linux)
+ # Override the default -g with a more liberal strip policy for the minimal JVM
+ JVM_STRIPFLAGS := --strip-unneeded
+ endif
endif
ifeq ($(call check-jvm-feature, dtrace), true)
--- a/hotspot/make/symbols/symbols-unix Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/make/symbols/symbols-unix Wed Nov 09 10:04:43 2016 -0800
@@ -125,7 +125,6 @@
JVM_GetProtectionDomain
JVM_GetSimpleBinaryName
JVM_GetStackAccessControlContext
-JVM_GetStackTraceElements
JVM_GetSystemPackage
JVM_GetSystemPackages
JVM_GetTemporaryDirectory
@@ -135,6 +134,8 @@
JVM_HoldsLock
JVM_IHashCode
JVM_InitProperties
+JVM_InitStackTraceElement
+JVM_InitStackTraceElementArray
JVM_InternString
JVM_Interrupt
JVM_InvokeMethod
@@ -178,7 +179,6 @@
JVM_StopThread
JVM_SupportsCX8
JVM_SuspendThread
-JVM_ToStackTraceElement
JVM_TotalMemory
JVM_UnloadLibrary
JVM_WaitForReferencePendingList
--- a/hotspot/make/test/JtregNative.gmk Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/make/test/JtregNative.gmk Wed Nov 09 10:04:43 2016 -0800
@@ -45,6 +45,7 @@
$(HOTSPOT_TOPDIR)/test/runtime/jni/8025979 \
$(HOTSPOT_TOPDIR)/test/runtime/jni/8033445 \
$(HOTSPOT_TOPDIR)/test/runtime/jni/checked \
+ $(HOTSPOT_TOPDIR)/test/runtime/jni/PrivateInterfaceMethods \
$(HOTSPOT_TOPDIR)/test/runtime/jni/ToStringInInterfaceTest \
$(HOTSPOT_TOPDIR)/test/runtime/modules/getModuleJNI \
$(HOTSPOT_TOPDIR)/test/runtime/SameObject \
--- a/hotspot/src/cpu/aarch64/vm/aarch64.ad Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/cpu/aarch64/vm/aarch64.ad Wed Nov 09 10:04:43 2016 -0800
@@ -3496,6 +3496,16 @@
return false;
}
+bool Matcher::const_oop_prefer_decode() {
+ // Prefer ConN+DecodeN over ConP in simple compressed oops mode.
+ return Universe::narrow_oop_base() == NULL;
+}
+
+bool Matcher::const_klass_prefer_decode() {
+ // Prefer ConNKlass+DecodeNKlass over ConP in simple compressed klass mode.
+ return Universe::narrow_klass_base() == NULL;
+}
+
// Is it better to copy float constants, or load them directly from
// memory? Intel can load a float constant from a direct address,
// requiring no extra registers. Most RISCs will have to materialize
@@ -15502,6 +15512,24 @@
ins_pipe(pipe_class_memory);
%}
+instruct string_indexofU_char(iRegP_R1 str1, iRegI_R2 cnt1, iRegI_R3 ch,
+ iRegI_R0 result, iRegI tmp1, iRegI tmp2,
+ iRegI tmp3, rFlagsReg cr)
+%{
+ match(Set result (StrIndexOfChar (Binary str1 cnt1) ch));
+ effect(USE_KILL str1, USE_KILL cnt1, USE_KILL ch,
+ TEMP tmp1, TEMP tmp2, TEMP tmp3, KILL cr);
+
+ format %{ "String IndexOf char[] $str1,$cnt1,$ch -> $result" %}
+
+ ins_encode %{
+ __ string_indexof_char($str1$$Register, $cnt1$$Register, $ch$$Register,
+ $result$$Register, $tmp1$$Register, $tmp2$$Register,
+ $tmp3$$Register);
+ %}
+ ins_pipe(pipe_class_memory);
+%}
+
instruct string_equalsL(iRegP_R1 str1, iRegP_R3 str2, iRegI_R4 cnt,
iRegI_R0 result, rFlagsReg cr)
%{
--- a/hotspot/src/cpu/aarch64/vm/interpreterRT_aarch64.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/cpu/aarch64/vm/interpreterRT_aarch64.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, Red Hat Inc. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@@ -130,8 +130,8 @@
if (_num_fp_args < Argument::n_float_register_parameters_c) {
__ ldrs(as_FloatRegister(_num_fp_args++), src);
} else {
- __ ldrh(r0, src);
- __ strh(r0, Address(to(), _stack_offset));
+ __ ldrw(r0, src);
+ __ strw(r0, Address(to(), _stack_offset));
_stack_offset += wordSize;
_num_fp_args++;
}
@@ -349,7 +349,7 @@
_num_fp_args++;
} else {
*_to++ = from_obj;
- _num_int_args++;
+ _num_fp_args++;
}
}
@@ -364,7 +364,7 @@
_num_fp_args++;
} else {
*_to++ = from_obj;
- _num_int_args++;
+ _num_fp_args++;
}
}
--- a/hotspot/src/cpu/aarch64/vm/jvmciCodeInstaller_aarch64.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/cpu/aarch64/vm/jvmciCodeInstaller_aarch64.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -60,12 +60,12 @@
void CodeInstaller::pd_patch_MetaspaceConstant(int pc_offset, Handle constant, TRAPS) {
address pc = _instructions->start() + pc_offset;
if (HotSpotMetaspaceConstantImpl::compressed(constant)) {
- narrowKlass narrowOop = record_narrow_metadata_reference(constant, CHECK);
+ narrowKlass narrowOop = record_narrow_metadata_reference(_instructions, pc, constant, CHECK);
TRACE_jvmci_3("relocating (narrow metaspace constant) at " PTR_FORMAT "/0x%x", p2i(pc), narrowOop);
Unimplemented();
} else {
NativeMovConstReg* move = nativeMovConstReg_at(pc);
- void* reference = record_metadata_reference(constant, CHECK);
+ void* reference = record_metadata_reference(_instructions, pc, constant, CHECK);
move->set_data((intptr_t) reference);
TRACE_jvmci_3("relocating (metaspace constant) at " PTR_FORMAT "/" PTR_FORMAT, p2i(pc), p2i(reference));
}
--- a/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -4508,6 +4508,67 @@
typedef void (MacroAssembler::* chr_insn)(Register Rt, const Address &adr);
typedef void (MacroAssembler::* uxt_insn)(Register Rd, Register Rn);
+void MacroAssembler::string_indexof_char(Register str1, Register cnt1,
+ Register ch, Register result,
+ Register tmp1, Register tmp2, Register tmp3)
+{
+ Label CH1_LOOP, HAS_ZERO, DO1_SHORT, DO1_LOOP, MATCH, NOMATCH, DONE;
+ Register cnt1_neg = cnt1;
+ Register ch1 = rscratch1;
+ Register result_tmp = rscratch2;
+
+ cmp(cnt1, 4);
+ br(LT, DO1_SHORT);
+
+ orr(ch, ch, ch, LSL, 16);
+ orr(ch, ch, ch, LSL, 32);
+
+ sub(cnt1, cnt1, 4);
+ mov(result_tmp, cnt1);
+ lea(str1, Address(str1, cnt1, Address::uxtw(1)));
+ sub(cnt1_neg, zr, cnt1, LSL, 1);
+
+ mov(tmp3, 0x0001000100010001);
+
+ BIND(CH1_LOOP);
+ ldr(ch1, Address(str1, cnt1_neg));
+ eor(ch1, ch, ch1);
+ sub(tmp1, ch1, tmp3);
+ orr(tmp2, ch1, 0x7fff7fff7fff7fff);
+ bics(tmp1, tmp1, tmp2);
+ br(NE, HAS_ZERO);
+ adds(cnt1_neg, cnt1_neg, 8);
+ br(LT, CH1_LOOP);
+
+ cmp(cnt1_neg, 8);
+ mov(cnt1_neg, 0);
+ br(LT, CH1_LOOP);
+ b(NOMATCH);
+
+ BIND(HAS_ZERO);
+ rev(tmp1, tmp1);
+ clz(tmp1, tmp1);
+ add(cnt1_neg, cnt1_neg, tmp1, LSR, 3);
+ b(MATCH);
+
+ BIND(DO1_SHORT);
+ mov(result_tmp, cnt1);
+ lea(str1, Address(str1, cnt1, Address::uxtw(1)));
+ sub(cnt1_neg, zr, cnt1, LSL, 1);
+ BIND(DO1_LOOP);
+ ldrh(ch1, Address(str1, cnt1_neg));
+ cmpw(ch, ch1);
+ br(EQ, MATCH);
+ adds(cnt1_neg, cnt1_neg, 2);
+ br(LT, DO1_LOOP);
+ BIND(NOMATCH);
+ mov(result, -1);
+ b(DONE);
+ BIND(MATCH);
+ add(result, result_tmp, cnt1_neg, ASR, 1);
+ BIND(DONE);
+}
+
// Compare strings.
void MacroAssembler::string_compare(Register str1, Register str2,
Register cnt1, Register cnt2, Register result,
--- a/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.hpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.hpp Wed Nov 09 10:04:43 2016 -0800
@@ -1229,6 +1229,9 @@
Register tmp1, Register tmp2,
Register tmp3, Register tmp4,
int int_cnt1, Register result, int ae);
+ void string_indexof_char(Register str1, Register cnt1,
+ Register ch, Register result,
+ Register tmp1, Register tmp2, Register tmp3);
private:
void add2_with_carry(Register final_dest_hi, Register dest_hi, Register dest_lo,
Register src1, Register src2);
--- a/hotspot/src/cpu/aarch64/vm/sharedRuntime_aarch64.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/cpu/aarch64/vm/sharedRuntime_aarch64.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -989,7 +989,16 @@
// A float arg may have to do float reg int reg conversion
static void float_move(MacroAssembler* masm, VMRegPair src, VMRegPair dst) {
- if (src.first() != dst.first()) {
+ assert(src.first()->is_stack() && dst.first()->is_stack() ||
+ src.first()->is_reg() && dst.first()->is_reg(), "Unexpected error");
+ if (src.first()->is_stack()) {
+ if (dst.first()->is_stack()) {
+ __ ldrw(rscratch1, Address(rfp, reg2offset_in(src.first())));
+ __ strw(rscratch1, Address(sp, reg2offset_out(dst.first())));
+ } else {
+ ShouldNotReachHere();
+ }
+ } else if (src.first() != dst.first()) {
if (src.is_single_phys_reg() && dst.is_single_phys_reg())
__ fmovs(dst.first()->as_FloatRegister(), src.first()->as_FloatRegister());
else
@@ -1023,7 +1032,16 @@
// A double move
static void double_move(MacroAssembler* masm, VMRegPair src, VMRegPair dst) {
- if (src.first() != dst.first()) {
+ assert(src.first()->is_stack() && dst.first()->is_stack() ||
+ src.first()->is_reg() && dst.first()->is_reg(), "Unexpected error");
+ if (src.first()->is_stack()) {
+ if (dst.first()->is_stack()) {
+ __ ldr(rscratch1, Address(rfp, reg2offset_in(src.first())));
+ __ str(rscratch1, Address(sp, reg2offset_out(dst.first())));
+ } else {
+ ShouldNotReachHere();
+ }
+ } else if (src.first() != dst.first()) {
if (src.is_single_phys_reg() && dst.is_single_phys_reg())
__ fmovd(dst.first()->as_FloatRegister(), src.first()->as_FloatRegister());
else
--- a/hotspot/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -2743,7 +2743,7 @@
__ align(CodeEntryAlignment);
StubCodeMark mark(this, "StubRoutines", "cipherBlockChaining_encryptAESCrypt");
- Label L_loadkeys_44, L_loadkeys_52, L_aes_loop, L_rounds_44, L_rounds_52;
+ Label L_loadkeys_44, L_loadkeys_52, L_aes_loop, L_rounds_44, L_rounds_52, _L_finish;
const Register from = c_rarg0; // source array address
const Register to = c_rarg1; // destination array address
@@ -2754,9 +2754,12 @@
const Register keylen = rscratch1;
address start = __ pc();
+
__ enter();
- __ mov(rscratch2, len_reg);
+ __ subsw(rscratch2, len_reg, zr);
+ __ br(Assembler::LE, _L_finish);
+
__ ldrw(keylen, Address(key, arrayOopDesc::length_offset_in_bytes() - arrayOopDesc::base_offset_in_bytes(T_INT)));
__ ld1(v0, __ T16B, rvec);
@@ -2814,11 +2817,13 @@
__ eor(v0, __ T16B, v0, v31);
__ st1(v0, __ T16B, __ post(to, 16));
- __ sub(len_reg, len_reg, 16);
- __ cbnz(len_reg, L_aes_loop);
+
+ __ subw(len_reg, len_reg, 16);
+ __ cbnzw(len_reg, L_aes_loop);
__ st1(v0, __ T16B, rvec);
+ __ BIND(_L_finish);
__ mov(r0, rscratch2);
__ leave();
@@ -2844,7 +2849,7 @@
__ align(CodeEntryAlignment);
StubCodeMark mark(this, "StubRoutines", "cipherBlockChaining_decryptAESCrypt");
- Label L_loadkeys_44, L_loadkeys_52, L_aes_loop, L_rounds_44, L_rounds_52;
+ Label L_loadkeys_44, L_loadkeys_52, L_aes_loop, L_rounds_44, L_rounds_52, _L_finish;
const Register from = c_rarg0; // source array address
const Register to = c_rarg1; // destination array address
@@ -2855,9 +2860,12 @@
const Register keylen = rscratch1;
address start = __ pc();
+
__ enter();
- __ mov(rscratch2, len_reg);
+ __ subsw(rscratch2, len_reg, zr);
+ __ br(Assembler::LE, _L_finish);
+
__ ldrw(keylen, Address(key, arrayOopDesc::length_offset_in_bytes() - arrayOopDesc::base_offset_in_bytes(T_INT)));
__ ld1(v2, __ T16B, rvec);
@@ -2920,11 +2928,12 @@
__ st1(v0, __ T16B, __ post(to, 16));
__ orr(v2, __ T16B, v1, v1);
- __ sub(len_reg, len_reg, 16);
- __ cbnz(len_reg, L_aes_loop);
+ __ subw(len_reg, len_reg, 16);
+ __ cbnzw(len_reg, L_aes_loop);
__ st1(v2, __ T16B, rvec);
+ __ BIND(_L_finish);
__ mov(r0, rscratch2);
__ leave();
--- a/hotspot/src/cpu/aarch64/vm/templateInterpreterGenerator_aarch64.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/cpu/aarch64/vm/templateInterpreterGenerator_aarch64.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -454,8 +454,9 @@
__ str(zr, Address(rfp, frame::interpreter_frame_last_sp_offset * wordSize));
#if INCLUDE_JVMCI
- // Check if we need to take lock at entry of synchronized method.
- if (UseJVMCICompiler) {
+ // Check if we need to take lock at entry of synchronized method. This can
+ // only occur on method entry so emit it only for vtos with step 0.
+ if (UseJVMCICompiler && state == vtos && step == 0) {
Label L;
__ ldr(rscratch1, Address(rthread, Thread::pending_exception_offset()));
__ cbz(rscratch1, L);
@@ -464,8 +465,17 @@
// Take lock.
lock_method();
__ bind(L);
+ } else {
+#ifdef ASSERT
+ if (UseJVMCICompiler) {
+ Label L;
+ __ ldr(rscratch1, Address(rthread, Thread::pending_exception_offset()));
+ __ cbz(rscratch1, L);
+ __ stop("unexpected pending monitor in deopt entry");
+ __ bind(L);
+ }
+#endif
}
-#endif
// handle exceptions
{
Label L;
--- a/hotspot/src/cpu/aarch64/vm/templateTable_aarch64.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/cpu/aarch64/vm/templateTable_aarch64.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -3717,19 +3717,15 @@
// allocate one if there's no free slot
{
- Label entry, loop, no_adjust;
+ Label entry, loop;
// 1. compute new pointers // rsp: old expression stack top
__ ldr(c_rarg1, monitor_block_bot); // c_rarg1: old expression stack bottom
- __ sub(esp, esp, entry_size); // move expression stack top
+ __ sub(esp, esp, entry_size); // move expression stack top
__ sub(c_rarg1, c_rarg1, entry_size); // move expression stack bottom
__ mov(c_rarg3, esp); // set start value for copy loop
__ str(c_rarg1, monitor_block_bot); // set new monitor block bottom
- __ cmp(sp, c_rarg3); // Check if we need to move sp
- __ br(Assembler::LO, no_adjust); // to allow more stack space
- // for our new esp
- __ sub(sp, sp, 2 * wordSize);
- __ bind(no_adjust);
+ __ sub(sp, sp, entry_size); // make room for the monitor
__ b(entry);
// 2. move expression stack contents
--- a/hotspot/src/cpu/ppc/vm/c1_MacroAssembler_ppc.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/cpu/ppc/vm/c1_MacroAssembler_ppc.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -64,17 +64,16 @@
void C1_MacroAssembler::build_frame(int frame_size_in_bytes, int bang_size_in_bytes) {
+ // Avoid stack bang as first instruction. It may get overwritten by patch_verified_entry.
+ const Register return_pc = R20;
+ mflr(return_pc);
+
+ // Make sure there is enough stack space for this method's activation.
assert(bang_size_in_bytes >= frame_size_in_bytes, "stack bang size incorrect");
- // Make sure there is enough stack space for this method's activation.
generate_stack_overflow_check(bang_size_in_bytes);
- // Create the frame.
- const Register return_pc = R0;
-
- mflr(return_pc);
- // Get callers sp.
- std(return_pc, _abi(lr), R1_SP); // SP->lr = return_pc
- push_frame(frame_size_in_bytes, R0); // SP -= frame_size_in_bytes
+ std(return_pc, _abi(lr), R1_SP); // SP->lr = return_pc
+ push_frame(frame_size_in_bytes, R0); // SP -= frame_size_in_bytes
}
--- a/hotspot/src/cpu/ppc/vm/ppc.ad Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/cpu/ppc/vm/ppc.ad Wed Nov 09 10:04:43 2016 -0800
@@ -1097,21 +1097,19 @@
// No entry point given, use the current pc.
if (entry_point == NULL) entry_point = __ pc();
- if (!Compile::current()->in_scratch_emit_size()) {
- // Put the entry point as a constant into the constant pool.
- const address entry_point_toc_addr = __ address_constant(entry_point, RelocationHolder::none);
- if (entry_point_toc_addr == NULL) {
- ciEnv::current()->record_out_of_memory_failure();
- return offsets;
- }
- const int entry_point_toc_offset = __ offset_to_method_toc(entry_point_toc_addr);
-
- // Emit the trampoline stub which will be related to the branch-and-link below.
- CallStubImpl::emit_trampoline_stub(_masm, entry_point_toc_offset, offsets.insts_call_instruction_offset);
- if (ciEnv::current()->failing()) { return offsets; } // Code cache may be full.
- __ relocate(rtype);
+ // Put the entry point as a constant into the constant pool.
+ const address entry_point_toc_addr = __ address_constant(entry_point, RelocationHolder::none);
+ if (entry_point_toc_addr == NULL) {
+ ciEnv::current()->record_out_of_memory_failure();
+ return offsets;
}
-
+ const int entry_point_toc_offset = __ offset_to_method_toc(entry_point_toc_addr);
+
+ // Emit the trampoline stub which will be related to the branch-and-link below.
+ CallStubImpl::emit_trampoline_stub(_masm, entry_point_toc_offset, offsets.insts_call_instruction_offset);
+ if (ciEnv::current()->failing()) { return offsets; } // Code cache may be full.
+ __ relocate(rtype);
+
// Note: At this point we do not have the address of the trampoline
// stub, and the entry point might be too far away for bl, so __ pc()
// serves as dummy and the bl will be patched later.
@@ -2166,6 +2164,16 @@
return false;
}
+bool Matcher::const_oop_prefer_decode() {
+ // Prefer ConN+DecodeN over ConP in simple compressed oops mode.
+ return Universe::narrow_oop_base() == NULL;
+}
+
+bool Matcher::const_klass_prefer_decode() {
+ // Prefer ConNKlass+DecodeNKlass over ConP in simple compressed klass mode.
+ return Universe::narrow_klass_base() == NULL;
+}
+
// Is it better to copy float constants, or load them directly from memory?
// Intel can load a float constant from a direct address, requiring no
// extra registers. Most RISCs will have to materialize an address into a
@@ -2424,23 +2432,21 @@
MacroAssembler _masm(&cbuf);
int toc_offset = 0;
- if (!ra_->C->in_scratch_emit_size()) {
- address const_toc_addr;
- // Create a non-oop constant, no relocation needed.
- // If it is an IC, it has a virtual_call_Relocation.
- const_toc_addr = __ long_constant((jlong)$src$$constant);
- if (const_toc_addr == NULL) {
- ciEnv::current()->record_out_of_memory_failure();
- return;
- }
-
- // Get the constant's TOC offset.
- toc_offset = __ offset_to_method_toc(const_toc_addr);
-
- // Keep the current instruction offset in mind.
- ((loadConLNode*)this)->_cbuf_insts_offset = __ offset();
- }
-
+ address const_toc_addr;
+ // Create a non-oop constant, no relocation needed.
+ // If it is an IC, it has a virtual_call_Relocation.
+ const_toc_addr = __ long_constant((jlong)$src$$constant);
+ if (const_toc_addr == NULL) {
+ ciEnv::current()->record_out_of_memory_failure();
+ return;
+ }
+
+ // Get the constant's TOC offset.
+ toc_offset = __ offset_to_method_toc(const_toc_addr);
+
+ // Keep the current instruction offset in mind.
+ ((loadConLNode*)this)->_cbuf_insts_offset = __ offset();
+
__ ld($dst$$Register, toc_offset, $toc$$Register);
%}
@@ -2576,31 +2582,29 @@
MacroAssembler _masm(&cbuf);
int toc_offset = 0;
- if (!ra_->C->in_scratch_emit_size()) {
- intptr_t val = $src$$constant;
- relocInfo::relocType constant_reloc = $src->constant_reloc(); // src
- address const_toc_addr;
- if (constant_reloc == relocInfo::oop_type) {
- // Create an oop constant and a corresponding relocation.
- AddressLiteral a = __ allocate_oop_address((jobject)val);
- const_toc_addr = __ address_constant((address)a.value(), RelocationHolder::none);
- __ relocate(a.rspec());
- } else if (constant_reloc == relocInfo::metadata_type) {
- AddressLiteral a = __ constant_metadata_address((Metadata *)val);
- const_toc_addr = __ address_constant((address)a.value(), RelocationHolder::none);
- __ relocate(a.rspec());
- } else {
- // Create a non-oop constant, no relocation needed.
- const_toc_addr = __ long_constant((jlong)$src$$constant);
- }
-
- if (const_toc_addr == NULL) {
- ciEnv::current()->record_out_of_memory_failure();
- return;
- }
- // Get the constant's TOC offset.
- toc_offset = __ offset_to_method_toc(const_toc_addr);
- }
+ intptr_t val = $src$$constant;
+ relocInfo::relocType constant_reloc = $src->constant_reloc(); // src
+ address const_toc_addr;
+ if (constant_reloc == relocInfo::oop_type) {
+ // Create an oop constant and a corresponding relocation.
+ AddressLiteral a = __ allocate_oop_address((jobject)val);
+ const_toc_addr = __ address_constant((address)a.value(), RelocationHolder::none);
+ __ relocate(a.rspec());
+ } else if (constant_reloc == relocInfo::metadata_type) {
+ AddressLiteral a = __ constant_metadata_address((Metadata *)val);
+ const_toc_addr = __ address_constant((address)a.value(), RelocationHolder::none);
+ __ relocate(a.rspec());
+ } else {
+ // Create a non-oop constant, no relocation needed.
+ const_toc_addr = __ long_constant((jlong)$src$$constant);
+ }
+
+ if (const_toc_addr == NULL) {
+ ciEnv::current()->record_out_of_memory_failure();
+ return;
+ }
+ // Get the constant's TOC offset.
+ toc_offset = __ offset_to_method_toc(const_toc_addr);
__ ld($dst$$Register, toc_offset, $toc$$Register);
%}
@@ -3272,28 +3276,26 @@
} else {
// Remember the offset not the address.
const int start_offset = __ offset();
+
// The trampoline stub.
- if (!Compile::current()->in_scratch_emit_size()) {
- // No entry point given, use the current pc.
- // Make sure branch fits into
- if (entry_point == 0) entry_point = __ pc();
-
- // Put the entry point as a constant into the constant pool.
- const address entry_point_toc_addr = __ address_constant(entry_point, RelocationHolder::none);
- if (entry_point_toc_addr == NULL) {
- ciEnv::current()->record_out_of_memory_failure();
- return;
- }
- const int entry_point_toc_offset = __ offset_to_method_toc(entry_point_toc_addr);
-
-
- // Emit the trampoline stub which will be related to the branch-and-link below.
- CallStubImpl::emit_trampoline_stub(_masm, entry_point_toc_offset, start_offset);
- if (ciEnv::current()->failing()) { return; } // Code cache may be full.
- int method_index = resolved_method_index(cbuf);
- __ relocate(_optimized_virtual ? opt_virtual_call_Relocation::spec(method_index)
- : static_call_Relocation::spec(method_index));
+ // No entry point given, use the current pc.
+ // Make sure branch fits into
+ if (entry_point == 0) entry_point = __ pc();
+
+ // Put the entry point as a constant into the constant pool.
+ const address entry_point_toc_addr = __ address_constant(entry_point, RelocationHolder::none);
+ if (entry_point_toc_addr == NULL) {
+ ciEnv::current()->record_out_of_memory_failure();
+ return;
}
+ const int entry_point_toc_offset = __ offset_to_method_toc(entry_point_toc_addr);
+
+ // Emit the trampoline stub which will be related to the branch-and-link below.
+ CallStubImpl::emit_trampoline_stub(_masm, entry_point_toc_offset, start_offset);
+ if (ciEnv::current()->failing()) { return; } // Code cache may be full.
+ int method_index = resolved_method_index(cbuf);
+ __ relocate(_optimized_virtual ? opt_virtual_call_Relocation::spec(method_index)
+ : static_call_Relocation::spec(method_index));
// The real call.
// Note: At this point we do not have the address of the trampoline
--- a/hotspot/src/cpu/ppc/vm/templateTable_ppc_64.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/cpu/ppc/vm/templateTable_ppc_64.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -2550,7 +2550,7 @@
__ lbzx(R17_tos, Rclass_or_obj, Roffset);
__ extsb(R17_tos, R17_tos);
__ push(ztos);
- if (!is_static) {
+ if (!is_static && rc == may_rewrite) {
// use btos rewriting, no truncating to t/f bit is needed for getfield.
patch_bytecode(Bytecodes::_fast_bgetfield, Rbc, Rscratch);
}
@@ -2874,7 +2874,9 @@
if (!is_static) { pop_and_check_object(Rclass_or_obj); } // Kills R11_scratch1.
__ andi(R17_tos, R17_tos, 0x1);
__ stbx(R17_tos, Rclass_or_obj, Roffset);
- if (!is_static) { patch_bytecode(Bytecodes::_fast_zputfield, Rbc, Rscratch, true, byte_no); }
+ if (!is_static && rc == may_rewrite) {
+ patch_bytecode(Bytecodes::_fast_zputfield, Rbc, Rscratch, true, byte_no);
+ }
if (!support_IRIW_for_not_multiple_copy_atomic_cpu) {
__ beq(CR_is_vol, Lvolatile); // Volatile?
}
--- a/hotspot/src/cpu/sparc/vm/jvmciCodeInstaller_sparc.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/cpu/sparc/vm/jvmciCodeInstaller_sparc.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -71,7 +71,7 @@
if (HotSpotMetaspaceConstantImpl::compressed(constant)) {
#ifdef _LP64
NativeMovConstReg32* move = nativeMovConstReg32_at(pc);
- narrowKlass narrowOop = record_narrow_metadata_reference(constant, CHECK);
+ narrowKlass narrowOop = record_narrow_metadata_reference(_instructions, pc, constant, CHECK);
move->set_data((intptr_t)narrowOop);
TRACE_jvmci_3("relocating (narrow metaspace constant) at " PTR_FORMAT "/0x%x", p2i(pc), narrowOop);
#else
@@ -79,7 +79,7 @@
#endif
} else {
NativeMovConstReg* move = nativeMovConstReg_at(pc);
- void* reference = record_metadata_reference(constant, CHECK);
+ void* reference = record_metadata_reference(_instructions, pc, constant, CHECK);
move->set_data((intptr_t)reference);
TRACE_jvmci_3("relocating (metaspace constant) at " PTR_FORMAT "/" PTR_FORMAT, p2i(pc), p2i(reference));
}
--- a/hotspot/src/cpu/sparc/vm/sparc.ad Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/cpu/sparc/vm/sparc.ad Wed Nov 09 10:04:43 2016 -0800
@@ -2003,6 +2003,20 @@
return false;
}
+bool Matcher::const_oop_prefer_decode() {
+ // TODO: Check if loading ConP from TOC in heap-based mode is better:
+ // Prefer ConN+DecodeN over ConP in simple compressed oops mode.
+ // return Universe::narrow_oop_base() == NULL;
+ return true;
+}
+
+bool Matcher::const_klass_prefer_decode() {
+ // TODO: Check if loading ConP from TOC in heap-based mode is better:
+ // Prefer ConNKlass+DecodeNKlass over ConP in simple compressed klass mode.
+ // return Universe::narrow_klass_base() == NULL;
+ return true;
+}
+
// Is it better to copy float constants, or load them directly from memory?
// Intel can load a float constant from a direct address, requiring no
// extra registers. Most RISCs will have to materialize an address into a
--- a/hotspot/src/cpu/sparc/vm/templateInterpreterGenerator_sparc.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/cpu/sparc/vm/templateInterpreterGenerator_sparc.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -384,8 +384,9 @@
address entry = __ pc();
__ get_constant_pool_cache(LcpoolCache); // load LcpoolCache
#if INCLUDE_JVMCI
- // Check if we need to take lock at entry of synchronized method.
- if (UseJVMCICompiler) {
+ // Check if we need to take lock at entry of synchronized method. This can
+ // only occur on method entry so emit it only for vtos with step 0.
+ if (UseJVMCICompiler && state == vtos && step == 0) {
Label L;
Address pending_monitor_enter_addr(G2_thread, JavaThread::pending_monitorenter_offset());
__ ldbool(pending_monitor_enter_addr, Gtemp); // Load if pending monitor enter
@@ -395,6 +396,17 @@
// Take lock.
lock_method();
__ bind(L);
+ } else {
+#ifdef ASSERT
+ if (UseJVMCICompiler) {
+ Label L;
+ Address pending_monitor_enter_addr(G2_thread, JavaThread::pending_monitorenter_offset());
+ __ ldbool(pending_monitor_enter_addr, Gtemp); // Load if pending monitor enter
+ __ cmp_and_br_short(Gtemp, G0, Assembler::equal, Assembler::pn, L);
+ __ stop("unexpected pending monitor in deopt entry");
+ __ bind(L);
+ }
+#endif
}
#endif
{ Label L;
--- a/hotspot/src/cpu/sparc/vm/vmStructs_sparc.hpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/cpu/sparc/vm/vmStructs_sparc.hpp Wed Nov 09 10:04:43 2016 -0800
@@ -84,7 +84,6 @@
declare_constant(VM_Version::sun4v_m) \
declare_constant(VM_Version::blk_init_instructions_m) \
declare_constant(VM_Version::fmaf_instructions_m) \
- declare_constant(VM_Version::fmau_instructions_m) \
declare_constant(VM_Version::sparc64_family_m) \
declare_constant(VM_Version::M_family_m) \
declare_constant(VM_Version::T_family_m) \
--- a/hotspot/src/cpu/sparc/vm/vm_version_sparc.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/cpu/sparc/vm/vm_version_sparc.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -179,7 +179,7 @@
assert((OptoLoopAlignment % relocInfo::addr_unit()) == 0, "alignment is not a multiple of NOP size");
char buf[512];
- jio_snprintf(buf, sizeof(buf), "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
+ jio_snprintf(buf, sizeof(buf), "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
(has_v9() ? ", v9" : (has_v8() ? ", v8" : "")),
(has_hardware_popc() ? ", popc" : ""),
(has_vis1() ? ", vis1" : ""),
@@ -193,6 +193,7 @@
(has_sha512() ? ", sha512" : ""),
(has_crc32c() ? ", crc32c" : ""),
(is_ultra3() ? ", ultra3" : ""),
+ (has_sparc5_instr() ? ", sparc5" : ""),
(is_sun4v() ? ", sun4v" : ""),
(is_niagara_plus() ? ", niagara_plus" : (is_niagara() ? ", niagara" : "")),
(is_sparc64() ? ", sparc64" : ""),
@@ -487,16 +488,11 @@
if (strstr(impl, "SPARC-T1") != NULL) {
features |= T1_model_m;
}
+ } else if (strstr(impl, "SUN4V-CPU") != NULL) {
+ // Generic or migration class LDOM
+ features |= T_family_m;
} else {
- if (strstr(impl, "SPARC") == NULL) {
-#ifndef PRODUCT
- // kstat on Solaris 8 virtual machines (branded zones)
- // returns "(unsupported)" implementation. Solaris 8 is not
- // supported anymore, but include this check to be on the
- // safe side.
- warning("Can't parse CPU implementation = '%s', assume generic SPARC", impl);
-#endif
- }
+ log_info(os, cpu)("Failed to parse CPU implementation = '%s'", impl);
}
os::free((void*)impl);
return features;
--- a/hotspot/src/cpu/sparc/vm/vm_version_sparc.hpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/cpu/sparc/vm/vm_version_sparc.hpp Wed Nov 09 10:04:43 2016 -0800
@@ -34,30 +34,29 @@
protected:
enum Feature_Flag {
- v8_instructions = 0,
- hardware_mul32 = 1,
- hardware_div32 = 2,
- hardware_fsmuld = 3,
- hardware_popc = 4,
- v9_instructions = 5,
- vis1_instructions = 6,
- vis2_instructions = 7,
- sun4v_instructions = 8,
+ v8_instructions = 0,
+ hardware_mul32 = 1,
+ hardware_div32 = 2,
+ hardware_fsmuld = 3,
+ hardware_popc = 4,
+ v9_instructions = 5,
+ vis1_instructions = 6,
+ vis2_instructions = 7,
+ sun4v_instructions = 8,
blk_init_instructions = 9,
- fmaf_instructions = 10,
- fmau_instructions = 11,
- vis3_instructions = 12,
- cbcond_instructions = 13,
- sparc64_family = 14,
- M_family = 15,
- T_family = 16,
- T1_model = 17,
- sparc5_instructions = 18,
- aes_instructions = 19,
- sha1_instruction = 20,
- sha256_instruction = 21,
- sha512_instruction = 22,
- crc32c_instruction = 23
+ fmaf_instructions = 10,
+ vis3_instructions = 11,
+ cbcond_instructions = 12,
+ sparc64_family = 13,
+ M_family = 14,
+ T_family = 15,
+ T1_model = 16,
+ sparc5_instructions = 17,
+ aes_instructions = 18,
+ sha1_instruction = 19,
+ sha256_instruction = 20,
+ sha512_instruction = 21,
+ crc32c_instruction = 22
};
enum Feature_Flag_Set {
@@ -75,7 +74,6 @@
sun4v_m = 1 << sun4v_instructions,
blk_init_instructions_m = 1 << blk_init_instructions,
fmaf_instructions_m = 1 << fmaf_instructions,
- fmau_instructions_m = 1 << fmau_instructions,
vis3_instructions_m = 1 << vis3_instructions,
cbcond_instructions_m = 1 << cbcond_instructions,
sparc64_family_m = 1 << sparc64_family,
--- a/hotspot/src/cpu/x86/vm/jvmciCodeInstaller_x86.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/cpu/x86/vm/jvmciCodeInstaller_x86.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -89,14 +89,14 @@
if (HotSpotMetaspaceConstantImpl::compressed(constant)) {
#ifdef _LP64
address operand = Assembler::locate_operand(pc, Assembler::narrow_oop_operand);
- *((narrowKlass*) operand) = record_narrow_metadata_reference(constant, CHECK);
+ *((narrowKlass*) operand) = record_narrow_metadata_reference(_instructions, operand, constant, CHECK);
TRACE_jvmci_3("relocating (narrow metaspace constant) at " PTR_FORMAT "/" PTR_FORMAT, p2i(pc), p2i(operand));
#else
JVMCI_ERROR("compressed Klass* on 32bit");
#endif
} else {
address operand = Assembler::locate_operand(pc, Assembler::imm_operand);
- *((void**) operand) = record_metadata_reference(constant, CHECK);
+ *((void**) operand) = record_metadata_reference(_instructions, operand, constant, CHECK);
TRACE_jvmci_3("relocating (metaspace constant) at " PTR_FORMAT "/" PTR_FORMAT, p2i(pc), p2i(operand));
}
}
--- a/hotspot/src/cpu/x86/vm/templateInterpreterGenerator_x86.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/cpu/x86/vm/templateInterpreterGenerator_x86.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -254,8 +254,9 @@
const Register thread = NOT_LP64(rcx) LP64_ONLY(r15_thread);
NOT_LP64(__ get_thread(thread));
#if INCLUDE_JVMCI
- // Check if we need to take lock at entry of synchronized method.
- if (UseJVMCICompiler) {
+ // Check if we need to take lock at entry of synchronized method. This can
+ // only occur on method entry so emit it only for vtos with step 0.
+ if (UseJVMCICompiler && state == vtos && step == 0) {
Label L;
__ cmpb(Address(thread, JavaThread::pending_monitorenter_offset()), 0);
__ jcc(Assembler::zero, L);
@@ -266,6 +267,16 @@
// Take lock.
lock_method();
__ bind(L);
+ } else {
+#ifdef ASSERT
+ if (UseJVMCICompiler) {
+ Label L;
+ __ cmpb(Address(r15_thread, JavaThread::pending_monitorenter_offset()), 0);
+ __ jccb(Assembler::zero, L);
+ __ stop("unexpected pending monitor in deopt entry");
+ __ bind(L);
+ }
+#endif
}
#endif
// handle exceptions
--- a/hotspot/src/cpu/x86/vm/x86_32.ad Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/cpu/x86/vm/x86_32.ad Wed Nov 09 10:04:43 2016 -0800
@@ -1452,6 +1452,15 @@
return true;
}
+bool Matcher::const_oop_prefer_decode() {
+ ShouldNotCallThis();
+ return true;
+}
+
+bool Matcher::const_klass_prefer_decode() {
+ ShouldNotCallThis();
+ return true;
+}
// Is it better to copy float constants, or load them directly from memory?
// Intel can load a float constant from a direct address, requiring no
--- a/hotspot/src/cpu/x86/vm/x86_64.ad Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/cpu/x86/vm/x86_64.ad Wed Nov 09 10:04:43 2016 -0800
@@ -1660,6 +1660,19 @@
return (LogKlassAlignmentInBytes <= 3);
}
+bool Matcher::const_oop_prefer_decode() {
+ // Prefer ConN+DecodeN over ConP.
+ return true;
+}
+
+bool Matcher::const_klass_prefer_decode() {
+ // TODO: Either support matching DecodeNKlass (heap-based) in operand
+ // or condisider the following:
+ // Prefer ConNKlass+DecodeNKlass over ConP in simple compressed klass mode.
+ //return Universe::narrow_klass_base() == NULL;
+ return true;
+}
+
// Is it better to copy float constants, or load them directly from
// memory? Intel can load a float constant from a direct address,
// requiring no extra registers. Most RISCs will have to materialize
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot.sparc/src/jdk/vm/ci/hotspot/sparc/SPARCHotSpotJVMCIBackendFactory.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot.sparc/src/jdk/vm/ci/hotspot/sparc/SPARCHotSpotJVMCIBackendFactory.java Wed Nov 09 10:04:43 2016 -0800
@@ -96,9 +96,6 @@
if ((config.vmVersionFeatures & config.sparcFmafInstructions) != 0) {
features.add(CPUFeature.FMAF);
}
- if ((config.vmVersionFeatures & config.sparcFmauInstructions) != 0) {
- features.add(CPUFeature.FMAU);
- }
if ((config.vmVersionFeatures & config.sparcSparc64Family) != 0) {
features.add(CPUFeature.SPARC64_FAMILY);
}
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot.sparc/src/jdk/vm/ci/hotspot/sparc/SPARCHotSpotVMConfig.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot.sparc/src/jdk/vm/ci/hotspot/sparc/SPARCHotSpotVMConfig.java Wed Nov 09 10:04:43 2016 -0800
@@ -55,7 +55,6 @@
final int sparcSun4v = getConstant("VM_Version::sun4v_m", Integer.class);
final int sparcBlkInitInstructions = getConstant("VM_Version::blk_init_instructions_m", Integer.class);
final int sparcFmafInstructions = getConstant("VM_Version::fmaf_instructions_m", Integer.class);
- final int sparcFmauInstructions = getConstant("VM_Version::fmau_instructions_m", Integer.class);
final int sparcSparc64Family = getConstant("VM_Version::sparc64_family_m", Integer.class);
final int sparcMFamily = getConstant("VM_Version::M_family_m", Integer.class);
final int sparcTFamily = getConstant("VM_Version::T_family_m", Integer.class);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/EmptyEventProvider.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package jdk.vm.ci.hotspot;
+
+/**
+ * An empty implementation for {@link EventProvider}. This implementation is used when no logging is
+ * requested.
+ */
+final class EmptyEventProvider implements EventProvider {
+
+ static InternalError shouldNotReachHere() {
+ throw new InternalError("should not reach here");
+ }
+
+ @Override
+ public CompilationEvent newCompilationEvent() {
+ return new EmptyCompilationEvent();
+ }
+
+ static class EmptyCompilationEvent implements CompilationEvent {
+ public void commit() {
+ throw shouldNotReachHere();
+ }
+
+ public boolean shouldWrite() {
+ // Events of this class should never been written.
+ return false;
+ }
+
+ public void begin() {
+ }
+
+ public void end() {
+ }
+
+ public void setMethod(String method) {
+ throw shouldNotReachHere();
+ }
+
+ public void setCompileId(int compileId) {
+ throw shouldNotReachHere();
+ }
+
+ public void setCompileLevel(int compileLevel) {
+ throw shouldNotReachHere();
+ }
+
+ public void setSucceeded(boolean succeeded) {
+ throw shouldNotReachHere();
+ }
+
+ public void setIsOsr(boolean isOsr) {
+ throw shouldNotReachHere();
+ }
+
+ public void setCodeSize(int codeSize) {
+ throw shouldNotReachHere();
+ }
+
+ public void setInlinedBytes(int inlinedBytes) {
+ throw shouldNotReachHere();
+ }
+ }
+
+ @Override
+ public CompilerFailureEvent newCompilerFailureEvent() {
+ return new EmptyCompilerFailureEvent();
+ }
+
+ static class EmptyCompilerFailureEvent implements CompilerFailureEvent {
+ public void commit() {
+ throw shouldNotReachHere();
+ }
+
+ public boolean shouldWrite() {
+ // Events of this class should never been written.
+ return false;
+ }
+
+ public void setCompileId(int compileId) {
+ throw shouldNotReachHere();
+ }
+
+ public void setMessage(String message) {
+ throw shouldNotReachHere();
+ }
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/EventProvider.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,131 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package jdk.vm.ci.hotspot;
+
+import jdk.vm.ci.hotspot.EmptyEventProvider.EmptyCompilationEvent;
+import jdk.vm.ci.hotspot.EmptyEventProvider.EmptyCompilerFailureEvent;
+import jdk.vm.ci.services.JVMCIPermission;
+
+/**
+ * Service-provider class for logging compiler related events.
+ */
+public interface EventProvider {
+
+ /**
+ * Creates and returns an empty implementation for {@link EventProvider}. This implementation
+ * can be used when no logging is requested.
+ */
+ static EventProvider createEmptyEventProvider() {
+ return new EmptyEventProvider();
+ }
+
+ /**
+ * Creates and returns an empty implementation for {@link CompilationEvent}.
+ */
+ static CompilationEvent createEmptyCompilationEvent() {
+ return new EmptyCompilationEvent();
+ }
+
+ /**
+ * Creates and returns an empty implementation for {@link CompilationEvent}.
+ */
+ static CompilerFailureEvent createEmptyCompilerFailureEvent() {
+ return new EmptyCompilerFailureEvent();
+ }
+
+ /**
+ * An instant event is an event that is not considered to have taken any time.
+ */
+ public interface InstantEvent {
+ /**
+ * Commits the event.
+ */
+ void commit();
+
+ /**
+ * Determines if this particular event instance would be committed to the data stream right
+ * now if application called {@link #commit()}. This in turn depends on whether the event is
+ * enabled and possible other factors.
+ *
+ * @return if this event would be committed on a call to {@link #commit()}.
+ */
+ boolean shouldWrite();
+ }
+
+ /**
+ * Timed events describe an operation that somehow consumes time.
+ */
+ public interface TimedEvent extends InstantEvent {
+ /**
+ * Starts the timing for this event.
+ */
+ void begin();
+
+ /**
+ * Ends the timing period for this event.
+ */
+ void end();
+ }
+
+ /**
+ * Creates a new {@link CompilationEvent}.
+ *
+ * @return a compilation event
+ */
+ public abstract CompilationEvent newCompilationEvent();
+
+ /**
+ * A compilation event.
+ */
+ public interface CompilationEvent extends TimedEvent {
+ void setMethod(String method);
+
+ void setCompileId(int compileId);
+
+ void setCompileLevel(int compileLevel);
+
+ void setSucceeded(boolean succeeded);
+
+ void setIsOsr(boolean isOsr);
+
+ void setCodeSize(int codeSize);
+
+ void setInlinedBytes(int inlinedBytes);
+ }
+
+ /**
+ * Creates a new {@link CompilerFailureEvent}.
+ *
+ * @return a compiler failure event
+ */
+ public abstract CompilerFailureEvent newCompilerFailureEvent();
+
+ /**
+ * A compiler failure event.
+ */
+ public interface CompilerFailureEvent extends InstantEvent {
+ void setCompileId(int compileId);
+
+ void setMessage(String message);
+ }
+}
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCICompilerConfig.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCICompilerConfig.java Wed Nov 09 10:04:43 2016 -0800
@@ -26,8 +26,10 @@
import jdk.vm.ci.common.JVMCIError;
import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.Option;
import jdk.vm.ci.runtime.JVMCICompiler;
+import jdk.vm.ci.runtime.JVMCICompilerFactory;
import jdk.vm.ci.runtime.JVMCIRuntime;
-import jdk.vm.ci.runtime.services.JVMCICompilerFactory;
+import jdk.vm.ci.services.JVMCIServiceLocator;
+import jdk.vm.ci.services.JVMCIPermission;
import jdk.vm.ci.services.Services;
final class HotSpotJVMCICompilerConfig {
@@ -37,7 +39,7 @@
* to perform a compilation. This allows the reflective parts of the JVMCI API to be used
* without requiring a compiler implementation to be available.
*/
- private static class DummyCompilerFactory extends JVMCICompilerFactory implements JVMCICompiler {
+ private static class DummyCompilerFactory implements JVMCICompilerFactory, JVMCICompiler {
public HotSpotCompilationRequestResult compileMethod(CompilationRequest request) {
throw new JVMCIError("no JVMCI compiler selected");
@@ -63,15 +65,16 @@
* Gets the selected system compiler factory.
*
* @return the selected system compiler factory
+ * @throws SecurityException if a security manager is present and it denies
+ * {@link JVMCIPermission} for any {@link JVMCIServiceLocator} loaded by this method
*/
static JVMCICompilerFactory getCompilerFactory() {
if (compilerFactory == null) {
JVMCICompilerFactory factory = null;
String compilerName = Option.Compiler.getString();
if (compilerName != null) {
- for (JVMCICompilerFactory f : Services.load(JVMCICompilerFactory.class)) {
+ for (JVMCICompilerFactory f : JVMCIServiceLocator.getProviders(JVMCICompilerFactory.class)) {
if (f.getCompilerName().equals(compilerName)) {
- Services.exportJVMCITo(f.getClass());
factory = f;
}
}
@@ -80,8 +83,9 @@
}
} else {
// Auto select a single available compiler
- for (JVMCICompilerFactory f : Services.load(JVMCICompilerFactory.class)) {
+ for (JVMCICompilerFactory f : JVMCIServiceLocator.getProviders(JVMCICompilerFactory.class)) {
if (factory == null) {
+ Services.exportJVMCITo(f.getClass());
factory = f;
} else {
// Multiple factories seen - cancel auto selection
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCICompilerFactory.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package jdk.vm.ci.hotspot;
+
+import jdk.vm.ci.runtime.JVMCICompilerFactory;
+
+/**
+ * HotSpot extensions to {@link JVMCICompilerFactory}.
+ */
+public abstract class HotSpotJVMCICompilerFactory implements JVMCICompilerFactory {
+
+ /**
+ * Gets 0 or more prefixes identifying classes that should by compiled by C1 in simple mode
+ * (i.e., {@code CompLevel_simple}) when HotSpot is running with tiered compilation. The
+ * prefixes should be class or package names using "/" as the separator, e.g. "jdk/vm/ci".
+ *
+ * @return 0 or more Strings identifying packages that should by compiled by the first tier only
+ * or null if no redirection to C1 should be performed.
+ */
+ public String[] getTrivialPrefixes() {
+ return null;
+ }
+
+ public enum CompilationLevelAdjustment {
+ /**
+ * No adjustment.
+ */
+ None,
+
+ /**
+ * Adjust based on declaring class of method.
+ */
+ ByHolder,
+
+ /**
+ * Adjust based on declaring class, name and signature of method.
+ */
+ ByFullSignature
+ }
+
+ /**
+ * Determines if this object may want to adjust the compilation level for a method that is being
+ * scheduled by the VM for compilation.
+ */
+ public CompilationLevelAdjustment getCompilationLevelAdjustment() {
+ return CompilationLevelAdjustment.None;
+ }
+
+ public enum CompilationLevel {
+ None,
+ Simple,
+ LimitedProfile,
+ FullProfile,
+ FullOptimization
+ }
+
+ /**
+ * Potentially modifies the compilation level currently selected by the VM compilation policy
+ * for a method.
+ *
+ * @param declaringClass the class in which the method is declared
+ * @param name the name of the method or {@code null} depending on the value that was returned
+ * by {@link #getCompilationLevelAdjustment()}
+ * @param signature the signature of the method or {@code null} depending on the value that was
+ * returned by {@link #getCompilationLevelAdjustment()}
+ * @param isOsr specifies if the compilation being scheduled in an OSR compilation
+ * @param level the compilation level currently selected by the VM compilation policy
+ * @return the compilation level to use for the compilation being scheduled (must be a valid
+ * {@code CompLevel} enum value)
+ */
+ public CompilationLevel adjustCompilationLevel(Class<?> declaringClass, String name, String signature, boolean isOsr, CompilationLevel level) {
+ throw new InternalError("Should not reach here");
+ }
+}
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java Wed Nov 09 10:04:43 2016 -0800
@@ -27,13 +27,11 @@
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
-import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
-import java.util.ServiceLoader;
import java.util.TreeMap;
import jdk.internal.misc.VM;
@@ -43,16 +41,15 @@
import jdk.vm.ci.code.InstalledCode;
import jdk.vm.ci.common.InitTimer;
import jdk.vm.ci.common.JVMCIError;
-import jdk.vm.ci.hotspot.services.HotSpotJVMCICompilerFactory;
-import jdk.vm.ci.hotspot.services.HotSpotJVMCICompilerFactory.CompilationLevel;
-import jdk.vm.ci.hotspot.services.HotSpotVMEventListener;
+import jdk.vm.ci.hotspot.HotSpotJVMCICompilerFactory.CompilationLevel;
import jdk.vm.ci.meta.JavaKind;
import jdk.vm.ci.meta.JavaType;
import jdk.vm.ci.meta.ResolvedJavaType;
import jdk.vm.ci.runtime.JVMCI;
import jdk.vm.ci.runtime.JVMCIBackend;
import jdk.vm.ci.runtime.JVMCICompiler;
-import jdk.vm.ci.runtime.services.JVMCICompilerFactory;
+import jdk.vm.ci.runtime.JVMCICompilerFactory;
+import jdk.vm.ci.services.JVMCIServiceLocator;
import jdk.vm.ci.services.Services;
/**
@@ -90,14 +87,17 @@
* A list of all supported JVMCI options.
*/
public enum Option {
+ // @formatter:off
Compiler(String.class, null, "Selects the system compiler."),
// Note: The following one is not used (see InitTimer.ENABLED). It is added here
- // so that -Djvmci.PrintFlags=true shows the option.
- InitTimer(boolean.class, false, "Specifies if initialization timing is enabled."),
- PrintConfig(boolean.class, false, "Prints VM configuration available via JVMCI and exits."),
- PrintFlags(boolean.class, false, "Prints all JVMCI flags and exits."),
- ShowFlags(boolean.class, false, "Prints all JVMCI flags and continues."),
- TraceMethodDataFilter(String.class, null, "");
+ // so that -XX:+JVMCIPrintProperties shows the option.
+ InitTimer(Boolean.class, false, "Specifies if initialization timing is enabled."),
+ PrintConfig(Boolean.class, false, "Prints VM configuration available via JVMCI."),
+ TraceMethodDataFilter(String.class, null,
+ "Enables tracing of profiling info when read by JVMCI.",
+ "Empty value: trace all methods",
+ "Non-empty value: trace methods whose fully qualified name contains the value.");
+ // @formatter:on
/**
* The prefix for system properties that are JVMCI options.
@@ -113,25 +113,25 @@
private Object value;
private final Object defaultValue;
private boolean isDefault;
- private final String help;
+ private final String[] helpLines;
- Option(Class<?> type, Object defaultValue, String help) {
+ Option(Class<?> type, Object defaultValue, String... helpLines) {
assert Character.isUpperCase(name().charAt(0)) : "Option name must start with upper-case letter: " + name();
this.type = type;
this.value = UNINITIALIZED;
this.defaultValue = defaultValue;
- this.help = help;
+ this.helpLines = helpLines;
}
@SuppressFBWarnings(value = "ES_COMPARING_STRINGS_WITH_EQ", justification = "sentinel must be String since it's a static final in an enum")
private Object getValue() {
if (value == UNINITIALIZED) {
- String propertyValue = VM.getSavedProperty(JVMCI_OPTION_PROPERTY_PREFIX + name());
+ String propertyValue = VM.getSavedProperty(getPropertyName());
if (propertyValue == null) {
this.value = defaultValue;
this.isDefault = true;
} else {
- if (type == boolean.class) {
+ if (type == Boolean.class) {
this.value = Boolean.parseBoolean(propertyValue);
} else if (type == String.class) {
this.value = propertyValue;
@@ -147,6 +147,13 @@
}
/**
+ * Gets the name of system property from which this option gets its value.
+ */
+ public String getPropertyName() {
+ return JVMCI_OPTION_PROPERTY_PREFIX + name();
+ }
+
+ /**
* Returns the option's value as boolean.
*
* @return option's value
@@ -165,16 +172,31 @@
}
/**
- * Prints all option flags to {@code out}.
+ * Prints a description of the properties used to configure shared JVMCI code.
*
* @param out stream to print to
*/
- public static void printFlags(PrintStream out) {
- out.println("[List of JVMCI options]");
- for (Option option : values()) {
+ public static void printProperties(PrintStream out) {
+ out.println("[JVMCI properties]");
+ int typeWidth = 0;
+ int nameWidth = 0;
+ Option[] values = values();
+ for (Option option : values) {
+ typeWidth = Math.max(typeWidth, option.type.getSimpleName().length());
+ nameWidth = Math.max(nameWidth, option.getPropertyName().length());
+ }
+ for (Option option : values) {
Object value = option.getValue();
- String assign = option.isDefault ? ":=" : " =";
- out.printf("%9s %-40s %s %-14s %s%n", option.type.getSimpleName(), option, assign, value, option.help);
+ if (value instanceof String) {
+ value = '"' + String.valueOf(value) + '"';
+ }
+ String assign = option.isDefault ? " =" : ":=";
+ String format = "%" + (typeWidth + 1) + "s %-" + (nameWidth + 1) + "s %s %s%n";
+ out.printf(format, option.type.getSimpleName(), option.getPropertyName(), assign, value);
+ String helpFormat = "%" + (typeWidth + 1) + "s %s%n";
+ for (String line : option.helpLines) {
+ out.printf(helpFormat, "", line);
+ }
}
}
}
@@ -221,11 +243,7 @@
if (vmEventListeners == null) {
synchronized (this) {
if (vmEventListeners == null) {
- List<HotSpotVMEventListener> listeners = new ArrayList<>();
- for (HotSpotVMEventListener vmEventListener : ServiceLoader.load(HotSpotVMEventListener.class)) {
- listeners.add(vmEventListener);
- }
- vmEventListeners = listeners;
+ vmEventListeners = JVMCIServiceLocator.getProviders(HotSpotVMEventListener.class);
}
}
}
@@ -239,7 +257,6 @@
@SuppressWarnings("unused") private final String[] trivialPrefixes;
@SuppressWarnings("try")
- @SuppressFBWarnings(value = "DM_EXIT", justification = "PrintFlags is meant to exit the VM")
private HotSpotJVMCIRuntime() {
compilerToVm = new CompilerToVM();
@@ -261,20 +278,6 @@
metaAccessContext = new HotSpotJVMCIMetaAccessContext();
- boolean printFlags = Option.PrintFlags.getBoolean();
- boolean showFlags = Option.ShowFlags.getBoolean();
- if (printFlags || showFlags) {
- Option.printFlags(System.out);
- if (printFlags) {
- System.exit(0);
- }
- }
-
- if (Option.PrintConfig.getBoolean()) {
- printConfig(configStore, compilerToVm);
- System.exit(0);
- }
-
compilerFactory = HotSpotJVMCICompilerConfig.getCompilerFactory();
if (compilerFactory instanceof HotSpotJVMCICompilerFactory) {
hsCompilerFactory = (HotSpotJVMCICompilerFactory) compilerFactory;
@@ -298,6 +301,16 @@
trivialPrefixes = null;
compilationLevelAdjustment = config.compLevelAdjustmentNone;
}
+
+ if (config.getFlag("JVMCIPrintProperties", Boolean.class)) {
+ PrintStream out = new PrintStream(getLogStream());
+ Option.printProperties(out);
+ compilerFactory.printProperties(out);
+ }
+
+ if (Option.PrintConfig.getBoolean()) {
+ printConfig(configStore, compilerToVm);
+ }
}
private JVMCIBackend registerBackend(JVMCIBackend backend) {
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMethodData.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMethodData.java Wed Nov 09 10:04:43 2016 -0800
@@ -53,9 +53,9 @@
* Reference to the C++ MethodData object.
*/
final long metaspaceMethodData;
- @SuppressWarnings("unused") private final HotSpotResolvedJavaMethodImpl method;
+ private final HotSpotResolvedJavaMethodImpl method;
- public HotSpotMethodData(long metaspaceMethodData, HotSpotResolvedJavaMethodImpl method) {
+ HotSpotMethodData(long metaspaceMethodData, HotSpotResolvedJavaMethodImpl method) {
this.metaspaceMethodData = metaspaceMethodData;
this.method = method;
}
@@ -107,6 +107,18 @@
return UNSAFE.getByte(metaspaceMethodData + config.methodDataOopTrapHistoryOffset + config.deoptReasonOSROffset + reasonIndex) & 0xFF;
}
+ public int getDecompileCount() {
+ return UNSAFE.getInt(metaspaceMethodData + config.methodDataDecompiles);
+ }
+
+ public int getOverflowRecompileCount() {
+ return UNSAFE.getInt(metaspaceMethodData + config.methodDataOverflowRecompiles);
+ }
+
+ public int getOverflowTrapCount() {
+ return UNSAFE.getInt(metaspaceMethodData + config.methodDataOverflowTraps);
+ }
+
public HotSpotMethodDataAccessor getNormalData(int position) {
if (position >= normalDataSize()) {
return null;
@@ -214,6 +226,12 @@
StringBuilder sb = new StringBuilder();
String nl = String.format("%n");
String nlIndent = String.format("%n%38s", "");
+ sb.append("Raw method data for ");
+ sb.append(method.format("%H.%n(%p)"));
+ sb.append(":");
+ sb.append(nl);
+ sb.append(String.format("nof_decompiles(%d) nof_overflow_recompiles(%d) nof_overflow_traps(%d)%n",
+ getDecompileCount(), getOverflowRecompileCount(), getOverflowTrapCount()));
if (hasNormalData()) {
int pos = 0;
HotSpotMethodDataAccessor data;
@@ -427,6 +445,10 @@
protected abstract long getTypesNotRecordedExecutionCount(HotSpotMethodData data, int position);
+ public int getNonprofiledCount(HotSpotMethodData data, int position) {
+ return data.readUnsignedIntAsSignedInt(position, NONPROFILED_COUNT_OFFSET);
+ }
+
private JavaTypeProfile createTypeProfile(TriState nullSeen, RawItemProfile<ResolvedJavaType> profile) {
if (profile.entries <= 0 || profile.totalCount <= 0) {
return null;
@@ -462,7 +484,7 @@
TriState nullSeen = getNullSeen(data, pos);
TriState exceptionSeen = getExceptionSeen(data, pos);
sb.append(format("count(%d) null_seen(%s) exception_seen(%s) nonprofiled_count(%d) entries(%d)", getCounterValue(data, pos), nullSeen, exceptionSeen,
- getTypesNotRecordedExecutionCount(data, pos), profile.entries));
+ getNonprofiledCount(data, pos), profile.entries));
for (int i = 0; i < profile.entries; i++) {
long count = profile.counts[i];
sb.append(format("%n %s (%d, %4.2f)", profile.items[i].toJavaName(), count, (double) count / profile.totalCount));
@@ -490,7 +512,7 @@
@Override
protected long getTypesNotRecordedExecutionCount(HotSpotMethodData data, int position) {
- return data.readUnsignedIntAsSignedInt(position, NONPROFILED_COUNT_OFFSET);
+ return getNonprofiledCount(data, position);
}
}
@@ -788,7 +810,8 @@
@Override
public StringBuilder appendTo(StringBuilder sb, HotSpotMethodData data, int pos) {
- return null;
+ sb.append("unknown profile data with tag: " + tag);
+ return sb;
}
}
@@ -822,10 +845,10 @@
private static boolean checkAccessorTags() {
int expectedTag = 0;
for (HotSpotMethodDataAccessor accessor : PROFILE_DATA_ACCESSORS) {
- if (expectedTag ==0 ) {
+ if (expectedTag == 0) {
assert accessor == null;
} else {
- assert accessor.tag == expectedTag: expectedTag + " != " + accessor.tag + " " + accessor;
+ assert accessor.tag == expectedTag : expectedTag + " != " + accessor.tag + " " + accessor;
}
expectedTag++;
}
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotProfilingInfo.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotProfilingInfo.java Wed Nov 09 10:04:43 2016 -0800
@@ -57,6 +57,18 @@
return method.getCodeSize();
}
+ public int getDecompileCount() {
+ return methodData.getDecompileCount();
+ }
+
+ public int getOverflowRecompileCount() {
+ return methodData.getOverflowRecompileCount();
+ }
+
+ public int getOverflowTrapCount() {
+ return methodData.getOverflowTrapCount();
+ }
+
@Override
public JavaTypeProfile getTypeProfile(int bci) {
if (!isMature) {
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl.java Wed Nov 09 10:04:43 2016 -0800
@@ -434,7 +434,6 @@
methodData = new HotSpotMethodData(metaspaceMethodData, this);
String methodDataFilter = Option.TraceMethodDataFilter.getString();
if (methodDataFilter != null && this.format("%H.%n").contains(methodDataFilter)) {
- System.out.println("Raw method data for " + this.format("%H.%n(%p)") + ":");
System.out.println(methodData.toString());
}
}
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfig.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfig.java Wed Nov 09 10:04:43 2016 -0800
@@ -160,6 +160,10 @@
final int methodDataOopTrapHistoryOffset = getFieldOffset("MethodData::_trap_hist._array[0]", Integer.class, "u1");
final int methodDataIRSizeOffset = getFieldOffset("MethodData::_jvmci_ir_size", Integer.class, "int");
+ final int methodDataDecompiles = getFieldOffset("MethodData::_nof_decompiles", Integer.class, "uint");
+ final int methodDataOverflowRecompiles = getFieldOffset("MethodData::_nof_overflow_recompiles", Integer.class, "uint");
+ final int methodDataOverflowTraps = getFieldOffset("MethodData::_nof_overflow_traps", Integer.class, "uint");
+
final int nmethodCompLevelOffset = getFieldOffset("nmethod::_comp_level", Integer.class, "int");
final int compilationLevelNone = getConstant("CompLevel_none", Integer.class);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMEventListener.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package jdk.vm.ci.hotspot;
+
+import jdk.vm.ci.code.CompiledCode;
+import jdk.vm.ci.code.InstalledCode;
+
+/**
+ * Listener for responding to VM events.
+ */
+public interface HotSpotVMEventListener {
+
+ /**
+ * Notifies this client that the VM is shutting down.
+ */
+ default void notifyShutdown() {
+ }
+
+ /**
+ * Notify on successful install into the code cache.
+ *
+ * @param hotSpotCodeCacheProvider the code cache into which the code was installed
+ * @param installedCode the code that was installed
+ * @param compiledCode the compiled code from which {@code installedCode} was produced
+ */
+ default void notifyInstall(HotSpotCodeCacheProvider hotSpotCodeCacheProvider, InstalledCode installedCode, CompiledCode compiledCode) {
+ }
+
+ /**
+ * Notify on completion of a bootstrap.
+ */
+ default void notifyBootstrapFinished() {
+ }
+}
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/services/EmptyEventProvider.java Wed Nov 09 15:20:30 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,113 +0,0 @@
-/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package jdk.vm.ci.hotspot.services;
-
-/**
- * An empty implementation for {@link EventProvider}. This implementation is used when no logging is
- * requested.
- */
-final class EmptyEventProvider extends EventProvider {
-
- EmptyEventProvider() {
- super(null);
- }
-
- static InternalError shouldNotReachHere() {
- throw new InternalError("should not reach here");
- }
-
- @Override
- public CompilationEvent newCompilationEvent() {
- return new EmptyCompilationEvent();
- }
-
- static class EmptyCompilationEvent implements CompilationEvent {
- public void commit() {
- throw shouldNotReachHere();
- }
-
- public boolean shouldWrite() {
- // Events of this class should never been written.
- return false;
- }
-
- public void begin() {
- }
-
- public void end() {
- }
-
- public void setMethod(String method) {
- throw shouldNotReachHere();
- }
-
- public void setCompileId(int compileId) {
- throw shouldNotReachHere();
- }
-
- public void setCompileLevel(int compileLevel) {
- throw shouldNotReachHere();
- }
-
- public void setSucceeded(boolean succeeded) {
- throw shouldNotReachHere();
- }
-
- public void setIsOsr(boolean isOsr) {
- throw shouldNotReachHere();
- }
-
- public void setCodeSize(int codeSize) {
- throw shouldNotReachHere();
- }
-
- public void setInlinedBytes(int inlinedBytes) {
- throw shouldNotReachHere();
- }
- }
-
- @Override
- public CompilerFailureEvent newCompilerFailureEvent() {
- return new EmptyCompilerFailureEvent();
- }
-
- static class EmptyCompilerFailureEvent implements CompilerFailureEvent {
- public void commit() {
- throw shouldNotReachHere();
- }
-
- public boolean shouldWrite() {
- // Events of this class should never been written.
- return false;
- }
-
- public void setCompileId(int compileId) {
- throw shouldNotReachHere();
- }
-
- public void setMessage(String message) {
- throw shouldNotReachHere();
- }
- }
-
-}
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/services/EventProvider.java Wed Nov 09 15:20:30 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,153 +0,0 @@
-/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package jdk.vm.ci.hotspot.services;
-
-import jdk.vm.ci.hotspot.services.EmptyEventProvider.EmptyCompilationEvent;
-import jdk.vm.ci.hotspot.services.EmptyEventProvider.EmptyCompilerFailureEvent;
-import jdk.vm.ci.services.JVMCIPermission;
-
-/**
- * Service-provider class for logging compiler related events.
- */
-public abstract class EventProvider {
-
- private static Void checkPermission() {
- SecurityManager sm = System.getSecurityManager();
- if (sm != null) {
- sm.checkPermission(new JVMCIPermission());
- }
- return null;
- }
-
- @SuppressWarnings("unused")
- EventProvider(Void ignore) {
- }
-
- /**
- * Initializes a new instance of this class.
- *
- * @throws SecurityException if a security manager has been installed and it denies
- * {@link JVMCIPermission}
- */
- protected EventProvider() {
- this(checkPermission());
- }
-
- /**
- * Creates and returns an empty implementation for {@link EventProvider}. This implementation
- * can be used when no logging is requested.
- */
- public static EventProvider createEmptyEventProvider() {
- return new EmptyEventProvider();
- }
-
- /**
- * Creates and returns an empty implementation for {@link CompilationEvent}.
- */
- public static CompilationEvent createEmptyCompilationEvent() {
- return new EmptyCompilationEvent();
- }
-
- /**
- * Creates and returns an empty implementation for {@link CompilationEvent}.
- */
- public static CompilerFailureEvent createEmptyCompilerFailureEvent() {
- return new EmptyCompilerFailureEvent();
- }
-
- /**
- * An instant event is an event that is not considered to have taken any time.
- */
- public interface InstantEvent {
- /**
- * Commits the event.
- */
- void commit();
-
- /**
- * Determines if this particular event instance would be committed to the data stream right
- * now if application called {@link #commit()}. This in turn depends on whether the event is
- * enabled and possible other factors.
- *
- * @return if this event would be committed on a call to {@link #commit()}.
- */
- boolean shouldWrite();
- }
-
- /**
- * Timed events describe an operation that somehow consumes time.
- */
- public interface TimedEvent extends InstantEvent {
- /**
- * Starts the timing for this event.
- */
- void begin();
-
- /**
- * Ends the timing period for this event.
- */
- void end();
- }
-
- /**
- * Creates a new {@link CompilationEvent}.
- *
- * @return a compilation event
- */
- public abstract CompilationEvent newCompilationEvent();
-
- /**
- * A compilation event.
- */
- public interface CompilationEvent extends TimedEvent {
- void setMethod(String method);
-
- void setCompileId(int compileId);
-
- void setCompileLevel(int compileLevel);
-
- void setSucceeded(boolean succeeded);
-
- void setIsOsr(boolean isOsr);
-
- void setCodeSize(int codeSize);
-
- void setInlinedBytes(int inlinedBytes);
- }
-
- /**
- * Creates a new {@link CompilerFailureEvent}.
- *
- * @return a compiler failure event
- */
- public abstract CompilerFailureEvent newCompilerFailureEvent();
-
- /**
- * A compiler failure event.
- */
- public interface CompilerFailureEvent extends InstantEvent {
- void setCompileId(int compileId);
-
- void setMessage(String message);
- }
-}
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/services/HotSpotJVMCICompilerFactory.java Wed Nov 09 15:20:30 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,94 +0,0 @@
-/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package jdk.vm.ci.hotspot.services;
-
-import jdk.vm.ci.runtime.services.JVMCICompilerFactory;
-
-/**
- * HotSpot extensions to {@link JVMCICompilerFactory}.
- */
-public abstract class HotSpotJVMCICompilerFactory extends JVMCICompilerFactory {
-
- /**
- * Gets 0 or more prefixes identifying classes that should by compiled by C1 in simple mode
- * (i.e., {@code CompLevel_simple}) when HotSpot is running with tiered compilation. The
- * prefixes should be class or package names using "/" as the separator, e.g. "jdk/vm/ci".
- *
- * @return 0 or more Strings identifying packages that should by compiled by the first tier only
- * or null if no redirection to C1 should be performed.
- */
- public String[] getTrivialPrefixes() {
- return null;
- }
-
- public enum CompilationLevelAdjustment {
- /**
- * No adjustment.
- */
- None,
-
- /**
- * Adjust based on declaring class of method.
- */
- ByHolder,
-
- /**
- * Adjust based on declaring class, name and signature of method.
- */
- ByFullSignature
- }
-
- /**
- * Determines if this object may want to adjust the compilation level for a method that is being
- * scheduled by the VM for compilation.
- */
- public CompilationLevelAdjustment getCompilationLevelAdjustment() {
- return CompilationLevelAdjustment.None;
- }
-
- public enum CompilationLevel {
- None,
- Simple,
- LimitedProfile,
- FullProfile,
- FullOptimization
- }
-
- /**
- * Potentially modifies the compilation level currently selected by the VM compilation policy
- * for a method.
- *
- * @param declaringClass the class in which the method is declared
- * @param name the name of the method or {@code null} depending on the value that was returned
- * by {@link #getCompilationLevelAdjustment()}
- * @param signature the signature of the method or {@code null} depending on the value that was
- * returned by {@link #getCompilationLevelAdjustment()}
- * @param isOsr specifies if the compilation being scheduled in an OSR compilation
- * @param level the compilation level currently selected by the VM compilation policy
- * @return the compilation level to use for the compilation being scheduled (must be a valid
- * {@code CompLevel} enum value)
- */
- public CompilationLevel adjustCompilationLevel(Class<?> declaringClass, String name, String signature, boolean isOsr, CompilationLevel level) {
- throw new InternalError("Should not reach here");
- }
-}
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/services/HotSpotVMEventListener.java Wed Nov 09 15:20:30 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,78 +0,0 @@
-/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package jdk.vm.ci.hotspot.services;
-
-import jdk.vm.ci.code.CompiledCode;
-import jdk.vm.ci.code.InstalledCode;
-import jdk.vm.ci.hotspot.HotSpotCodeCacheProvider;
-import jdk.vm.ci.services.JVMCIPermission;
-
-/**
- * Service-provider class for responding to VM events.
- */
-public abstract class HotSpotVMEventListener {
-
- private static Void checkPermission() {
- SecurityManager sm = System.getSecurityManager();
- if (sm != null) {
- sm.checkPermission(new JVMCIPermission());
- }
- return null;
- }
-
- @SuppressWarnings("unused")
- HotSpotVMEventListener(Void ignore) {
- }
-
- /**
- * Initializes a new instance of this class.
- *
- * @throws SecurityException if a security manager has been installed and it denies
- * {@link JVMCIPermission}
- */
- protected HotSpotVMEventListener() {
- this(checkPermission());
- }
-
- /**
- * Notifies this client that the VM is shutting down.
- */
- public void notifyShutdown() {
- }
-
- /**
- * Notify on successful install into the code cache.
- *
- * @param hotSpotCodeCacheProvider
- * @param installedCode
- * @param compiledCode
- */
- public void notifyInstall(HotSpotCodeCacheProvider hotSpotCodeCacheProvider, InstalledCode installedCode, CompiledCode compiledCode) {
- }
-
- /**
- * Notify on completion of a bootstrap.
- */
- public void notifyBootstrapFinished() {
- }
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.runtime/src/jdk/vm/ci/runtime/JVMCICompilerFactory.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package jdk.vm.ci.runtime;
+
+import java.io.PrintStream;
+
+/**
+ * Factory for creating JVMCI compilers.
+ */
+public interface JVMCICompilerFactory {
+
+ /**
+ * Get the name of this compiler. The name is used by JVMCI to determine which factory to use.
+ */
+ String getCompilerName();
+
+ /**
+ * Notifies this object that it has been selected to {@linkplain #createCompiler(JVMCIRuntime)
+ * create} a compiler and it should now perform any heavy weight initialization that it deferred
+ * during construction.
+ */
+ default void onSelection() {
+ }
+
+ /**
+ * Create a new instance of a {@link JVMCICompiler}.
+ */
+ JVMCICompiler createCompiler(JVMCIRuntime runtime);
+
+ /**
+ * Prints a description of the properties used to configure this compiler.
+ *
+ * @param out where to print the message
+ */
+ default void printProperties(PrintStream out) {
+ }
+}
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.runtime/src/jdk/vm/ci/runtime/services/JVMCICompilerFactory.java Wed Nov 09 15:20:30 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,73 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package jdk.vm.ci.runtime.services;
-
-import jdk.vm.ci.runtime.JVMCICompiler;
-import jdk.vm.ci.runtime.JVMCIRuntime;
-import jdk.vm.ci.services.JVMCIPermission;
-
-/**
- * Service-provider class for creating JVMCI compilers.
- */
-public abstract class JVMCICompilerFactory {
-
- private static Void checkPermission() {
- SecurityManager sm = System.getSecurityManager();
- if (sm != null) {
- sm.checkPermission(new JVMCIPermission());
- }
- return null;
- }
-
- @SuppressWarnings("unused")
- private JVMCICompilerFactory(Void ignore) {
- }
-
- /**
- * Initializes a new instance of this class.
- *
- * @throws SecurityException if a security manager has been installed and it denies
- * {@link JVMCIPermission}
- */
- protected JVMCICompilerFactory() {
- this(checkPermission());
- }
-
- /**
- * Get the name of this compiler. The name is used by JVMCI to determine which factory to use.
- */
- public abstract String getCompilerName();
-
- /**
- * Notifies this object that it has been selected to {@linkplain #createCompiler(JVMCIRuntime)
- * create} a compiler and it should now perform any heavy weight initialization that it deferred
- * during construction.
- */
- public void onSelection() {
- }
-
- /**
- * Create a new instance of a {@link JVMCICompiler}.
- */
- public abstract JVMCICompiler createCompiler(JVMCIRuntime runtime);
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.services/src/jdk/vm/ci/services/JVMCIServiceLocator.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package jdk.vm.ci.services;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Service-provider class for the runtime to locate providers of JVMCI services where the latter are
+ * not in packages exported by the JVMCI module. As part of instantiating
+ * {@link JVMCIServiceLocator}, all JVMCI packages will be {@linkplain Services#exportJVMCITo(Class)
+ * exported} to the module defining the class of the instantiated object.
+ *
+ * While the {@link #getProvider(Class)} method can be used directly, it's usually easier to use
+ * {@link #getProviders(Class)}.
+ */
+public abstract class JVMCIServiceLocator {
+
+ private static Void checkPermission() {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null) {
+ sm.checkPermission(new JVMCIPermission());
+ }
+ return null;
+ }
+
+ @SuppressWarnings("unused")
+ private JVMCIServiceLocator(Void ignore) {
+ }
+
+ /**
+ * Creates a capability for accessing JVMCI. Once successfully instantiated, JVMCI exports all
+ * its packages to the module defining the type of this object.
+ *
+ * @throws SecurityException if a security manager has been installed and it denies
+ * {@link JVMCIPermission}
+ */
+ protected JVMCIServiceLocator() {
+ this(checkPermission());
+ Services.exportJVMCITo(getClass());
+ }
+
+ /**
+ * Gets the provider of the service defined by {@code service} or {@code null} if this object
+ * does not have a provider for {@code service}.
+ */
+ public abstract <S> S getProvider(Class<S> service);
+
+ /**
+ * Gets the providers of the service defined by {@code service} by querying the
+ * {@link JVMCIServiceLocator} providers obtained by {@link Services#load(Class)}.
+ */
+ public static <S> List<S> getProviders(Class<S> service) {
+ List<S> providers = new ArrayList<>();
+ for (JVMCIServiceLocator access : Services.load(JVMCIServiceLocator.class)) {
+ S provider = access.getProvider(service);
+ if (provider != null) {
+ providers.add(provider);
+ }
+ }
+ return providers;
+ }
+}
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.sparc/src/jdk/vm/ci/sparc/SPARC.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.sparc/src/jdk/vm/ci/sparc/SPARC.java Wed Nov 09 10:04:43 2016 -0800
@@ -349,7 +349,6 @@
SUN4V,
BLK_INIT_INSTRUCTIONS,
FMAF,
- FMAU,
SPARC64_FAMILY,
M_FAMILY,
T_FAMILY,
--- a/hotspot/src/jdk.vm.ci/share/classes/module-info.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/jdk.vm.ci/share/classes/module-info.java Wed Nov 09 10:04:43 2016 -0800
@@ -25,12 +25,9 @@
module jdk.vm.ci {
exports jdk.vm.ci.services;
- exports jdk.vm.ci.runtime.services;
- exports jdk.vm.ci.hotspot.services;
- uses jdk.vm.ci.hotspot.services.HotSpotVMEventListener;
+ uses jdk.vm.ci.services.JVMCIServiceLocator;
uses jdk.vm.ci.hotspot.HotSpotJVMCIBackendFactory;
- uses jdk.vm.ci.runtime.services.JVMCICompilerFactory;
provides jdk.vm.ci.hotspot.HotSpotJVMCIBackendFactory with
jdk.vm.ci.hotspot.aarch64.AArch64HotSpotJVMCIBackendFactory;
--- a/hotspot/src/os/solaris/vm/os_solaris.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/os/solaris/vm/os_solaris.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -2563,7 +2563,7 @@
uint64_t outdata[2];
uint_t validity = 0;
- if (os::Solaris::meminfo(&addr, 1, info_types, 2, outdata, &validity) < 0) {
+ if (meminfo(&addr, 1, info_types, 2, outdata, &validity) < 0) {
return false;
}
@@ -2601,7 +2601,7 @@
addrs_count++;
}
- if (os::Solaris::meminfo(addrs, addrs_count, info_types, types, outdata, validity) < 0) {
+ if (meminfo(addrs, addrs_count, info_types, types, outdata, validity) < 0) {
return NULL;
}
@@ -4160,9 +4160,6 @@
void report_error(const char* file_name, int line_no, const char* title,
const char* format, ...);
-// (Static) wrapper for getisax(2) call.
-os::Solaris::getisax_func_t os::Solaris::_getisax = 0;
-
// (Static) wrappers for the liblgrp API
os::Solaris::lgrp_home_func_t os::Solaris::_lgrp_home;
os::Solaris::lgrp_init_func_t os::Solaris::_lgrp_init;
@@ -4174,9 +4171,6 @@
os::Solaris::lgrp_cookie_stale_func_t os::Solaris::_lgrp_cookie_stale;
os::Solaris::lgrp_cookie_t os::Solaris::_lgrp_cookie = 0;
-// (Static) wrapper for meminfo() call.
-os::Solaris::meminfo_func_t os::Solaris::_meminfo = 0;
-
static address resolve_symbol_lazy(const char* name) {
address addr = (address) dlsym(RTLD_DEFAULT, name);
if (addr == NULL) {
@@ -4300,27 +4294,6 @@
return false;
}
-void os::Solaris::misc_sym_init() {
- address func;
-
- // getisax
- func = resolve_symbol_lazy("getisax");
- if (func != NULL) {
- os::Solaris::_getisax = CAST_TO_FN_PTR(getisax_func_t, func);
- }
-
- // meminfo
- func = resolve_symbol_lazy("meminfo");
- if (func != NULL) {
- os::Solaris::set_meminfo(CAST_TO_FN_PTR(meminfo_func_t, func));
- }
-}
-
-uint_t os::Solaris::getisax(uint32_t* array, uint_t n) {
- assert(_getisax != NULL, "_getisax not set");
- return _getisax(array, n);
-}
-
// int pset_getloadavg(psetid_t pset, double loadavg[], int nelem);
typedef long (*pset_getloadavg_type)(psetid_t pset, double loadavg[], int nelem);
static pset_getloadavg_type pset_getloadavg_ptr = NULL;
@@ -4351,10 +4324,6 @@
Solaris::initialize_system_info();
- // Initialize misc. symbols as soon as possible, so we can use them
- // if we need them.
- Solaris::misc_sym_init();
-
int fd = ::open("/dev/zero", O_RDWR);
if (fd < 0) {
fatal("os::init: cannot open /dev/zero (%s)", os::strerror(errno));
--- a/hotspot/src/os/solaris/vm/os_solaris.hpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/os/solaris/vm/os_solaris.hpp Wed Nov 09 10:04:43 2016 -0800
@@ -73,8 +73,6 @@
LGRP_VIEW_OS // what's available to operating system
} lgrp_view_t;
- typedef uint_t (*getisax_func_t)(uint32_t* array, uint_t n);
-
typedef lgrp_id_t (*lgrp_home_func_t)(idtype_t idtype, id_t id);
typedef lgrp_cookie_t (*lgrp_init_func_t)(lgrp_view_t view);
typedef int (*lgrp_fini_func_t)(lgrp_cookie_t cookie);
@@ -86,11 +84,6 @@
lgrp_rsrc_t type);
typedef int (*lgrp_nlgrps_func_t)(lgrp_cookie_t cookie);
typedef int (*lgrp_cookie_stale_func_t)(lgrp_cookie_t cookie);
- typedef int (*meminfo_func_t)(const uint64_t inaddr[], int addr_count,
- const uint_t info_req[], int info_count,
- uint64_t outdata[], uint_t validity[]);
-
- static getisax_func_t _getisax;
static lgrp_home_func_t _lgrp_home;
static lgrp_init_func_t _lgrp_init;
@@ -102,8 +95,6 @@
static lgrp_cookie_stale_func_t _lgrp_cookie_stale;
static lgrp_cookie_t _lgrp_cookie;
- static meminfo_func_t _meminfo;
-
// Large Page Support
static bool is_valid_page_size(size_t bytes);
static size_t page_size_for_alignment(size_t alignment);
@@ -191,8 +182,6 @@
static void libthread_init();
static void synchronization_init();
static bool liblgrp_init();
- // Load miscellaneous symbols.
- static void misc_sym_init();
// This boolean allows users to forward their own non-matching signals
// to JVM_handle_solaris_signal, harmlessly.
static bool signal_handlers_are_installed;
@@ -272,17 +261,6 @@
}
static lgrp_cookie_t lgrp_cookie() { return _lgrp_cookie; }
- static bool supports_getisax() { return _getisax != NULL; }
- static uint_t getisax(uint32_t* array, uint_t n);
-
- static void set_meminfo(meminfo_func_t func) { _meminfo = func; }
- static int meminfo (const uint64_t inaddr[], int addr_count,
- const uint_t info_req[], int info_count,
- uint64_t outdata[], uint_t validity[]) {
- return _meminfo != NULL ? _meminfo(inaddr, addr_count, info_req, info_count,
- outdata, validity) : -1;
- }
-
static sigset_t* unblocked_signals();
static sigset_t* vm_signals();
static sigset_t* allowdebug_blocked_signals();
--- a/hotspot/src/os/windows/vm/os_windows.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/os/windows/vm/os_windows.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -784,7 +784,7 @@
__try {
RaiseException (MS_VC_EXCEPTION, 0, sizeof(info)/sizeof(DWORD), (const ULONG_PTR*)&info );
- } __except(EXCEPTION_CONTINUE_EXECUTION) {}
+ } __except(EXCEPTION_EXECUTE_HANDLER) {}
}
bool os::distribute_processes(uint length, uint* distribution) {
--- a/hotspot/src/os/windows/vm/perfMemory_windows.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/os/windows/vm/perfMemory_windows.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -1404,12 +1404,14 @@
objectname); /* name for object */
if (fmh == NULL) {
+ DWORD lasterror = GetLastError();
if (PrintMiscellaneous && Verbose) {
warning("OpenFileMapping failed for shared memory object %s:"
- " lasterror = %d\n", objectname, GetLastError());
+ " lasterror = %d\n", objectname, lasterror);
}
- THROW_MSG_(vmSymbols::java_lang_Exception(),
- "Could not open PerfMemory", INVALID_HANDLE_VALUE);
+ THROW_MSG_(vmSymbols::java_lang_IllegalArgumentException(),
+ err_msg("Could not open PerfMemory, error %d", lasterror),
+ INVALID_HANDLE_VALUE);
}
return fmh;;
--- a/hotspot/src/os_cpu/solaris_sparc/vm/vm_version_solaris_sparc.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/os_cpu/solaris_sparc/vm/vm_version_solaris_sparc.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -343,8 +343,15 @@
#define _SC_L2CACHE_LINESZ 527 /* Size of L2 cache line */
#endif
+// Hardware capability bits that appeared after Solaris 11.1
+#ifndef AV_SPARC_FMAF
+#define AV_SPARC_FMAF 0x00000100 /* Fused Multiply-Add */
+#endif
+#ifndef AV2_SPARC_SPARC5
+#define AV2_SPARC_SPARC5 0x00000008 /* The 29 new fp and sub instructions */
+#endif
+
int VM_Version::platform_features(int features) {
- assert(os::Solaris::supports_getisax(), "getisax() must be available");
// Check 32-bit architecture.
if (Sysinfo(SI_ARCHITECTURE_32).match("sparc")) {
@@ -357,119 +364,75 @@
}
// Extract valid instruction set extensions.
- uint_t avs[2];
- uint_t avn = os::Solaris::getisax(avs, 2);
- assert(avn <= 2, "should return two or less av's");
- uint_t av = avs[0];
-
- log_info(os, cpu)("getisax(2) returned: " PTR32_FORMAT, av);
- if (avn > 1) {
- log_info(os, cpu)(" " PTR32_FORMAT, avs[1]);
- }
+ uint_t avs[AV_HW2_IDX + 1];
+ uint_t avn = getisax(avs, ARRAY_SIZE(avs));
- if (av & AV_SPARC_MUL32) features |= hardware_mul32_m;
- if (av & AV_SPARC_DIV32) features |= hardware_div32_m;
- if (av & AV_SPARC_FSMULD) features |= hardware_fsmuld_m;
- if (av & AV_SPARC_V8PLUS) features |= v9_instructions_m;
- if (av & AV_SPARC_POPC) features |= hardware_popc_m;
- if (av & AV_SPARC_VIS) features |= vis1_instructions_m;
- if (av & AV_SPARC_VIS2) features |= vis2_instructions_m;
- if (avn > 1) {
- uint_t av2 = avs[1];
-#ifndef AV2_SPARC_SPARC5
-#define AV2_SPARC_SPARC5 0x00000008 /* The 29 new fp and sub instructions */
-#endif
- if (av2 & AV2_SPARC_SPARC5) features |= sparc5_instructions_m;
+ log_info(os, cpu)("getisax(2) returned %d words:", avn);
+ for (int i = 0; i < avn; i++) {
+ log_info(os, cpu)(" word %d: " PTR32_FORMAT, i, avs[i]);
}
- // We only build on Solaris 10 and up, but some of the values below
- // are not defined on all versions of Solaris 10, so we define them,
- // if necessary.
-#ifndef AV_SPARC_ASI_BLK_INIT
-#define AV_SPARC_ASI_BLK_INIT 0x0080 /* ASI_BLK_INIT_xxx ASI */
-#endif
- if (av & AV_SPARC_ASI_BLK_INIT) features |= blk_init_instructions_m;
-
-#ifndef AV_SPARC_FMAF
-#define AV_SPARC_FMAF 0x0100 /* Fused Multiply-Add */
-#endif
- if (av & AV_SPARC_FMAF) features |= fmaf_instructions_m;
-
-#ifndef AV_SPARC_FMAU
-#define AV_SPARC_FMAU 0x0200 /* Unfused Multiply-Add */
-#endif
- if (av & AV_SPARC_FMAU) features |= fmau_instructions_m;
-
-#ifndef AV_SPARC_VIS3
-#define AV_SPARC_VIS3 0x0400 /* VIS3 instruction set extensions */
-#endif
- if (av & AV_SPARC_VIS3) features |= vis3_instructions_m;
+ uint_t av1 = avs[AV_HW1_IDX];
+ if (av1 & AV_SPARC_MUL32) features |= hardware_mul32_m;
+ if (av1 & AV_SPARC_DIV32) features |= hardware_div32_m;
+ if (av1 & AV_SPARC_FSMULD) features |= hardware_fsmuld_m;
+ if (av1 & AV_SPARC_V8PLUS) features |= v9_instructions_m;
+ if (av1 & AV_SPARC_POPC) features |= hardware_popc_m;
+ if (av1 & AV_SPARC_VIS) features |= vis1_instructions_m;
+ if (av1 & AV_SPARC_VIS2) features |= vis2_instructions_m;
+ if (av1 & AV_SPARC_ASI_BLK_INIT) features |= blk_init_instructions_m;
+ if (av1 & AV_SPARC_FMAF) features |= fmaf_instructions_m;
+ if (av1 & AV_SPARC_VIS3) features |= vis3_instructions_m;
+ if (av1 & AV_SPARC_CBCOND) features |= cbcond_instructions_m;
+ if (av1 & AV_SPARC_CRC32C) features |= crc32c_instruction_m;
+ if (av1 & AV_SPARC_AES) features |= aes_instructions_m;
+ if (av1 & AV_SPARC_SHA1) features |= sha1_instruction_m;
+ if (av1 & AV_SPARC_SHA256) features |= sha256_instruction_m;
+ if (av1 & AV_SPARC_SHA512) features |= sha512_instruction_m;
-#ifndef AV_SPARC_CBCOND
-#define AV_SPARC_CBCOND 0x10000000 /* compare and branch instrs supported */
-#endif
- if (av & AV_SPARC_CBCOND) features |= cbcond_instructions_m;
-
-#ifndef AV_SPARC_CRC32C
-#define AV_SPARC_CRC32C 0x20000000 /* crc32c instruction supported */
-#endif
- if (av & AV_SPARC_CRC32C) features |= crc32c_instruction_m;
-
-#ifndef AV_SPARC_AES
-#define AV_SPARC_AES 0x00020000 /* aes instrs supported */
-#endif
- if (av & AV_SPARC_AES) features |= aes_instructions_m;
-
-#ifndef AV_SPARC_SHA1
-#define AV_SPARC_SHA1 0x00400000 /* sha1 instruction supported */
-#endif
- if (av & AV_SPARC_SHA1) features |= sha1_instruction_m;
-
-#ifndef AV_SPARC_SHA256
-#define AV_SPARC_SHA256 0x00800000 /* sha256 instruction supported */
-#endif
- if (av & AV_SPARC_SHA256) features |= sha256_instruction_m;
-
-#ifndef AV_SPARC_SHA512
-#define AV_SPARC_SHA512 0x01000000 /* sha512 instruction supported */
-#endif
- if (av & AV_SPARC_SHA512) features |= sha512_instruction_m;
+ if (avn > AV_HW2_IDX) {
+ uint_t av2 = avs[AV_HW2_IDX];
+ if (av2 & AV2_SPARC_SPARC5) features |= sparc5_instructions_m;
+ }
// Determine the machine type.
if (Sysinfo(SI_MACHINE).match("sun4v")) {
features |= sun4v_m;
}
- bool use_solaris_12_api = false;
- Sysinfo impl(SI_CPUBRAND);
- if (impl.valid()) {
- // If SI_CPUBRAND works, that means Solaris 12 API to get the cache line sizes
- // is available to us as well
- use_solaris_12_api = true;
- features |= parse_features(impl.value());
+ // If SI_CPUBRAND works, that means Solaris 12 API to get the cache line sizes
+ // is available to us as well
+ Sysinfo cpu_info(SI_CPUBRAND);
+ bool use_solaris_12_api = cpu_info.valid();
+ const char* impl;
+ int impl_m = 0;
+ if (use_solaris_12_api) {
+ impl = cpu_info.value();
+ log_info(os, cpu)("Parsing CPU implementation from %s", impl);
+ impl_m = parse_features(impl);
} else {
// Otherwise use kstat to determine the machine type.
kstat_ctl_t* kc = kstat_open();
- kstat_t* ksp = kstat_lookup(kc, (char*)"cpu_info", -1, NULL);
- const char* implementation;
- bool has_implementation = false;
- if (ksp != NULL) {
- if (kstat_read(kc, ksp, NULL) != -1 && ksp->ks_data != NULL) {
- kstat_named_t* knm = (kstat_named_t *)ksp->ks_data;
- for (int i = 0; i < ksp->ks_ndata; i++) {
- if (strcmp((const char*)&(knm[i].name),"implementation") == 0) {
- implementation = KSTAT_NAMED_STR_PTR(&knm[i]);
- has_implementation = true;
- log_info(os, cpu)("cpu_info.implementation: %s", implementation);
- features |= parse_features(implementation);
- break;
+ if (kc != NULL) {
+ kstat_t* ksp = kstat_lookup(kc, (char*)"cpu_info", -1, NULL);
+ if (ksp != NULL) {
+ if (kstat_read(kc, ksp, NULL) != -1 && ksp->ks_data != NULL) {
+ kstat_named_t* knm = (kstat_named_t *)ksp->ks_data;
+ for (int i = 0; i < ksp->ks_ndata; i++) {
+ if (strcmp((const char*)&(knm[i].name), "implementation") == 0) {
+ impl = KSTAT_NAMED_STR_PTR(&knm[i]);
+ log_info(os, cpu)("Parsing CPU implementation from %s", impl);
+ impl_m = parse_features(impl);
+ break;
+ }
}
- } // for(
+ }
}
+ kstat_close(kc);
}
- assert(has_implementation, "unknown cpu info (changed kstat interface?)");
- kstat_close(kc);
}
+ assert(impl_m != 0, "Unknown CPU implementation %s", impl);
+ features |= impl_m;
bool is_sun4v = (features & sun4v_m) != 0;
if (use_solaris_12_api && is_sun4v) {
--- a/hotspot/src/share/vm/asm/assembler.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/share/vm/asm/assembler.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -153,6 +153,8 @@
void Label::add_patch_at(CodeBuffer* cb, int branch_loc) {
assert(_loc == -1, "Label is unbound");
+ // Don't add patch locations during scratch emit.
+ if (cb->insts()->scratch_emit()) { return; }
if (_patch_index < PatchCacheSize) {
_patches[_patch_index] = branch_loc;
} else {
--- a/hotspot/src/share/vm/asm/codeBuffer.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/share/vm/asm/codeBuffer.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -331,6 +331,8 @@
}
void CodeSection::relocate(address at, RelocationHolder const& spec, int format) {
+ // Do not relocate in scratch buffers.
+ if (scratch_emit()) { return; }
Relocation* reloc = spec.reloc();
relocInfo::relocType rtype = (relocInfo::relocType) reloc->type();
if (rtype == relocInfo::none) return;
--- a/hotspot/src/share/vm/asm/codeBuffer.hpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/share/vm/asm/codeBuffer.hpp Wed Nov 09 10:04:43 2016 -0800
@@ -92,6 +92,7 @@
address _locs_point; // last relocated position (grows upward)
bool _locs_own; // did I allocate the locs myself?
bool _frozen; // no more expansion of this section
+ bool _scratch_emit; // Buffer is used for scratch emit, don't relocate.
char _index; // my section number (SECT_INST, etc.)
CodeBuffer* _outer; // enclosing CodeBuffer
@@ -108,6 +109,7 @@
_locs_point = NULL;
_locs_own = false;
_frozen = false;
+ _scratch_emit = false;
debug_only(_index = (char)-1);
debug_only(_outer = (CodeBuffer*)badAddress);
}
@@ -166,6 +168,10 @@
bool is_frozen() const { return _frozen; }
bool has_locs() const { return _locs_end != NULL; }
+ // Mark scratch buffer.
+ void set_scratch_emit() { _scratch_emit = true; }
+ bool scratch_emit() { return _scratch_emit; }
+
CodeBuffer* outer() const { return _outer; }
// is a given address in this section? (2nd version is end-inclusive)
--- a/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -1493,6 +1493,21 @@
// Check to see whether we are inlining. If so, Return
// instructions become Gotos to the continuation point.
if (continuation() != NULL) {
+
+ int invoke_bci = state()->caller_state()->bci();
+
+ if (x != NULL && !ignore_return) {
+ ciMethod* caller = state()->scope()->caller()->method();
+ Bytecodes::Code invoke_raw_bc = caller->raw_code_at_bci(invoke_bci);
+ if (invoke_raw_bc == Bytecodes::_invokehandle || invoke_raw_bc == Bytecodes::_invokedynamic) {
+ ciType* declared_ret_type = caller->get_declared_signature_at_bci(invoke_bci)->return_type();
+ if (declared_ret_type->is_klass() && x->exact_type() == NULL &&
+ x->declared_type() != declared_ret_type && declared_ret_type != compilation()->env()->Object_klass()) {
+ x = append(new TypeCast(declared_ret_type->as_klass(), x, copy_state_before()));
+ }
+ }
+ }
+
assert(!method()->is_synchronized() || InlineSynchronizedMethods, "can not inline synchronized methods yet");
if (compilation()->env()->dtrace_method_probes()) {
@@ -1516,7 +1531,6 @@
// State at end of inlined method is the state of the caller
// without the method parameters on stack, including the
// return value, if any, of the inlined method on operand stack.
- int invoke_bci = state()->caller_state()->bci();
set_state(state()->caller_state()->copy_for_parsing());
if (x != NULL) {
if (!ignore_return) {
@@ -1929,7 +1943,7 @@
// number of implementors for decl_interface is 0 or 1. If
// it's 0 then no class implements decl_interface and there's
// no point in inlining.
- if (!holder->is_loaded() || decl_interface->nof_implementors() != 1 || decl_interface->has_default_methods()) {
+ if (!holder->is_loaded() || decl_interface->nof_implementors() != 1 || decl_interface->has_nonstatic_concrete_methods()) {
singleton = NULL;
}
}
@@ -4308,7 +4322,7 @@
void GraphBuilder::profile_call(ciMethod* callee, Value recv, ciKlass* known_holder, Values* obj_args, bool inlined) {
assert(known_holder == NULL || (known_holder->is_instance_klass() &&
(!known_holder->is_interface() ||
- ((ciInstanceKlass*)known_holder)->has_default_methods())), "should be default method");
+ ((ciInstanceKlass*)known_holder)->has_nonstatic_concrete_methods())), "should be non-static concrete method");
if (known_holder != NULL) {
if (known_holder->exact_klass() == NULL) {
known_holder = compilation()->cha_exact_type(known_holder);
--- a/hotspot/src/share/vm/c1/c1_Instruction.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/share/vm/c1/c1_Instruction.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -360,7 +360,8 @@
}
ciType* Invoke::declared_type() const {
- ciType *t = _target->signature()->return_type();
+ ciSignature* declared_signature = state()->scope()->method()->get_declared_signature_at_bci(state()->bci());
+ ciType *t = declared_signature->return_type();
assert(t->basic_type() != T_VOID, "need return value of void method?");
return t;
}
--- a/hotspot/src/share/vm/ci/ciInstanceKlass.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/share/vm/ci/ciInstanceKlass.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -58,7 +58,7 @@
_init_state = ik->init_state();
_nonstatic_field_size = ik->nonstatic_field_size();
_has_nonstatic_fields = ik->has_nonstatic_fields();
- _has_default_methods = ik->has_default_methods();
+ _has_nonstatic_concrete_methods = ik->has_nonstatic_concrete_methods();
_is_anonymous = ik->is_anonymous();
_nonstatic_fields = NULL; // initialized lazily by compute_nonstatic_fields:
_has_injected_fields = -1;
--- a/hotspot/src/share/vm/ci/ciInstanceKlass.hpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/share/vm/ci/ciInstanceKlass.hpp Wed Nov 09 10:04:43 2016 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -52,7 +52,7 @@
bool _has_finalizer;
bool _has_subklass;
bool _has_nonstatic_fields;
- bool _has_default_methods;
+ bool _has_nonstatic_concrete_methods;
bool _is_anonymous;
ciFlags _flags;
@@ -174,9 +174,9 @@
return 2;
}
}
- bool has_default_methods() {
+ bool has_nonstatic_concrete_methods() {
assert(is_loaded(), "must be loaded");
- return _has_default_methods;
+ return _has_nonstatic_concrete_methods;
}
bool is_anonymous() {
--- a/hotspot/src/share/vm/ci/ciMethod.hpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/share/vm/ci/ciMethod.hpp Wed Nov 09 10:04:43 2016 -0800
@@ -256,6 +256,14 @@
return get_method_at_bci(bci, ignored_will_link, &ignored_declared_signature);
}
+ ciSignature* get_declared_signature_at_bci(int bci) {
+ bool ignored_will_link;
+ ciSignature* declared_signature;
+ get_method_at_bci(bci, ignored_will_link, &declared_signature);
+ assert(declared_signature != NULL, "cannot be null");
+ return declared_signature;
+ }
+
// Given a certain calling environment, find the monomorphic target
// for the call. Return NULL if the call is not monomorphic in
// its calling environment.
--- a/hotspot/src/share/vm/classfile/classFileParser.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/share/vm/classfile/classFileParser.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -798,11 +798,11 @@
void ClassFileParser::parse_interfaces(const ClassFileStream* const stream,
const int itfs_len,
ConstantPool* const cp,
- bool* const has_default_methods,
+ bool* const has_nonstatic_concrete_methods,
TRAPS) {
assert(stream != NULL, "invariant");
assert(cp != NULL, "invariant");
- assert(has_default_methods != NULL, "invariant");
+ assert(has_nonstatic_concrete_methods != NULL, "invariant");
if (itfs_len == 0) {
_local_interfaces = Universe::the_empty_klass_array();
@@ -844,8 +844,8 @@
"Implementing class");
}
- if (InstanceKlass::cast(interf())->has_default_methods()) {
- *has_default_methods = true;
+ if (InstanceKlass::cast(interf())->has_nonstatic_concrete_methods()) {
+ *has_nonstatic_concrete_methods = true;
}
_local_interfaces->at_put(index, interf());
}
@@ -2830,12 +2830,12 @@
bool is_interface,
AccessFlags* promoted_flags,
bool* has_final_method,
- bool* declares_default_methods,
+ bool* declares_nonstatic_concrete_methods,
TRAPS) {
assert(cfs != NULL, "invariant");
assert(promoted_flags != NULL, "invariant");
assert(has_final_method != NULL, "invariant");
- assert(declares_default_methods != NULL, "invariant");
+ assert(declares_nonstatic_concrete_methods != NULL, "invariant");
assert(NULL == _methods, "invariant");
@@ -2860,11 +2860,11 @@
if (method->is_final()) {
*has_final_method = true;
}
- // declares_default_methods: declares concrete instance methods, any access flags
+ // declares_nonstatic_concrete_methods: declares concrete instance methods, any access flags
// used for interface initialization, and default method inheritance analysis
- if (is_interface && !(*declares_default_methods)
+ if (is_interface && !(*declares_nonstatic_concrete_methods)
&& !method->is_abstract() && !method->is_static()) {
- *declares_default_methods = true;
+ *declares_nonstatic_concrete_methods = true;
}
_methods->at_put(index, method);
}
@@ -5250,8 +5250,8 @@
ik->set_minor_version(_minor_version);
ik->set_major_version(_major_version);
- ik->set_has_default_methods(_has_default_methods);
- ik->set_declares_default_methods(_declares_default_methods);
+ ik->set_has_nonstatic_concrete_methods(_has_nonstatic_concrete_methods);
+ ik->set_declares_nonstatic_concrete_methods(_declares_nonstatic_concrete_methods);
if (_host_klass != NULL) {
assert (ik->is_anonymous(), "should be the same");
@@ -5311,12 +5311,9 @@
// check if this class overrides any final method
check_final_method_override(ik, CHECK);
- // check that if this class is an interface then it doesn't have static methods
- if (ik->is_interface()) {
- /* An interface in a JAVA 8 classfile can be static */
- if (_major_version < JAVA_8_VERSION) {
- check_illegal_static_method(ik, CHECK);
- }
+ // reject static interface methods prior to Java 8
+ if (ik->is_interface() && _major_version < JAVA_8_VERSION) {
+ check_illegal_static_method(ik, CHECK);
}
// Obtain this_klass' module entry
@@ -5336,9 +5333,9 @@
assert(_all_mirandas != NULL, "invariant");
- // Generate any default methods - default methods are interface methods
- // that have a default implementation. This is new with Lambda project.
- if (_has_default_methods ) {
+ // Generate any default methods - default methods are public interface methods
+ // that have a default implementation. This is new with Java 8.
+ if (_has_nonstatic_concrete_methods) {
DefaultMethods::generate_default_methods(ik,
_all_mirandas,
CHECK);
@@ -5523,8 +5520,8 @@
_java_fields_count(0),
_need_verify(false),
_relax_verify(false),
- _has_default_methods(false),
- _declares_default_methods(false),
+ _has_nonstatic_concrete_methods(false),
+ _declares_nonstatic_concrete_methods(false),
_has_final_method(false),
_has_finalizer(false),
_has_empty_finalizer(false),
@@ -5778,9 +5775,22 @@
// Anonymous classes such as generated LambdaForm classes are also not included.
if (SystemDictionaryShared::is_sharing_possible(_loader_data) &&
_host_klass == NULL) {
+ oop class_loader = _loader_data->class_loader();
ResourceMark rm(THREAD);
- classlist_file->print_cr("%s", _class_name->as_C_string());
- classlist_file->flush();
+ // For the boot and platform class loaders, check if the class is not found in the
+ // java runtime image. Additional check for the boot class loader is if the class
+ // is not found in the boot loader's appended entries. This indicates that the class
+ // is not useable during run time, such as the ones found in the --patch-module entries,
+ // so it should not be included in the classlist file.
+ if (((class_loader == NULL && !ClassLoader::contains_append_entry(stream->source())) ||
+ SystemDictionary::is_platform_class_loader(class_loader)) &&
+ !ClassLoader::is_jrt(stream->source())) {
+ tty->print_cr("skip writing class %s from source %s to classlist file",
+ _class_name->as_C_string(), stream->source());
+ } else {
+ classlist_file->print_cr("%s", _class_name->as_C_string());
+ classlist_file->flush();
+ }
}
}
#endif
@@ -5798,7 +5808,7 @@
parse_interfaces(stream,
_itfs_len,
cp,
- &_has_default_methods,
+ &_has_nonstatic_concrete_methods,
CHECK);
assert(_local_interfaces != NULL, "invariant");
@@ -5821,7 +5831,7 @@
_access_flags.is_interface(),
&promoted_flags,
&_has_final_method,
- &_declares_default_methods,
+ &_declares_nonstatic_concrete_methods,
CHECK);
assert(_methods != NULL, "invariant");
@@ -5829,8 +5839,8 @@
// promote flags from parse_methods() to the klass' flags
_access_flags.add_promoted_flags(promoted_flags.as_int());
- if (_declares_default_methods) {
- _has_default_methods = true;
+ if (_declares_nonstatic_concrete_methods) {
+ _has_nonstatic_concrete_methods = true;
}
// Additional attributes/annotations
@@ -5884,8 +5894,8 @@
}
if (_super_klass != NULL) {
- if (_super_klass->has_default_methods()) {
- _has_default_methods = true;
+ if (_super_klass->has_nonstatic_concrete_methods()) {
+ _has_nonstatic_concrete_methods = true;
}
if (_super_klass->is_interface()) {
--- a/hotspot/src/share/vm/classfile/classFileParser.hpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/share/vm/classfile/classFileParser.hpp Wed Nov 09 10:04:43 2016 -0800
@@ -139,8 +139,8 @@
bool _need_verify;
bool _relax_verify;
- bool _has_default_methods;
- bool _declares_default_methods;
+ bool _has_nonstatic_concrete_methods;
+ bool _declares_nonstatic_concrete_methods;
bool _has_final_method;
// precomputed flags
@@ -186,7 +186,7 @@
void parse_interfaces(const ClassFileStream* const stream,
const int itfs_len,
ConstantPool* const cp,
- bool* has_default_methods,
+ bool* has_nonstatic_concrete_methods,
TRAPS);
const InstanceKlass* parse_super_class(ConstantPool* const cp,
@@ -224,7 +224,7 @@
bool is_interface,
AccessFlags* const promoted_flags,
bool* const has_final_method,
- bool* const declares_default_methods,
+ bool* const declares_nonstatic_concrete_methods,
TRAPS);
const u2* parse_exception_table(const ClassFileStream* const stream,
--- a/hotspot/src/share/vm/classfile/classLoader.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/share/vm/classfile/classLoader.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -81,7 +81,6 @@
typedef void (JNICALL *ZipClose_t)(jzfile *zip);
typedef jzentry* (JNICALL *FindEntry_t)(jzfile *zip, const char *name, jint *sizeP, jint *nameLen);
typedef jboolean (JNICALL *ReadEntry_t)(jzfile *zip, jzentry *entry, unsigned char *buf, char *namebuf);
-typedef jboolean (JNICALL *ReadMappedEntry_t)(jzfile *zip, jzentry *entry, unsigned char **buf, char *namebuf);
typedef jzentry* (JNICALL *GetNextEntry_t)(jzfile *zip, jint n);
typedef jboolean (JNICALL *ZipInflateFully_t)(void *inBuf, jlong inLen, void *outBuf, jlong outLen, char **pmsg);
typedef jint (JNICALL *Crc32_t)(jint crc, const jbyte *buf, jint len);
@@ -91,7 +90,6 @@
static ZipClose_t ZipClose = NULL;
static FindEntry_t FindEntry = NULL;
static ReadEntry_t ReadEntry = NULL;
-static ReadMappedEntry_t ReadMappedEntry = NULL;
static GetNextEntry_t GetNextEntry = NULL;
static canonicalize_fn_t CanonicalizeEntry = NULL;
static ZipInflateFully_t ZipInflateFully = NULL;
@@ -353,15 +351,10 @@
filename = NEW_RESOURCE_ARRAY(char, name_len + 1);
}
- // file found, get pointer to the entry in mmapped jar file.
- if (ReadMappedEntry == NULL ||
- !(*ReadMappedEntry)(_zip, entry, &buffer, filename)) {
- // mmapped access not available, perhaps due to compression,
- // read contents into resource array
- int size = (*filesize) + ((nul_terminate) ? 1 : 0);
- buffer = NEW_RESOURCE_ARRAY(u1, size);
- if (!(*ReadEntry)(_zip, entry, buffer, filename)) return NULL;
- }
+ // read contents into resource array
+ int size = (*filesize) + ((nul_terminate) ? 1 : 0);
+ buffer = NEW_RESOURCE_ARRAY(u1, size);
+ if (!(*ReadEntry)(_zip, entry, buffer, filename)) return NULL;
// return result
if (nul_terminate) {
@@ -952,11 +945,11 @@
}
// returns true if entry already on class path
-bool ClassLoader::contains_entry(ClassPathEntry *entry) {
+bool ClassLoader::contains_append_entry(const char* name) {
ClassPathEntry* e = _first_append_entry;
while (e != NULL) {
// assume zip entries have been canonicalized
- if (strcmp(entry->name(), e->name()) == 0) {
+ if (strcmp(name, e->name()) == 0) {
return true;
}
e = e->next();
@@ -998,7 +991,7 @@
// Do not reorder the bootclasspath which would break get_system_package().
// Add new entry to linked list
- if (!check_for_duplicates || !contains_entry(new_entry)) {
+ if (!check_for_duplicates || !contains_append_entry(new_entry->name())) {
ClassLoaderExt::add_class_path_entry(path, check_for_duplicates, new_entry);
}
return true;
@@ -1079,7 +1072,6 @@
ZipClose = CAST_TO_FN_PTR(ZipClose_t, os::dll_lookup(handle, "ZIP_Close"));
FindEntry = CAST_TO_FN_PTR(FindEntry_t, os::dll_lookup(handle, "ZIP_FindEntry"));
ReadEntry = CAST_TO_FN_PTR(ReadEntry_t, os::dll_lookup(handle, "ZIP_ReadEntry"));
- ReadMappedEntry = CAST_TO_FN_PTR(ReadMappedEntry_t, os::dll_lookup(handle, "ZIP_ReadMappedEntry"));
GetNextEntry = CAST_TO_FN_PTR(GetNextEntry_t, os::dll_lookup(handle, "ZIP_GetNextEntry"));
ZipInflateFully = CAST_TO_FN_PTR(ZipInflateFully_t, os::dll_lookup(handle, "ZIP_InflateFully"));
Crc32 = CAST_TO_FN_PTR(Crc32_t, os::dll_lookup(handle, "ZIP_CRC32"));
@@ -2049,7 +2041,6 @@
if (nm != NULL && !m->is_method_handle_intrinsic()) {
// Throw out the code so that the code cache doesn't fill up
nm->make_not_entrant();
- m->clear_code();
}
CompileBroker::compile_method(m, InvocationEntryBci, CompLevel_full_optimization,
methodHandle(), 0, CompileTask::Reason_CTW, THREAD);
@@ -2068,7 +2059,6 @@
if (nm != NULL && !m->is_method_handle_intrinsic()) {
// Throw out the code so that the code cache doesn't fill up
nm->make_not_entrant();
- m->clear_code();
}
}
}
--- a/hotspot/src/share/vm/classfile/classLoader.hpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/share/vm/classfile/classLoader.hpp Wed Nov 09 10:04:43 2016 -0800
@@ -451,7 +451,7 @@
static void set_first_append_entry(ClassPathEntry* entry);
// indicates if class path already contains a entry (exact match by name)
- static bool contains_entry(ClassPathEntry* entry);
+ static bool contains_append_entry(const char* name);
// adds a class path list
static void add_to_list(ClassPathEntry* new_entry);
--- a/hotspot/src/share/vm/classfile/classLoaderData.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/share/vm/classfile/classLoaderData.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -639,7 +639,6 @@
#undef CLD_DUMP_KLASSES
void ClassLoaderData::dump(outputStream * const out) {
- ResourceMark rm;
out->print("ClassLoaderData CLD: " PTR_FORMAT ", loader: " PTR_FORMAT ", loader_klass: " PTR_FORMAT " %s {",
p2i(this), p2i((void *)class_loader()),
p2i(class_loader() != NULL ? class_loader()->klass() : NULL), loader_name());
@@ -656,7 +655,6 @@
#ifdef CLD_DUMP_KLASSES
if (Verbose) {
- ResourceMark rm;
Klass* k = _klasses;
while (k != NULL) {
out->print_cr("klass " PTR_FORMAT ", %s, CT: %d, MUT: %d", k, k->name()->as_C_string(),
--- a/hotspot/src/share/vm/classfile/defaultMethods.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/share/vm/classfile/defaultMethods.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -914,7 +914,7 @@
BytecodeBuffer buffer;
if (log_is_enabled(Debug, defaultmethods)) {
- ResourceMark rm;
+ ResourceMark rm(THREAD);
outputStream* logstream = Log(defaultmethods)::debug_stream();
logstream->print("for slot: ");
slot->print_on(logstream);
@@ -929,6 +929,7 @@
if (method->has_target()) {
Method* selected = method->get_selected_target();
if (selected->method_holder()->is_interface()) {
+ assert(!selected->is_private(), "pushing private interface method as default");
defaults.push(selected);
}
} else if (method->throws_exception()) {
--- a/hotspot/src/share/vm/classfile/javaClasses.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/share/vm/classfile/javaClasses.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -780,19 +780,26 @@
// Put the class on the fixup_module_list to patch later when the java.lang.reflect.Module
// for java.base is known.
assert(!Universe::is_module_initialized(), "Incorrect java.lang.reflect.Module pre module system initialization");
- MutexLocker m1(Module_lock, THREAD);
- // Keep list of classes needing java.base module fixup
- if (!ModuleEntryTable::javabase_defined()) {
- if (fixup_module_field_list() == NULL) {
- GrowableArray<Klass*>* list =
- new (ResourceObj::C_HEAP, mtModule) GrowableArray<Klass*>(500, true);
- set_fixup_module_field_list(list);
+
+ bool javabase_was_defined = false;
+ {
+ MutexLocker m1(Module_lock, THREAD);
+ // Keep list of classes needing java.base module fixup
+ if (!ModuleEntryTable::javabase_defined()) {
+ if (fixup_module_field_list() == NULL) {
+ GrowableArray<Klass*>* list =
+ new (ResourceObj::C_HEAP, mtModule) GrowableArray<Klass*>(500, true);
+ set_fixup_module_field_list(list);
+ }
+ k->class_loader_data()->inc_keep_alive();
+ fixup_module_field_list()->push(k());
+ } else {
+ javabase_was_defined = true;
}
- k->class_loader_data()->inc_keep_alive();
- fixup_module_field_list()->push(k());
- } else {
- // java.base was defined at some point between calling create_mirror()
- // and obtaining the Module_lock, patch this particular class with java.base.
+ }
+
+ // If java.base was already defined then patch this particular class with java.base.
+ if (javabase_was_defined) {
ModuleEntry *javabase_entry = ModuleEntryTable::javabase_moduleEntry();
assert(javabase_entry != NULL && javabase_entry->module() != NULL,
"Setting class module field, java.base should be defined");
@@ -2168,6 +2175,14 @@
const char* str = holder->external_name();
oop classname = StringTable::intern((char*) str, CHECK);
java_lang_StackTraceElement::set_declaringClass(element(), classname);
+ java_lang_StackTraceElement::set_declaringClassObject(element(), holder->java_mirror());
+
+ oop loader = holder->class_loader();
+ if (loader != NULL) {
+ oop loader_name = java_lang_ClassLoader::name(loader);
+ if (loader_name != NULL)
+ java_lang_StackTraceElement::set_classLoaderName(element(), loader_name);
+ }
// The method can be NULL if the requested class version is gone
Symbol* sym = !method.is_null() ? method->name() : holder->constants()->symbol_at(cpref);
@@ -3426,6 +3441,7 @@
bool java_lang_ClassLoader::offsets_computed = false;
int java_lang_ClassLoader::_loader_data_offset = -1;
int java_lang_ClassLoader::parallelCapable_offset = -1;
+int java_lang_ClassLoader::name_offset = -1;
int java_lang_ClassLoader::unnamedModule_offset = -1;
ClassLoaderData** java_lang_ClassLoader::loader_data_addr(oop loader) {
@@ -3446,6 +3462,9 @@
compute_optional_offset(parallelCapable_offset,
k1, vmSymbols::parallelCapable_name(), vmSymbols::concurrenthashmap_signature());
+ compute_offset(name_offset,
+ k1, vmSymbols::name_name(), vmSymbols::string_signature());
+
compute_offset(unnamedModule_offset,
k1, vmSymbols::unnamedModule_name(), vmSymbols::module_signature());
@@ -3457,6 +3476,11 @@
return loader->obj_field(parent_offset);
}
+oop java_lang_ClassLoader::name(oop loader) {
+ assert(is_instance(loader), "loader must be oop");
+ return loader->obj_field(name_offset);
+}
+
bool java_lang_ClassLoader::isAncestor(oop loader, oop cl) {
assert(is_instance(loader), "loader must be oop");
assert(cl == NULL || is_instance(cl), "cl argument must be oop");
@@ -3612,12 +3636,14 @@
int java_lang_System::static_out_offset;
int java_lang_System::static_err_offset;
int java_lang_System::static_security_offset;
-int java_lang_StackTraceElement::declaringClass_offset;
int java_lang_StackTraceElement::methodName_offset;
int java_lang_StackTraceElement::fileName_offset;
int java_lang_StackTraceElement::lineNumber_offset;
int java_lang_StackTraceElement::moduleName_offset;
int java_lang_StackTraceElement::moduleVersion_offset;
+int java_lang_StackTraceElement::classLoaderName_offset;
+int java_lang_StackTraceElement::declaringClass_offset;
+int java_lang_StackTraceElement::classOrLoaderModuleClassName_offset;
int java_lang_StackFrameInfo::_declaringClass_offset;
int java_lang_StackFrameInfo::_memberName_offset;
int java_lang_StackFrameInfo::_bci_offset;
@@ -3662,6 +3688,14 @@
element->obj_field_put(moduleVersion_offset, value);
}
+void java_lang_StackTraceElement::set_classLoaderName(oop element, oop value) {
+ element->obj_field_put(classLoaderName_offset, value);
+}
+
+void java_lang_StackTraceElement::set_declaringClassObject(oop element, oop value) {
+ element->obj_field_put(classOrLoaderModuleClassName_offset, value);
+}
+
// Support for java_lang_StackFrameInfo
void java_lang_StackFrameInfo::set_declaringClass(oop element, oop value) {
element->obj_field_put(_declaringClass_offset, value);
@@ -3777,6 +3811,8 @@
java_lang_System::static_security_offset = java_lang_System::hc_static_security_offset * x;
// java_lang_StackTraceElement
+ java_lang_StackTraceElement::classOrLoaderModuleClassName_offset= java_lang_StackTraceElement::hc_classOrLoaderModuleClassName_offset* x + header;
+ java_lang_StackTraceElement::classLoaderName_offset = java_lang_StackTraceElement::hc_classLoaderName_offset * x + header;
java_lang_StackTraceElement::moduleName_offset = java_lang_StackTraceElement::hc_moduleName_offset * x + header;
java_lang_StackTraceElement::moduleVersion_offset = java_lang_StackTraceElement::hc_moduleVersion_offset * x + header;
java_lang_StackTraceElement::declaringClass_offset = java_lang_StackTraceElement::hc_declaringClass_offset * x + header;
@@ -3978,10 +4014,14 @@
// java.lang.StackTraceElement
- CHECK_OFFSET("java/lang/StackTraceElement", java_lang_StackTraceElement, declaringClass, "Ljava/lang/String;");
- CHECK_OFFSET("java/lang/StackTraceElement", java_lang_StackTraceElement, methodName, "Ljava/lang/String;");
- CHECK_OFFSET("java/lang/StackTraceElement", java_lang_StackTraceElement, fileName, "Ljava/lang/String;");
- CHECK_OFFSET("java/lang/StackTraceElement", java_lang_StackTraceElement, lineNumber, "I");
+ CHECK_OFFSET("java/lang/StackTraceElement", java_lang_StackTraceElement, classOrLoaderModuleClassName, "Ljava/lang/Object;");
+ CHECK_OFFSET("java/lang/StackTraceElement", java_lang_StackTraceElement, classLoaderName, "Ljava/lang/String;");
+ CHECK_OFFSET("java/lang/StackTraceElement", java_lang_StackTraceElement, moduleName, "Ljava/lang/String;");
+ CHECK_OFFSET("java/lang/StackTraceElement", java_lang_StackTraceElement, moduleVersion, "Ljava/lang/String;");
+ CHECK_OFFSET("java/lang/StackTraceElement", java_lang_StackTraceElement, declaringClass, "Ljava/lang/String;");
+ CHECK_OFFSET("java/lang/StackTraceElement", java_lang_StackTraceElement, methodName, "Ljava/lang/String;");
+ CHECK_OFFSET("java/lang/StackTraceElement", java_lang_StackTraceElement, fileName, "Ljava/lang/String;");
+ CHECK_OFFSET("java/lang/StackTraceElement", java_lang_StackTraceElement, lineNumber, "I");
// java.lang.ref.Reference
--- a/hotspot/src/share/vm/classfile/javaClasses.hpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/share/vm/classfile/javaClasses.hpp Wed Nov 09 10:04:43 2016 -0800
@@ -1225,6 +1225,7 @@
static bool offsets_computed;
static int parent_offset;
static int parallelCapable_offset;
+ static int name_offset;
static int unnamedModule_offset;
public:
@@ -1234,6 +1235,7 @@
static ClassLoaderData* loader_data(oop loader);
static oop parent(oop loader);
+ static oop name(oop loader);
static bool isAncestor(oop loader, oop cl);
// Support for parallelCapable field
@@ -1291,14 +1293,18 @@
class java_lang_StackTraceElement: AllStatic {
private:
enum {
- hc_moduleName_offset = 0,
- hc_moduleVersion_offset = 1,
- hc_declaringClass_offset = 2,
- hc_methodName_offset = 3,
- hc_fileName_offset = 4,
- hc_lineNumber_offset = 5
+ hc_classOrLoaderModuleClassName_offset = 0,
+ hc_classLoaderName_offset = 1,
+ hc_moduleName_offset = 2,
+ hc_moduleVersion_offset = 3,
+ hc_declaringClass_offset = 4,
+ hc_methodName_offset = 5,
+ hc_fileName_offset = 6,
+ hc_lineNumber_offset = 7
};
+ static int classOrLoaderModuleClassName_offset;
+ static int classLoaderName_offset;
static int moduleName_offset;
static int moduleVersion_offset;
static int declaringClass_offset;
@@ -1307,12 +1313,14 @@
static int lineNumber_offset;
// Setters
+ static void set_classLoaderName(oop element, oop value);
static void set_moduleName(oop element, oop value);
static void set_moduleVersion(oop element, oop value);
static void set_declaringClass(oop element, oop value);
static void set_methodName(oop element, oop value);
static void set_fileName(oop element, oop value);
static void set_lineNumber(oop element, int value);
+ static void set_declaringClassObject(oop element, oop value);
public:
// Create an instance of StackTraceElement
--- a/hotspot/src/share/vm/classfile/klassFactory.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/share/vm/classfile/klassFactory.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -74,7 +74,7 @@
(SharedClassPathEntry*)FileMapInfo::shared_classpath(path_index);
ClassFileStream* stream = new ClassFileStream(ptr,
end_ptr - ptr,
- ent->_name,
+ ent == NULL ? NULL : ent->_name,
ClassFileStream::verify);
ClassFileParser parser(stream,
class_name,
--- a/hotspot/src/share/vm/classfile/moduleEntry.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/share/vm/classfile/moduleEntry.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -368,9 +368,6 @@
// Store pointer to the ModuleEntry for java.base in the java.lang.reflect.Module object.
java_lang_reflect_Module::set_module_entry(module_handle(), jb_module);
-
- // Patch any previously loaded classes' module field with java.base's java.lang.reflect.Module.
- patch_javabase_entries(module_handle);
}
// Within java.lang.Class instances there is a java.lang.reflect.Module field
@@ -378,7 +375,6 @@
// definition, classes needing their module field set are added to the fixup_module_list.
// Their module field is set once java.base's java.lang.reflect.Module is known to the VM.
void ModuleEntryTable::patch_javabase_entries(Handle module_handle) {
- assert(Module_lock->owned_by_self(), "should have the Module_lock");
if (module_handle.is_null()) {
fatal("Unable to patch the module field of classes loaded prior to java.base's definition, invalid java.lang.reflect.Module");
}
--- a/hotspot/src/share/vm/classfile/modules.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/share/vm/classfile/modules.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -244,6 +244,12 @@
"Module java.base is already defined");
}
+ // Only the thread that actually defined the base module will get here,
+ // so no locking is needed.
+
+ // Patch any previously loaded class's module field with java.base's java.lang.reflect.Module.
+ ModuleEntryTable::patch_javabase_entries(module_handle);
+
log_debug(modules)("define_javabase_module(): Definition of module: java.base,"
" version: %s, location: %s, package #: %d",
module_version != NULL ? module_version : "NULL",
--- a/hotspot/src/share/vm/classfile/systemDictionary.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/share/vm/classfile/systemDictionary.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -1234,7 +1234,7 @@
SharedClassPathEntry* ent =
(SharedClassPathEntry*)FileMapInfo::shared_classpath(path_index);
if (!Universe::is_module_initialized()) {
- assert(ent->is_jrt(),
+ assert(ent != NULL && ent->is_jrt(),
"Loading non-bootstrap classes before the module system is initialized");
assert(class_loader.is_null(), "sanity");
return true;
@@ -1257,6 +1257,7 @@
}
if (class_loader.is_null()) {
+ assert(ent != NULL, "Shared class for NULL classloader must have valid SharedClassPathEntry");
// The NULL classloader can load archived class originated from the
// "modules" jimage and the -Xbootclasspath/a. For class from the
// "modules" jimage, the PackageEntry/ModuleEntry must be defined
--- a/hotspot/src/share/vm/classfile/systemDictionary.hpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/share/vm/classfile/systemDictionary.hpp Wed Nov 09 10:04:43 2016 -0800
@@ -226,7 +226,7 @@
WKID_LIMIT,
#if INCLUDE_JVMCI
- FIRST_JVMCI_WKID = WK_KLASS_ENUM_NAME(HotSpotCompiledCode_klass),
+ FIRST_JVMCI_WKID = WK_KLASS_ENUM_NAME(JVMCI_klass),
LAST_JVMCI_WKID = WK_KLASS_ENUM_NAME(Value_klass),
#endif
--- a/hotspot/src/share/vm/code/nmethod.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/share/vm/code/nmethod.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -1252,7 +1252,7 @@
if (method() != NULL && (method()->code() == this ||
method()->from_compiled_entry() == verified_entry_point())) {
HandleMark hm;
- method()->clear_code();
+ method()->clear_code(false /* already owns Patching_lock */);
}
} // leave critical region under Patching_lock
--- a/hotspot/src/share/vm/gc/cms/concurrentMarkSweepGeneration.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/share/vm/gc/cms/concurrentMarkSweepGeneration.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -2340,13 +2340,11 @@
{
StrongRootsScope srs(1);
- gch->gen_process_roots(&srs,
- GenCollectedHeap::OldGen,
+ gch->cms_process_roots(&srs,
true, // young gen as roots
GenCollectedHeap::ScanningOption(roots_scanning_options()),
should_unload_classes(),
¬Older,
- NULL,
NULL);
}
@@ -2414,13 +2412,11 @@
{
StrongRootsScope srs(1);
- gch->gen_process_roots(&srs,
- GenCollectedHeap::OldGen,
+ gch->cms_process_roots(&srs,
true, // young gen as roots
GenCollectedHeap::ScanningOption(roots_scanning_options()),
should_unload_classes(),
¬Older,
- NULL,
&cld_closure);
}
@@ -2903,13 +2899,11 @@
StrongRootsScope srs(1);
- gch->gen_process_roots(&srs,
- GenCollectedHeap::OldGen,
+ gch->cms_process_roots(&srs,
true, // young gen as roots
GenCollectedHeap::ScanningOption(roots_scanning_options()),
should_unload_classes(),
¬Older,
- NULL,
&cld_closure);
}
}
@@ -4290,13 +4284,11 @@
CLDToOopClosure cld_closure(&par_mri_cl, true);
- gch->gen_process_roots(_strong_roots_scope,
- GenCollectedHeap::OldGen,
+ gch->cms_process_roots(_strong_roots_scope,
false, // yg was scanned above
GenCollectedHeap::ScanningOption(_collector->CMSCollector::roots_scanning_options()),
_collector->should_unload_classes(),
&par_mri_cl,
- NULL,
&cld_closure);
assert(_collector->should_unload_classes()
|| (_collector->CMSCollector::roots_scanning_options() & GenCollectedHeap::SO_AllCodeCache),
@@ -4421,13 +4413,11 @@
// ---------- remaining roots --------------
_timer.reset();
_timer.start();
- gch->gen_process_roots(_strong_roots_scope,
- GenCollectedHeap::OldGen,
+ gch->cms_process_roots(_strong_roots_scope,
false, // yg was scanned above
GenCollectedHeap::ScanningOption(_collector->CMSCollector::roots_scanning_options()),
_collector->should_unload_classes(),
&par_mrias_cl,
- NULL,
NULL); // The dirty klasses will be handled below
assert(_collector->should_unload_classes()
@@ -4970,13 +4960,11 @@
gch->rem_set()->prepare_for_younger_refs_iterate(false); // Not parallel.
StrongRootsScope srs(1);
- gch->gen_process_roots(&srs,
- GenCollectedHeap::OldGen,
+ gch->cms_process_roots(&srs,
true, // young gen as roots
GenCollectedHeap::ScanningOption(roots_scanning_options()),
should_unload_classes(),
&mrias_cl,
- NULL,
NULL); // The dirty klasses will be handled below
assert(should_unload_classes()
--- a/hotspot/src/share/vm/gc/cms/parNewGeneration.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/share/vm/gc/cms/parNewGeneration.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -605,14 +605,10 @@
false);
par_scan_state.start_strong_roots();
- gch->gen_process_roots(_strong_roots_scope,
- GenCollectedHeap::YoungGen,
- true, // Process younger gens, if any, as strong roots.
- GenCollectedHeap::SO_ScavengeCodeCache,
- GenCollectedHeap::StrongAndWeakRoots,
- &par_scan_state.to_space_root_closure(),
- &par_scan_state.older_gen_closure(),
- &cld_scan_closure);
+ gch->young_process_roots(_strong_roots_scope,
+ &par_scan_state.to_space_root_closure(),
+ &par_scan_state.older_gen_closure(),
+ &cld_scan_closure);
par_scan_state.end_strong_roots();
--- a/hotspot/src/share/vm/gc/g1/g1BiasedArray.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/share/vm/gc/g1/g1BiasedArray.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -53,99 +53,4 @@
biased_index, bias(), length());
}
-class TestMappedArray : public G1BiasedMappedArray<int> {
-protected:
- virtual int default_value() const { return 0xBAADBABE; }
-public:
- static void test_biasedarray() {
- const size_t REGION_SIZE_IN_WORDS = 512;
- const size_t NUM_REGIONS = 20;
- HeapWord* fake_heap = (HeapWord*)LP64_ONLY(0xBAAA00000) NOT_LP64(0xBA000000); // Any value that is non-zero
-
- TestMappedArray array;
- array.initialize(fake_heap, fake_heap + REGION_SIZE_IN_WORDS * NUM_REGIONS,
- REGION_SIZE_IN_WORDS * HeapWordSize);
- // Check address calculation (bounds)
- assert(array.bottom_address_mapped() == fake_heap,
- "bottom mapped address should be " PTR_FORMAT ", but is " PTR_FORMAT, p2i(fake_heap), p2i(array.bottom_address_mapped()));
- assert(array.end_address_mapped() == (fake_heap + REGION_SIZE_IN_WORDS * NUM_REGIONS), "must be");
-
- int* bottom = array.address_mapped_to(fake_heap);
- assert((void*)bottom == (void*) array.base(), "must be");
- int* end = array.address_mapped_to(fake_heap + REGION_SIZE_IN_WORDS * NUM_REGIONS);
- assert((void*)end == (void*)(array.base() + array.length()), "must be");
- // The entire array should contain default value elements
- for (int* current = bottom; current < end; current++) {
- assert(*current == array.default_value(), "must be");
- }
-
- // Test setting values in the table
-
- HeapWord* region_start_address = fake_heap + REGION_SIZE_IN_WORDS * (NUM_REGIONS / 2);
- HeapWord* region_end_address = fake_heap + (REGION_SIZE_IN_WORDS * (NUM_REGIONS / 2) + REGION_SIZE_IN_WORDS - 1);
-
- // Set/get by address tests: invert some value; first retrieve one
- int actual_value = array.get_by_index(NUM_REGIONS / 2);
- array.set_by_index(NUM_REGIONS / 2, ~actual_value);
- // Get the same value by address, should correspond to the start of the "region"
- int value = array.get_by_address(region_start_address);
- assert(value == ~actual_value, "must be");
- // Get the same value by address, at one HeapWord before the start
- value = array.get_by_address(region_start_address - 1);
- assert(value == array.default_value(), "must be");
- // Get the same value by address, at the end of the "region"
- value = array.get_by_address(region_end_address);
- assert(value == ~actual_value, "must be");
- // Make sure the next value maps to another index
- value = array.get_by_address(region_end_address + 1);
- assert(value == array.default_value(), "must be");
-
- // Reset the value in the array
- array.set_by_address(region_start_address + (region_end_address - region_start_address) / 2, actual_value);
-
- // The entire array should have the default value again
- for (int* current = bottom; current < end; current++) {
- assert(*current == array.default_value(), "must be");
- }
-
- // Set/get by index tests: invert some value
- idx_t index = NUM_REGIONS / 2;
- actual_value = array.get_by_index(index);
- array.set_by_index(index, ~actual_value);
-
- value = array.get_by_index(index);
- assert(value == ~actual_value, "must be");
-
- value = array.get_by_index(index - 1);
- assert(value == array.default_value(), "must be");
-
- value = array.get_by_index(index + 1);
- assert(value == array.default_value(), "must be");
-
- array.set_by_index(0, 0);
- value = array.get_by_index(0);
- assert(value == 0, "must be");
-
- array.set_by_index(array.length() - 1, 0);
- value = array.get_by_index(array.length() - 1);
- assert(value == 0, "must be");
-
- array.set_by_index(index, 0);
-
- // The array should have three zeros, and default values otherwise
- size_t num_zeros = 0;
- for (int* current = bottom; current < end; current++) {
- assert(*current == array.default_value() || *current == 0, "must be");
- if (*current == 0) {
- num_zeros++;
- }
- }
- assert(num_zeros == 3, "must be");
- }
-};
-
-void TestG1BiasedArray_test() {
- TestMappedArray::test_biasedarray();
-}
-
#endif
--- a/hotspot/src/share/vm/gc/serial/defNewGeneration.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/share/vm/gc/serial/defNewGeneration.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -648,15 +648,10 @@
// See: CardTableModRefBSForCTRS::non_clean_card_iterate_possibly_parallel.
StrongRootsScope srs(0);
- gch->gen_process_roots(&srs,
- GenCollectedHeap::YoungGen,
- true, // Process younger gens, if any,
- // as strong roots.
- GenCollectedHeap::SO_ScavengeCodeCache,
- GenCollectedHeap::StrongAndWeakRoots,
- &fsc_with_no_gc_barrier,
- &fsc_with_gc_barrier,
- &cld_scan_closure);
+ gch->young_process_roots(&srs,
+ &fsc_with_no_gc_barrier,
+ &fsc_with_gc_barrier,
+ &cld_scan_closure);
}
// "evacuate followers".
--- a/hotspot/src/share/vm/gc/serial/genMarkSweep.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/share/vm/gc/serial/genMarkSweep.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -196,14 +196,13 @@
{
StrongRootsScope srs(1);
- gch->gen_process_roots(&srs,
- GenCollectedHeap::OldGen,
- false, // Younger gens are not roots.
- GenCollectedHeap::SO_None,
- ClassUnloading,
- &follow_root_closure,
- &follow_root_closure,
- &follow_cld_closure);
+ gch->full_process_roots(&srs,
+ false, // not the adjust phase
+ GenCollectedHeap::SO_None,
+ ClassUnloading, // only strong roots if ClassUnloading
+ // is enabled
+ &follow_root_closure,
+ &follow_cld_closure);
}
// Process reference objects found during marking
@@ -295,14 +294,12 @@
{
StrongRootsScope srs(1);
- gch->gen_process_roots(&srs,
- GenCollectedHeap::OldGen,
- false, // Younger gens are not roots.
- GenCollectedHeap::SO_AllCodeCache,
- GenCollectedHeap::StrongAndWeakRoots,
- &adjust_pointer_closure,
- &adjust_pointer_closure,
- &adjust_cld_closure);
+ gch->full_process_roots(&srs,
+ true, // this is the adjust phase
+ GenCollectedHeap::SO_AllCodeCache,
+ false, // all roots
+ &adjust_pointer_closure,
+ &adjust_cld_closure);
}
gch->gen_process_weak_roots(&adjust_pointer_closure);
--- a/hotspot/src/share/vm/gc/shared/gcTraceTime.inline.hpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/share/vm/gc/shared/gcTraceTime.inline.hpp Wed Nov 09 10:04:43 2016 -0800
@@ -35,7 +35,6 @@
#include "prims/jni_md.h"
#include "utilities/ticks.hpp"
-#define LOG_STOP_TIME_FORMAT "(%.3fs, %.3fs) %.3fms"
#define LOG_STOP_HEAP_FORMAT SIZE_FORMAT "M->" SIZE_FORMAT "M(" SIZE_FORMAT "M)"
inline void GCTraceTimeImpl::log_start(jlong start_counter) {
@@ -46,7 +45,7 @@
if (_gc_cause != GCCause::_no_gc) {
out.print(" (%s)", GCCause::to_string(_gc_cause));
}
- out.print_cr(" (%.3fs)", TimeHelper::counter_to_seconds(start_counter));
+ out.cr();
}
}
@@ -71,7 +70,7 @@
out.print(" " LOG_STOP_HEAP_FORMAT, used_before_m, used_m, capacity_m);
}
- out.print_cr(" " LOG_STOP_TIME_FORMAT, start_time_in_secs, stop_time_in_secs, duration_in_ms);
+ out.print_cr(" %.3fms", duration_in_ms);
}
inline void GCTraceTimeImpl::time_stamp(Ticks& ticks) {
@@ -117,7 +116,7 @@
GCTraceConcTimeImpl<Level, T0, T1, T2, T3, T4, GuardTag>::GCTraceConcTimeImpl(const char* title) :
_enabled(LogImpl<T0, T1, T2, T3, T4, GuardTag>::is_level(Level)), _start_time(os::elapsed_counter()), _title(title) {
if (_enabled) {
- LogImpl<T0, T1, T2, T3, T4>::template write<Level>("%s (%.3fs)", _title, TimeHelper::counter_to_seconds(_start_time));
+ LogImpl<T0, T1, T2, T3, T4>::template write<Level>("%s", _title);
}
}
@@ -125,11 +124,8 @@
GCTraceConcTimeImpl<Level, T0, T1, T2, T3, T4, GuardTag>::~GCTraceConcTimeImpl() {
if (_enabled) {
jlong stop_time = os::elapsed_counter();
- LogImpl<T0, T1, T2, T3, T4>::template write<Level>("%s " LOG_STOP_TIME_FORMAT,
- _title,
- TimeHelper::counter_to_seconds(_start_time),
- TimeHelper::counter_to_seconds(stop_time),
- TimeHelper::counter_to_millis(stop_time - _start_time));
+ LogImpl<T0, T1, T2, T3, T4>::template write<Level>("%s %0.3fms", _title,
+ TimeHelper::counter_to_millis(stop_time - _start_time));
}
}
--- a/hotspot/src/share/vm/gc/shared/genCollectedHeap.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/share/vm/gc/shared/genCollectedHeap.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -613,16 +613,6 @@
SystemDictionary::roots_oops_do(strong_roots, weak_roots);
}
- // All threads execute the following. A specific chunk of buckets
- // from the StringTable are the individual tasks.
- if (weak_roots != NULL) {
- if (is_par) {
- StringTable::possibly_parallel_oops_do(weak_roots);
- } else {
- StringTable::oops_do(weak_roots);
- }
- }
-
if (!_process_strong_tasks->is_task_claimed(GCH_PS_CodeCache_oops_do)) {
if (so & SO_ScavengeCodeCache) {
assert(code_roots != NULL, "must supply closure for code cache");
@@ -644,46 +634,82 @@
}
}
-void GenCollectedHeap::gen_process_roots(StrongRootsScope* scope,
- GenerationType type,
+void GenCollectedHeap::process_string_table_roots(StrongRootsScope* scope,
+ OopClosure* root_closure) {
+ assert(root_closure != NULL, "Must be set");
+ // All threads execute the following. A specific chunk of buckets
+ // from the StringTable are the individual tasks.
+ if (scope->n_threads() > 1) {
+ StringTable::possibly_parallel_oops_do(root_closure);
+ } else {
+ StringTable::oops_do(root_closure);
+ }
+}
+
+void GenCollectedHeap::young_process_roots(StrongRootsScope* scope,
+ OopsInGenClosure* root_closure,
+ OopsInGenClosure* old_gen_closure,
+ CLDClosure* cld_closure) {
+ MarkingCodeBlobClosure mark_code_closure(root_closure, CodeBlobToOopClosure::FixRelocations);
+
+ process_roots(scope, SO_ScavengeCodeCache, root_closure, root_closure,
+ cld_closure, cld_closure, &mark_code_closure);
+ process_string_table_roots(scope, root_closure);
+
+ if (!_process_strong_tasks->is_task_claimed(GCH_PS_younger_gens)) {
+ root_closure->reset_generation();
+ }
+
+ // When collection is parallel, all threads get to cooperate to do
+ // old generation scanning.
+ old_gen_closure->set_generation(_old_gen);
+ rem_set()->younger_refs_iterate(_old_gen, old_gen_closure, scope->n_threads());
+ old_gen_closure->reset_generation();
+
+ _process_strong_tasks->all_tasks_completed(scope->n_threads());
+}
+
+void GenCollectedHeap::cms_process_roots(StrongRootsScope* scope,
bool young_gen_as_roots,
ScanningOption so,
bool only_strong_roots,
- OopsInGenClosure* not_older_gens,
- OopsInGenClosure* older_gens,
+ OopsInGenClosure* root_closure,
CLDClosure* cld_closure) {
- const bool is_adjust_phase = !only_strong_roots && !young_gen_as_roots;
-
- bool is_moving_collection = false;
- if (type == YoungGen || is_adjust_phase) {
- // young collections are always moving
- is_moving_collection = true;
- }
-
- MarkingCodeBlobClosure mark_code_closure(not_older_gens, is_moving_collection);
- OopsInGenClosure* weak_roots = only_strong_roots ? NULL : not_older_gens;
+ MarkingCodeBlobClosure mark_code_closure(root_closure, !CodeBlobToOopClosure::FixRelocations);
+ OopsInGenClosure* weak_roots = only_strong_roots ? NULL : root_closure;
CLDClosure* weak_cld_closure = only_strong_roots ? NULL : cld_closure;
- process_roots(scope, so,
- not_older_gens, weak_roots,
- cld_closure, weak_cld_closure,
- &mark_code_closure);
+ process_roots(scope, so, root_closure, weak_roots, cld_closure, weak_cld_closure, &mark_code_closure);
+ if (!only_strong_roots) {
+ process_string_table_roots(scope, root_closure);
+ }
+
+ if (young_gen_as_roots &&
+ !_process_strong_tasks->is_task_claimed(GCH_PS_younger_gens)) {
+ root_closure->set_generation(_young_gen);
+ _young_gen->oop_iterate(root_closure);
+ root_closure->reset_generation();
+ }
+
+ _process_strong_tasks->all_tasks_completed(scope->n_threads());
+}
- if (young_gen_as_roots) {
- if (!_process_strong_tasks->is_task_claimed(GCH_PS_younger_gens)) {
- if (type == OldGen) {
- not_older_gens->set_generation(_young_gen);
- _young_gen->oop_iterate(not_older_gens);
- }
- not_older_gens->reset_generation();
- }
- }
- // When collection is parallel, all threads get to cooperate to do
- // old generation scanning.
- if (type == YoungGen) {
- older_gens->set_generation(_old_gen);
- rem_set()->younger_refs_iterate(_old_gen, older_gens, scope->n_threads());
- older_gens->reset_generation();
+void GenCollectedHeap::full_process_roots(StrongRootsScope* scope,
+ bool is_adjust_phase,
+ ScanningOption so,
+ bool only_strong_roots,
+ OopsInGenClosure* root_closure,
+ CLDClosure* cld_closure) {
+ MarkingCodeBlobClosure mark_code_closure(root_closure, is_adjust_phase);
+ OopsInGenClosure* weak_roots = only_strong_roots ? NULL : root_closure;
+ CLDClosure* weak_cld_closure = only_strong_roots ? NULL : cld_closure;
+
+ process_roots(scope, so, root_closure, weak_roots, cld_closure, weak_cld_closure, &mark_code_closure);
+ if (is_adjust_phase) {
+ // We never treat the string table as roots during marking
+ // for the full gc, so we only need to process it during
+ // the adjust phase.
+ process_string_table_roots(scope, root_closure);
}
_process_strong_tasks->all_tasks_completed(scope->n_threads());
--- a/hotspot/src/share/vm/gc/shared/genCollectedHeap.hpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/share/vm/gc/shared/genCollectedHeap.hpp Wed Nov 09 10:04:43 2016 -0800
@@ -374,16 +374,7 @@
// asserted to be this type.
static GenCollectedHeap* heap();
- // Invoke the "do_oop" method of one of the closures "not_older_gens"
- // or "older_gens" on root locations for the generations depending on
- // the type. (The "older_gens" closure is used for scanning references
- // from older generations; "not_older_gens" is used everywhere else.)
- // If "younger_gens_as_roots" is false, younger generations are
- // not scanned as roots; in this case, the caller must be arranging to
- // scan the younger generations itself. (For example, a generation might
- // explicitly mark reachable objects in younger generations, to avoid
- // excess storage retention.)
- // The "so" argument determines which of the roots
+ // The ScanningOption determines which of the roots
// the closure is applied to:
// "SO_None" does none;
enum ScanningOption {
@@ -401,19 +392,34 @@
CLDClosure* weak_cld_closure,
CodeBlobToOopClosure* code_roots);
+ void process_string_table_roots(StrongRootsScope* scope,
+ OopClosure* root_closure);
+
public:
- static const bool StrongAndWeakRoots = false;
- static const bool StrongRootsOnly = true;
+ void young_process_roots(StrongRootsScope* scope,
+ OopsInGenClosure* root_closure,
+ OopsInGenClosure* old_gen_closure,
+ CLDClosure* cld_closure);
- void gen_process_roots(StrongRootsScope* scope,
- GenerationType type,
+ // If "young_gen_as_roots" is false, younger generations are
+ // not scanned as roots; in this case, the caller must be arranging to
+ // scan the younger generations itself. (For example, a generation might
+ // explicitly mark reachable objects in younger generations, to avoid
+ // excess storage retention.)
+ void cms_process_roots(StrongRootsScope* scope,
bool young_gen_as_roots,
ScanningOption so,
bool only_strong_roots,
- OopsInGenClosure* not_older_gens,
- OopsInGenClosure* older_gens,
+ OopsInGenClosure* root_closure,
CLDClosure* cld_closure);
+ void full_process_roots(StrongRootsScope* scope,
+ bool is_adjust_phase,
+ ScanningOption so,
+ bool only_strong_roots,
+ OopsInGenClosure* root_closure,
+ CLDClosure* cld_closure);
+
// Apply "root_closure" to all the weak roots of the system.
// These include JNI weak roots, string table,
// and referents of reachable weak refs.
--- a/hotspot/src/share/vm/interpreter/invocationCounter.hpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/share/vm/interpreter/invocationCounter.hpp Wed Nov 09 10:04:43 2016 -0800
@@ -40,6 +40,7 @@
class InvocationCounter VALUE_OBJ_CLASS_SPEC {
friend class VMStructs;
+ friend class JVMCIVMStructs;
friend class ciReplay;
private: // bit no: |31 3| 2 | 1 0 |
unsigned int _counter; // format: [count|carry|state]
--- a/hotspot/src/share/vm/interpreter/linkResolver.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/share/vm/interpreter/linkResolver.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -858,8 +858,10 @@
}
if (log_develop_is_enabled(Trace, itables)) {
- trace_method_resolution("invokeinterface resolved method: caller-class",
- link_info.current_klass(), resolved_klass,
+ char buf[200];
+ jio_snprintf(buf, sizeof(buf), "%s resolved interface method: caller-class:",
+ Bytecodes::name(code));
+ trace_method_resolution(buf, link_info.current_klass(), resolved_klass,
resolved_method, true);
}
@@ -1424,7 +1426,7 @@
}
if (log_develop_is_enabled(Trace, itables)) {
- trace_method_resolution("invokeinterface selected method: receiver-class",
+ trace_method_resolution("invokeinterface selected method: receiver-class:",
recv_klass, resolved_klass, sel_method, true);
}
// setup result
--- a/hotspot/src/share/vm/jvmci/jvmciCodeInstaller.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/share/vm/jvmci/jvmciCodeInstaller.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -172,7 +172,7 @@
return map;
}
-void* CodeInstaller::record_metadata_reference(Handle constant, TRAPS) {
+void* CodeInstaller::record_metadata_reference(CodeSection* section, address dest, Handle constant, TRAPS) {
/*
* This method needs to return a raw (untyped) pointer, since the value of a pointer to the base
* class is in general not equal to the pointer of the subclass. When patching metaspace pointers,
@@ -184,12 +184,14 @@
Klass* klass = java_lang_Class::as_Klass(HotSpotResolvedObjectTypeImpl::javaClass(obj));
assert(!HotSpotMetaspaceConstantImpl::compressed(constant), "unexpected compressed klass pointer %s @ " INTPTR_FORMAT, klass->name()->as_C_string(), p2i(klass));
int index = _oop_recorder->find_index(klass);
+ section->relocate(dest, metadata_Relocation::spec(index));
TRACE_jvmci_3("metadata[%d of %d] = %s", index, _oop_recorder->metadata_count(), klass->name()->as_C_string());
return klass;
} else if (obj->is_a(HotSpotResolvedJavaMethodImpl::klass())) {
Method* method = (Method*) (address) HotSpotResolvedJavaMethodImpl::metaspaceMethod(obj);
assert(!HotSpotMetaspaceConstantImpl::compressed(constant), "unexpected compressed method pointer %s @ " INTPTR_FORMAT, method->name()->as_C_string(), p2i(method));
int index = _oop_recorder->find_index(method);
+ section->relocate(dest, metadata_Relocation::spec(index));
TRACE_jvmci_3("metadata[%d of %d] = %s", index, _oop_recorder->metadata_count(), method->name()->as_C_string());
return method;
} else {
@@ -198,7 +200,7 @@
}
#ifdef _LP64
-narrowKlass CodeInstaller::record_narrow_metadata_reference(Handle constant, TRAPS) {
+narrowKlass CodeInstaller::record_narrow_metadata_reference(CodeSection* section, address dest, Handle constant, TRAPS) {
oop obj = HotSpotMetaspaceConstantImpl::metaspaceObject(constant);
assert(HotSpotMetaspaceConstantImpl::compressed(constant), "unexpected uncompressed pointer");
@@ -208,6 +210,7 @@
Klass* klass = java_lang_Class::as_Klass(HotSpotResolvedObjectTypeImpl::javaClass(obj));
int index = _oop_recorder->find_index(klass);
+ section->relocate(dest, metadata_Relocation::spec(index));
TRACE_jvmci_3("narrowKlass[%d of %d] = %s", index, _oop_recorder->metadata_count(), klass->name()->as_C_string());
return Klass::encode_klass(klass);
}
@@ -701,12 +704,12 @@
if (constant->is_a(HotSpotMetaspaceConstantImpl::klass())) {
if (HotSpotMetaspaceConstantImpl::compressed(constant)) {
#ifdef _LP64
- *((narrowKlass*) dest) = record_narrow_metadata_reference(constant, CHECK_OK);
+ *((narrowKlass*) dest) = record_narrow_metadata_reference(_constants, dest, constant, CHECK_OK);
#else
JVMCI_ERROR_OK("unexpected compressed Klass* in 32-bit mode");
#endif
} else {
- *((void**) dest) = record_metadata_reference(constant, CHECK_OK);
+ *((void**) dest) = record_metadata_reference(_constants, dest, constant, CHECK_OK);
}
} else if (constant->is_a(HotSpotObjectConstantImpl::klass())) {
Handle obj = HotSpotObjectConstantImpl::object(constant);
--- a/hotspot/src/share/vm/jvmci/jvmciCodeInstaller.hpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/share/vm/jvmci/jvmciCodeInstaller.hpp Wed Nov 09 10:04:43 2016 -0800
@@ -189,9 +189,9 @@
ScopeValue* get_scope_value(Handle value, BasicType type, GrowableArray<ScopeValue*>* objects, ScopeValue* &second, TRAPS);
MonitorValue* get_monitor_value(Handle value, GrowableArray<ScopeValue*>* objects, TRAPS);
- void* record_metadata_reference(Handle constant, TRAPS);
+ void* record_metadata_reference(CodeSection* section, address dest, Handle constant, TRAPS);
#ifdef _LP64
- narrowKlass record_narrow_metadata_reference(Handle constant, TRAPS);
+ narrowKlass record_narrow_metadata_reference(CodeSection* section, address dest, Handle constant, TRAPS);
#endif
// extract the fields of the HotSpotCompiledCode
--- a/hotspot/src/share/vm/jvmci/jvmciRuntime.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/share/vm/jvmci/jvmciRuntime.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -640,8 +640,6 @@
JVM_END
Handle JVMCIRuntime::callStatic(const char* className, const char* methodName, const char* signature, JavaCallArguments* args, TRAPS) {
- guarantee(!_HotSpotJVMCIRuntime_initialized, "cannot reinitialize HotSpotJVMCIRuntime");
-
TempNewSymbol name = SymbolTable::new_symbol(className, CHECK_(Handle()));
KlassHandle klass = SystemDictionary::resolve_or_fail(name, true, CHECK_(Handle()));
TempNewSymbol runtime = SymbolTable::new_symbol(methodName, CHECK_(Handle()));
@@ -656,42 +654,37 @@
}
void JVMCIRuntime::initialize_HotSpotJVMCIRuntime(TRAPS) {
- if (JNIHandles::resolve(_HotSpotJVMCIRuntime_instance) == NULL) {
- ResourceMark rm;
-#ifdef ASSERT
- // This should only be called in the context of the JVMCI class being initialized
- TempNewSymbol name = SymbolTable::new_symbol("jdk/vm/ci/runtime/JVMCI", CHECK);
- Klass* k = SystemDictionary::resolve_or_null(name, CHECK);
- instanceKlassHandle klass = InstanceKlass::cast(k);
- assert(klass->is_being_initialized() && klass->is_reentrant_initialization(THREAD),
- "HotSpotJVMCIRuntime initialization should only be triggered through JVMCI initialization");
-#endif
+ guarantee(!_HotSpotJVMCIRuntime_initialized, "cannot reinitialize HotSpotJVMCIRuntime");
+ JVMCIRuntime::initialize_well_known_classes(CHECK);
+ // This should only be called in the context of the JVMCI class being initialized
+ instanceKlassHandle klass = InstanceKlass::cast(SystemDictionary::JVMCI_klass());
+ guarantee(klass->is_being_initialized() && klass->is_reentrant_initialization(THREAD),
+ "HotSpotJVMCIRuntime initialization should only be triggered through JVMCI initialization");
- Handle result = callStatic("jdk/vm/ci/hotspot/HotSpotJVMCIRuntime",
- "runtime",
- "()Ljdk/vm/ci/hotspot/HotSpotJVMCIRuntime;", NULL, CHECK);
- objArrayOop trivial_prefixes = HotSpotJVMCIRuntime::trivialPrefixes(result);
- if (trivial_prefixes != NULL) {
- char** prefixes = NEW_C_HEAP_ARRAY(char*, trivial_prefixes->length(), mtCompiler);
- for (int i = 0; i < trivial_prefixes->length(); i++) {
- oop str = trivial_prefixes->obj_at(i);
- if (str == NULL) {
- THROW(vmSymbols::java_lang_NullPointerException());
- } else {
- prefixes[i] = strdup(java_lang_String::as_utf8_string(str));
- }
+ Handle result = callStatic("jdk/vm/ci/hotspot/HotSpotJVMCIRuntime",
+ "runtime",
+ "()Ljdk/vm/ci/hotspot/HotSpotJVMCIRuntime;", NULL, CHECK);
+ objArrayOop trivial_prefixes = HotSpotJVMCIRuntime::trivialPrefixes(result);
+ if (trivial_prefixes != NULL) {
+ char** prefixes = NEW_C_HEAP_ARRAY(char*, trivial_prefixes->length(), mtCompiler);
+ for (int i = 0; i < trivial_prefixes->length(); i++) {
+ oop str = trivial_prefixes->obj_at(i);
+ if (str == NULL) {
+ THROW(vmSymbols::java_lang_NullPointerException());
+ } else {
+ prefixes[i] = strdup(java_lang_String::as_utf8_string(str));
}
- _trivial_prefixes = prefixes;
- _trivial_prefixes_count = trivial_prefixes->length();
}
- int adjustment = HotSpotJVMCIRuntime::compilationLevelAdjustment(result);
- assert(adjustment >= JVMCIRuntime::none &&
- adjustment <= JVMCIRuntime::by_full_signature,
- "compilation level adjustment out of bounds");
- _comp_level_adjustment = (CompLevelAdjustment) adjustment;
- _HotSpotJVMCIRuntime_initialized = true;
- _HotSpotJVMCIRuntime_instance = JNIHandles::make_global(result());
+ _trivial_prefixes = prefixes;
+ _trivial_prefixes_count = trivial_prefixes->length();
}
+ int adjustment = HotSpotJVMCIRuntime::compilationLevelAdjustment(result);
+ assert(adjustment >= JVMCIRuntime::none &&
+ adjustment <= JVMCIRuntime::by_full_signature,
+ "compilation level adjustment out of bounds");
+ _comp_level_adjustment = (CompLevelAdjustment) adjustment;
+ _HotSpotJVMCIRuntime_initialized = true;
+ _HotSpotJVMCIRuntime_instance = JNIHandles::make_global(result());
}
void JVMCIRuntime::initialize_JVMCI(TRAPS) {
--- a/hotspot/src/share/vm/jvmci/jvmci_globals.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/share/vm/jvmci/jvmci_globals.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -85,6 +85,7 @@
CHECK_NOT_SET(JVMCIUseFastLocking, EnableJVMCI)
CHECK_NOT_SET(JVMCINMethodSizeLimit, EnableJVMCI)
CHECK_NOT_SET(MethodProfileWidth, EnableJVMCI)
+ CHECK_NOT_SET(JVMCIPrintProperties, EnableJVMCI)
CHECK_NOT_SET(TraceUncollectedSpeculations, EnableJVMCI)
#ifndef PRODUCT
--- a/hotspot/src/share/vm/jvmci/jvmci_globals.hpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/share/vm/jvmci/jvmci_globals.hpp Wed Nov 09 10:04:43 2016 -0800
@@ -49,6 +49,9 @@
experimental(bool, UseJVMCICompiler, false, \
"Use JVMCI as the default compiler") \
\
+ experimental(bool, JVMCIPrintProperties, false, \
+ "Prints properties used by the JVMCI compiler") \
+ \
experimental(bool, BootstrapJVMCI, false, \
"Bootstrap JVMCI before running Java main method") \
\
--- a/hotspot/src/share/vm/jvmci/systemDictionary_jvmci.hpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/share/vm/jvmci/systemDictionary_jvmci.hpp Wed Nov 09 10:04:43 2016 -0800
@@ -29,6 +29,7 @@
#else
#define JVMCI_WK_KLASSES_DO(do_klass) \
/* JVMCI classes. These are loaded on-demand. */ \
+ do_klass(JVMCI_klass, jdk_vm_ci_runtime_JVMCI, Jvmci) \
do_klass(HotSpotCompiledCode_klass, jdk_vm_ci_hotspot_HotSpotCompiledCode, Jvmci) \
do_klass(HotSpotCompiledCode_Comment_klass, jdk_vm_ci_hotspot_HotSpotCompiledCode_Comment, Jvmci) \
do_klass(HotSpotCompiledNmethod_klass, jdk_vm_ci_hotspot_HotSpotCompiledNmethod, Jvmci) \
--- a/hotspot/src/share/vm/jvmci/vmStructs_jvmci.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/share/vm/jvmci/vmStructs_jvmci.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -169,6 +169,8 @@
nonstatic_field(JVMCIEnv, _task, CompileTask*) \
nonstatic_field(JVMCIEnv, _jvmti_can_hotswap_or_post_breakpoint, bool) \
\
+ nonstatic_field(InvocationCounter, _counter, unsigned int) \
+ \
nonstatic_field(Klass, _secondary_super_cache, Klass*) \
nonstatic_field(Klass, _secondary_supers, Array<Klass*>*) \
nonstatic_field(Klass, _super, Klass*) \
@@ -199,13 +201,34 @@
volatile_nonstatic_field(Method, _code, CompiledMethod*) \
volatile_nonstatic_field(Method, _from_compiled_entry, address) \
\
+ nonstatic_field(MethodCounters, _nmethod_age, int) \
+ nonstatic_field(MethodCounters, _interpreter_invocation_limit, int) \
+ nonstatic_field(MethodCounters, _interpreter_backward_branch_limit, int) \
+ nonstatic_field(MethodCounters, _interpreter_profile_limit, int) \
+ nonstatic_field(MethodCounters, _invoke_mask, int) \
+ nonstatic_field(MethodCounters, _backedge_mask, int) \
+ nonstatic_field(MethodCounters, _interpreter_invocation_count, int) \
+ nonstatic_field(MethodCounters, _interpreter_throwout_count, u2) \
+ JVMTI_ONLY(nonstatic_field(MethodCounters, _number_of_breakpoints, u2)) \
nonstatic_field(MethodCounters, _invocation_counter, InvocationCounter) \
nonstatic_field(MethodCounters, _backedge_counter, InvocationCounter) \
\
nonstatic_field(MethodData, _size, int) \
+ nonstatic_field(MethodData, _method, Method*) \
nonstatic_field(MethodData, _data_size, int) \
nonstatic_field(MethodData, _data[0], intptr_t) \
+ nonstatic_field(MethodData, _parameters_type_data_di, int) \
+ nonstatic_field(MethodData, _nof_decompiles, uint) \
+ nonstatic_field(MethodData, _nof_overflow_recompiles, uint) \
+ nonstatic_field(MethodData, _nof_overflow_traps, uint) \
nonstatic_field(MethodData, _trap_hist._array[0], u1) \
+ nonstatic_field(MethodData, _eflags, intx) \
+ nonstatic_field(MethodData, _arg_local, intx) \
+ nonstatic_field(MethodData, _arg_stack, intx) \
+ nonstatic_field(MethodData, _arg_returned, intx) \
+ nonstatic_field(MethodData, _tenure_traps, uint) \
+ nonstatic_field(MethodData, _invoke_mask, int) \
+ nonstatic_field(MethodData, _backedge_mask, int) \
nonstatic_field(MethodData, _jvmci_ir_size, int) \
\
nonstatic_field(nmethod, _verified_entry_point, address) \
@@ -290,6 +313,7 @@
declare_toplevel_type(ExceptionTableElement) \
declare_toplevel_type(Flag) \
declare_toplevel_type(Flag*) \
+ declare_toplevel_type(InvocationCounter) \
declare_toplevel_type(JVMCIEnv) \
declare_toplevel_type(LocalVariableTableElement) \
declare_toplevel_type(narrowKlass) \
@@ -688,7 +712,6 @@
declare_constant(VM_Version::sun4v_m) \
declare_constant(VM_Version::blk_init_instructions_m) \
declare_constant(VM_Version::fmaf_instructions_m) \
- declare_constant(VM_Version::fmau_instructions_m) \
declare_constant(VM_Version::sparc64_family_m) \
declare_constant(VM_Version::M_family_m) \
declare_constant(VM_Version::T_family_m) \
--- a/hotspot/src/share/vm/jvmci/vmSymbols_jvmci.hpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/share/vm/jvmci/vmSymbols_jvmci.hpp Wed Nov 09 10:04:43 2016 -0800
@@ -29,6 +29,7 @@
#define JVMCI_VM_SYMBOLS_DO(template, do_alias)
#else
#define JVMCI_VM_SYMBOLS_DO(template, do_alias) \
+ template(jdk_vm_ci_runtime_JVMCI, "jdk/vm/ci/runtime/JVMCI") \
template(jdk_vm_ci_hotspot_HotSpotCompiledCode, "jdk/vm/ci/hotspot/HotSpotCompiledCode") \
template(jdk_vm_ci_hotspot_HotSpotCompiledCode_Comment, "jdk/vm/ci/hotspot/HotSpotCompiledCode$Comment") \
template(jdk_vm_ci_hotspot_HotSpotCompiledNmethod, "jdk/vm/ci/hotspot/HotSpotCompiledNmethod") \
--- a/hotspot/src/share/vm/logging/log.cpp Wed Nov 09 15:20:30 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1197 +0,0 @@
-/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-#include "precompiled.hpp"
-
-/////////////// Unit tests ///////////////
-
-#ifndef PRODUCT
-
-#include "gc/shared/gcTraceTime.inline.hpp"
-#include "logging/log.hpp"
-#include "logging/logConfiguration.hpp"
-#include "logging/logFileOutput.hpp"
-#include "logging/logMessage.hpp"
-#include "logging/logMessageBuffer.hpp"
-#include "logging/logOutput.hpp"
-#include "logging/logTagLevelExpression.hpp"
-#include "logging/logTagSet.hpp"
-#include "logging/logTagSetDescriptions.hpp"
-#include "logging/logStream.inline.hpp"
-#include "memory/resourceArea.hpp"
-
-#define assert_str_eq(s1, s2) \
- assert(strcmp(s1, s2) == 0, "Expected '%s' to equal '%s'", s1, s2)
-
-#define assert_char_in(c, s) \
- assert(strchr(s, c) != NULL, "Expected '%s' to contain character '%c'", s, c)
-
-#define assert_char_not_in(c, s) \
- assert(strchr(s, c) == NULL, "Expected '%s' to *not* contain character '%c'", s, c)
-
-void Test_log_tag_combinations_limit() {
- assert(LogTagLevelExpression::MaxCombinations > LogTagSet::ntagsets(),
- "Combination limit (" SIZE_FORMAT ") not sufficient "
- "for configuring all available tag sets (" SIZE_FORMAT ")",
- LogTagLevelExpression::MaxCombinations, LogTagSet::ntagsets());
-}
-
-// Read a complete line from fp and return it as a resource allocated string.
-// Returns NULL on EOF.
-static char* read_line(FILE* fp) {
- assert(fp != NULL, "bad fp");
- int buflen = 512;
- char* buf = NEW_RESOURCE_ARRAY(char, buflen);
- long pos = ftell(fp);
-
- char* ret = fgets(buf, buflen, fp);
- while (ret != NULL && buf[strlen(buf) - 1] != '\n' && !feof(fp)) {
- // retry with a larger buffer
- buf = REALLOC_RESOURCE_ARRAY(char, buf, buflen, buflen * 2);
- buflen *= 2;
- // rewind to beginning of line
- fseek(fp, pos, SEEK_SET);
- // retry read with new buffer
- ret = fgets(buf, buflen, fp);
- }
- return ret;
-}
-
-static bool file_contains_substrings_in_order(const char* filename, const char* substrs[]) {
- FILE* fp = fopen(filename, "r");
- assert(fp != NULL, "error opening file %s: %s", filename, strerror(errno));
-
- size_t idx = 0;
- while (substrs[idx] != NULL) {
- ResourceMark rm;
- char* line = read_line(fp);
- if (line == NULL) {
- break;
- }
- for (char* match = strstr(line, substrs[idx]); match != NULL;) {
- size_t match_len = strlen(substrs[idx]);
- idx++;
- if (substrs[idx] == NULL) {
- break;
- }
- match = strstr(match + match_len, substrs[idx]);
- }
- }
-
- fclose(fp);
- return substrs[idx] == NULL;
-}
-
-static bool file_contains_substring(const char* filename, const char* substr) {
- const char* strs[] = {substr, NULL};
- return file_contains_substrings_in_order(filename, strs);
-}
-
-static size_t number_of_lines_with_substring_in_file(const char* filename,
- const char* substr) {
- FILE* fp = fopen(filename, "r");
- assert(fp != NULL, "error opening file %s: %s", filename, strerror(errno));
-
- size_t ret = 0;
- for (;;) {
- ResourceMark rm;
- char* line = read_line(fp);
- if (line == NULL) {
- break;
- }
- if (strstr(line, substr) != NULL) {
- ret++;
- }
- }
-
- fclose(fp);
- return ret;
-}
-
-static bool file_exists(const char* filename) {
- struct stat st;
- return os::stat(filename, &st) == 0;
-}
-
-static void delete_file(const char* filename) {
- if (!file_exists(filename)) {
- return;
- }
- int ret = remove(filename);
- assert(ret == 0, "failed to remove file '%s': %s", filename, strerror(errno));
-}
-
-static void create_directory(const char* name) {
- assert(!file_exists(name), "can't create directory: %s already exists", name);
- bool failed;
-#ifdef _WINDOWS
- failed = !CreateDirectory(name, NULL);
-#else
- failed = mkdir(name, 0777);
-#endif
- assert(!failed, "failed to create directory %s", name);
-}
-
-class TestLogFile {
- private:
- char file_name[256];
-
- void set_name(const char* test_name) {
- const char* tmpdir = os::get_temp_directory();
- int pos = jio_snprintf(file_name, sizeof(file_name), "%s%svmtest.%s.%d.log", tmpdir, os::file_separator(), test_name, os::current_process_id());
- assert(pos > 0, "too small log file name buffer");
- assert((size_t)pos < sizeof(file_name), "too small log file name buffer");
- }
-
- public:
- TestLogFile(const char* test_name) {
- set_name(test_name);
- remove(name());
- }
-
- ~TestLogFile() {
- remove(name());
- }
-
- const char* name() {
- return file_name;
- }
-};
-
-class TestLogSavedConfig {
- private:
- char* _saved_config;
- char* _new_output;
- Log(logging) _log;
- public:
- TestLogSavedConfig(const char* apply_output = NULL, const char* apply_setting = NULL) : _new_output(0) {
- ResourceMark rm;
- _saved_config = os::strdup_check_oom(LogOutput::Stdout->config_string());
- bool success = LogConfiguration::parse_log_arguments("stdout", "all=off", NULL, NULL, _log.error_stream());
- assert(success, "test unable to turn all off");
-
- if (apply_output) {
- _new_output = os::strdup_check_oom(apply_output);
- bool success = LogConfiguration::parse_log_arguments(_new_output, apply_setting, NULL, NULL, _log.error_stream());
- assert(success, "test unable to apply test log configuration");
- }
- }
-
- ~TestLogSavedConfig() {
- ResourceMark rm;
- if (_new_output) {
- bool success = LogConfiguration::parse_log_arguments(_new_output, "all=off", NULL, NULL, _log.error_stream());
- assert(success, "test unable to turn all off");
- os::free(_new_output);
- }
-
- bool success = LogConfiguration::parse_log_arguments("stdout", _saved_config, NULL, NULL, _log.error_stream());
- assert(success, "test unable to restore log configuration");
- os::free(_saved_config);
- }
-};
-
-void Test_configure_stdout() {
- LogOutput* stdoutput = LogOutput::Stdout;
- TestLogSavedConfig tlsc;
-
- // Enable 'logging=info', verifying it has been set
- LogConfiguration::configure_stdout(LogLevel::Info, true, LOG_TAGS(logging));
- assert_str_eq("logging=info", stdoutput->config_string());
- assert(log_is_enabled(Info, logging), "logging was not properly enabled");
-
- // Enable 'gc=debug' (no wildcard), verifying no other tags are enabled
- LogConfiguration::configure_stdout(LogLevel::Debug, true, LOG_TAGS(gc));
- // No '+' character means only single tags are enabled, and no combinations
- assert_char_not_in('+', stdoutput->config_string());
- assert(log_is_enabled(Debug, gc), "logging was not properly enabled");
-
- // Enable 'gc*=trace' (with wildcard), verifying at least one tag combination is enabled (gc+...)
- LogConfiguration::configure_stdout(LogLevel::Trace, false, LOG_TAGS(gc));
- assert_char_in('+', stdoutput->config_string());
- assert(log_is_enabled(Trace, gc), "logging was not properly enabled");
-
- // Disable 'gc*' and 'logging', verifying all logging is properly disabled
- LogConfiguration::configure_stdout(LogLevel::Off, false, LOG_TAGS(gc));
- LogConfiguration::configure_stdout(LogLevel::Off, true, LOG_TAGS(logging));
- assert_str_eq("all=off", stdoutput->config_string());
-}
-
-static const char* ExpectedLine = "a (hopefully) unique log line for testing";
-
-static void init_file(const char* filename, const char* options = "") {
- LogConfiguration::parse_log_arguments(filename, "logging=trace", "", options,
- Log(logging)::error_stream());
- log_debug(logging)("%s", ExpectedLine);
- LogConfiguration::parse_log_arguments(filename, "all=off", "", "",
- Log(logging)::error_stream());
-}
-
-void Test_log_file_startup_rotation() {
- ResourceMark rm;
- const size_t rotations = 5;
- const char* filename = "start-rotate-test";
- char* rotated_file[rotations];
- for (size_t i = 0; i < rotations; i++) {
- size_t len = strlen(filename) + 3;
- rotated_file[i] = NEW_RESOURCE_ARRAY(char, len);
- jio_snprintf(rotated_file[i], len, "%s." SIZE_FORMAT, filename, i);
- delete_file(rotated_file[i]);
- };
-
- delete_file(filename);
- init_file(filename);
- assert(file_exists(filename),
- "configured logging to file '%s' but file was not found", filename);
-
- // Initialize the same file a bunch more times to trigger rotations
- for (size_t i = 0; i < rotations; i++) {
- init_file(filename);
- assert(file_exists(rotated_file[i]), "existing file was not rotated");
- }
-
- // Remove a file and expect its slot to be re-used
- delete_file(rotated_file[1]);
- init_file(filename);
- assert(file_exists(rotated_file[1]), "log file not properly rotated");
-
- // Clean up after test
- delete_file(filename);
- for (size_t i = 0; i < rotations; i++) {
- delete_file(rotated_file[i]);
- }
-}
-
-void Test_log_file_startup_truncation() {
- ResourceMark rm;
- const char* filename = "start-truncate-test";
- const char* archived_filename = "start-truncate-test.0";
-
- delete_file(filename);
- delete_file(archived_filename);
-
- // Use the same log file twice and expect it to be overwritten/truncated
- init_file(filename, "filecount=0");
- assert(file_exists(filename), "couldn't find log file: %s", filename);
-
- init_file(filename, "filecount=0");
- assert(file_exists(filename), "couldn't find log file: %s", filename);
- assert(!file_exists(archived_filename),
- "existing log file %s was not properly truncated when filecount was 0",
- filename);
-
- // Verify that the file was really truncated and not just appended
- assert(number_of_lines_with_substring_in_file(filename, ExpectedLine) == 1,
- "log file %s appended rather than truncated", filename);
-
- delete_file(filename);
- delete_file(archived_filename);
-}
-
-class LogMessageTest {
- private:
- static Log(logging) _log;
- static const char* _level_filename[];
-
- static void test_level_inclusion();
- static void test_long_message();
- static void test_message_with_many_lines();
- static void test_line_order();
- static void test_prefixing();
- static void test_scoped_messages();
- static void test_scoped_flushing();
- static void test_scoped_reset();
-
- public:
- static void test();
-};
-
-const char* LogMessageTest::_level_filename[] = {
- NULL, // LogLevel::Off
-#define LOG_LEVEL(name, printname) "multiline-" #printname ".log",
- LOG_LEVEL_LIST
-#undef LOG_LEVEL
-};
-
-void Test_multiline_logging() {
- LogMessageTest::test();
-}
-
-void LogMessageTest::test() {
- ResourceMark rm;
-
- for (int i = 0; i < LogLevel::Count; i++) {
- char buf[32];
- // Attempt to remove possibly pre-existing log files
- remove(_level_filename[i]);
-
- jio_snprintf(buf, sizeof(buf), "logging=%s", LogLevel::name(static_cast<LogLevelType>(i)));
- bool success = LogConfiguration::parse_log_arguments(_level_filename[i], buf,
- NULL, NULL, _log.error_stream());
- assert(success, "unable to configure logging to file '%s'", _level_filename[i]);
- }
-
- test_level_inclusion();
- test_line_order();
- test_long_message();
- test_message_with_many_lines();
- test_prefixing();
- test_scoped_messages();
- test_scoped_flushing();
- test_scoped_reset();
-
- // Stop logging to the files and remove them.
- for (int i = 0; i < LogLevel::Count; i++) {
- LogConfiguration::parse_log_arguments(_level_filename[i], "all=off", NULL, NULL, _log.error_stream());
- remove(_level_filename[i]);
- }
-}
-
-// Verify that messages with multiple levels are written
-// to outputs configured for all the corresponding levels
-void LogMessageTest::test_level_inclusion() {
- const size_t message_count = 10;
- LogMessageBuffer msg[message_count];
-
- struct {
- int message_number;
- LogLevelType level;
- } lines[] = {
- { 0, LogLevel::Error },
- { 1, LogLevel::Info },
- { 2, LogLevel::Info }, { 2, LogLevel::Debug },
- { 3, LogLevel::Info }, { 3, LogLevel::Warning },
- { 4, LogLevel::Debug }, { 4, LogLevel::Warning },
- { 5, LogLevel::Trace }, { 5, LogLevel::Debug },
- { 6, LogLevel::Warning }, { 6, LogLevel::Error },
- { 7, LogLevel::Trace }, { 7, LogLevel::Info }, { 7, LogLevel::Debug },
- { 8, LogLevel::Trace }, { 8, LogLevel::Debug }, { 8, LogLevel::Info },
- { 8, LogLevel::Warning }, { 8, LogLevel::Error},
- { 9, LogLevel::Trace }
- };
-
- // Fill in messages with the above lines
- for (size_t i = 0; i < ARRAY_SIZE(lines); i++) {
- switch (lines[i].level) {
-#define LOG_LEVEL(name, printname) \
- case LogLevel::name: \
- msg[lines[i].message_number].printname("msg[%d]: " #printname, lines[i].message_number); \
- break;
-LOG_LEVEL_LIST
-#undef LOG_LEVEL
- }
- }
-
- for (size_t i = 0; i < message_count; i++) {
- _log.write(msg[i]);
- }
-
- // Verify that lines are written to the expected log files
- for (size_t i = 0; i < ARRAY_SIZE(lines); i++) {
- char expected[256];
- jio_snprintf(expected, sizeof(expected), "msg[%d]: %s",
- lines[i].message_number, LogLevel::name(lines[i].level));
- for (int level = lines[i].level; level > 0; level--) {
- assert(file_contains_substring(_level_filename[level], expected),
- "line #" SIZE_FORMAT " missing from log file '%s'", i, _level_filename[level]);
- }
- for (int level = lines[i].level + 1; level < LogLevel::Count; level++) {
- assert(!file_contains_substring(_level_filename[level], expected),
- "line #" SIZE_FORMAT " erroneously included in log file '%s'", i, _level_filename[level]);
- }
- }
-}
-
-// Verify that messages are logged in the order they are added to the log message
-void LogMessageTest::test_line_order() {
- LogMessageBuffer msg;
- msg.info("info line").error("error line").trace("trace line")
- .error("another error").warning("warning line").debug("debug line");
- _log.write(msg);
-
- const char* expected[] = { "info line", "error line", "trace line",
- "another error", "warning line", "debug line", NULL };
- assert(file_contains_substrings_in_order(_level_filename[LogLevel::Trace], expected),
- "output missing or in incorrect order");
-}
-
-void LogMessageTest::test_long_message() {
- // Write 10K bytes worth of log data
- LogMessageBuffer msg;
- const size_t size = 10 * K;
- const char* start_marker = "#start#";
- const char* end_marker = "#the end#";
- char* data = NEW_C_HEAP_ARRAY(char, size, mtLogging);
-
- // fill buffer with start_marker...some data...end_marker
- sprintf(data, "%s", start_marker);
- for (size_t i = strlen(start_marker); i < size; i++) {
- data[i] = '0' + (i % 10);
- }
- sprintf(data + size - strlen(end_marker) - 1, "%s", end_marker);
-
- msg.trace("%s", data); // Adds a newline, making the message exactly 10K in length.
- _log.write(msg);
-
- const char* expected[] = { start_marker, "0123456789", end_marker, NULL };
- assert(file_contains_substrings_in_order(_level_filename[LogLevel::Trace], expected),
- "unable to print long line");
- FREE_C_HEAP_ARRAY(char, data);
-}
-
-void LogMessageTest::test_message_with_many_lines() {
- const size_t lines = 100;
- const size_t line_length = 16;
-
- LogMessageBuffer msg;
- for (size_t i = 0; i < lines; i++) {
- msg.info("Line #" SIZE_FORMAT, i);
- }
- _log.write(msg);
-
- char expected_lines_data[lines][line_length];
- const char* expected_lines[lines + 1];
- for (size_t i = 0; i < lines; i++) {
- jio_snprintf(&expected_lines_data[i][0], line_length, "Line #" SIZE_FORMAT, i);
- expected_lines[i] = expected_lines_data[i];
- }
- expected_lines[lines] = NULL;
-
- assert(file_contains_substrings_in_order(_level_filename[LogLevel::Trace], expected_lines),
- "couldn't find all lines in multiline message");
-}
-
-static size_t dummy_prefixer(char* buf, size_t len) {
- static int i = 0;
- const char* prefix = "some prefix: ";
- const size_t prefix_len = strlen(prefix);
- if (len < prefix_len) {
- return prefix_len;
- }
- jio_snprintf(buf, len, "%s", prefix);
- return prefix_len;
-}
-
-void LogMessageTest::test_prefixing() {
- LogMessageBuffer msg;
- msg.set_prefix(dummy_prefixer);
- for (int i = 0; i < 3; i++) {
- msg.info("test %d", i);
- }
- msg.set_prefix(NULL);
- msg.info("test 3");
- _log.write(msg);
-
- const char* expected[] = {
- "] some prefix: test 0",
- "] some prefix: test 1",
- "] some prefix: test 2",
- "] test 3",
- NULL
- };
- assert(file_contains_substrings_in_order(_level_filename[LogLevel::Trace], expected), "error in prefixed output");
-}
-
-void LogMessageTest::test_scoped_messages() {
- {
- LogMessage(logging) msg;
- msg.info("scoped info");
- msg.warning("scoped warn");
- assert(!file_contains_substring(_level_filename[LogLevel::Info], "scoped info"),
- "scoped log message written prematurely");
- }
- assert(file_contains_substring(_level_filename[LogLevel::Info], "scoped info"),
- "missing output from scoped log message");
- assert(file_contains_substring(_level_filename[LogLevel::Warning], "scoped warn"),
- "missing output from scoped log message");
-}
-
-void LogMessageTest::test_scoped_flushing() {
- {
- LogMessage(logging) msg;
- msg.info("manual flush info");
- msg.flush();
- assert(file_contains_substring(_level_filename[LogLevel::Info], "manual flush info"),
- "missing output from manually flushed scoped log message");
- }
- const char* tmp[] = {"manual flush info", "manual flush info", NULL};
- assert(!file_contains_substrings_in_order(_level_filename[LogLevel::Info], tmp),
- "log file contains duplicate lines from single scoped log message");
-}
-
-void LogMessageTest::test_scoped_reset() {
- {
- LogMessage(logging) msg, partial;
- msg.info("%s", "info reset msg");
- msg.reset();
- partial.info("%s", "info reset msg");
- partial.reset();
- partial.trace("%s", "trace reset msg");
- }
- assert(!file_contains_substring(_level_filename[LogLevel::Info], "info reset msg"),
- "reset message written anyway");
- assert(file_contains_substring(_level_filename[LogLevel::Trace], "trace reset msg"),
- "missing message from partially reset scoped log message");
-}
-
-
-static int Test_logconfiguration_subscribe_triggered = 0;
-
-static void Test_logconfiguration_subscribe_helper() {
- Test_logconfiguration_subscribe_triggered++;
-}
-
-void Test_logconfiguration_subscribe() {
- ResourceMark rm;
- Log(logging) log;
-
- TestLogSavedConfig log_cfg("stdout", "logging*=trace");
-
- LogConfiguration::register_update_listener(&Test_logconfiguration_subscribe_helper);
-
- LogConfiguration::parse_log_arguments("stdout", "logging=trace", NULL, NULL, log.error_stream());
- assert(Test_logconfiguration_subscribe_triggered == 1, "subscription not triggered (1)");
-
- LogConfiguration::configure_stdout(LogLevel::Debug, true, LOG_TAGS(gc));
- assert(Test_logconfiguration_subscribe_triggered == 2, "subscription not triggered (2)");
-
- LogConfiguration::disable_logging();
- assert(Test_logconfiguration_subscribe_triggered == 3, "subscription not triggered (3)");
-}
-
-#define LOG_PREFIX_STR "THE_PREFIX "
-#define LOG_LINE_STR "a log line"
-
-size_t Test_log_prefix_prefixer(char* buf, size_t len) {
- int ret = jio_snprintf(buf, len, LOG_PREFIX_STR);
- assert(ret > 0, "Failed to print prefix. Log buffer too small?");
- return (size_t) ret;
-}
-
-void Test_log_prefix() {
- TestLogFile log_file("log_prefix");
- TestLogSavedConfig log_cfg(log_file.name(), "logging+test=trace");
-
- log_trace(logging, test)(LOG_LINE_STR);
-
- FILE* fp = fopen(log_file.name(), "r");
- assert(fp, "File read error");
- char output[1024];
- if (fgets(output, 1024, fp) != NULL) {
- assert(strstr(output, LOG_PREFIX_STR LOG_LINE_STR), "logging prefix error");
- }
- fclose(fp);
-}
-
-void Test_log_big() {
- char big_msg[4096] = {0};
- char Xchar = '~';
-
- TestLogFile log_file("log_big");
- TestLogSavedConfig log_cfg(log_file.name(), "logging+test=trace");
-
- memset(big_msg, Xchar, sizeof(big_msg) - 1);
-
- log_trace(logging, test)("%s", big_msg);
-
- FILE* fp = fopen(log_file.name(), "r");
- assert(fp, "File read error");
- char output[sizeof(big_msg)+128 /*decorators*/ ];
- if (fgets(output, sizeof(output), fp) != NULL) {
- assert(strstr(output, LOG_PREFIX_STR), "logging prefix error");
- size_t count = 0;
- for (size_t ps = 0 ; output[ps + count] != '\0'; output[ps + count] == Xchar ? count++ : ps++);
- assert(count == (sizeof(big_msg) - 1) , "logging msg error");
- }
- fclose(fp);
-}
-
-void Test_logtagset_duplicates() {
- for (LogTagSet* ts = LogTagSet::first(); ts != NULL; ts = ts->next()) {
- char ts_name[512];
- ts->label(ts_name, sizeof(ts_name), ",");
-
- // verify that NO_TAG is never followed by a real tag
- for (size_t i = 0; i < LogTag::MaxTags; i++) {
- if (ts->tag(i) == LogTag::__NO_TAG) {
- for (i++; i < LogTag::MaxTags; i++) {
- assert(ts->tag(i) == LogTag::__NO_TAG,
- "NO_TAG was followed by a real tag (%s) in tagset %s",
- LogTag::name(ts->tag(i)), ts_name);
- }
- }
- }
-
- // verify that there are no duplicate tagsets (same tags in different order)
- for (LogTagSet* other = ts->next(); other != NULL; other = other->next()) {
- if (ts->ntags() != other->ntags()) {
- continue;
- }
- bool equal = true;
- for (size_t i = 0; i < ts->ntags(); i++) {
- LogTagType tag = ts->tag(i);
- if (!other->contains(tag)) {
- equal = false;
- break;
- }
- }
- // Since tagsets are implemented using template arguments, using both of
- // the (logically equivalent) tagsets (t1, t2) and (t2, t1) somewhere will
- // instantiate two different LogTagSetMappings. This causes multiple
- // tagset instances to be created for the same logical set. We want to
- // avoid this to save time, memory and prevent any confusion around it.
- if (equal) {
- char other_name[512];
- other->label(other_name, sizeof(other_name), ",");
- assert(false, "duplicate LogTagSets found: '%s' vs '%s' "
- "(tags must always be specified in the same order for each tagset)",
- ts_name, other_name);
- }
- }
- }
-}
-
-#define Test_logtarget_string_literal "First line"
-
-
-static void Test_logtarget_on() {
- TestLogFile log_file("log_target");
- TestLogSavedConfig tlsc(log_file.name(), "gc=debug");
-
- LogTarget(Debug, gc) log;
-
- assert(log.is_enabled(), "assert");
-
- // Log the line and expect it to be available in the output file.
- log.print(Test_logtarget_string_literal);
-
- FILE* fp = fopen(log_file.name(), "r");
- assert(fp != NULL, "File read error");
-
- char output[256 /* Large enough buffer */];
- char* res = fgets(output, sizeof(output), fp);
- assert(res != NULL, "assert");
-
- assert(strstr(output, Test_logtarget_string_literal) != NULL, "log line missing");
-
- fclose(fp);
-}
-
-static void Test_logtarget_off() {
- TestLogFile log_file("log_target");
- TestLogSavedConfig tlsc(log_file.name(), "gc=info");
-
- LogTarget(Debug, gc) log;
-
- if (log.is_enabled()) {
- // The log config could have been redirected gc=debug to a file. If gc=debug
- // is enabled, we can only test that the LogTarget returns the same value
- // as the log_is_enabled function. The rest of the test will be ignored.
- assert(log.is_enabled() == log_is_enabled(Debug, gc), "assert");
- log_warning(logging)("This test doesn't support runs with -Xlog");
- return;
- }
-
- // Try to log, but expect this to be filtered out.
- log.print(Test_logtarget_string_literal);
-
- // Log a dummy line so that fgets doesn't return NULL because the file is empty.
- log_info(gc)("Dummy line");
-
- FILE* fp = fopen(log_file.name(), "r");
- assert(fp != NULL, "File read error");
-
- char output[256 /* Large enough buffer */];
- char* res = fgets(output, sizeof(output), fp);
- assert(res != NULL, "assert");
-
- assert(strstr(output, Test_logtarget_string_literal) == NULL, "log line not missing");
-
- fclose(fp);
-}
-
-void Test_logtarget() {
- Test_logtarget_on();
- Test_logtarget_off();
-}
-
-
-static void Test_logstream_helper(outputStream* stream) {
- TestLogFile log_file("log_stream");
- TestLogSavedConfig tlsc(log_file.name(), "gc=debug");
-
- // Try to log, but expect this to be filtered out.
- stream->print("%d ", 3); stream->print("workers"); stream->cr();
-
- FILE* fp = fopen(log_file.name(), "r");
- assert(fp != NULL, "File read error");
-
- char output[256 /* Large enough buffer */];
- char* res = fgets(output, sizeof(output), fp);
- assert(res != NULL, "assert");
-
- assert(strstr(output, "3 workers") != NULL, "log line missing");
-
- fclose(fp);
-}
-
-static void Test_logstream_log() {
- Log(gc) log;
- LogStream stream(log.debug());
-
- Test_logstream_helper(&stream);
-}
-
-static void Test_logstream_logtarget() {
- LogTarget(Debug, gc) log;
- LogStream stream(log);
-
- Test_logstream_helper(&stream);
-}
-
-static void Test_logstream_logstreamhandle() {
- LogStreamHandle(Debug, gc) stream;
-
- Test_logstream_helper(&stream);
-}
-
-static void Test_logstream_no_rm() {
- ResourceMark rm;
- outputStream* stream = LogTarget(Debug, gc)::stream();
-
- Test_logstream_helper(stream);
-}
-
-static void Test_logstreamcheap_log() {
- Log(gc) log;
- LogStreamCHeap stream(log.debug());
-
- Test_logstream_helper(&stream);
-}
-
-static void Test_logstreamcheap_logtarget() {
- LogTarget(Debug, gc) log;
- LogStreamCHeap stream(log);
-
- Test_logstream_helper(&stream);
-}
-
-void Test_logstream() {
- // Test LogStreams with embedded ResourceMark.
- Test_logstream_log();
- Test_logstream_logtarget();
- Test_logstream_logstreamhandle();
-
- // Test LogStreams without embedded ResourceMark.
- Test_logstream_no_rm();
-
- // Test LogStreams backed by CHeap memory.
- Test_logstreamcheap_log();
- Test_logstreamcheap_logtarget();
-}
-
-void Test_loghandle_on() {
- TestLogFile log_file("log_handle");
- TestLogSavedConfig tlsc(log_file.name(), "gc=debug");
-
- Log(gc) log;
- LogHandle log_handle(log);
-
- assert(log_handle.is_debug(), "assert");
-
- // Try to log through a LogHandle.
- log_handle.debug("%d workers", 3);
-
- FILE* fp = fopen(log_file.name(), "r");
- assert(fp, "File read error");
-
- char output[256 /* Large enough buffer */];
- char* res = fgets(output, sizeof(output), fp);
- assert(res != NULL, "assert");
-
- assert(strstr(output, "3 workers") != NULL, "log line missing");
-
- fclose(fp);
-}
-
-void Test_loghandle_off() {
- TestLogFile log_file("log_handle");
- TestLogSavedConfig tlsc(log_file.name(), "gc=info");
-
- Log(gc) log;
- LogHandle log_handle(log);
-
- if (log_handle.is_debug()) {
- // The log config could have been redirected gc=debug to a file. If gc=debug
- // is enabled, we can only test that the LogTarget returns the same value
- // as the log_is_enabled function. The rest of the test will be ignored.
- assert(log_handle.is_debug() == log_is_enabled(Debug, gc), "assert");
- log_warning(logging)("This test doesn't support runs with -Xlog");
- return;
- }
-
- // Try to log through a LogHandle. Should fail, since only info is turned on.
- log_handle.debug("%d workers", 3);
-
- // Log a dummy line so that fgets doesn't return NULL because the file is empty.
- log_info(gc)("Dummy line");
-
- FILE* fp = fopen(log_file.name(), "r");
- assert(fp, "File read error");
-
- char output[256 /* Large enough buffer */];
- char* res = fgets(output, sizeof(output), fp);
- assert(res != NULL, "assert");
-
- assert(strstr(output, "3 workers") == NULL, "log line missing");
-
- fclose(fp);
-}
-
-void Test_loghandle() {
- Test_loghandle_on();
- Test_loghandle_off();
-}
-
-static void Test_logtargethandle_on() {
- TestLogFile log_file("log_handle");
- TestLogSavedConfig tlsc(log_file.name(), "gc=debug");
-
- LogTarget(Debug, gc) log;
- LogTargetHandle log_handle(log);
-
- assert(log_handle.is_enabled(), "assert");
-
- // Try to log through a LogHandle.
- log_handle.print("%d workers", 3);
-
- FILE* fp = fopen(log_file.name(), "r");
- assert(fp, "File read error");
-
- char output[256 /* Large enough buffer */];
- char* res = fgets(output, sizeof(output), fp);
- assert(res != NULL, "assert");
-
- assert(strstr(output, "3 workers") != NULL, "log line missing");
-
- fclose(fp);
-}
-
-static void Test_logtargethandle_off() {
- TestLogFile log_file("log_handle");
- TestLogSavedConfig tlsc(log_file.name(), "gc=info");
-
- LogTarget(Debug, gc) log;
- LogTargetHandle log_handle(log);
-
- if (log_handle.is_enabled()) {
- // The log config could have been redirected gc=debug to a file. If gc=debug
- // is enabled, we can only test that the LogTarget returns the same value
- // as the log_is_enabled function. The rest of the test will be ignored.
- assert(log_handle.is_enabled() == log_is_enabled(Debug, gc), "assert");
- log_warning(logging)("This test doesn't support runs with -Xlog");
- return;
- }
-
- // Try to log through a LogHandle. Should fail, since only info is turned on.
- log_handle.print("%d workers", 3);
-
- // Log a dummy line so that fgets doesn't return NULL because the file is empty.
- log_info(gc)("Dummy line");
-
- FILE* fp = fopen(log_file.name(), "r");
- assert(fp, "File read error");
-
- char output[256 /* Large enough buffer */];
- char* res = fgets(output, sizeof(output), fp);
- assert(res != NULL, "assert");
-
- assert(strstr(output, "3 workers") == NULL, "log line missing");
-
- fclose(fp);
-}
-
-void Test_logtargethandle() {
- Test_logtargethandle_on();
- Test_logtargethandle_off();
-}
-
-static void Test_log_gctracetime_full() {
- TestLogFile log_file("log_gctracetime");
- TestLogSavedConfig tlsc(log_file.name(), "gc=debug,gc+start=debug");
-
- LogTarget(Debug, gc) gc_debug;
- LogTarget(Debug, gc, start) gc_start_debug;
-
- assert(gc_debug.is_enabled(), "assert");
- assert(gc_start_debug.is_enabled(), "assert");
-
- {
- MutexLocker lock(Heap_lock); // Needed to read heap usage
- GCTraceTime(Debug, gc) timer("Test GC", NULL, GCCause::_allocation_failure, true);
- }
-
- FILE* fp = fopen(log_file.name(), "r");
- assert(fp, "File read error");
-
- char output[256 /* Large enough buffer */];
-
- char* res = fgets(output, sizeof(output), fp);
- assert(res != NULL, "assert");
-
- // [2.975s][debug][gc,start] Test GC (Allocation Failure) (2.975s)
- assert(strstr(output, "[gc,start") != NULL, "Incorrect tag set");
- assert(strstr(output, "] Test GC (Allocation Failure) (") != NULL, "Incorrect log line");
- assert(strstr(output, "s)") != NULL, "Incorrect log line");
-
- res = fgets(output, sizeof(output), fp);
- assert(res != NULL, "assert");
-
- // [2.975s][debug][gc ] Test GC (Allocation Failure) 59M->59M(502M) (2.975s, 2.975s) 0.026ms
- assert(strstr(output, "[gc ") != NULL, "Incorrect tag set");
- assert(strstr(output, "] Test GC (Allocation Failure) ") != NULL, "Incorrect log line");
- assert(strstr(output, "M) (") != NULL, "Incorrect log line");
- assert(strstr(output, "s, ") != NULL, "Incorrect log line");
- assert(strstr(output, "s) ") != NULL, "Incorrect log line");
- assert(strstr(output, "ms") != NULL, "Incorrect log line");
-
- fclose(fp);
-}
-
-static void Test_log_gctracetime_full_multitag() {
- TestLogFile log_file("log_gctracetime");
- TestLogSavedConfig tlsc(log_file.name(), "gc+ref=debug,gc+ref+start=debug");
-
- LogTarget(Debug, gc, ref) gc_debug;
- LogTarget(Debug, gc, ref, start) gc_start_debug;
-
- assert(gc_debug.is_enabled(), "assert");
- assert(gc_start_debug.is_enabled(), "assert");
-
- {
- MutexLocker lock(Heap_lock); // Needed to read heap usage
- GCTraceTime(Debug, gc, ref) timer("Test GC", NULL, GCCause::_allocation_failure, true);
- }
-
- FILE* fp = fopen(log_file.name(), "r");
- assert(fp, "File read error");
-
- char output[256 /* Large enough buffer */];
-
- char* res = fgets(output, sizeof(output), fp);
- assert(res != NULL, "assert");
-
- // [2.975s][debug][gc,start] Test GC (Allocation Failure) (2.975s)
- assert(strstr(output, "[gc,ref,start") != NULL, "Incorrect tag set");
- assert(strstr(output, "] Test GC (Allocation Failure) (") != NULL, "Incorrect log line");
- assert(strstr(output, "s)") != NULL, "Incorrect log line");
-
- res = fgets(output, sizeof(output), fp);
- assert(res != NULL, "assert");
-
- // [2.975s][debug][gc ] Test GC (Allocation Failure) 59M->59M(502M) (2.975s, 2.975s) 0.026ms
- assert(strstr(output, "[gc,ref ") != NULL, "Incorrect tag set");
- assert(strstr(output, "] Test GC (Allocation Failure) ") != NULL, "Incorrect log line");
- assert(strstr(output, "M) (") != NULL, "Incorrect log line");
- assert(strstr(output, "s, ") != NULL, "Incorrect log line");
- assert(strstr(output, "s) ") != NULL, "Incorrect log line");
- assert(strstr(output, "ms") != NULL, "Incorrect log line");
-
- fclose(fp);
-}
-
-static void Test_log_gctracetime_no_heap() {
- TestLogFile log_file("log_gctracetime");
- TestLogSavedConfig tlsc(log_file.name(), "gc=debug,gc+start=debug");
-
- LogTarget(Debug, gc) gc_debug;
- LogTarget(Debug, gc, start) gc_start_debug;
-
- assert(gc_debug.is_enabled(), "assert");
- assert(gc_start_debug.is_enabled(), "assert");
-
- {
- GCTraceTime(Debug, gc) timer("Test GC", NULL, GCCause::_allocation_failure, false);
- }
-
- FILE* fp = fopen(log_file.name(), "r");
- assert(fp, "File read error");
-
- char output[256 /* Large enough buffer */];
-
- char* res = fgets(output, sizeof(output), fp);
- assert(res != NULL, "assert");
-
- // [2.975s][debug][gc,start] Test GC (Allocation Failure) (2.975s)
- assert(strstr(output, "[gc,start") != NULL, "Incorrect tag set");
- assert(strstr(output, "] Test GC (Allocation Failure) (") != NULL, "Incorrect log line");
- assert(strstr(output, "s)") != NULL, "Incorrect log line");
-
- res = fgets(output, sizeof(output), fp);
- assert(res != NULL, "assert");
-
- // [2.975s][debug][gc ] Test GC (Allocation Failure) (2.975s, 2.975s) 0.026ms
- assert(strstr(output, "[gc ") != NULL, "Incorrect tag set");
- assert(strstr(output, "] Test GC (Allocation Failure) (") != NULL, "Incorrect log line");
- assert(strstr(output, "M) (") == NULL, "Incorrect log line");
- assert(strstr(output, "s, ") != NULL, "Incorrect log line");
- assert(strstr(output, "s) ") != NULL, "Incorrect log line");
- assert(strstr(output, "ms") != NULL, "Incorrect log line");
-
- fclose(fp);
-}
-
-static void Test_log_gctracetime_no_cause() {
- TestLogFile log_file("log_gctracetime");
- TestLogSavedConfig tlsc(log_file.name(), "gc=debug,gc+start=debug");
-
- LogTarget(Debug, gc) gc_debug;
- LogTarget(Debug, gc, start) gc_start_debug;
-
- assert(gc_debug.is_enabled(), "assert");
- assert(gc_start_debug.is_enabled(), "assert");
-
- {
- MutexLocker lock(Heap_lock); // Needed to read heap usage
- GCTraceTime(Debug, gc) timer("Test GC", NULL, GCCause::_no_gc, true);
- }
-
- FILE* fp = fopen(log_file.name(), "r");
- assert(fp, "File read error");
-
- char output[256 /* Large enough buffer */];
-
- char* res = fgets(output, sizeof(output), fp);
- assert(res != NULL, "assert");
-
- // [2.975s][debug][gc,start] Test GC (2.975s)
- assert(strstr(output, "[gc,start") != NULL, "Incorrect tag set");
- assert(strstr(output, "] Test GC (") != NULL, "Incorrect log line");
- assert(strstr(output, "s)") != NULL, "Incorrect log line");
-
- res = fgets(output, sizeof(output), fp);
- assert(res != NULL, "assert");
-
- // [2.975s][debug][gc ] Test GC 59M->59M(502M) (2.975s, 2.975s) 0.026ms
- assert(strstr(output, "[gc ") != NULL, "Incorrect tag set");
- assert(strstr(output, "] Test GC ") != NULL, "Incorrect log line");
- assert(strstr(output, "M) (") != NULL, "Incorrect log line");
- assert(strstr(output, "s, ") != NULL, "Incorrect log line");
- assert(strstr(output, "s) ") != NULL, "Incorrect log line");
- assert(strstr(output, "ms") != NULL, "Incorrect log line");
-
- fclose(fp);
-}
-
-static void Test_log_gctracetime_no_heap_no_cause() {
- TestLogFile log_file("log_gctracetime");
- TestLogSavedConfig tlsc(log_file.name(), "gc=debug,gc+start=debug");
-
- LogTarget(Debug, gc) gc_debug;
- LogTarget(Debug, gc, start) gc_start_debug;
-
- assert(gc_debug.is_enabled(), "assert");
- assert(gc_start_debug.is_enabled(), "assert");
-
- {
- MutexLocker lock(Heap_lock); // Needed to read heap usage
- GCTraceTime(Debug, gc) timer("Test GC", NULL, GCCause::_no_gc, false);
- }
-
- FILE* fp = fopen(log_file.name(), "r");
- assert(fp, "File read error");
-
- char output[256 /* Large enough buffer */];
-
- char* res = fgets(output, sizeof(output), fp);
- assert(res != NULL, "assert");
-
- // [2.975s][debug][gc,start] Test GC (2.975s)
- assert(strstr(output, "[gc,start") != NULL, "Incorrect tag set");
- assert(strstr(output, "] Test GC (") != NULL, "Incorrect log line");
- assert(strstr(output, "s)") != NULL, "Incorrect log line");
-
- res = fgets(output, sizeof(output), fp);
- assert(res != NULL, "assert");
-
- // [2.975s][debug][gc ] Test GC (2.975s, 2.975s) 0.026ms
- assert(strstr(output, "[gc ") != NULL, "Incorrect tag set");
- assert(strstr(output, "] Test GC (") != NULL, "Incorrect log line");
- assert(strstr(output, "M) (") == NULL, "Incorrect log line");
- assert(strstr(output, "s, ") != NULL, "Incorrect log line");
- assert(strstr(output, "s) ") != NULL, "Incorrect log line");
- assert(strstr(output, "ms") != NULL, "Incorrect log line");
-
- fclose(fp);
-}
-
-void Test_log_gctracetime() {
- Test_log_gctracetime_full();
- Test_log_gctracetime_full_multitag();
- Test_log_gctracetime_no_heap();
- Test_log_gctracetime_no_cause();
- Test_log_gctracetime_no_heap_no_cause();
-}
-
-void Test_invalid_log_file() {
- ResourceMark rm;
- stringStream ss;
- const char* target_name = "tmplogdir";
-
- // Attempt to log to a directory (existing log not a regular file)
- create_directory(target_name);
- LogFileOutput bad_file("file=tmplogdir");
- assert(bad_file.initialize("", &ss) == false, "file was initialized "
- "when there was an existing directory with the same name");
- assert(strstr(ss.as_string(), "tmplogdir is not a regular file") != NULL,
- "missing expected error message, received msg: %s", ss.as_string());
- ss.reset();
- remove(target_name);
-}
-
-// Ensure -Xlog:help and LogConfiguration::describe contain tagset descriptions
-void Test_logtagset_descriptions() {
- for (LogTagSetDescription* d = tagset_descriptions; d->tagset != NULL; d++) {
- char expected[1024];
- d->tagset->label(expected, sizeof(expected), "+");
- jio_snprintf(expected + strlen(expected),
- sizeof(expected) - strlen(expected),
- ": %s", d->descr);
-
- ResourceMark rm;
- stringStream ss;
- LogConfiguration::describe(&ss);
- assert(strstr(ss.as_string(), expected) != NULL,
- "missing log tag set descriptions in LogConfiguration::describe");
-
- TestLogFile file("log_tagset_descriptions");
- FILE* fp = fopen(file.name(), "w+");
- assert(fp != NULL, "File open error");
- LogConfiguration::print_command_line_help(fp);
- fclose(fp);
- assert(number_of_lines_with_substring_in_file(file.name(), expected) > 0,
- "missing log tag set descriptions in -Xlog:help output");
- }
-}
-#endif // PRODUCT
--- a/hotspot/src/share/vm/logging/logFileOutput.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/share/vm/logging/logFileOutput.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -97,11 +97,7 @@
if (ret != 0) {
return false;
}
-#ifdef _WINDOWS
- return (st.st_mode & S_IFMT) == _S_IFREG;
-#else
- return S_ISREG(st.st_mode);
-#endif
+ return (st.st_mode & S_IFMT) == S_IFREG;
}
// Try to find the next number that should be used for file rotation.
--- a/hotspot/src/share/vm/logging/logTag.hpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/share/vm/logging/logTag.hpp Wed Nov 09 10:04:43 2016 -0800
@@ -40,6 +40,7 @@
LOG_TAG(attach) \
LOG_TAG(barrier) \
LOG_TAG(biasedlocking) \
+ LOG_TAG(blocks) \
LOG_TAG(bot) \
LOG_TAG(breakpoint) \
LOG_TAG(census) \
@@ -105,6 +106,7 @@
LOG_TAG(scavenge) \
LOG_TAG(scrub) \
LOG_TAG(stacktrace) \
+ LOG_TAG(stackwalk) \
LOG_TAG(start) \
LOG_TAG(startuptime) \
LOG_TAG(state) \
--- a/hotspot/src/share/vm/memory/filemap.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/share/vm/memory/filemap.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -263,7 +263,7 @@
} else {
struct stat st;
if (os::stat(name, &st) == 0) {
- if ((st.st_mode & S_IFDIR) == S_IFDIR) {
+ if ((st.st_mode & S_IFMT) == S_IFDIR) {
if (!os::dir_is_empty(name)) {
ClassLoader::exit_with_path_failure(
"Cannot have non-empty directory in archived classpaths", name);
--- a/hotspot/src/share/vm/memory/filemap.hpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/share/vm/memory/filemap.hpp Wed Nov 09 10:04:43 2016 -0800
@@ -283,11 +283,15 @@
bool validate_classpath_entry_table();
static SharedClassPathEntry* shared_classpath(int index) {
+ if (index < 0) {
+ return NULL;
+ }
char* p = (char*)_classpath_entry_table;
p += _classpath_entry_size * index;
return (SharedClassPathEntry*)p;
}
static const char* shared_classpath_name(int index) {
+ assert(index >= 0, "Sanity");
return shared_classpath(index)->_name;
}
--- a/hotspot/src/share/vm/memory/metaspace.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/share/vm/memory/metaspace.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -249,10 +249,65 @@
void print_on(outputStream* st) const;
};
+class SmallBlocks : public CHeapObj<mtClass> {
+ const static uint _small_block_max_size = sizeof(TreeChunk<Metablock, FreeList<Metablock> >)/HeapWordSize;
+ const static uint _small_block_min_size = sizeof(Metablock)/HeapWordSize;
+
+ private:
+ FreeList<Metablock> _small_lists[_small_block_max_size - _small_block_min_size];
+
+ FreeList<Metablock>& list_at(size_t word_size) {
+ assert(word_size >= _small_block_min_size, "There are no metaspace objects less than %u words", _small_block_min_size);
+ return _small_lists[word_size - _small_block_min_size];
+ }
+
+ public:
+ SmallBlocks() {
+ for (uint i = _small_block_min_size; i < _small_block_max_size; i++) {
+ uint k = i - _small_block_min_size;
+ _small_lists[k].set_size(i);
+ }
+ }
+
+ size_t total_size() const {
+ size_t result = 0;
+ for (uint i = _small_block_min_size; i < _small_block_max_size; i++) {
+ uint k = i - _small_block_min_size;
+ result = result + _small_lists[k].count() * _small_lists[k].size();
+ }
+ return result;
+ }
+
+ static uint small_block_max_size() { return _small_block_max_size; }
+ static uint small_block_min_size() { return _small_block_min_size; }
+
+ MetaWord* get_block(size_t word_size) {
+ if (list_at(word_size).count() > 0) {
+ MetaWord* new_block = (MetaWord*) list_at(word_size).get_chunk_at_head();
+ return new_block;
+ } else {
+ return NULL;
+ }
+ }
+ void return_block(Metablock* free_chunk, size_t word_size) {
+ list_at(word_size).return_chunk_at_head(free_chunk, false);
+ assert(list_at(word_size).count() > 0, "Should have a chunk");
+ }
+
+ void print_on(outputStream* st) const {
+ st->print_cr("SmallBlocks:");
+ for (uint i = _small_block_min_size; i < _small_block_max_size; i++) {
+ uint k = i - _small_block_min_size;
+ st->print_cr("small_lists size " SIZE_FORMAT " count " SIZE_FORMAT, _small_lists[k].size(), _small_lists[k].count());
+ }
+ }
+};
+
// Used to manage the free list of Metablocks (a block corresponds
// to the allocation of a quantum of metadata).
-class BlockFreelist VALUE_OBJ_CLASS_SPEC {
+class BlockFreelist : public CHeapObj<mtClass> {
BlockTreeDictionary* const _dictionary;
+ SmallBlocks* _small_blocks;
// Only allocate and split from freelist if the size of the allocation
// is at least 1/4th the size of the available block.
@@ -260,6 +315,12 @@
// Accessors
BlockTreeDictionary* dictionary() const { return _dictionary; }
+ SmallBlocks* small_blocks() {
+ if (_small_blocks == NULL) {
+ _small_blocks = new SmallBlocks();
+ }
+ return _small_blocks;
+ }
public:
BlockFreelist();
@@ -269,8 +330,15 @@
MetaWord* get_block(size_t word_size);
void return_block(MetaWord* p, size_t word_size);
- size_t total_size() { return dictionary()->total_size(); }
-
+ size_t total_size() const {
+ size_t result = dictionary()->total_size();
+ if (_small_blocks != NULL) {
+ result = result + _small_blocks->total_size();
+ }
+ return result;
+ }
+
+ static size_t min_dictionary_size() { return TreeChunk<Metablock, FreeList<Metablock> >::min_size(); }
void print_on(outputStream* st) const;
};
@@ -629,7 +697,7 @@
// are assumed to be in chunks in use by the SpaceManager
// and all chunks in use by a SpaceManager are freed when
// the class loader using the SpaceManager is collected.
- BlockFreelist _block_freelists;
+ BlockFreelist* _block_freelists;
// protects virtualspace and chunk expansions
static const char* _expand_lock_name;
@@ -643,9 +711,7 @@
_chunks_in_use[index] = v;
}
- BlockFreelist* block_freelists() const {
- return (BlockFreelist*) &_block_freelists;
- }
+ BlockFreelist* block_freelists() const { return _block_freelists; }
Metaspace::MetadataType mdtype() { return _mdtype; }
@@ -763,7 +829,9 @@
void verify_allocated_blocks_words();
#endif
- size_t get_raw_word_size(size_t word_size) {
+ // This adjusts the size given to be greater than the minimum allocation size in
+ // words for data in metaspace. Esentially the minimum size is currently 3 words.
+ size_t get_allocation_word_size(size_t word_size) {
size_t byte_size = word_size * BytesPerWord;
size_t raw_bytes_size = MAX2(byte_size, sizeof(Metablock));
@@ -807,20 +875,45 @@
// BlockFreelist methods
-BlockFreelist::BlockFreelist() : _dictionary(new BlockTreeDictionary()) {}
+BlockFreelist::BlockFreelist() : _dictionary(new BlockTreeDictionary()), _small_blocks(NULL) {}
BlockFreelist::~BlockFreelist() {
delete _dictionary;
+ if (_small_blocks != NULL) {
+ delete _small_blocks;
+ }
}
void BlockFreelist::return_block(MetaWord* p, size_t word_size) {
+ assert(word_size >= SmallBlocks::small_block_min_size(), "never return dark matter");
+
Metablock* free_chunk = ::new (p) Metablock(word_size);
+ if (word_size < SmallBlocks::small_block_max_size()) {
+ small_blocks()->return_block(free_chunk, word_size);
+ } else {
dictionary()->return_chunk(free_chunk);
}
+ log_trace(gc, metaspace, freelist, blocks)("returning block at " INTPTR_FORMAT " size = "
+ SIZE_FORMAT, p2i(free_chunk), word_size);
+}
MetaWord* BlockFreelist::get_block(size_t word_size) {
- if (word_size < TreeChunk<Metablock, FreeList<Metablock> >::min_size()) {
- // Dark matter. Too small for dictionary.
+ assert(word_size >= SmallBlocks::small_block_min_size(), "never get dark matter");
+
+ // Try small_blocks first.
+ if (word_size < SmallBlocks::small_block_max_size()) {
+ // Don't create small_blocks() until needed. small_blocks() allocates the small block list for
+ // this space manager.
+ MetaWord* new_block = (MetaWord*) small_blocks()->get_block(word_size);
+ if (new_block != NULL) {
+ log_trace(gc, metaspace, freelist, blocks)("getting block at " INTPTR_FORMAT " size = " SIZE_FORMAT,
+ p2i(new_block), word_size);
+ return new_block;
+ }
+ }
+
+ if (word_size < BlockFreelist::min_dictionary_size()) {
+ // If allocation in small blocks fails, this is Dark Matter. Too small for dictionary.
return NULL;
}
@@ -839,15 +932,20 @@
MetaWord* new_block = (MetaWord*)free_block;
assert(block_size >= word_size, "Incorrect size of block from freelist");
const size_t unused = block_size - word_size;
- if (unused >= TreeChunk<Metablock, FreeList<Metablock> >::min_size()) {
+ if (unused >= SmallBlocks::small_block_min_size()) {
return_block(new_block + word_size, unused);
}
+ log_trace(gc, metaspace, freelist, blocks)("getting block at " INTPTR_FORMAT " size = " SIZE_FORMAT,
+ p2i(new_block), word_size);
return new_block;
}
void BlockFreelist::print_on(outputStream* st) const {
dictionary()->print_free_lists(st);
+ if (_small_blocks != NULL) {
+ _small_blocks->print_on(st);
+ }
}
// VirtualSpaceNode methods
@@ -2075,6 +2173,7 @@
_allocated_blocks_words(0),
_allocated_chunks_words(0),
_allocated_chunks_count(0),
+ _block_freelists(NULL),
_lock(lock)
{
initialize();
@@ -2164,8 +2263,10 @@
log.trace("~SpaceManager(): " PTR_FORMAT, p2i(this));
ResourceMark rm;
locked_print_chunks_in_use_on(log.trace_stream());
+ if (block_freelists() != NULL) {
block_freelists()->print_on(log.trace_stream());
}
+ }
// Have to update before the chunks_in_use lists are emptied
// below.
@@ -2215,6 +2316,10 @@
}
log.trace("updated dictionary count " SIZE_FORMAT " %s", chunk_manager()->humongous_dictionary()->total_count(), chunk_size_name(HumongousIndex));
chunk_manager()->slow_locked_verify();
+
+ if (_block_freelists != NULL) {
+ delete _block_freelists;
+ }
}
const char* SpaceManager::chunk_size_name(ChunkIndex index) const {
@@ -2253,10 +2358,12 @@
void SpaceManager::deallocate(MetaWord* p, size_t word_size) {
assert_lock_strong(_lock);
- size_t raw_word_size = get_raw_word_size(word_size);
- size_t min_size = TreeChunk<Metablock, FreeList<Metablock> >::min_size();
- assert(raw_word_size >= min_size,
- "Should not deallocate dark matter " SIZE_FORMAT "<" SIZE_FORMAT, word_size, min_size);
+ // Allocations and deallocations are in raw_word_size
+ size_t raw_word_size = get_allocation_word_size(word_size);
+ // Lazily create a block_freelist
+ if (block_freelists() == NULL) {
+ _block_freelists = new BlockFreelist();
+ }
block_freelists()->return_block(p, raw_word_size);
}
@@ -2312,8 +2419,9 @@
void SpaceManager::retire_current_chunk() {
if (current_chunk() != NULL) {
size_t remaining_words = current_chunk()->free_word_size();
- if (remaining_words >= TreeChunk<Metablock, FreeList<Metablock> >::min_size()) {
- block_freelists()->return_block(current_chunk()->allocate(remaining_words), remaining_words);
+ if (remaining_words >= BlockFreelist::min_dictionary_size()) {
+ MetaWord* ptr = current_chunk()->allocate(remaining_words);
+ deallocate(ptr, remaining_words);
inc_used_metrics(remaining_words);
}
}
@@ -2350,7 +2458,7 @@
* will be made to allocate a small chunk.
*/
MetaWord* SpaceManager::get_small_chunk_and_allocate(size_t word_size) {
- size_t raw_word_size = get_raw_word_size(word_size);
+ size_t raw_word_size = get_allocation_word_size(word_size);
if (raw_word_size + Metachunk::overhead() > small_chunk_size()) {
return NULL;
@@ -2380,8 +2488,7 @@
MetaWord* SpaceManager::allocate(size_t word_size) {
MutexLockerEx cl(lock(), Mutex::_no_safepoint_check_flag);
-
- size_t raw_word_size = get_raw_word_size(word_size);
+ size_t raw_word_size = get_allocation_word_size(word_size);
BlockFreelist* fl = block_freelists();
MetaWord* p = NULL;
// Allocation from the dictionary is expensive in the sense that
@@ -2389,7 +2496,7 @@
// from the dictionary until it starts to get fat. Is this
// a reasonable policy? Maybe an skinny dictionary is fast enough
// for allocations. Do some profiling. JJJ
- if (fl->total_size() > allocation_from_dictionary_limit) {
+ if (fl != NULL && fl->total_size() > allocation_from_dictionary_limit) {
p = fl->get_block(raw_word_size);
}
if (p == NULL) {
@@ -2441,7 +2548,7 @@
// If there are blocks in the dictionary, then
// verification of chunks does not work since
// being in the dictionary alters a chunk.
- if (block_freelists()->total_size() == 0) {
+ if (block_freelists() != NULL && block_freelists()->total_size() == 0) {
for (ChunkIndex i = ZeroIndex; i < NumberOfInUseLists; i = next_chunk_index(i)) {
Metachunk* curr = chunks_in_use(i);
while (curr != NULL) {
@@ -2499,7 +2606,7 @@
}
if (log_is_enabled(Trace, gc, metaspace, freelist)) {
- block_freelists()->print_on(out);
+ if (block_freelists() != NULL) block_freelists()->print_on(out);
}
size_t free = current_chunk() == NULL ? 0 : current_chunk()->free_word_size();
@@ -3410,18 +3517,11 @@
|| Thread::current()->is_VM_thread(), "should be the VM thread");
if (DumpSharedSpaces && PrintSharedSpaces) {
- record_deallocation(ptr, vsm()->get_raw_word_size(word_size));
+ record_deallocation(ptr, vsm()->get_allocation_word_size(word_size));
}
MutexLockerEx ml(vsm()->lock(), Mutex::_no_safepoint_check_flag);
- if (word_size < TreeChunk<Metablock, FreeList<Metablock> >::min_size()) {
- // Dark matter. Too small for dictionary.
-#ifdef ASSERT
- Copy::fill_to_words((HeapWord*)ptr, word_size, 0xf5f5f5f5);
-#endif
- return;
- }
if (is_class && using_class_space()) {
class_vsm()->deallocate(ptr, word_size);
} else {
@@ -3451,7 +3551,7 @@
report_out_of_shared_space(read_only ? SharedReadOnly : SharedReadWrite);
}
if (PrintSharedSpaces) {
- space->record_allocation(result, type, space->vsm()->get_raw_word_size(word_size));
+ space->record_allocation(result, type, space->vsm()->get_allocation_word_size(word_size));
}
// Zero initialize.
@@ -3509,10 +3609,11 @@
// If result is still null, we are out of memory.
Log(gc, metaspace, freelist) log;
- if (log.is_trace()) {
- log.trace("Metaspace allocation failed for size " SIZE_FORMAT, word_size);
+ if (log.is_info()) {
+ log.info("Metaspace (%s) allocation failed for size " SIZE_FORMAT,
+ is_class_space_allocation(mdtype) ? "class" : "data", word_size);
ResourceMark rm;
- outputStream* out = log.trace_stream();
+ outputStream* out = log.info_stream();
if (loader_data->metaspace_or_null() != NULL) {
loader_data->dump(out);
}
--- a/hotspot/src/share/vm/oops/constMethod.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/share/vm/oops/constMethod.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -368,23 +368,36 @@
return (AnnotationArray**)constMethod_end() - offset;
}
+Array<u1>* copy_annotations(ClassLoaderData* loader_data, AnnotationArray* from, TRAPS) {
+ int length = from->length();
+ Array<u1>* a = MetadataFactory::new_array<u1>(loader_data, length, 0, CHECK_NULL);
+ memcpy((void*)a->adr_at(0), (void*)from->adr_at(0), length);
+ return a;
+}
+
// copy annotations from 'cm' to 'this'
-void ConstMethod::copy_annotations_from(ConstMethod* cm) {
+// Must make copy because these are deallocated with their constMethod, if redefined.
+void ConstMethod::copy_annotations_from(ClassLoaderData* loader_data, ConstMethod* cm, TRAPS) {
+ Array<u1>* a;
if (cm->has_method_annotations()) {
assert(has_method_annotations(), "should be allocated already");
- set_method_annotations(cm->method_annotations());
+ a = copy_annotations(loader_data, cm->method_annotations(), CHECK);
+ set_method_annotations(a);
}
if (cm->has_parameter_annotations()) {
assert(has_parameter_annotations(), "should be allocated already");
- set_parameter_annotations(cm->parameter_annotations());
+ a = copy_annotations(loader_data, cm->parameter_annotations(), CHECK);
+ set_parameter_annotations(a);
}
if (cm->has_type_annotations()) {
assert(has_type_annotations(), "should be allocated already");
- set_type_annotations(cm->type_annotations());
+ a = copy_annotations(loader_data, cm->type_annotations(), CHECK);
+ set_type_annotations(a);
}
if (cm->has_default_annotations()) {
assert(has_default_annotations(), "should be allocated already");
- set_default_annotations(cm->default_annotations());
+ a = copy_annotations(loader_data, cm->default_annotations(), CHECK);
+ set_default_annotations(a);
}
}
--- a/hotspot/src/share/vm/oops/constMethod.hpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/share/vm/oops/constMethod.hpp Wed Nov 09 10:04:43 2016 -0800
@@ -469,7 +469,7 @@
}
// Copy annotations from other ConstMethod
- void copy_annotations_from(ConstMethod* cm);
+ void copy_annotations_from(ClassLoaderData* loader_data, ConstMethod* cm, TRAPS);
// byte codes
void set_code(address code) {
--- a/hotspot/src/share/vm/oops/instanceKlass.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/share/vm/oops/instanceKlass.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -674,20 +674,20 @@
// Eagerly initialize superinterfaces that declare default methods (concrete instance: any access)
void InstanceKlass::initialize_super_interfaces(instanceKlassHandle this_k, TRAPS) {
- assert (this_k->has_default_methods(), "caller should have checked this");
+ assert (this_k->has_nonstatic_concrete_methods(), "caller should have checked this");
for (int i = 0; i < this_k->local_interfaces()->length(); ++i) {
Klass* iface = this_k->local_interfaces()->at(i);
InstanceKlass* ik = InstanceKlass::cast(iface);
// Initialization is depth first search ie. we start with top of the inheritance tree
- // has_default_methods drives searching superinterfaces since it
- // means has_default_methods in its superinterface hierarchy
- if (ik->has_default_methods()) {
+ // has_nonstatic_concrete_methods drives searching superinterfaces since it
+ // means has_nonstatic_concrete_methods in its superinterface hierarchy
+ if (ik->has_nonstatic_concrete_methods()) {
ik->initialize_super_interfaces(ik, CHECK);
}
// Only initialize() interfaces that "declare" concrete methods.
- if (ik->should_be_initialized() && ik->declares_default_methods()) {
+ if (ik->should_be_initialized() && ik->declares_nonstatic_concrete_methods()) {
ik->initialize(CHECK);
}
}
@@ -761,11 +761,11 @@
if (super_klass != NULL && super_klass->should_be_initialized()) {
super_klass->initialize(THREAD);
}
- // If C implements any interfaces that declares a non-abstract, non-static method,
+ // If C implements any interface that declares a non-static, concrete method,
// the initialization of C triggers initialization of its super interfaces.
- // Only need to recurse if has_default_methods which includes declaring and
- // inheriting default methods
- if (!HAS_PENDING_EXCEPTION && this_k->has_default_methods()) {
+ // Only need to recurse if has_nonstatic_concrete_methods which includes declaring and
+ // having a superinterface that declares, non-static, concrete methods
+ if (!HAS_PENDING_EXCEPTION && this_k->has_nonstatic_concrete_methods()) {
this_k->initialize_super_interfaces(this_k, THREAD);
}
--- a/hotspot/src/share/vm/oops/instanceKlass.hpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/share/vm/oops/instanceKlass.hpp Wed Nov 09 10:04:43 2016 -0800
@@ -207,18 +207,18 @@
// Start after _misc_kind field.
enum {
- _misc_rewritten = 1 << 2, // methods rewritten.
- _misc_has_nonstatic_fields = 1 << 3, // for sizing with UseCompressedOops
- _misc_should_verify_class = 1 << 4, // allow caching of preverification
- _misc_is_anonymous = 1 << 5, // has embedded _host_klass field
- _misc_is_contended = 1 << 6, // marked with contended annotation
- _misc_has_default_methods = 1 << 7, // class/superclass/implemented interfaces has default methods
- _misc_declares_default_methods = 1 << 8, // directly declares default methods (any access)
- _misc_has_been_redefined = 1 << 9, // class has been redefined
- _misc_is_scratch_class = 1 << 10, // class is the redefined scratch class
- _misc_is_shared_boot_class = 1 << 11, // defining class loader is boot class loader
- _misc_is_shared_platform_class = 1 << 12, // defining class loader is platform class loader
- _misc_is_shared_app_class = 1 << 13 // defining class loader is app class loader
+ _misc_rewritten = 1 << 2, // methods rewritten.
+ _misc_has_nonstatic_fields = 1 << 3, // for sizing with UseCompressedOops
+ _misc_should_verify_class = 1 << 4, // allow caching of preverification
+ _misc_is_anonymous = 1 << 5, // has embedded _host_klass field
+ _misc_is_contended = 1 << 6, // marked with contended annotation
+ _misc_has_nonstatic_concrete_methods = 1 << 7, // class/superclass/implemented interfaces has non-static, concrete methods
+ _misc_declares_nonstatic_concrete_methods = 1 << 8, // directly declares non-static, concrete methods
+ _misc_has_been_redefined = 1 << 9, // class has been redefined
+ _misc_is_scratch_class = 1 << 10, // class is the redefined scratch class
+ _misc_is_shared_boot_class = 1 << 11, // defining class loader is boot class loader
+ _misc_is_shared_platform_class = 1 << 12, // defining class loader is platform class loader
+ _misc_is_shared_app_class = 1 << 13 // defining class loader is app class loader
};
u2 loader_type_bits() {
return _misc_is_shared_boot_class|_misc_is_shared_platform_class|_misc_is_shared_app_class;
@@ -814,25 +814,25 @@
#endif // INCLUDE_JVMTI
- bool has_default_methods() const {
- return (_misc_flags & _misc_has_default_methods) != 0;
+ bool has_nonstatic_concrete_methods() const {
+ return (_misc_flags & _misc_has_nonstatic_concrete_methods) != 0;
}
- void set_has_default_methods(bool b) {
+ void set_has_nonstatic_concrete_methods(bool b) {
if (b) {
- _misc_flags |= _misc_has_default_methods;
+ _misc_flags |= _misc_has_nonstatic_concrete_methods;
} else {
- _misc_flags &= ~_misc_has_default_methods;
+ _misc_flags &= ~_misc_has_nonstatic_concrete_methods;
}
}
- bool declares_default_methods() const {
- return (_misc_flags & _misc_declares_default_methods) != 0;
+ bool declares_nonstatic_concrete_methods() const {
+ return (_misc_flags & _misc_declares_nonstatic_concrete_methods) != 0;
}
- void set_declares_default_methods(bool b) {
+ void set_declares_nonstatic_concrete_methods(bool b) {
if (b) {
- _misc_flags |= _misc_declares_default_methods;
+ _misc_flags |= _misc_declares_nonstatic_concrete_methods;
} else {
- _misc_flags &= ~_misc_declares_default_methods;
+ _misc_flags &= ~_misc_declares_nonstatic_concrete_methods;
}
}
--- a/hotspot/src/share/vm/oops/klassVtable.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/share/vm/oops/klassVtable.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -226,7 +226,7 @@
HandleMark hm(THREAD);
assert(default_methods->at(i)->is_method(), "must be a Method*");
methodHandle mh(THREAD, default_methods->at(i));
-
+ assert(!mh->is_private(), "private interface method in the default method list");
bool needs_new_entry = update_inherited_vtable(ik(), mh, super_vtable_len, i, checkconstraints, CHECK);
// needs new entry
@@ -362,14 +362,16 @@
Array<int>* def_vtable_indices = NULL;
bool is_default = false;
- // default methods are concrete methods in superinterfaces which are added to the vtable
- // with their real method_holder
+
+ // default methods are non-private concrete methods in superinterfaces which are added
+ // to the vtable with their real method_holder.
// Since vtable and itable indices share the same storage, don't touch
- // the default method's real vtable/itable index
+ // the default method's real vtable/itable index.
// default_vtable_indices stores the vtable value relative to this inheritor
if (default_index >= 0 ) {
is_default = true;
def_vtable_indices = klass->default_vtable_indices();
+ assert(!target_method()->is_private(), "private interface method flagged as default");
assert(def_vtable_indices != NULL, "def vtable alloc?");
assert(default_index <= def_vtable_indices->length(), "def vtable len?");
} else {
@@ -395,12 +397,15 @@
// This method will either be assigned its own itable index later,
// or be assigned an inherited vtable index in the loop below.
// default methods inherited by classes store their vtable indices
- // in the inheritor's default_vtable_indices
+ // in the inheritor's default_vtable_indices.
// default methods inherited by interfaces may already have a
- // valid itable index, if so, don't change it
- // overpass methods in an interface will be assigned an itable index later
- // by an inheriting class
- if (!is_default || !target_method()->has_itable_index()) {
+ // valid itable index, if so, don't change it.
+ // Overpass methods in an interface will be assigned an itable index later
+ // by an inheriting class.
+ // Private interface methods have no itable index and are always invoked nonvirtually,
+ // so they retain their nonvirtual_vtable_index value, and therefore can_be_statically_bound()
+ // will return true.
+ if ((!is_default || !target_method()->has_itable_index()) && !target_method()->is_private()) {
target_method()->set_vtable_index(Method::pending_itable_index);
}
}
@@ -597,7 +602,9 @@
// abstract method entries using default inheritance rules
if (target_method()->method_holder() != NULL &&
target_method()->method_holder()->is_interface() &&
- !target_method()->is_abstract() ) {
+ !target_method()->is_abstract()) {
+ assert(target_method()->is_default_method() || target_method()->is_private(),
+ "unexpected interface method type");
return false;
}
@@ -606,10 +613,8 @@
return true;
}
- // private methods in classes always have a new entry in the vtable
- // specification interpretation since classic has
- // private methods not overriding
- // JDK8 adds private methods in interfaces which require invokespecial
+ // private methods in classes always have a new entry in the vtable.
+ // Specification interpretation since classic has private methods not overriding.
if (target_method()->is_private()) {
return true;
}
@@ -1088,6 +1093,7 @@
inline bool interface_method_needs_itable_index(Method* m) {
if (m->is_static()) return false; // e.g., Stream.empty
if (m->is_initializer()) return false; // <init> or <clinit>
+ if (m->is_private()) return false; // requires invokeSpecial
// If an interface redeclares a method from java.lang.Object,
// it should already have a vtable index, don't touch it.
// e.g., CharSequence.toString (from initialize_vtable)
--- a/hotspot/src/share/vm/oops/method.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/share/vm/oops/method.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -97,7 +97,7 @@
// Fix and bury in Method*
set_interpreter_entry(NULL); // sets i2i entry and from_int
set_adapter_entry(NULL);
- clear_code(); // from_c/from_i get set to c2i/i2i
+ clear_code(false /* don't need a lock */); // from_c/from_i get set to c2i/i2i
if (access_flags.is_native()) {
clear_native_function();
@@ -277,7 +277,8 @@
}
address Method::bcp_from(int bci) const {
- assert((is_native() && bci == 0) || (!is_native() && 0 <= bci && bci < code_size()), "illegal bci: %d", bci);
+ assert((is_native() && bci == 0) || (!is_native() && 0 <= bci && bci < code_size()),
+ "illegal bci: %d for %s method", bci, is_native() ? "native" : "non-native");
address bcp = code_base() + bci;
assert(is_native() && bcp == code_base() || contains(bcp), "bcp doesn't belong to this method");
return bcp;
@@ -558,7 +559,7 @@
bool Method::is_final_method(AccessFlags class_access_flags) const {
// or "does_not_require_vtable_entry"
// default method or overpass can occur, is not final (reuses vtable entry)
- // private methods get vtable entries for backward class compatibility.
+ // private methods in classes get vtable entries for backward class compatibility.
if (is_overpass() || is_default_method()) return false;
return is_final() || class_access_flags.is_final();
}
@@ -570,7 +571,7 @@
bool Method::is_default_method() const {
if (method_holder() != NULL &&
method_holder()->is_interface() &&
- !is_abstract()) {
+ !is_abstract() && !is_private()) {
return true;
} else {
return false;
@@ -583,7 +584,9 @@
ResourceMark rm;
bool is_nonv = (vtable_index() == nonvirtual_vtable_index);
if (class_access_flags.is_interface()) {
- assert(is_nonv == is_static(), "is_nonv=%s", name_and_sig_as_C_string());
+ assert(is_nonv == is_static() || is_nonv == is_private(),
+ "nonvirtual unexpected for non-static, non-private: %s",
+ name_and_sig_as_C_string());
}
#endif
assert(valid_vtable_index() || valid_itable_index(), "method must be linked before we ask this question");
@@ -904,8 +907,8 @@
}
// Revert to using the interpreter and clear out the nmethod
-void Method::clear_code() {
-
+void Method::clear_code(bool acquire_lock /* = true */) {
+ MutexLockerEx pl(acquire_lock ? Patching_lock : NULL, Mutex::_no_safepoint_check_flag);
// this may be NULL if c2i adapters have not been made yet
// Only should happen at allocate time.
if (adapter() == NULL) {
@@ -1074,6 +1077,7 @@
// Install compiled code. Instantly it can execute.
void Method::set_code(methodHandle mh, CompiledMethod *code) {
+ MutexLockerEx pl(Patching_lock, Mutex::_no_safepoint_check_flag);
assert( code, "use clear_code to remove code" );
assert( mh->check_code(), "" );
@@ -1376,7 +1380,7 @@
}
// copy annotations over to new method
- newcm->copy_annotations_from(cm);
+ newcm->copy_annotations_from(loader_data, cm, CHECK_NULL);
return newm;
}
--- a/hotspot/src/share/vm/oops/method.hpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/share/vm/oops/method.hpp Wed Nov 09 10:04:43 2016 -0800
@@ -436,7 +436,7 @@
address verified_code_entry();
bool check_code() const; // Not inline to avoid circular ref
CompiledMethod* volatile code() const { assert( check_code(), "" ); return (CompiledMethod *)OrderAccess::load_ptr_acquire(&_code); }
- void clear_code(); // Clear out any compiled code
+ void clear_code(bool acquire_lock = true); // Clear out any compiled code
static void set_code(methodHandle mh, CompiledMethod* code);
void set_adapter_entry(AdapterHandlerEntry* adapter) {
constMethod()->set_adapter_entry(adapter);
@@ -584,6 +584,7 @@
// checks method and its method holder
bool is_final_method() const;
bool is_final_method(AccessFlags class_access_flags) const;
+ // interface method declared with 'default' - excludes private interface methods
bool is_default_method() const;
// true if method needs no dynamic dispatch (final and/or no vtable entry)
--- a/hotspot/src/share/vm/oops/methodData.hpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/share/vm/oops/methodData.hpp Wed Nov 09 10:04:43 2016 -0800
@@ -1190,12 +1190,11 @@
#if INCLUDE_JVMCI
// Description of the different counters
// ReceiverTypeData for instanceof/checkcast/aastore:
- // C1/C2: count is incremented on type overflow and decremented for failed type checks
- // JVMCI: count decremented for failed type checks and nonprofiled_count is incremented on type overflow
- // TODO (chaeubl): in fact, JVMCI should also increment the count for failed type checks to mimic the C1/C2 behavior
+ // count is decremented for failed type checks
+ // JVMCI only: nonprofiled_count is incremented on type overflow
// VirtualCallData for invokevirtual/invokeinterface:
- // C1/C2: count is incremented on type overflow
- // JVMCI: count is incremented on type overflow, nonprofiled_count is incremented on method overflow
+ // count is incremented on type overflow
+ // JVMCI only: nonprofiled_count is incremented on method overflow
// JVMCI is interested in knowing the percentage of type checks involving a type not explicitly in the profile
nonprofiled_count_off_set = counter_cell_count,
--- a/hotspot/src/share/vm/opto/compile.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/share/vm/opto/compile.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -574,6 +574,10 @@
buf.consts()->initialize_shared_locs(&locs_buf[lsize * 0], lsize);
buf.insts()->initialize_shared_locs( &locs_buf[lsize * 1], lsize);
buf.stubs()->initialize_shared_locs( &locs_buf[lsize * 2], lsize);
+ // Mark as scratch buffer.
+ buf.consts()->set_scratch_emit();
+ buf.insts()->set_scratch_emit();
+ buf.stubs()->set_scratch_emit();
// Do the emission.
@@ -2867,15 +2871,20 @@
addp->Opcode() == Op_ConP &&
addp == n->in(AddPNode::Base) &&
n->in(AddPNode::Offset)->is_Con()) {
+ // If the transformation of ConP to ConN+DecodeN is beneficial depends
+ // on the platform and on the compressed oops mode.
// Use addressing with narrow klass to load with offset on x86.
- // On sparc loading 32-bits constant and decoding it have less
- // instructions (4) then load 64-bits constant (7).
+ // Some platforms can use the constant pool to load ConP.
// Do this transformation here since IGVN will convert ConN back to ConP.
const Type* t = addp->bottom_type();
- if (t->isa_oopptr() || t->isa_klassptr()) {
+ bool is_oop = t->isa_oopptr() != NULL;
+ bool is_klass = t->isa_klassptr() != NULL;
+
+ if ((is_oop && Matcher::const_oop_prefer_decode() ) ||
+ (is_klass && Matcher::const_klass_prefer_decode())) {
Node* nn = NULL;
- int op = t->isa_oopptr() ? Op_ConN : Op_ConNKlass;
+ int op = is_oop ? Op_ConN : Op_ConNKlass;
// Look for existing ConN node of the same exact type.
Node* r = root();
@@ -2891,7 +2900,7 @@
if (nn != NULL) {
// Decode a narrow oop to match address
// [R12 + narrow_oop_reg<<3 + offset]
- if (t->isa_oopptr()) {
+ if (is_oop) {
nn = new DecodeNNode(nn, t);
} else {
nn = new DecodeNKlassNode(nn, t);
--- a/hotspot/src/share/vm/opto/loopnode.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/share/vm/opto/loopnode.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -1687,6 +1687,12 @@
Node *init2 = phi2->in( LoopNode::EntryControl );
int stride_con2 = incr2->in(2)->get_int();
+ // The ratio of the two strides cannot be represented as an int
+ // if stride_con2 is min_int and stride_con is -1.
+ if (stride_con2 == min_jint && stride_con == -1) {
+ continue;
+ }
+
// The general case here gets a little tricky. We want to find the
// GCD of all possible parallel IV's and make a new IV using this
// GCD for the loop. Then all possible IVs are simple multiples of
--- a/hotspot/src/share/vm/opto/macro.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/share/vm/opto/macro.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -439,12 +439,6 @@
Node* adr = _igvn.transform(new AddPNode(base, base, MakeConX(offset)));
const TypePtr* adr_type = _igvn.type(base)->is_ptr()->add_offset(offset);
Node* m = ac->in(TypeFunc::Memory);
- while (m->is_MergeMem()) {
- m = m->as_MergeMem()->memory_at(C->get_alias_index(adr_type));
- if (m->is_Proj() && m->in(0)->is_MemBar()) {
- m = m->in(0)->in(TypeFunc::Memory);
- }
- }
res = LoadNode::make(_igvn, ctl, m, adr, adr_type, type, bt, MemNode::unordered, LoadNode::Pinned);
} else {
if (ac->modifies(offset, offset, &_igvn, true)) {
@@ -978,6 +972,17 @@
return true;
}
+static void disconnect_projections(MultiNode* n, PhaseIterGVN& igvn) {
+ Node* ctl_proj = n->proj_out(TypeFunc::Control);
+ Node* mem_proj = n->proj_out(TypeFunc::Memory);
+ if (ctl_proj != NULL) {
+ igvn.replace_node(ctl_proj, n->in(0));
+ }
+ if (mem_proj != NULL) {
+ igvn.replace_node(mem_proj, n->in(TypeFunc::Memory));
+ }
+}
+
// Process users of eliminated allocation.
void PhaseMacroExpand::process_users_of_allocation(CallNode *alloc) {
Node* res = alloc->result_cast();
@@ -1008,13 +1013,13 @@
// Disconnect ArrayCopy node
ArrayCopyNode* ac = n->as_ArrayCopy();
assert(ac->is_clonebasic(), "unexpected array copy kind");
- Node* ctl_proj = ac->proj_out(TypeFunc::Control);
- Node* mem_proj = ac->proj_out(TypeFunc::Memory);
- if (ctl_proj != NULL) {
- _igvn.replace_node(ctl_proj, n->in(0));
- }
- if (mem_proj != NULL) {
- _igvn.replace_node(mem_proj, n->in(TypeFunc::Memory));
+ Node* membar_after = ac->proj_out(TypeFunc::Control)->unique_ctrl_out();
+ disconnect_projections(ac, _igvn);
+ assert(alloc->in(0)->is_Proj() && alloc->in(0)->in(0)->Opcode() == Op_MemBarCPUOrder, "mem barrier expected before allocation");
+ Node* membar_before = alloc->in(0)->in(0);
+ disconnect_projections(membar_before->as_MemBar(), _igvn);
+ if (membar_after->is_MemBar()) {
+ disconnect_projections(membar_after->as_MemBar(), _igvn);
}
} else {
eliminate_card_mark(n);
--- a/hotspot/src/share/vm/opto/matcher.hpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/share/vm/opto/matcher.hpp Wed Nov 09 10:04:43 2016 -0800
@@ -457,6 +457,9 @@
static bool narrow_oop_use_complex_address();
static bool narrow_klass_use_complex_address();
+ static bool const_oop_prefer_decode();
+ static bool const_klass_prefer_decode();
+
// Generate implicit null check for narrow oops if it can fold
// into address expression (x64).
//
--- a/hotspot/src/share/vm/prims/jni.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/share/vm/prims/jni.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -1173,7 +1173,7 @@
args->set_java_argument_object(&java_args);
// handle arguments
- assert(!method->is_static(), "method should not be static");
+ assert(!method->is_static(), "method %s should not be static", method->name_and_sig_as_C_string());
args->push_receiver(h_recv); // Push jobject handle
// Fill out JavaCallArguments object
--- a/hotspot/src/share/vm/prims/jvm.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/share/vm/prims/jvm.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -503,16 +503,27 @@
JVM_END
-JVM_ENTRY(void, JVM_GetStackTraceElements(JNIEnv *env, jobject throwable, jobjectArray stackTrace))
- JVMWrapper("JVM_GetStackTraceElements");
+// java.lang.StackTraceElement //////////////////////////////////////////////
+
+
+JVM_ENTRY(void, JVM_InitStackTraceElementArray(JNIEnv *env, jobjectArray elements, jobject throwable))
+ JVMWrapper("JVM_InitStackTraceElementArray");
Handle exception(THREAD, JNIHandles::resolve(throwable));
- objArrayOop st = objArrayOop(JNIHandles::resolve(stackTrace));
+ objArrayOop st = objArrayOop(JNIHandles::resolve(elements));
objArrayHandle stack_trace(THREAD, st);
// Fill in the allocated stack trace
java_lang_Throwable::get_stack_trace_elements(exception, stack_trace, CHECK);
JVM_END
+JVM_ENTRY(void, JVM_InitStackTraceElement(JNIEnv* env, jobject element, jobject stackFrameInfo))
+ JVMWrapper("JVM_InitStackTraceElement");
+ Handle stack_frame_info(THREAD, JNIHandles::resolve_non_null(stackFrameInfo));
+ Handle stack_trace_element(THREAD, JNIHandles::resolve_non_null(element));
+ java_lang_StackFrameInfo::to_stack_trace_element(stack_frame_info, stack_trace_element, THREAD);
+JVM_END
+
+
// java.lang.StackWalker //////////////////////////////////////////////////////
@@ -566,13 +577,6 @@
start_index, frames_array_h, THREAD);
JVM_END
-JVM_ENTRY(void, JVM_ToStackTraceElement(JNIEnv *env, jobject frame, jobject stack))
- JVMWrapper("JVM_ToStackTraceElement");
- Handle stack_frame_info(THREAD, JNIHandles::resolve_non_null(frame));
- Handle stack_trace_element(THREAD, JNIHandles::resolve_non_null(stack));
- java_lang_StackFrameInfo::to_stack_trace_element(stack_frame_info, stack_trace_element, THREAD);
-JVM_END
-
// java.lang.Object ///////////////////////////////////////////////
--- a/hotspot/src/share/vm/prims/jvm.h Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/share/vm/prims/jvm.h Wed Nov 09 10:04:43 2016 -0800
@@ -189,8 +189,14 @@
JNIEXPORT void JNICALL
JVM_FillInStackTrace(JNIEnv *env, jobject throwable);
+/*
+ * java.lang.StackTraceElement
+ */
JNIEXPORT void JNICALL
-JVM_GetStackTraceElements(JNIEnv *env, jobject throwable, jobjectArray elements);
+JVM_InitStackTraceElementArray(JNIEnv *env, jobjectArray elements, jobject throwable);
+
+JNIEXPORT void JNICALL
+JVM_InitStackTraceElement(JNIEnv* env, jobject element, jobject stackFrameInfo);
/*
* java.lang.StackWalker
@@ -212,9 +218,6 @@
jint frame_count, jint start_index,
jobjectArray frames);
-JNIEXPORT void JNICALL
-JVM_ToStackTraceElement(JNIEnv* env, jobject frame, jobject stackElement);
-
/*
* java.lang.Thread
*/
--- a/hotspot/src/share/vm/prims/stackwalk.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/share/vm/prims/stackwalk.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -26,6 +26,7 @@
#include "classfile/javaClasses.hpp"
#include "classfile/javaClasses.inline.hpp"
#include "classfile/vmSymbols.hpp"
+#include "logging/log.hpp"
#include "memory/oopFactory.hpp"
#include "oops/oop.inline.hpp"
#include "oops/objArrayOop.inline.hpp"
@@ -105,10 +106,8 @@
int max_nframes, int start_index,
objArrayHandle frames_array,
int& end_index, TRAPS) {
- if (TraceStackWalk) {
- tty->print_cr("fill_in_frames limit=%d start=%d frames length=%d",
- max_nframes, start_index, frames_array->length());
- }
+ log_debug(stackwalk)("fill_in_frames limit=%d start=%d frames length=%d",
+ max_nframes, start_index, frames_array->length());
assert(max_nframes > 0, "invalid max_nframes");
assert(start_index + max_nframes <= frames_array->length(), "oob");
@@ -122,18 +121,24 @@
// not set) and when StackWalker::getCallerClass is called
if (!ShowHiddenFrames && (skip_hidden_frames(mode) || get_caller_class(mode))) {
if (method->is_hidden()) {
- if (TraceStackWalk) {
- tty->print(" hidden method: "); method->print_short_name();
- tty->print("\n");
+ if (log_is_enabled(Debug, stackwalk)) {
+ ResourceMark rm(THREAD);
+ outputStream* st = Log(stackwalk)::debug_stream();
+ st->print(" hidden method: ");
+ method->print_short_name(st);
+ st->cr();
}
continue;
}
}
int index = end_index++;
- if (TraceStackWalk) {
- tty->print(" %d: frame method: ", index); method->print_short_name();
- tty->print_cr(" bci=%d", stream.bci());
+ if (log_is_enabled(Debug, stackwalk)) {
+ ResourceMark rm(THREAD);
+ outputStream* st = Log(stackwalk)::debug_stream();
+ st->print(" %d: frame method: ", index);
+ method->print_short_name(st);
+ st->print_cr(" bci=%d", stream.bci());
}
if (!need_method_info(mode) && get_caller_class(mode) &&
@@ -317,10 +322,8 @@
TRAPS) {
ResourceMark rm(THREAD);
JavaThread* jt = (JavaThread*)THREAD;
- if (TraceStackWalk) {
- tty->print_cr("Start walking: mode " JLONG_FORMAT " skip %d frames batch size %d",
- mode, skip_frames, frame_count);
- }
+ log_debug(stackwalk)("Start walking: mode " JLONG_FORMAT " skip %d frames batch size %d",
+ mode, skip_frames, frame_count);
if (frames_array.is_null()) {
THROW_MSG_(vmSymbols::java_lang_NullPointerException(), "frames_array is NULL", NULL);
@@ -355,8 +358,12 @@
break;
}
- if (TraceStackWalk) {
- tty->print(" skip "); stream.method()->print_short_name(); tty->print("\n");
+ if (log_is_enabled(Debug, stackwalk)) {
+ ResourceMark rm(THREAD);
+ outputStream* st = Log(stackwalk)::debug_stream();
+ st->print(" skip ");
+ stream.method()->print_short_name(st);
+ st->cr();
}
stream.next();
}
@@ -364,8 +371,12 @@
// stack frame has been traversed individually and resume stack walk
// from the stack frame at depth == skip_frames.
for (int n=0; n < skip_frames && !stream.at_end(); stream.next(), n++) {
- if (TraceStackWalk) {
- tty->print(" skip "); stream.method()->print_short_name(); tty->cr();
+ if (log_is_enabled(Debug, stackwalk)) {
+ ResourceMark rm(THREAD);
+ outputStream* st = Log(stackwalk)::debug_stream();
+ st->print(" skip ");
+ stream.method()->print_short_name(st);
+ st->cr();
}
}
}
@@ -438,10 +449,9 @@
THROW_MSG_(vmSymbols::java_lang_NullPointerException(), "frames_array is NULL", 0L);
}
- if (TraceStackWalk) {
- tty->print_cr("StackWalk::fetchNextBatch frame_count %d existing_stream " PTR_FORMAT " start %d frames %d",
- frame_count, p2i(existing_stream), start_index, frames_array->length());
- }
+ log_debug(stackwalk)("StackWalk::fetchNextBatch frame_count %d existing_stream "
+ PTR_FORMAT " start %d frames %d",
+ frame_count, p2i(existing_stream), start_index, frames_array->length());
int end_index = start_index;
if (frame_count <= 0) {
return end_index; // No operation.
--- a/hotspot/src/share/vm/runtime/arguments.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/share/vm/runtime/arguments.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -351,14 +351,6 @@
* Deprecated options should be tested in VMDeprecatedOptions.java.
*/
-// Obsolete or deprecated -XX flag.
-typedef struct {
- const char* name;
- JDK_Version deprecated_in; // When the deprecation warning started (or "undefined").
- JDK_Version obsolete_in; // When the obsolete warning started (or "undefined").
- JDK_Version expired_in; // When the option expires (or "undefined").
-} SpecialFlag;
-
// The special_jvm_flags table declares options that are being deprecated and/or obsoleted. The
// "deprecated_in" or "obsolete_in" fields may be set to "undefined", but not both.
// When the JDK version reaches 'deprecated_in' limit, the JVM will process this flag on
@@ -380,6 +372,8 @@
// -------------- Deprecated Flags --------------
// --- Non-alias flags - sorted by obsolete_in then expired_in:
{ "MaxGCMinorPauseMillis", JDK_Version::jdk(8), JDK_Version::undefined(), JDK_Version::undefined() },
+ { "AutoGCSelectPauseMillis", JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::jdk(10) },
+ { "UseAutoGCSelectPolicy", JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::jdk(10) },
{ "UseParNewGC", JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::jdk(10) },
{ "ConvertSleepToYield", JDK_Version::jdk(9), JDK_Version::jdk(10), JDK_Version::jdk(11) },
{ "ConvertYieldToSleep", JDK_Version::jdk(9), JDK_Version::jdk(10), JDK_Version::jdk(11) },
@@ -500,7 +494,14 @@
}
}
+extern bool lookup_special_flag_ext(const char *flag_name, SpecialFlag& flag);
+
static bool lookup_special_flag(const char *flag_name, SpecialFlag& flag) {
+ // Allow extensions to have priority
+ if (lookup_special_flag_ext(flag_name, flag)) {
+ return true;
+ }
+
for (size_t i = 0; special_jvm_flags[i].name != NULL; i++) {
if ((strcmp(special_jvm_flags[i].name, flag_name) == 0)) {
flag = special_jvm_flags[i];
@@ -1805,10 +1806,15 @@
void Arguments::select_gc_ergonomically() {
#if INCLUDE_ALL_GCS
if (os::is_server_class_machine()) {
- if (should_auto_select_low_pause_collector()) {
- FLAG_SET_ERGO_IF_DEFAULT(bool, UseConcMarkSweepGC, true);
+ if (!UseAutoGCSelectPolicy) {
+ FLAG_SET_ERGO_IF_DEFAULT(bool, UseG1GC, true);
} else {
- FLAG_SET_ERGO_IF_DEFAULT(bool, UseG1GC, true);
+ if (should_auto_select_low_pause_collector()) {
+ FLAG_SET_ERGO_IF_DEFAULT(bool, UseConcMarkSweepGC, true);
+ FLAG_SET_ERGO_IF_DEFAULT(bool, UseParNewGC, true);
+ } else {
+ FLAG_SET_ERGO_IF_DEFAULT(bool, UseParallelGC, true);
+ }
}
} else {
FLAG_SET_ERGO_IF_DEFAULT(bool, UseSerialGC, true);
@@ -2875,11 +2881,13 @@
if (FLAG_SET_CMDLINE(bool, UseConcMarkSweepGC, true) != Flag::SUCCESS) {
return JNI_EINVAL;
}
+ handle_extra_cms_flags("-Xconcgc uses UseConcMarkSweepGC");
// -Xnoconcgc
} else if (match_option(option, "-Xnoconcgc")) {
if (FLAG_SET_CMDLINE(bool, UseConcMarkSweepGC, false) != Flag::SUCCESS) {
return JNI_EINVAL;
}
+ handle_extra_cms_flags("-Xnoconcgc uses UseConcMarkSweepGC");
// -Xbatch
} else if (match_option(option, "-Xbatch")) {
if (FLAG_SET_CMDLINE(bool, BackgroundCompilation, false) != Flag::SUCCESS) {
@@ -4169,6 +4177,15 @@
return true;
}
+void Arguments::handle_extra_cms_flags(const char* msg) {
+ SpecialFlag flag;
+ const char *flag_name = "UseConcMarkSweepGC";
+ if (lookup_special_flag(flag_name, flag)) {
+ handle_aliases_and_deprecation(flag_name, /* print warning */ true);
+ warning("%s", msg);
+ }
+}
+
// Parse entry point called from JNI_CreateJavaVM
jint Arguments::parse(const JavaVMInitArgs* initial_cmd_args) {
--- a/hotspot/src/share/vm/runtime/arguments.hpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/share/vm/runtime/arguments.hpp Wed Nov 09 10:04:43 2016 -0800
@@ -41,6 +41,14 @@
typedef jint (JNICALL *vfprintf_hook_t)(FILE *fp, const char *format, va_list args) ATTRIBUTE_PRINTF(2, 0);
}
+// Obsolete or deprecated -XX flag.
+struct SpecialFlag {
+ const char* name;
+ JDK_Version deprecated_in; // When the deprecation warning started (or "undefined").
+ JDK_Version obsolete_in; // When the obsolete warning started (or "undefined").
+ JDK_Version expired_in; // When the option expires (or "undefined").
+};
+
// PathString is used as:
// - the underlying value for a SystemProperty
// - the path portion of an --patch-module module/path pair
@@ -519,6 +527,8 @@
static bool handle_deprecated_print_gc_flags();
+ static void handle_extra_cms_flags(const char* msg);
+
static jint parse_vm_init_args(const JavaVMInitArgs *java_tool_options_args,
const JavaVMInitArgs *java_options_args,
const JavaVMInitArgs *cmd_line_args);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/vm/runtime/arguments_ext.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#include "precompiled.hpp"
+#include "runtime/arguments.hpp"
+
+bool lookup_special_flag_ext(const char *flag_name, SpecialFlag& flag) {
+ return false;
+}
--- a/hotspot/src/share/vm/runtime/globals.hpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/share/vm/runtime/globals.hpp Wed Nov 09 10:04:43 2016 -0800
@@ -2887,9 +2887,6 @@
"exceptions (0 means all)") \
range(0, max_jint/2) \
\
- develop(bool, TraceStackWalk, false, \
- "Trace stack walking") \
- \
/* notice: the max range value here is max_jint, not max_intx */ \
/* because of overflow issue */ \
diagnostic(intx, GuaranteedSafepointInterval, 1000, \
--- a/hotspot/src/share/vm/runtime/mutex.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/share/vm/runtime/mutex.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -452,7 +452,7 @@
ParkEvent * const ESelf = Self->_MutexEvent;
assert(_OnDeck != ESelf, "invariant");
- // As an optimization, spinners could conditionally try to set ONDECK to _LBIT
+ // As an optimization, spinners could conditionally try to set _OnDeck to _LBIT
// Synchronizer.cpp uses a similar optimization.
if (TrySpin(Self)) goto Exeunt;
@@ -463,7 +463,7 @@
OrderAccess::fence();
// Optional optimization ... try barging on the inner lock
- if ((NativeMonitorFlags & 32) && CASPTR (&_OnDeck, NULL, UNS(Self)) == 0) {
+ if ((NativeMonitorFlags & 32) && CASPTR (&_OnDeck, NULL, UNS(ESelf)) == 0) {
goto OnDeck_LOOP;
}
@@ -471,14 +471,14 @@
// At any given time there is at most one ondeck thread.
// ondeck implies not resident on cxq and not resident on EntryList
- // Only the OnDeck thread can try to acquire -- contended for -- the lock.
+ // Only the OnDeck thread can try to acquire -- contend for -- the lock.
// CONSIDER: use Self->OnDeck instead of m->OnDeck.
// Deschedule Self so that others may run.
- while (_OnDeck != ESelf) {
+ while (OrderAccess::load_ptr_acquire(&_OnDeck) != ESelf) {
ParkCommon(ESelf, 0);
}
- // Self is now in the ONDECK position and will remain so until it
+ // Self is now in the OnDeck position and will remain so until it
// manages to acquire the lock.
OnDeck_LOOP:
for (;;) {
@@ -501,8 +501,8 @@
// A. Shift or defer dropping the inner lock until the subsequent IUnlock() operation.
// This might avoid potential reacquisition of the inner lock in IUlock().
// B. While still holding the inner lock, attempt to opportunistically select
- // and unlink the next ONDECK thread from the EntryList.
- // If successful, set ONDECK to refer to that thread, otherwise clear ONDECK.
+ // and unlink the next OnDeck thread from the EntryList.
+ // If successful, set OnDeck to refer to that thread, otherwise clear OnDeck.
// It's critical that the select-and-unlink operation run in constant-time as
// it executes when holding the outer lock and may artificially increase the
// effective length of the critical section.
@@ -529,7 +529,7 @@
OrderAccess::release_store(&_LockWord.Bytes[_LSBINDEX], 0); // drop outer lock
OrderAccess::storeload();
- ParkEvent * const w = _OnDeck;
+ ParkEvent * const w = _OnDeck; // raw load as we will just return if non-NULL
assert(RelaxAssert || w != Thread::current()->_MutexEvent, "invariant");
if (w != NULL) {
// Either we have a valid ondeck thread or ondeck is transiently "locked"
@@ -537,7 +537,7 @@
// OnDeck allows us to discriminate two cases. If the latter, the
// responsibility for progress and succession lies with that other thread.
// For good performance, we also depend on the fact that redundant unpark()
- // operations are cheap. That is, repeated Unpark()ing of the ONDECK thread
+ // operations are cheap. That is, repeated Unpark()ing of the OnDeck thread
// is inexpensive. This approach provides implicit futile wakeup throttling.
// Note that the referent "w" might be stale with respect to the lock.
// In that case the following unpark() is harmless and the worst that'll happen
@@ -586,8 +586,13 @@
_EntryList = w->ListNext;
// as a diagnostic measure consider setting w->_ListNext = BAD
assert(UNS(_OnDeck) == _LBIT, "invariant");
- _OnDeck = w; // pass OnDeck to w.
- // w will clear OnDeck once it acquires the outer lock
+
+ // Pass OnDeck role to w, ensuring that _EntryList has been set first.
+ // w will clear _OnDeck once it acquires the outer lock.
+ // Note that once we set _OnDeck that thread can acquire the mutex, proceed
+ // with its critical section and then enter this code to unlock the mutex. So
+ // you can have multiple threads active in IUnlock at the same time.
+ OrderAccess::release_store_ptr(&_OnDeck, w);
// Another optional optimization ...
// For heavily contended locks it's not uncommon that some other
@@ -835,7 +840,7 @@
// ESelf is now on the cxq, EntryList or at the OnDeck position.
// The following fragment is extracted from Monitor::ILock()
for (;;) {
- if (_OnDeck == ESelf && TrySpin(Self)) break;
+ if (OrderAccess::load_ptr_acquire(&_OnDeck) == ESelf && TrySpin(Self)) break;
ParkCommon(ESelf, 0);
}
assert(_OnDeck == ESelf, "invariant");
@@ -1050,10 +1055,10 @@
// At any given time there is at most one ondeck thread.
// ondeck implies not resident on cxq and not resident on EntryList
- // Only the OnDeck thread can try to acquire -- contended for -- the lock.
+ // Only the OnDeck thread can try to acquire -- contend for -- the lock.
// CONSIDER: use Self->OnDeck instead of m->OnDeck.
for (;;) {
- if (_OnDeck == ESelf && TrySpin(NULL)) break;
+ if (OrderAccess::load_ptr_acquire(&_OnDeck) == ESelf && TrySpin(NULL)) break;
ParkCommon(ESelf, 0);
}
--- a/hotspot/src/share/vm/runtime/mutex.hpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/share/vm/runtime/mutex.hpp Wed Nov 09 10:04:43 2016 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -81,7 +81,9 @@
// *in that order*. If their implementations change such that these
// assumptions are violated, a whole lot of code will break.
-// The default length of monitor name is chosen to be 64 to avoid false sharing.
+// The default length of monitor name was originally chosen to be 64 to avoid
+// false sharing. Now, PaddedMonitor is available for this purpose.
+// TODO: Check if _name[MONITOR_NAME_LEN] should better get replaced by const char*.
static const int MONITOR_NAME_LEN = 64;
class Monitor : public CHeapObj<mtInternal> {
@@ -254,6 +256,18 @@
};
+class PaddedMonitor : public Monitor {
+ enum {
+ CACHE_LINE_PADDING = (int)DEFAULT_CACHE_LINE_SIZE - (int)sizeof(Monitor),
+ PADDING_LEN = CACHE_LINE_PADDING > 0 ? CACHE_LINE_PADDING : 1
+ };
+ char _padding[PADDING_LEN];
+ public:
+ PaddedMonitor(int rank, const char *name, bool allow_vm_block = false,
+ SafepointCheckRequired safepoint_check_required = _safepoint_check_always) :
+ Monitor(rank, name, allow_vm_block, safepoint_check_required) {};
+};
+
// Normally we'd expect Monitor to extend Mutex in the sense that a monitor
// constructed from pthreads primitives might extend a mutex by adding
// a condvar and some extra metadata. In fact this was the case until J2SE7.
@@ -292,5 +306,16 @@
}
};
+class PaddedMutex : public Mutex {
+ enum {
+ CACHE_LINE_PADDING = (int)DEFAULT_CACHE_LINE_SIZE - (int)sizeof(Mutex),
+ PADDING_LEN = CACHE_LINE_PADDING > 0 ? CACHE_LINE_PADDING : 1
+ };
+ char _padding[PADDING_LEN];
+public:
+ PaddedMutex(int rank, const char *name, bool allow_vm_block = false,
+ SafepointCheckRequired safepoint_check_required = _safepoint_check_always) :
+ Mutex(rank, name, allow_vm_block, safepoint_check_required) {};
+};
#endif // SHARE_VM_RUNTIME_MUTEX_HPP
--- a/hotspot/src/share/vm/runtime/mutexLocker.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/share/vm/runtime/mutexLocker.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -169,122 +169,123 @@
_mutex_array[_num_mutex++] = var; \
}
+// Using Padded subclasses to prevent false sharing of these global monitors and mutexes.
void mutex_init() {
- def(tty_lock , Mutex , event, true, Monitor::_safepoint_check_never); // allow to lock in VM
+ def(tty_lock , PaddedMutex , event, true, Monitor::_safepoint_check_never); // allow to lock in VM
- def(CGC_lock , Monitor, special, true, Monitor::_safepoint_check_never); // coordinate between fore- and background GC
- def(STS_lock , Monitor, leaf, true, Monitor::_safepoint_check_never);
+ def(CGC_lock , PaddedMonitor, special, true, Monitor::_safepoint_check_never); // coordinate between fore- and background GC
+ def(STS_lock , PaddedMonitor, leaf, true, Monitor::_safepoint_check_never);
if (UseConcMarkSweepGC || UseG1GC) {
- def(FullGCCount_lock , Monitor, leaf, true, Monitor::_safepoint_check_never); // in support of ExplicitGCInvokesConcurrent
+ def(FullGCCount_lock , PaddedMonitor, leaf, true, Monitor::_safepoint_check_never); // in support of ExplicitGCInvokesConcurrent
}
if (UseG1GC) {
- def(SATB_Q_FL_lock , Mutex , special, true, Monitor::_safepoint_check_never);
- def(SATB_Q_CBL_mon , Monitor, nonleaf, true, Monitor::_safepoint_check_never);
- def(Shared_SATB_Q_lock , Mutex, nonleaf, true, Monitor::_safepoint_check_never);
+ def(SATB_Q_FL_lock , PaddedMutex , special, true, Monitor::_safepoint_check_never);
+ def(SATB_Q_CBL_mon , PaddedMonitor, nonleaf, true, Monitor::_safepoint_check_never);
+ def(Shared_SATB_Q_lock , PaddedMutex , nonleaf, true, Monitor::_safepoint_check_never);
- def(DirtyCardQ_FL_lock , Mutex , special, true, Monitor::_safepoint_check_never);
- def(DirtyCardQ_CBL_mon , Monitor, nonleaf, true, Monitor::_safepoint_check_never);
- def(Shared_DirtyCardQ_lock , Mutex, nonleaf, true, Monitor::_safepoint_check_never);
+ def(DirtyCardQ_FL_lock , PaddedMutex , special, true, Monitor::_safepoint_check_never);
+ def(DirtyCardQ_CBL_mon , PaddedMonitor, nonleaf, true, Monitor::_safepoint_check_never);
+ def(Shared_DirtyCardQ_lock , PaddedMutex , nonleaf, true, Monitor::_safepoint_check_never);
- def(FreeList_lock , Mutex, leaf , true, Monitor::_safepoint_check_never);
- def(SecondaryFreeList_lock , Monitor, leaf , true, Monitor::_safepoint_check_never);
- def(OldSets_lock , Mutex , leaf , true, Monitor::_safepoint_check_never);
- def(RootRegionScan_lock , Monitor, leaf , true, Monitor::_safepoint_check_never);
- def(MMUTracker_lock , Mutex , leaf , true, Monitor::_safepoint_check_never);
+ def(FreeList_lock , PaddedMutex , leaf , true, Monitor::_safepoint_check_never);
+ def(SecondaryFreeList_lock , PaddedMonitor, leaf , true, Monitor::_safepoint_check_never);
+ def(OldSets_lock , PaddedMutex , leaf , true, Monitor::_safepoint_check_never);
+ def(RootRegionScan_lock , PaddedMonitor, leaf , true, Monitor::_safepoint_check_never);
+ def(MMUTracker_lock , PaddedMutex , leaf , true, Monitor::_safepoint_check_never);
- def(StringDedupQueue_lock , Monitor, leaf, true, Monitor::_safepoint_check_never);
- def(StringDedupTable_lock , Mutex , leaf, true, Monitor::_safepoint_check_never);
+ def(StringDedupQueue_lock , PaddedMonitor, leaf, true, Monitor::_safepoint_check_never);
+ def(StringDedupTable_lock , PaddedMutex , leaf, true, Monitor::_safepoint_check_never);
- def(MarkStackFreeList_lock , Mutex , leaf , true, Monitor::_safepoint_check_never);
- def(MarkStackChunkList_lock , Mutex , leaf , true, Monitor::_safepoint_check_never);
+ def(MarkStackFreeList_lock , PaddedMutex , leaf , true, Monitor::_safepoint_check_never);
+ def(MarkStackChunkList_lock , PaddedMutex , leaf , true, Monitor::_safepoint_check_never);
}
- def(ParGCRareEvent_lock , Mutex , leaf , true, Monitor::_safepoint_check_sometimes);
- def(DerivedPointerTableGC_lock , Mutex, leaf, true, Monitor::_safepoint_check_never);
- def(CodeCache_lock , Mutex , special, true, Monitor::_safepoint_check_never);
- def(RawMonitor_lock , Mutex, special, true, Monitor::_safepoint_check_never);
- def(OopMapCacheAlloc_lock , Mutex, leaf, true, Monitor::_safepoint_check_always); // used for oop_map_cache allocation.
+ def(ParGCRareEvent_lock , PaddedMutex , leaf , true, Monitor::_safepoint_check_sometimes);
+ def(DerivedPointerTableGC_lock , PaddedMutex , leaf, true, Monitor::_safepoint_check_never);
+ def(CodeCache_lock , PaddedMutex , special, true, Monitor::_safepoint_check_never);
+ def(RawMonitor_lock , PaddedMutex , special, true, Monitor::_safepoint_check_never);
+ def(OopMapCacheAlloc_lock , PaddedMutex , leaf, true, Monitor::_safepoint_check_always); // used for oop_map_cache allocation.
- def(Patching_lock , Mutex , special, true, Monitor::_safepoint_check_never); // used for safepointing and code patching.
- def(Service_lock , Monitor, special, true, Monitor::_safepoint_check_never); // used for service thread operations
- def(JmethodIdCreation_lock , Mutex , leaf, true, Monitor::_safepoint_check_always); // used for creating jmethodIDs.
+ def(Patching_lock , PaddedMutex , special, true, Monitor::_safepoint_check_never); // used for safepointing and code patching.
+ def(Service_lock , PaddedMonitor, special, true, Monitor::_safepoint_check_never); // used for service thread operations
+ def(JmethodIdCreation_lock , PaddedMutex , leaf, true, Monitor::_safepoint_check_always); // used for creating jmethodIDs.
- def(SystemDictionary_lock , Monitor, leaf, true, Monitor::_safepoint_check_always); // lookups done by VM thread
- def(Module_lock , Mutex , leaf+2, true, Monitor::_safepoint_check_always);
- def(InlineCacheBuffer_lock , Mutex , leaf, true, Monitor::_safepoint_check_always);
- def(VMStatistic_lock , Mutex , leaf, false, Monitor::_safepoint_check_always);
- def(ExpandHeap_lock , Mutex , leaf, true, Monitor::_safepoint_check_always); // Used during compilation by VM thread
- def(JNIHandleBlockFreeList_lock , Mutex , leaf, true, Monitor::_safepoint_check_never); // handles are used by VM thread
- def(SignatureHandlerLibrary_lock , Mutex , leaf, false, Monitor::_safepoint_check_always);
- def(SymbolTable_lock , Mutex , leaf+2, true, Monitor::_safepoint_check_always);
- def(StringTable_lock , Mutex , leaf, true, Monitor::_safepoint_check_always);
- def(ProfilePrint_lock , Mutex , leaf, false, Monitor::_safepoint_check_always); // serial profile printing
- def(ExceptionCache_lock , Mutex , leaf, false, Monitor::_safepoint_check_always); // serial profile printing
- def(OsrList_lock , Mutex , leaf, true, Monitor::_safepoint_check_never);
- def(Debug1_lock , Mutex , leaf, true, Monitor::_safepoint_check_never);
+ def(SystemDictionary_lock , PaddedMonitor, leaf, true, Monitor::_safepoint_check_always); // lookups done by VM thread
+ def(Module_lock , PaddedMutex , leaf+2, true, Monitor::_safepoint_check_always);
+ def(InlineCacheBuffer_lock , PaddedMutex , leaf, true, Monitor::_safepoint_check_always);
+ def(VMStatistic_lock , PaddedMutex , leaf, false, Monitor::_safepoint_check_always);
+ def(ExpandHeap_lock , PaddedMutex , leaf, true, Monitor::_safepoint_check_always); // Used during compilation by VM thread
+ def(JNIHandleBlockFreeList_lock , PaddedMutex , leaf, true, Monitor::_safepoint_check_never); // handles are used by VM thread
+ def(SignatureHandlerLibrary_lock , PaddedMutex , leaf, false, Monitor::_safepoint_check_always);
+ def(SymbolTable_lock , PaddedMutex , leaf+2, true, Monitor::_safepoint_check_always);
+ def(StringTable_lock , PaddedMutex , leaf, true, Monitor::_safepoint_check_always);
+ def(ProfilePrint_lock , PaddedMutex , leaf, false, Monitor::_safepoint_check_always); // serial profile printing
+ def(ExceptionCache_lock , PaddedMutex , leaf, false, Monitor::_safepoint_check_always); // serial profile printing
+ def(OsrList_lock , PaddedMutex , leaf, true, Monitor::_safepoint_check_never);
+ def(Debug1_lock , PaddedMutex , leaf, true, Monitor::_safepoint_check_never);
#ifndef PRODUCT
- def(FullGCALot_lock , Mutex , leaf, false, Monitor::_safepoint_check_always); // a lock to make FullGCALot MT safe
+ def(FullGCALot_lock , PaddedMutex , leaf, false, Monitor::_safepoint_check_always); // a lock to make FullGCALot MT safe
#endif
- def(BeforeExit_lock , Monitor, leaf, true, Monitor::_safepoint_check_always);
- def(PerfDataMemAlloc_lock , Mutex , leaf, true, Monitor::_safepoint_check_always); // used for allocating PerfData memory for performance data
- def(PerfDataManager_lock , Mutex , leaf, true, Monitor::_safepoint_check_always); // used for synchronized access to PerfDataManager resources
+ def(BeforeExit_lock , PaddedMonitor, leaf, true, Monitor::_safepoint_check_always);
+ def(PerfDataMemAlloc_lock , PaddedMutex , leaf, true, Monitor::_safepoint_check_always); // used for allocating PerfData memory for performance data
+ def(PerfDataManager_lock , PaddedMutex , leaf, true, Monitor::_safepoint_check_always); // used for synchronized access to PerfDataManager resources
// CMS_modUnionTable_lock leaf
// CMS_bitMap_lock leaf 1
// CMS_freeList_lock leaf 2
- def(Safepoint_lock , Monitor, safepoint, true, Monitor::_safepoint_check_sometimes); // locks SnippetCache_lock/Threads_lock
+ def(Safepoint_lock , PaddedMonitor, safepoint, true, Monitor::_safepoint_check_sometimes); // locks SnippetCache_lock/Threads_lock
- def(Threads_lock , Monitor, barrier, true, Monitor::_safepoint_check_sometimes);
+ def(Threads_lock , PaddedMonitor, barrier, true, Monitor::_safepoint_check_sometimes);
- def(VMOperationQueue_lock , Monitor, nonleaf, true, Monitor::_safepoint_check_sometimes); // VM_thread allowed to block on these
- def(VMOperationRequest_lock , Monitor, nonleaf, true, Monitor::_safepoint_check_sometimes);
- def(RetData_lock , Mutex , nonleaf, false, Monitor::_safepoint_check_always);
- def(Terminator_lock , Monitor, nonleaf, true, Monitor::_safepoint_check_sometimes);
- def(VtableStubs_lock , Mutex , nonleaf, true, Monitor::_safepoint_check_always);
- def(Notify_lock , Monitor, nonleaf, true, Monitor::_safepoint_check_always);
- def(JNIGlobalHandle_lock , Mutex , nonleaf, true, Monitor::_safepoint_check_always); // locks JNIHandleBlockFreeList_lock
- def(JNICritical_lock , Monitor, nonleaf, true, Monitor::_safepoint_check_always); // used for JNI critical regions
- def(AdapterHandlerLibrary_lock , Mutex , nonleaf, true, Monitor::_safepoint_check_always);
+ def(VMOperationQueue_lock , PaddedMonitor, nonleaf, true, Monitor::_safepoint_check_sometimes); // VM_thread allowed to block on these
+ def(VMOperationRequest_lock , PaddedMonitor, nonleaf, true, Monitor::_safepoint_check_sometimes);
+ def(RetData_lock , PaddedMutex , nonleaf, false, Monitor::_safepoint_check_always);
+ def(Terminator_lock , PaddedMonitor, nonleaf, true, Monitor::_safepoint_check_sometimes);
+ def(VtableStubs_lock , PaddedMutex , nonleaf, true, Monitor::_safepoint_check_always);
+ def(Notify_lock , PaddedMonitor, nonleaf, true, Monitor::_safepoint_check_always);
+ def(JNIGlobalHandle_lock , PaddedMutex , nonleaf, true, Monitor::_safepoint_check_always); // locks JNIHandleBlockFreeList_lock
+ def(JNICritical_lock , PaddedMonitor, nonleaf, true, Monitor::_safepoint_check_always); // used for JNI critical regions
+ def(AdapterHandlerLibrary_lock , PaddedMutex , nonleaf, true, Monitor::_safepoint_check_always);
- def(Heap_lock , Monitor, nonleaf+1, false, Monitor::_safepoint_check_sometimes);
- def(JfieldIdCreation_lock , Mutex , nonleaf+1, true, Monitor::_safepoint_check_always); // jfieldID, Used in VM_Operation
- def(MemberNameTable_lock , Mutex , nonleaf+1, false, Monitor::_safepoint_check_always); // Used to protect MemberNameTable
+ def(Heap_lock , PaddedMonitor, nonleaf+1, false, Monitor::_safepoint_check_sometimes);
+ def(JfieldIdCreation_lock , PaddedMutex , nonleaf+1, true, Monitor::_safepoint_check_always); // jfieldID, Used in VM_Operation
+ def(MemberNameTable_lock , PaddedMutex , nonleaf+1, false, Monitor::_safepoint_check_always); // Used to protect MemberNameTable
- def(CompiledIC_lock , Mutex , nonleaf+2, false, Monitor::_safepoint_check_always); // locks VtableStubs_lock, InlineCacheBuffer_lock
- def(CompileTaskAlloc_lock , Mutex , nonleaf+2, true, Monitor::_safepoint_check_always);
- def(CompileStatistics_lock , Mutex , nonleaf+2, false, Monitor::_safepoint_check_always);
- def(DirectivesStack_lock , Mutex , special, true, Monitor::_safepoint_check_never);
- def(MultiArray_lock , Mutex , nonleaf+2, false, Monitor::_safepoint_check_always); // locks SymbolTable_lock
+ def(CompiledIC_lock , PaddedMutex , nonleaf+2, false, Monitor::_safepoint_check_always); // locks VtableStubs_lock, InlineCacheBuffer_lock
+ def(CompileTaskAlloc_lock , PaddedMutex , nonleaf+2, true, Monitor::_safepoint_check_always);
+ def(CompileStatistics_lock , PaddedMutex , nonleaf+2, false, Monitor::_safepoint_check_always);
+ def(DirectivesStack_lock , PaddedMutex , special, true, Monitor::_safepoint_check_never);
+ def(MultiArray_lock , PaddedMutex , nonleaf+2, false, Monitor::_safepoint_check_always); // locks SymbolTable_lock
- def(JvmtiThreadState_lock , Mutex , nonleaf+2, false, Monitor::_safepoint_check_always); // Used by JvmtiThreadState/JvmtiEventController
- def(Management_lock , Mutex , nonleaf+2, false, Monitor::_safepoint_check_always); // used for JVM management
+ def(JvmtiThreadState_lock , PaddedMutex , nonleaf+2, false, Monitor::_safepoint_check_always); // Used by JvmtiThreadState/JvmtiEventController
+ def(Management_lock , PaddedMutex , nonleaf+2, false, Monitor::_safepoint_check_always); // used for JVM management
- def(Compile_lock , Mutex , nonleaf+3, true, Monitor::_safepoint_check_sometimes);
- def(MethodData_lock , Mutex , nonleaf+3, false, Monitor::_safepoint_check_always);
- def(TouchedMethodLog_lock , Mutex , nonleaf+3, false, Monitor::_safepoint_check_always);
+ def(Compile_lock , PaddedMutex , nonleaf+3, true, Monitor::_safepoint_check_sometimes);
+ def(MethodData_lock , PaddedMutex , nonleaf+3, false, Monitor::_safepoint_check_always);
+ def(TouchedMethodLog_lock , PaddedMutex , nonleaf+3, false, Monitor::_safepoint_check_always);
- def(MethodCompileQueue_lock , Monitor, nonleaf+4, true, Monitor::_safepoint_check_always);
- def(Debug2_lock , Mutex , nonleaf+4, true, Monitor::_safepoint_check_never);
- def(Debug3_lock , Mutex , nonleaf+4, true, Monitor::_safepoint_check_never);
- def(CompileThread_lock , Monitor, nonleaf+5, false, Monitor::_safepoint_check_always);
- def(PeriodicTask_lock , Monitor, nonleaf+5, true, Monitor::_safepoint_check_sometimes);
- def(RedefineClasses_lock , Monitor, nonleaf+5, true, Monitor::_safepoint_check_always);
+ def(MethodCompileQueue_lock , PaddedMonitor, nonleaf+4, true, Monitor::_safepoint_check_always);
+ def(Debug2_lock , PaddedMutex , nonleaf+4, true, Monitor::_safepoint_check_never);
+ def(Debug3_lock , PaddedMutex , nonleaf+4, true, Monitor::_safepoint_check_never);
+ def(CompileThread_lock , PaddedMonitor, nonleaf+5, false, Monitor::_safepoint_check_always);
+ def(PeriodicTask_lock , PaddedMonitor, nonleaf+5, true, Monitor::_safepoint_check_sometimes);
+ def(RedefineClasses_lock , PaddedMonitor, nonleaf+5, true, Monitor::_safepoint_check_always);
if (WhiteBoxAPI) {
- def(Compilation_lock , Monitor, leaf, false, Monitor::_safepoint_check_never);
+ def(Compilation_lock , PaddedMonitor, leaf, false, Monitor::_safepoint_check_never);
}
#ifdef INCLUDE_TRACE
- def(JfrMsg_lock , Monitor, leaf, true, Monitor::_safepoint_check_always);
- def(JfrBuffer_lock , Mutex, leaf, true, Monitor::_safepoint_check_never);
- def(JfrThreadGroups_lock , Mutex, leaf, true, Monitor::_safepoint_check_always);
- def(JfrStream_lock , Mutex, leaf+1, true, Monitor::_safepoint_check_never); // ensure to rank lower than 'safepoint'
- def(JfrStacktrace_lock , Mutex, special, true, Monitor::_safepoint_check_sometimes);
+ def(JfrMsg_lock , PaddedMonitor, leaf, true, Monitor::_safepoint_check_always);
+ def(JfrBuffer_lock , PaddedMutex , leaf, true, Monitor::_safepoint_check_never);
+ def(JfrThreadGroups_lock , PaddedMutex , leaf, true, Monitor::_safepoint_check_always);
+ def(JfrStream_lock , PaddedMutex , leaf+1, true, Monitor::_safepoint_check_never); // ensure to rank lower than 'safepoint'
+ def(JfrStacktrace_lock , PaddedMutex , special, true, Monitor::_safepoint_check_sometimes);
#endif
#ifndef SUPPORTS_NATIVE_CX8
- def(UnsafeJlong_lock , Mutex, special, false, Monitor::_safepoint_check_never);
+ def(UnsafeJlong_lock , PaddedMutex , special, false, Monitor::_safepoint_check_never);
#endif
}
--- a/hotspot/src/share/vm/runtime/thread.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/share/vm/runtime/thread.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -3768,10 +3768,21 @@
SystemDictionary::compute_java_system_loader(CHECK_(JNI_ERR));
#if INCLUDE_JVMCI
- if (EnableJVMCI && UseJVMCICompiler && (!UseInterpreter || !BackgroundCompilation)) {
- // 8145270: Force initialization of JVMCI runtime otherwise requests for blocking
- // compilations via JVMCI will not actually block until JVMCI is initialized.
- JVMCIRuntime::force_initialization(CHECK_JNI_ERR);
+ if (EnableJVMCI) {
+ // Initialize JVMCI eagerly if JVMCIPrintProperties is enabled.
+ // The JVMCI Java initialization code will read this flag and
+ // do the printing if it's set.
+ bool init = JVMCIPrintProperties;
+
+ if (!init) {
+ // 8145270: Force initialization of JVMCI runtime otherwise requests for blocking
+ // compilations via JVMCI will not actually block until JVMCI is initialized.
+ init = UseJVMCICompiler && (!UseInterpreter || !BackgroundCompilation);
+ }
+
+ if (init) {
+ JVMCIRuntime::force_initialization(CHECK_JNI_ERR);
+ }
}
#endif
--- a/hotspot/src/share/vm/utilities/internalVMTests.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/src/share/vm/utilities/internalVMTests.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -58,30 +58,12 @@
run_unit_test(TestNewSize_test);
run_unit_test(TestOldSize_test);
run_unit_test(TestBitMap_test);
- run_unit_test(TestResourcehash_test);
run_unit_test(ObjectMonitor_test);
- run_unit_test(Test_log_tag_combinations_limit);
- run_unit_test(Test_logtarget);
- run_unit_test(Test_logstream);
- run_unit_test(Test_loghandle);
- run_unit_test(Test_logtargethandle);
- run_unit_test(Test_log_gctracetime);
- run_unit_test(Test_configure_stdout);
- run_unit_test(Test_logconfiguration_subscribe);
- run_unit_test(Test_log_prefix);
- run_unit_test(Test_log_big);
- run_unit_test(Test_logtagset_duplicates);
- run_unit_test(Test_logtagset_descriptions);
- run_unit_test(Test_log_file_startup_rotation);
- run_unit_test(Test_log_file_startup_truncation);
- run_unit_test(Test_invalid_log_file);
- run_unit_test(Test_multiline_logging);
run_unit_test(DirectivesParser_test);
#if INCLUDE_VM_STRUCTS
run_unit_test(VMStructs_test);
#endif
#if INCLUDE_ALL_GCS
- run_unit_test(TestG1BiasedArray_test);
run_unit_test(TestBufferingOopClosure_test);
if (UseG1GC) {
run_unit_test(FreeRegionList_test);
--- a/hotspot/src/share/vm/utilities/resourceHash.cpp Wed Nov 09 15:20:30 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,182 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-#include "precompiled.hpp"
-#include "memory/allocation.hpp"
-#include "memory/resourceArea.hpp"
-#include "utilities/debug.hpp"
-#include "utilities/resourceHash.hpp"
-
-#ifndef PRODUCT
-
-/////////////// Unit tests ///////////////
-
-class TestResourceHashtable : public AllStatic {
- typedef void* K;
- typedef int V;
-
- static unsigned identity_hash(const K& k) {
- return (unsigned)(uintptr_t)k;
- }
-
- static unsigned bad_hash(const K& k) {
- return 1;
- }
-
- class EqualityTestIter {
- public:
- bool do_entry(K const& k, V const& v) {
- assert((uintptr_t)k == (uintptr_t)v, "");
- return true; // continue iteration
- }
- };
-
- template<
- unsigned (*HASH) (K const&) = primitive_hash<K>,
- bool (*EQUALS)(K const&, K const&) = primitive_equals<K>,
- unsigned SIZE = 256,
- ResourceObj::allocation_type ALLOC_TYPE = ResourceObj::RESOURCE_AREA,
- MEMFLAGS MEM_TYPE = mtInternal
- >
- class Runner : public AllStatic {
- static void* as_K(uintptr_t val) { return (void*)val; }
-
- public:
- static void test_small() {
- EqualityTestIter et;
- ResourceHashtable<K, V, HASH, EQUALS, SIZE, ALLOC_TYPE, MEM_TYPE> rh;
-
- assert(!rh.contains(as_K(0x1)), "");
-
- assert(rh.put(as_K(0x1), 0x1), "");
- assert(rh.contains(as_K(0x1)), "");
-
- assert(!rh.put(as_K(0x1), 0x1), "");
-
- assert(rh.put(as_K(0x2), 0x2), "");
- assert(rh.put(as_K(0x3), 0x3), "");
- assert(rh.put(as_K(0x4), 0x4), "");
- assert(rh.put(as_K(0x5), 0x5), "");
-
- assert(!rh.remove(as_K(0x0)), "");
- rh.iterate(&et);
-
- assert(rh.remove(as_K(0x1)), "");
- rh.iterate(&et);
-
- }
-
- // We use keys with the low bits cleared since the default hash will do some shifting
- static void test_small_shifted() {
- EqualityTestIter et;
- ResourceHashtable<K, V, HASH, EQUALS, SIZE, ALLOC_TYPE, MEM_TYPE> rh;
-
- assert(!rh.contains(as_K(0x10)), "");
-
- assert(rh.put(as_K(0x10), 0x10), "");
- assert(rh.contains(as_K(0x10)), "");
-
- assert(!rh.put(as_K(0x10), 0x10), "");
-
- assert(rh.put(as_K(0x20), 0x20), "");
- assert(rh.put(as_K(0x30), 0x30), "");
- assert(rh.put(as_K(0x40), 0x40), "");
- assert(rh.put(as_K(0x50), 0x50), "");
-
- assert(!rh.remove(as_K(0x00)), "");
-
- assert(rh.remove(as_K(0x10)), "");
-
- rh.iterate(&et);
- }
-
- static void test(unsigned num_elements = SIZE) {
- EqualityTestIter et;
- ResourceHashtable<K, V, HASH, EQUALS, SIZE, ALLOC_TYPE, MEM_TYPE> rh;
-
- for (uintptr_t i = 0; i < num_elements; ++i) {
- assert(rh.put(as_K(i), i), "");
- }
-
- rh.iterate(&et);
-
- for (uintptr_t i = num_elements; i > 0; --i) {
- uintptr_t index = i - 1;
- assert(rh.remove(as_K(index)), "");
- }
- rh.iterate(&et);
- for (uintptr_t i = num_elements; i > 0; --i) {
- uintptr_t index = i - 1;
- assert(!rh.remove(as_K(index)), "");
- }
- rh.iterate(&et);
- }
- };
-
- public:
- static void run_tests() {
- {
- ResourceMark rm;
- Runner<>::test_small();
- Runner<>::test_small_shifted();
- Runner<>::test();
- }
-
- {
- ResourceMark rm;
- Runner<identity_hash>::test_small();
- Runner<identity_hash>::test_small_shifted();
- Runner<identity_hash>::test();
- }
-
- {
- ResourceMark rm;
- Runner<bad_hash>::test_small();
- Runner<bad_hash>::test_small_shifted();
- Runner<bad_hash>::test();
- }
-
-
- assert(Thread::current()->resource_area()->nesting() == 0, "this code depends on not having an active ResourceMark");
- // The following test calls will cause an assert if resource allocations occur since we don't have an active mark
- Runner<primitive_hash<K>, primitive_equals<K>, 512, ResourceObj::C_HEAP>::test_small();
- Runner<primitive_hash<K>, primitive_equals<K>, 512, ResourceObj::C_HEAP>::test_small_shifted();
- Runner<primitive_hash<K>, primitive_equals<K>, 512, ResourceObj::C_HEAP>::test();
-
- Runner<bad_hash, primitive_equals<K>, 512, ResourceObj::C_HEAP>::test_small();
- Runner<bad_hash, primitive_equals<K>, 512, ResourceObj::C_HEAP>::test_small_shifted();
- Runner<bad_hash, primitive_equals<K>, 512, ResourceObj::C_HEAP>::test();
-
- Runner<identity_hash, primitive_equals<K>, 1, ResourceObj::C_HEAP>::test_small();
- Runner<identity_hash, primitive_equals<K>, 1, ResourceObj::C_HEAP>::test_small_shifted();
- Runner<identity_hash, primitive_equals<K>, 1, ResourceObj::C_HEAP>::test(512);
- }
-};
-
-void TestResourcehash_test() {
- TestResourceHashtable::run_tests();
-}
-
-#endif // not PRODUCT
-
--- a/hotspot/test/Makefile Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/Makefile Wed Nov 09 10:04:43 2016 -0800
@@ -66,6 +66,7 @@
ifeq ($(ARCH), i386)
ARCH=i586
endif
+ NUM_CORES := $(shell LC_MESSAGES=C /usr/sbin/psrinfo -v | grep -c on-line)
endif
ifeq ($(UNAME_S), Linux)
PLATFORM = linux
@@ -74,6 +75,7 @@
ifeq ($(ARCH), i386)
ARCH = i586
endif
+ NUM_CORES := $(shell cat /proc/cpuinfo | grep -c processor)
endif
ifeq ($(UNAME_S), Darwin)
PLATFORM = bsd
@@ -82,6 +84,7 @@
ifeq ($(ARCH), i386)
ARCH = i586
endif
+ NUM_CORES := $(shell /usr/sbin/sysctl -n hw.ncpu)
endif
ifeq ($(findstring BSD,$(UNAME_S)), BSD)
PLATFORM = bsd
@@ -115,6 +118,13 @@
endif
endif
EXESUFFIX = .exe
+ ifneq ($(NUMBER_OF_PROCESSORS), )
+ NUM_CORES := $(NUMBER_OF_PROCESSORS)
+ else
+ ifneq ($(HOTSPOT_BUILD_JOBS), )
+ NUM_CORES := $(HOTSPOT_BUILD_JOBS)
+ endif
+ endif
endif
ifdef ALT_SLASH_JAVA
@@ -308,9 +318,22 @@
TEST_SELECTION = $(TESTDIRS)
endif
-ifdef CONCURRENCY
- JTREG_BASIC_OPTIONS += -concurrency:$(CONCURRENCY)
+# Concurrency based on min(cores / 2, 12)
+ifdef NUM_CORES
+ CONCURRENCY := $(shell expr $(NUM_CORES) / 2)
+ ifeq ($(CONCURRENCY), 0)
+ CONCURRENCY := 1
+ else ifeq ($(shell expr $(CONCURRENCY) \> 12), 1)
+ CONCURRENCY := 12
+ endif
+else
+ CONCURRENCY := 1
endif
+JTREG_BASIC_OPTIONS += -concurrency:$(CONCURRENCY)
+
+# Make sure MaxRAMFraction is high enough to not cause OOM or swapping since we may end up with a lot of JVM's
+JTREG_BASIC_OPTIONS += -vmoption:-XX:MaxRAMFraction=$(shell expr $(CONCURRENCY) \* 4)
+
ifdef EXTRA_JTREG_OPTIONS
JTREG_BASIC_OPTIONS += $(EXTRA_JTREG_OPTIONS)
endif
--- a/hotspot/test/TEST.groups Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/TEST.groups Wed Nov 09 10:04:43 2016 -0800
@@ -370,6 +370,7 @@
-runtime/modules/ModuleStress/ModuleStressGC.java \
-runtime/NMT \
-runtime/RedefineObject/TestRedefineObject.java \
+ -runtime/RedefineTests/RedefineLeak.java \
-runtime/RedefineTests/RedefinePreviousVersions.java \
-runtime/RedefineTests/RedefineRunningMethods.java \
-runtime/RedefineTests/RedefineRunningMethodsWithBacktrace.java \
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/arraycopy/TestEliminatedCloneBadMemEdge.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2016, Red Hat, Inc. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8166836
+ * @summary Elimination of clone's ArrayCopyNode may make compilation fail silently
+ * @run main/othervm -XX:-BackgroundCompilation -XX:-UseOnStackReplacement -XX:CompileCommand=dontinline,TestEliminatedCloneBadMemEdge::not_inlined TestEliminatedCloneBadMemEdge
+ *
+ */
+
+public class TestEliminatedCloneBadMemEdge implements Cloneable {
+
+ int f1;
+ int f2;
+ int f3;
+ int f4;
+ int f5;
+ int f6;
+ int f7;
+ int f8;
+ int f9;
+
+ static void not_inlined() {}
+
+ static void test(TestEliminatedCloneBadMemEdge o1) throws CloneNotSupportedException {
+ TestEliminatedCloneBadMemEdge o2 = (TestEliminatedCloneBadMemEdge)o1.clone();
+ not_inlined();
+ o2.f1 = 0x42;
+ }
+
+ static public void main(String[] args) throws CloneNotSupportedException {
+ TestEliminatedCloneBadMemEdge o1 = new TestEliminatedCloneBadMemEdge();
+ for (int i = 0; i < 20000; i++) {
+ test(o1);
+ }
+ }
+}
--- a/hotspot/test/compiler/c1/NullCheckTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c1/NullCheckTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c1/Test6579789.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c1/Test6579789.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c1/Test6795465.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c1/Test6795465.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c1/Test6849574.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c1/Test6849574.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c1/Test6855215.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c1/Test6855215.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c1/Test6932496.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c1/Test6932496.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c1/Test7042153.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c1/Test7042153.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c1/Test7090976.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c1/Test7090976.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c1/Test7103261.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c1/Test7103261.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c1/Test7123108.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c1/Test7123108.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c1/Test8004051.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c1/Test8004051.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c1/TestArrayCopy.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c1/TestArrayCopy.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c1/TestDeoptInt.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c1/TestDeoptInt.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c1/TestUnalignedLoad.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c1/TestUnalignedLoad.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c2/FloatingPointFoldingTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/FloatingPointFoldingTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c2/IVTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/IVTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c2/InterruptedTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/InterruptedTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/*
--- a/hotspot/test/compiler/c2/Test6186134.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/Test6186134.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c2/Test6196102.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/Test6196102.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c2/Test6357214.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/Test6357214.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c2/Test6443505.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/Test6443505.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c2/Test6559156.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/Test6559156.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c2/Test6661247.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/Test6661247.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/*
--- a/hotspot/test/compiler/c2/Test6732154.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/Test6732154.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c2/Test6753639.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/Test6753639.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c2/Test6792161.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/Test6792161.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c2/Test6796786.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/Test6796786.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c2/Test6799693.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/Test6799693.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/*
--- a/hotspot/test/compiler/c2/Test6823453.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/Test6823453.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/*
--- a/hotspot/test/compiler/c2/Test6832293.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/Test6832293.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/*
--- a/hotspot/test/compiler/c2/Test6850611.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/Test6850611.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c2/Test6851282.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/Test6851282.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c2/Test6852078.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/Test6852078.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c2/Test6857159.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/Test6857159.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c2/Test6885584.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/Test6885584.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c2/Test6897150.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/Test6897150.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c2/Test6905845.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/Test6905845.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c2/Test6910605_1.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/Test6910605_1.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c2/Test6910605_2.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/Test6910605_2.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c2/Test6916644.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/Test6916644.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c2/Test6930043.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/Test6930043.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c2/Test6931567.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/Test6931567.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c2/Test6935022.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/Test6935022.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c2/Test6956668.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/Test6956668.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c2/Test6959129.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/Test6959129.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c2/Test6968348.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/Test6968348.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c2/Test6985295.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/Test6985295.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c2/Test6992759.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/Test6992759.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c2/Test7002666.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/Test7002666.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c2/Test7009359.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/Test7009359.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c2/Test7020614.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/Test7020614.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c2/Test7024475.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/Test7024475.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c2/Test7041100.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/Test7041100.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c2/Test7046096.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/Test7046096.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c2/Test7047069.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/Test7047069.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c2/Test7048332.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/Test7048332.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c2/Test7068051.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/Test7068051.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c2/Test7110586.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/Test7110586.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c2/Test7125879.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/Test7125879.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c2/Test7160610.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/Test7160610.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c2/Test7169782.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/Test7169782.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c2/Test7174363.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/Test7174363.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c2/Test7177917.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/Test7177917.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c2/Test7190310.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/Test7190310.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/*
--- a/hotspot/test/compiler/c2/Test7190310_unsafe.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/Test7190310_unsafe.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/*
--- a/hotspot/test/compiler/c2/Test7199742.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/Test7199742.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c2/Test8002069.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/Test8002069.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c2/TestDominatingDeadCheckCast.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/TestDominatingDeadCheckCast.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c2/cr6340864/TestByteVect.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/cr6340864/TestByteVect.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c2/cr6340864/TestDoubleVect.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/cr6340864/TestDoubleVect.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c2/cr6340864/TestFloatVect.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/cr6340864/TestFloatVect.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c2/cr6340864/TestIntVect.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/cr6340864/TestIntVect.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c2/cr6340864/TestLongVect.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/cr6340864/TestLongVect.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c2/cr6340864/TestShortVect.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/cr6340864/TestShortVect.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c2/cr6663854/Test6663854.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/cr6663854/Test6663854.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c2/cr6711117/Test.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/cr6711117/Test.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/*
--- a/hotspot/test/compiler/c2/cr6890943/Test6890943.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/cr6890943/Test6890943.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c2/cr7005594/Test7005594.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/cr7005594/Test7005594.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c2/cr7192963/TestByteVect.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/cr7192963/TestByteVect.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c2/cr7192963/TestDoubleVect.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/cr7192963/TestDoubleVect.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c2/cr7192963/TestFloatVect.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/cr7192963/TestFloatVect.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c2/cr7192963/TestIntVect.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/cr7192963/TestIntVect.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c2/cr7192963/TestLongVect.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/cr7192963/TestLongVect.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c2/cr7192963/TestShortVect.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/cr7192963/TestShortVect.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c2/cr7200264/TestIntVect.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/cr7200264/TestIntVect.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c2/cr8004867/TestIntAtomicCAS.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/cr8004867/TestIntAtomicCAS.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c2/cr8004867/TestIntAtomicOrdered.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/cr8004867/TestIntAtomicOrdered.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c2/cr8004867/TestIntAtomicVolatile.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/cr8004867/TestIntAtomicVolatile.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c2/cr8004867/TestIntUnsafeCAS.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/cr8004867/TestIntUnsafeCAS.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c2/cr8004867/TestIntUnsafeOrdered.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/cr8004867/TestIntUnsafeOrdered.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/c2/cr8004867/TestIntUnsafeVolatile.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/c2/cr8004867/TestIntUnsafeVolatile.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/codecache/OverflowCodeCacheTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/codecache/OverflowCodeCacheTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/*
--- a/hotspot/test/compiler/codecache/stress/CodeCacheStressRunner.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/codecache/stress/CodeCacheStressRunner.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
package compiler.codecache.stress;
--- a/hotspot/test/compiler/codecache/stress/Helper.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/codecache/stress/Helper.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
package compiler.codecache.stress;
--- a/hotspot/test/compiler/codecache/stress/OverloadCompileQueueTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/codecache/stress/OverloadCompileQueueTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/*
--- a/hotspot/test/compiler/codecache/stress/RandomAllocationTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/codecache/stress/RandomAllocationTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/*
--- a/hotspot/test/compiler/codecache/stress/UnexpectedDeoptimizationTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/codecache/stress/UnexpectedDeoptimizationTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/*
--- a/hotspot/test/compiler/codegen/Test6431242.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/codegen/Test6431242.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/*
--- a/hotspot/test/compiler/codegen/Test6909839.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/codegen/Test6909839.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/codegen/Test6942326.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/codegen/Test6942326.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/codegen/Test7009231.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/codegen/Test7009231.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/codegen/Test7100757.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/codegen/Test7100757.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/codegen/TestBooleanVect.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/codegen/TestBooleanVect.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/codegen/TestByteDoubleVect.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/codegen/TestByteDoubleVect.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/codegen/TestByteFloatVect.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/codegen/TestByteFloatVect.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/codegen/TestByteIntVect.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/codegen/TestByteIntVect.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/codegen/TestByteLongVect.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/codegen/TestByteLongVect.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/codegen/TestByteShortVect.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/codegen/TestByteShortVect.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/codegen/TestByteVect.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/codegen/TestByteVect.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/codegen/TestCharShortVect.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/codegen/TestCharShortVect.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/codegen/TestCharVect.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/codegen/TestCharVect.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/codegen/TestCharVect2.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/codegen/TestCharVect2.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/codegen/TestDoubleVect.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/codegen/TestDoubleVect.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/codegen/TestFloatDoubleVect.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/codegen/TestFloatDoubleVect.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/codegen/TestFloatVect.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/codegen/TestFloatVect.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/codegen/TestIntDoubleVect.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/codegen/TestIntDoubleVect.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/codegen/TestIntFloatVect.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/codegen/TestIntFloatVect.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/codegen/TestIntLongVect.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/codegen/TestIntLongVect.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/codegen/TestIntVect.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/codegen/TestIntVect.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/codegen/TestLongDoubleVect.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/codegen/TestLongDoubleVect.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/codegen/TestLongFloatVect.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/codegen/TestLongFloatVect.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/codegen/TestLongVect.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/codegen/TestLongVect.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/codegen/TestShortDoubleVect.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/codegen/TestShortDoubleVect.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/codegen/TestShortFloatVect.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/codegen/TestShortFloatVect.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/codegen/TestShortIntVect.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/codegen/TestShortIntVect.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/codegen/TestShortLongVect.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/codegen/TestShortLongVect.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/codegen/TestShortVect.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/codegen/TestShortVect.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/codegen/aes/TestAESBase.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/codegen/aes/TestAESBase.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,10 +19,8 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
-
package compiler.codegen.aes;
import jdk.test.lib.Utils;
--- a/hotspot/test/compiler/codegen/aes/TestAESDecode.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/codegen/aes/TestAESDecode.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
package compiler.codegen.aes;
--- a/hotspot/test/compiler/codegen/aes/TestAESEncode.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/codegen/aes/TestAESEncode.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
package compiler.codegen.aes;
--- a/hotspot/test/compiler/codegen/aes/TestAESMain.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/codegen/aes/TestAESMain.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/controldependency/TestEliminatedCastPPAtPhi.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/controldependency/TestEliminatedCastPPAtPhi.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/cpuflags/AESIntrinsicsBase.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/cpuflags/AESIntrinsicsBase.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
package compiler.cpuflags;
--- a/hotspot/test/compiler/cpuflags/TestAESIntrinsicsOnSupportedConfig.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/cpuflags/TestAESIntrinsicsOnSupportedConfig.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/*
--- a/hotspot/test/compiler/cpuflags/TestAESIntrinsicsOnUnsupportedConfig.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/cpuflags/TestAESIntrinsicsOnUnsupportedConfig.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/*
--- a/hotspot/test/compiler/cpuflags/TestSSE4Disabled.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/cpuflags/TestSSE4Disabled.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/*
--- a/hotspot/test/compiler/cpuflags/predicate/AESSupportPredicate.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/cpuflags/predicate/AESSupportPredicate.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,8 +19,8 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
+
package compiler.cpuflags.predicate;
import sun.hotspot.cpuinfo.CPUInfo;
--- a/hotspot/test/compiler/escapeAnalysis/Test6726999.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/escapeAnalysis/Test6726999.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/*
--- a/hotspot/test/compiler/escapeAnalysis/Test6775880.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/escapeAnalysis/Test6775880.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/*
--- a/hotspot/test/compiler/escapeAnalysis/Test6895383.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/escapeAnalysis/Test6895383.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/escapeAnalysis/Test6896727.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/escapeAnalysis/Test6896727.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/*
--- a/hotspot/test/compiler/escapeAnalysis/cr6795161/Test.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/escapeAnalysis/cr6795161/Test.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/*
--- a/hotspot/test/compiler/floatingpoint/Test15FloatJNIArgs.java Wed Nov 09 15:20:30 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-/*
- * Copyright (c) 2015 SAP SE. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/* @test
- * @bug 8139258
- * @summary Regression test for 8139258 which failed to properly pass float args
- * to a jni function on ppc64le.
- *
- * @run main/othervm/native -Xint compiler.floatingpoint.Test15FloatJNIArgs
- * @run main/othervm/native -XX:+TieredCompilation -Xcomp compiler.floatingpoint.Test15FloatJNIArgs
- * @run main/othervm/native -XX:-TieredCompilation -Xcomp compiler.floatingpoint.Test15FloatJNIArgs
- */
-
-package compiler.floatingpoint;
-
-public class Test15FloatJNIArgs {
- static {
- try {
- System.loadLibrary("Test15FloatJNIArgs");
- } catch (UnsatisfiedLinkError e) {
- System.out.println("could not load native lib: " + e);
- }
- }
-
- public static native float add15floats(
- float f1, float f2, float f3, float f4,
- float f5, float f6, float f7, float f8,
- float f9, float f10, float f11, float f12,
- float f13, float f14, float f15);
-
- static void test() throws Exception {
- float sum = Test15FloatJNIArgs.add15floats(1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
- 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
- if (sum != 15.0f) {
- throw new Error("Passed 15 times 1.0f to jni function which didn't add them properly: " + sum);
- }
- }
-
- public static void main(String[] args) throws Exception {
- for (int i = 0; i < 200; ++i) {
- test();
- }
- }
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/floatingpoint/TestFloatJNIArgs.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2015, 2016 SAP SE. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+ * @bug 8139258 8165673
+ * @summary Regression test for passing float args to a jni function.
+ *
+ *
+ * @run main/othervm/native -Xint compiler.floatingpoint.TestFloatJNIArgs
+ * @run main/othervm/native -XX:+TieredCompilation -Xcomp compiler.floatingpoint.TestFloatJNIArgs
+ * @run main/othervm/native -XX:-TieredCompilation -Xcomp compiler.floatingpoint.TestFloatJNIArgs
+ */
+
+package compiler.floatingpoint;
+
+public class TestFloatJNIArgs {
+ static {
+ try {
+ System.loadLibrary("TestFloatJNIArgs");
+ } catch (UnsatisfiedLinkError e) {
+ System.out.println("could not load native lib: " + e);
+ }
+ }
+
+ public static native float add15floats(
+ float f1, float f2, float f3, float f4,
+ float f5, float f6, float f7, float f8,
+ float f9, float f10, float f11, float f12,
+ float f13, float f14, float f15);
+
+ public static native float add10floats(
+ float f1, float f2, float f3, float f4,
+ float f5, float f6, float f7, float f8,
+ float f9, float f10);
+
+ public static native float addFloatsInts(
+ float f1, float f2, float f3, float f4,
+ float f5, float f6, float f7, float f8,
+ float f9, float f10, float f11, float f12,
+ float f13, float f14, float f15, int a16, int a17);
+
+ public static native double add15doubles(
+ double d1, double d2, double d3, double d4,
+ double d5, double d6, double d7, double d8,
+ double d9, double d10, double d11, double d12,
+ double d13, double d14, double d15);
+
+ static void test() throws Exception {
+ float sum = TestFloatJNIArgs.add15floats(1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
+ 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
+ if (sum != 15.0f) {
+ throw new Error("Passed 15 times 1.0f to jni function which didn't add them properly: " + sum);
+ }
+
+ float sum1 = TestFloatJNIArgs.add10floats(1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
+ if (sum1 != 10.0f) {
+ throw new Error("Passed 10 times 1.0f to jni function which didn't add them properly: " + sum1);
+ }
+
+ float sum2 = TestFloatJNIArgs.addFloatsInts(1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
+ 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1, 1);
+ if (sum2 != 17.0f) {
+ throw new Error("Passed 17 times 1 to jni function which didn't add them properly: " + sum2);
+ }
+
+ double dsum = TestFloatJNIArgs.add15doubles(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
+ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0);
+ if (dsum != 15.0) {
+ throw new Error("Passed 15 times 1.0 to jni function which didn't add them properly: " + dsum);
+ }
+ }
+
+ public static void main(String[] args) throws Exception {
+ for (int i = 0; i < 200; ++i) {
+ test();
+ }
+ }
+}
--- a/hotspot/test/compiler/floatingpoint/libTest15FloatJNIArgs.c Wed Nov 09 15:20:30 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2015. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-#include <jni.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-JNIEXPORT jfloat JNICALL Java_compiler_floatingpoint_Test15FloatJNIArgs_add15floats
- (JNIEnv *env, jclass cls,
- jfloat f1, jfloat f2, jfloat f3, jfloat f4,
- jfloat f5, jfloat f6, jfloat f7, jfloat f8,
- jfloat f9, jfloat f10, jfloat f11, jfloat f12,
- jfloat f13, jfloat f14, jfloat f15) {
- return f1 + f2 + f3 + f4 + f5 + f6 + f7 + f8 + f9 + f10 + f11 + f12 + f13 + f14 + f15;
-}
-
-#ifdef __cplusplus
-}
-#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/floatingpoint/libTestFloatJNIArgs.c Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2015, 2016. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+JNIEXPORT jfloat JNICALL Java_compiler_floatingpoint_TestFloatJNIArgs_add15floats
+ (JNIEnv *env, jclass cls,
+ jfloat f1, jfloat f2, jfloat f3, jfloat f4,
+ jfloat f5, jfloat f6, jfloat f7, jfloat f8,
+ jfloat f9, jfloat f10, jfloat f11, jfloat f12,
+ jfloat f13, jfloat f14, jfloat f15) {
+ return f1 + f2 + f3 + f4 + f5 + f6 + f7 + f8 + f9 + f10 + f11 + f12 + f13 + f14 + f15;
+}
+
+JNIEXPORT jfloat JNICALL Java_compiler_floatingpoint_TestFloatJNIArgs_add10floats
+ (JNIEnv *env, jclass cls,
+ jfloat f1, jfloat f2, jfloat f3, jfloat f4,
+ jfloat f5, jfloat f6, jfloat f7, jfloat f8,
+ jfloat f9, jfloat f10) {
+ return f1 + f2 + f3 + f4 + f5 + f6 + f7 + f8 + f9 + f10;
+}
+
+JNIEXPORT jfloat JNICALL Java_compiler_floatingpoint_TestFloatJNIArgs_addFloatsInts
+ (JNIEnv *env, jclass cls,
+ jfloat f1, jfloat f2, jfloat f3, jfloat f4,
+ jfloat f5, jfloat f6, jfloat f7, jfloat f8,
+ jfloat f9, jfloat f10, jfloat f11, jfloat f12,
+ jfloat f13, jfloat f14, jfloat f15, jint a16, jint a17) {
+ return f1 + f2 + f3 + f4 + f5 + f6 + f7 + f8 + f9 + f10 + f11 + f12 + f13 + f14 + f15 + a16 + a17;
+}
+
+JNIEXPORT jdouble JNICALL Java_compiler_floatingpoint_TestFloatJNIArgs_add15doubles
+ (JNIEnv *env, jclass cls,
+ jdouble f1, jdouble f2, jdouble f3, jdouble f4,
+ jdouble f5, jdouble f6, jdouble f7, jdouble f8,
+ jdouble f9, jdouble f10, jdouble f11, jdouble f12,
+ jdouble f13, jdouble f14, jdouble f15) {
+ return f1 + f2 + f3 + f4 + f5 + f6 + f7 + f8 + f9 + f10 + f11 + f12 + f13 + f14 + f15;
+}
+
+
+#ifdef __cplusplus
+}
+#endif
--- a/hotspot/test/compiler/gcbarriers/G1CrashTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/gcbarriers/G1CrashTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/gcbarriers/PreserveFPRegistersTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/gcbarriers/PreserveFPRegistersTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/inlining/InlineAccessors.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/inlining/InlineAccessors.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,8 +19,8 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
+
/**
* @test
* @bug 8140650
--- a/hotspot/test/compiler/interpreter/cr7116216/LargeFrame.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/interpreter/cr7116216/LargeFrame.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
package compiler.interpreter.cr7116216;
--- a/hotspot/test/compiler/interpreter/cr7116216/StackOverflow.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/interpreter/cr7116216/StackOverflow.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/intrinsics/Test6982370.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/intrinsics/Test6982370.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/intrinsics/bigInteger/TestMulAdd.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/intrinsics/bigInteger/TestMulAdd.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/intrinsics/bigInteger/TestMultiplyToLen.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/intrinsics/bigInteger/TestMultiplyToLen.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/intrinsics/bigInteger/TestMultiplyToLenReturnProfile.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/intrinsics/bigInteger/TestMultiplyToLenReturnProfile.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/intrinsics/bigInteger/TestSquareToLen.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/intrinsics/bigInteger/TestSquareToLen.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/intrinsics/bmi/BMITestRunner.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/intrinsics/bmi/BMITestRunner.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
package compiler.intrinsics.bmi;
--- a/hotspot/test/compiler/intrinsics/bmi/Expr.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/intrinsics/bmi/Expr.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
package compiler.intrinsics.bmi;
--- a/hotspot/test/compiler/intrinsics/bmi/TestAndnI.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/intrinsics/bmi/TestAndnI.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/intrinsics/bmi/TestAndnL.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/intrinsics/bmi/TestAndnL.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/intrinsics/bmi/TestBlsiI.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/intrinsics/bmi/TestBlsiI.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/intrinsics/bmi/TestBlsiL.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/intrinsics/bmi/TestBlsiL.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/intrinsics/bmi/TestBlsmskI.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/intrinsics/bmi/TestBlsmskI.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/intrinsics/bmi/TestBlsmskL.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/intrinsics/bmi/TestBlsmskL.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/intrinsics/bmi/TestBlsrI.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/intrinsics/bmi/TestBlsrI.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/intrinsics/bmi/TestBlsrL.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/intrinsics/bmi/TestBlsrL.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/intrinsics/bmi/TestLzcntI.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/intrinsics/bmi/TestLzcntI.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/intrinsics/bmi/TestLzcntL.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/intrinsics/bmi/TestLzcntL.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/intrinsics/bmi/TestTzcntI.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/intrinsics/bmi/TestTzcntI.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/intrinsics/bmi/TestTzcntL.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/intrinsics/bmi/TestTzcntL.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/intrinsics/bmi/verifycode/BmiIntrinsicBase.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/intrinsics/bmi/verifycode/BmiIntrinsicBase.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
package compiler.intrinsics.bmi.verifycode;
--- a/hotspot/test/compiler/intrinsics/klass/TestIsPrimitive.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/intrinsics/klass/TestIsPrimitive.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/*
--- a/hotspot/test/compiler/intrinsics/object/TestClone.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/intrinsics/object/TestClone.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/*
--- a/hotspot/test/compiler/intrinsics/sha/TestSHA.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/intrinsics/sha/TestSHA.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/intrinsics/unsafe/AllocateUninitializedArray.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/intrinsics/unsafe/AllocateUninitializedArray.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/*
--- a/hotspot/test/compiler/intrinsics/unsafe/TestUnsafeMismatchedArrayFieldAccess.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/intrinsics/unsafe/TestUnsafeMismatchedArrayFieldAccess.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/intrinsics/unsafe/TestUnsafeUnalignedMismatchedAccesses.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/intrinsics/unsafe/TestUnsafeUnalignedMismatchedAccesses.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/intrinsics/unsafe/UnsafeTwoCASLong.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/intrinsics/unsafe/UnsafeTwoCASLong.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/*
--- a/hotspot/test/compiler/jsr292/CreatesInterfaceDotEqualsCallInfo.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/jsr292/CreatesInterfaceDotEqualsCallInfo.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/jsr292/LongReferenceCastingTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/jsr292/LongReferenceCastingTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/jsr292/MHInlineTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/jsr292/MHInlineTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,8 +19,8 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
+
/**
* @test
* @bug 8062280
--- a/hotspot/test/compiler/jsr292/Test7082949.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/jsr292/Test7082949.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/jsr292/TestArrayReturnType.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8134389
+ *
+ * @run main/othervm -Xbatch compiler.jsr292.TestArrayReturnType
+ * @run main/othervm -Xbatch -XX:-Inline compiler.jsr292.TestArrayReturnType
+ * @run main/othervm -Xbatch
+ * -XX:CompileCommand=exclude,compiler.jsr292.TestArrayReturnType::testArrayReturnType
+ * compiler.jsr292.TestArrayReturnType
+ */
+
+package compiler.jsr292;
+
+
+import java.lang.invoke.MethodHandle;
+import java.lang.invoke.MethodHandles;
+import java.lang.invoke.MethodType;
+
+public class TestArrayReturnType {
+
+ static final MethodHandle mh;
+ static int[] testArray = new int[1];
+ static {
+ try {
+ mh = MethodHandles.lookup().findStatic(TestArrayReturnType.class, "testArrayReturnType", MethodType.methodType(int[].class));
+ } catch (Exception e) {
+ throw new Error(e);
+ }
+ }
+
+ static int[] testArrayReturnType() {
+ return testArray;
+ }
+
+ public static void test() throws Throwable {
+ int a[] = (int[])mh.invokeExact();
+ for (int i=0; i<a.length; i++) {
+ a[i] = 1;
+ }
+ }
+
+ public static void main(String[] args) throws Throwable {
+ for (int i=0; i<15000; i++) {
+ test();
+ }
+ System.out.println("TEST PASSED");
+ }
+}
--- a/hotspot/test/compiler/jsr292/cr6990212/Test6990212.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/jsr292/cr6990212/Test6990212.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/jsr292/methodHandleExceptions/ByteClassLoader.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/jsr292/methodHandleExceptions/ByteClassLoader.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
package compiler.jsr292.methodHandleExceptions;
--- a/hotspot/test/compiler/jsr292/methodHandleExceptions/TestAMEnotNPE.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/jsr292/methodHandleExceptions/TestAMEnotNPE.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/jsr292/methodHandleExceptions/p/C.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/jsr292/methodHandleExceptions/p/C.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
package p;
--- a/hotspot/test/compiler/jsr292/methodHandleExceptions/p/Dok.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/jsr292/methodHandleExceptions/p/Dok.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
package p;
--- a/hotspot/test/compiler/jsr292/methodHandleExceptions/p/E.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/jsr292/methodHandleExceptions/p/E.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
package p;
--- a/hotspot/test/compiler/jsr292/methodHandleExceptions/p/F.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/jsr292/methodHandleExceptions/p/F.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
package p;
--- a/hotspot/test/compiler/jsr292/methodHandleExceptions/p/I.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/jsr292/methodHandleExceptions/p/I.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
package p;
--- a/hotspot/test/compiler/jsr292/methodHandleExceptions/p/Tdirect.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/jsr292/methodHandleExceptions/p/Tdirect.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
package p;
--- a/hotspot/test/compiler/jsr292/methodHandleExceptions/p/Treflect.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/jsr292/methodHandleExceptions/p/Treflect.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
package p;
--- a/hotspot/test/compiler/jvmci/JVM_GetJVMCIRuntimeTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/jvmci/JVM_GetJVMCIRuntimeTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/jvmci/SecurityRestrictionsTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/jvmci/SecurityRestrictionsTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/jvmci/TestJVMCIPrintProperties.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test TestBasicLogOutput
+ * @summary Ensure -XX:-JVMCIPrintProperties can be enabled and successfully prints expected output to stdout.
+ * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64")
+ * @library /test/lib
+ */
+
+import jdk.test.lib.process.ProcessTools;
+import jdk.test.lib.process.OutputAnalyzer;
+
+public class TestJVMCIPrintProperties {
+
+ public static void main(String[] args) throws Exception {
+ ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
+ "-XX:+UnlockExperimentalVMOptions",
+ "-XX:+EnableJVMCI",
+ "-XX:+JVMCIPrintProperties",
+ "-version");
+ OutputAnalyzer output = new OutputAnalyzer(pb.start());
+ output.shouldContain("[JVMCI properties]"); // expected message
+ output.shouldContain("String jvmci.Compiler"); // expected message
+ output.shouldContain("Boolean jvmci.InitTimer"); // expected message
+ output.shouldContain("Boolean jvmci.PrintConfig"); // expected message
+ output.shouldContain("String jvmci.TraceMethodDataFilter"); // expected message
+ output.shouldHaveExitValue(0);
+ }
+}
--- a/hotspot/test/compiler/jvmci/common/JVMCIHelpers.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/jvmci/common/JVMCIHelpers.java Wed Nov 09 10:04:43 2016 -0800
@@ -25,17 +25,29 @@
import jdk.vm.ci.code.CompilationRequest;
import jdk.vm.ci.code.CompilationRequestResult;
-import jdk.vm.ci.hotspot.services.HotSpotVMEventListener;
+import jdk.vm.ci.hotspot.HotSpotVMEventListener;
+import jdk.vm.ci.services.JVMCIServiceLocator;
import jdk.vm.ci.runtime.JVMCICompiler;
import jdk.vm.ci.runtime.JVMCIRuntime;
-import jdk.vm.ci.runtime.services.JVMCICompilerFactory;
+import jdk.vm.ci.runtime.JVMCICompilerFactory;
/*
* A stub classes to be able to use jvmci
*/
-public class JVMCIHelpers {
+public class JVMCIHelpers extends JVMCIServiceLocator {
- public static class EmptyVMEventListener extends HotSpotVMEventListener {
+ @Override
+ public <S> S getProvider(Class<S> service) {
+ if (service == JVMCICompilerFactory.class) {
+ return service.cast(new EmptyCompilerFactory());
+ }
+ if (service == HotSpotVMEventListener.class) {
+ return service.cast(new EmptyVMEventListener());
+ }
+ return null;
+ }
+
+ public static class EmptyVMEventListener implements HotSpotVMEventListener {
// just empty, using default interface methods
}
@@ -54,7 +66,7 @@
}
}
- public static class EmptyCompilerFactory extends JVMCICompilerFactory {
+ public static class EmptyCompilerFactory implements JVMCICompilerFactory {
@Override
public String getCompilerName() {
--- a/hotspot/test/compiler/jvmci/common/services/jdk.vm.ci.hotspot.services.HotSpotVMEventListener Wed Nov 09 15:20:30 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-compiler.jvmci.common.JVMCIHelpers$EmptyVMEventListener
--- a/hotspot/test/compiler/jvmci/common/services/jdk.vm.ci.runtime.JVMCICompiler Wed Nov 09 15:20:30 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-compiler.jvmci.common.JVMCIHelpers$EmptyHotspotCompiler
--- a/hotspot/test/compiler/jvmci/common/services/jdk.vm.ci.runtime.services.JVMCICompilerFactory Wed Nov 09 15:20:30 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-compiler.jvmci.common.JVMCIHelpers$EmptyCompilerFactory
--- a/hotspot/test/compiler/jvmci/common/testcases/TestCase.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/jvmci/common/testcases/TestCase.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
package compiler.jvmci.common.testcases;
--- a/hotspot/test/compiler/jvmci/compilerToVM/AllocateCompileIdTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/jvmci/compilerToVM/AllocateCompileIdTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,8 +19,8 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
+
/**
* @test
* @bug 8136421
--- a/hotspot/test/compiler/jvmci/compilerToVM/CanInlineMethodTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/jvmci/compilerToVM/CanInlineMethodTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/jvmci/compilerToVM/CompileCodeTestCase.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/jvmci/compilerToVM/CompileCodeTestCase.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
package compiler.jvmci.compilerToVM;
--- a/hotspot/test/compiler/jvmci/compilerToVM/ConstantPoolTestCase.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/jvmci/compilerToVM/ConstantPoolTestCase.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
package compiler.jvmci.compilerToVM;
--- a/hotspot/test/compiler/jvmci/compilerToVM/ConstantPoolTestsHelper.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/jvmci/compilerToVM/ConstantPoolTestsHelper.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,8 +19,8 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
+
package compiler.jvmci.compilerToVM;
import compiler.jvmci.common.testcases.MultipleAbstractImplementer;
--- a/hotspot/test/compiler/jvmci/compilerToVM/DisassembleCodeBlobTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/jvmci/compilerToVM/DisassembleCodeBlobTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/*
--- a/hotspot/test/compiler/jvmci/compilerToVM/DoNotInlineOrCompileTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/jvmci/compilerToVM/DoNotInlineOrCompileTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/jvmci/compilerToVM/DummyAbstractClass.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/jvmci/compilerToVM/DummyAbstractClass.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
package compiler.jvmci.compilerToVM;
--- a/hotspot/test/compiler/jvmci/compilerToVM/DummyClass.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/jvmci/compilerToVM/DummyClass.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
package compiler.jvmci.compilerToVM;
--- a/hotspot/test/compiler/jvmci/compilerToVM/DummyInterface.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/jvmci/compilerToVM/DummyInterface.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
package compiler.jvmci.compilerToVM;
--- a/hotspot/test/compiler/jvmci/compilerToVM/GetBytecodeTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/jvmci/compilerToVM/GetBytecodeTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/jvmci/compilerToVM/GetConstantPoolTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/jvmci/compilerToVM/GetConstantPoolTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/*
--- a/hotspot/test/compiler/jvmci/compilerToVM/GetExceptionTableTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/jvmci/compilerToVM/GetExceptionTableTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/jvmci/compilerToVM/GetLineNumberTableTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/jvmci/compilerToVM/GetLineNumberTableTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/jvmci/compilerToVM/GetLocalVariableTableTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/jvmci/compilerToVM/GetLocalVariableTableTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/jvmci/compilerToVM/GetStackTraceElementTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/jvmci/compilerToVM/GetStackTraceElementTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/jvmci/compilerToVM/HasCompiledCodeForOSRTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/jvmci/compilerToVM/HasCompiledCodeForOSRTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/jvmci/compilerToVM/InvalidateInstalledCodeTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/jvmci/compilerToVM/InvalidateInstalledCodeTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/*
--- a/hotspot/test/compiler/jvmci/compilerToVM/JVM_RegisterJVMCINatives.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/jvmci/compilerToVM/JVM_RegisterJVMCINatives.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/*
--- a/hotspot/test/compiler/jvmci/compilerToVM/LookupKlassInPoolTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/jvmci/compilerToVM/LookupKlassInPoolTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/*
--- a/hotspot/test/compiler/jvmci/compilerToVM/LookupKlassRefIndexInPoolTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/jvmci/compilerToVM/LookupKlassRefIndexInPoolTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/*
--- a/hotspot/test/compiler/jvmci/compilerToVM/LookupMethodInPoolTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/jvmci/compilerToVM/LookupMethodInPoolTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/*
--- a/hotspot/test/compiler/jvmci/compilerToVM/LookupNameAndTypeRefIndexInPoolTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/jvmci/compilerToVM/LookupNameAndTypeRefIndexInPoolTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/*
--- a/hotspot/test/compiler/jvmci/compilerToVM/LookupNameInPoolTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/jvmci/compilerToVM/LookupNameInPoolTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/*
--- a/hotspot/test/compiler/jvmci/compilerToVM/LookupSignatureInPoolTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/jvmci/compilerToVM/LookupSignatureInPoolTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/*
--- a/hotspot/test/compiler/jvmci/compilerToVM/MethodIsIgnoredBySecurityStackWalkTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/jvmci/compilerToVM/MethodIsIgnoredBySecurityStackWalkTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/jvmci/compilerToVM/ReprofileTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/jvmci/compilerToVM/ReprofileTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/jvmci/compilerToVM/ResolveConstantInPoolTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/jvmci/compilerToVM/ResolveConstantInPoolTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/*
--- a/hotspot/test/compiler/jvmci/compilerToVM/ResolveFieldInPoolTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/jvmci/compilerToVM/ResolveFieldInPoolTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/*
--- a/hotspot/test/compiler/jvmci/compilerToVM/ResolvePossiblyCachedConstantInPoolTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/jvmci/compilerToVM/ResolvePossiblyCachedConstantInPoolTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/*
--- a/hotspot/test/compiler/jvmci/compilerToVM/ResolveTypeInPoolTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/jvmci/compilerToVM/ResolveTypeInPoolTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/*
--- a/hotspot/test/compiler/jvmci/compilerToVM/ShouldInlineMethodTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/jvmci/compilerToVM/ShouldInlineMethodTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/jvmci/events/JvmciNotifyBootstrapFinishedEventTest.config Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/jvmci/events/JvmciNotifyBootstrapFinishedEventTest.config Wed Nov 09 10:04:43 2016 -0800
@@ -1,1 +1,2 @@
compiler.jvmci.events.JvmciNotifyBootstrapFinishedEventTest
+compiler.jvmci.common.JVMCIHelpers
--- a/hotspot/test/compiler/jvmci/events/JvmciNotifyBootstrapFinishedEventTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/jvmci/events/JvmciNotifyBootstrapFinishedEventTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -37,9 +37,8 @@
*
* @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper
* @build compiler.jvmci.common.JVMCIHelpers
- * @run driver jdk.test.lib.FileInstaller ../common/services/ ./META-INF/services/
* @run driver jdk.test.lib.FileInstaller ./JvmciNotifyBootstrapFinishedEventTest.config
- * ./META-INF/services/jdk.vm.ci.hotspot.services.HotSpotVMEventListener
+ * ./META-INF/services/jdk.vm.ci.services.JVMCIServiceLocator
* @run driver ClassFileInstaller
* compiler.jvmci.common.JVMCIHelpers$EmptyHotspotCompiler
* compiler.jvmci.common.JVMCIHelpers$EmptyCompilerFactory
@@ -60,9 +59,10 @@
package compiler.jvmci.events;
import jdk.test.lib.Asserts;
-import jdk.vm.ci.hotspot.services.HotSpotVMEventListener;
+import jdk.vm.ci.services.JVMCIServiceLocator;
+import jdk.vm.ci.hotspot.HotSpotVMEventListener;
-public class JvmciNotifyBootstrapFinishedEventTest extends HotSpotVMEventListener {
+public class JvmciNotifyBootstrapFinishedEventTest extends JVMCIServiceLocator implements HotSpotVMEventListener {
private static final boolean BOOTSTRAP = Boolean
.getBoolean("compiler.jvmci.events.JvmciNotifyBootstrapFinishedEventTest.bootstrap");
private static volatile int gotBoostrapNotification = 0;
@@ -76,6 +76,14 @@
}
@Override
+ public <S> S getProvider(Class<S> service) {
+ if (service == HotSpotVMEventListener.class) {
+ return service.cast(this);
+ }
+ return null;
+ }
+
+ @Override
public void notifyBootstrapFinished() {
gotBoostrapNotification++;
}
--- a/hotspot/test/compiler/jvmci/events/JvmciNotifyInstallEventTest.config Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/jvmci/events/JvmciNotifyInstallEventTest.config Wed Nov 09 10:04:43 2016 -0800
@@ -1,1 +1,2 @@
compiler.jvmci.events.JvmciNotifyInstallEventTest
+compiler.jvmci.common.JVMCIHelpers
--- a/hotspot/test/compiler/jvmci/events/JvmciNotifyInstallEventTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/jvmci/events/JvmciNotifyInstallEventTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -38,9 +38,8 @@
*
* @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper
* @build compiler.jvmci.common.JVMCIHelpers
- * @run driver jdk.test.lib.FileInstaller ../common/services/ ./META-INF/services/
* @run driver jdk.test.lib.FileInstaller ./JvmciNotifyInstallEventTest.config
- * ./META-INF/services/jdk.vm.ci.hotspot.services.HotSpotVMEventListener
+ * ./META-INF/services/jdk.vm.ci.services.JVMCIServiceLocator
* @run driver ClassFileInstaller
* compiler.jvmci.common.JVMCIHelpers$EmptyHotspotCompiler
* compiler.jvmci.common.JVMCIHelpers$EmptyCompilerFactory
@@ -73,6 +72,7 @@
import compiler.jvmci.common.testcases.SimpleClass;
import jdk.test.lib.Asserts;
import jdk.test.lib.Utils;
+import jdk.vm.ci.services.JVMCIServiceLocator;
import jdk.vm.ci.code.CompiledCode;
import jdk.vm.ci.code.InstalledCode;
import jdk.vm.ci.code.site.DataPatch;
@@ -82,13 +82,13 @@
import jdk.vm.ci.hotspot.HotSpotCompiledCode.Comment;
import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime;
import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod;
-import jdk.vm.ci.hotspot.services.HotSpotVMEventListener;
+import jdk.vm.ci.hotspot.HotSpotVMEventListener;
import jdk.vm.ci.meta.Assumptions.Assumption;
import jdk.vm.ci.meta.ResolvedJavaMethod;
import java.lang.reflect.Method;
-public class JvmciNotifyInstallEventTest extends HotSpotVMEventListener {
+public class JvmciNotifyInstallEventTest extends JVMCIServiceLocator implements HotSpotVMEventListener {
private static final String METHOD_NAME = "testMethod";
private static final boolean FAIL_ON_INIT = !Boolean.getBoolean(
"compiler.jvmci.events.JvmciNotifyInstallEventTest.failoninit");
@@ -98,6 +98,14 @@
new JvmciNotifyInstallEventTest().runTest();
}
+ @Override
+ public <S> S getProvider(Class<S> service) {
+ if (service == HotSpotVMEventListener.class) {
+ return service.cast(this);
+ }
+ return null;
+ }
+
private void runTest() {
if (gotInstallNotification != 0) {
throw new Error("Got install notification before test actions");
--- a/hotspot/test/compiler/jvmci/events/JvmciShutdownEventListener.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/jvmci/events/JvmciShutdownEventListener.java Wed Nov 09 10:04:43 2016 -0800
@@ -23,10 +23,11 @@
package compiler.jvmci.events;
+import jdk.vm.ci.services.JVMCIServiceLocator;
import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime;
-import jdk.vm.ci.hotspot.services.HotSpotVMEventListener;
+import jdk.vm.ci.hotspot.HotSpotVMEventListener;
-public class JvmciShutdownEventListener extends HotSpotVMEventListener {
+public class JvmciShutdownEventListener extends JVMCIServiceLocator implements HotSpotVMEventListener {
public static final String MESSAGE = "Shutdown notified";
public static final String GOT_INTERNAL_ERROR = "Got internal error";
@@ -39,6 +40,14 @@
}
@Override
+ public <S> S getProvider(Class<S> service) {
+ if (service == HotSpotVMEventListener.class) {
+ return service.cast(this);
+ }
+ return null;
+ }
+
+ @Override
public void notifyShutdown() {
System.out.println(MESSAGE);
}
--- a/hotspot/test/compiler/jvmci/events/JvmciShutdownEventTest.config Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/jvmci/events/JvmciShutdownEventTest.config Wed Nov 09 10:04:43 2016 -0800
@@ -1,1 +1,2 @@
compiler.jvmci.events.JvmciShutdownEventListener
+compiler.jvmci.common.JVMCIHelpers
--- a/hotspot/test/compiler/jvmci/events/JvmciShutdownEventTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/jvmci/events/JvmciShutdownEventTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -34,9 +34,8 @@
*
* @build compiler.jvmci.common.JVMCIHelpers
* compiler.jvmci.events.JvmciShutdownEventListener
- * @run driver jdk.test.lib.FileInstaller ../common/services/ ./META-INF/services/
* @run driver jdk.test.lib.FileInstaller ./JvmciShutdownEventTest.config
- * ./META-INF/services/jdk.vm.ci.hotspot.services.HotSpotVMEventListener
+ * ./META-INF/services/jdk.vm.ci.services.JVMCIServiceLocator
* @run driver ClassFileInstaller
* compiler.jvmci.common.JVMCIHelpers$EmptyHotspotCompiler
* compiler.jvmci.common.JVMCIHelpers$EmptyCompilerFactory
--- a/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/libNativeCallTest.c Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/libNativeCallTest.c Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
#include <stdio.h>
--- a/hotspot/test/compiler/linkage/LinkageErrors.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/linkage/LinkageErrors.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,8 +19,8 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
+
/*
* @test
* @bug 8132879
--- a/hotspot/test/compiler/loopopts/BadPredicateAfterPartialPeel.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/loopopts/BadPredicateAfterPartialPeel.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/loopopts/ConstFPVectorization.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/loopopts/ConstFPVectorization.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/loopopts/CountedLoopProblem.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/loopopts/CountedLoopProblem.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/loopopts/Test6659207.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/loopopts/Test6659207.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/*
--- a/hotspot/test/compiler/loopopts/Test7044738.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/loopopts/Test7044738.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/loopopts/Test7052494.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/loopopts/Test7052494.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/loopopts/TestArraysFillDeadControl.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/loopopts/TestArraysFillDeadControl.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/loopopts/TestCastIINoLoopLimitCheck.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/loopopts/TestCastIINoLoopLimitCheck.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/loopopts/TestDeadBackbranchArrayAccess.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/loopopts/TestDeadBackbranchArrayAccess.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/loopopts/TestImpossibleIV.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2016 Google, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8166742
+ * @summary C2 IV elimination throws FPE
+ * @run main/othervm -XX:-TieredCompilation -XX:-BackgroundCompilation TestImpossibleIV
+ * @author Chuck Rasbold rasbold@google.com
+ */
+
+/*
+ * Use -XX:-TieredCompilation to get C2 only.
+ * Use -XX:-BackgroundCompilation to wait for compilation before test exit.
+ */
+
+public class TestImpossibleIV {
+
+ static private void testMethod() {
+ int sum = 0;
+ // A unit count-down loop which has an induction variable with
+ // MIN_VALUE stride.
+ for (int i = 100000; i >= 0; i--) {
+ sum += Integer.MIN_VALUE;
+ }
+ }
+
+ public static void main(String[] args) {
+ testMethod();
+ }
+}
--- a/hotspot/test/compiler/loopopts/TestMoveStoresOutOfLoops.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/loopopts/TestMoveStoresOutOfLoops.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/loopopts/TestPredicateLostDependency.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/loopopts/TestPredicateLostDependency.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/loopopts/TestSplitIfBlocksDisabled.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/loopopts/TestSplitIfBlocksDisabled.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/loopopts/TestSplitIfUnswitchedLoopsEliminated.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/loopopts/TestSplitIfUnswitchedLoopsEliminated.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/loopopts/UseCountedLoopSafepoints.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/loopopts/UseCountedLoopSafepoints.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
package compiler.loopopts;
--- a/hotspot/test/compiler/loopopts/superword/ProdRed_Double.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/loopopts/superword/ProdRed_Double.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/loopopts/superword/ProdRed_Float.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/loopopts/superword/ProdRed_Float.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/loopopts/superword/ProdRed_Int.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/loopopts/superword/ProdRed_Int.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/loopopts/superword/ReductionPerf.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/loopopts/superword/ReductionPerf.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/loopopts/superword/SumRedAbsNeg_Double.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/loopopts/superword/SumRedAbsNeg_Double.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/loopopts/superword/SumRedAbsNeg_Float.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/loopopts/superword/SumRedAbsNeg_Float.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/loopopts/superword/SumRedSqrt_Double.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/loopopts/superword/SumRedSqrt_Double.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/loopopts/superword/SumRed_Double.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/loopopts/superword/SumRed_Double.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/loopopts/superword/SumRed_Float.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/loopopts/superword/SumRed_Float.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/loopopts/superword/SumRed_Int.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/loopopts/superword/SumRed_Int.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/loopopts/superword/SumRed_Long.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/loopopts/superword/SumRed_Long.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/loopopts/superword/TestVectorizationWithInvariant.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/loopopts/superword/TestVectorizationWithInvariant.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/memoryinitialization/ZeroTLABTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/memoryinitialization/ZeroTLABTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/*
--- a/hotspot/test/compiler/rangechecks/PowerOf2SizedArraysChecks.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/rangechecks/PowerOf2SizedArraysChecks.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/rangechecks/TestRangeCheckEliminationDisabled.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/rangechecks/TestRangeCheckEliminationDisabled.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/rangechecks/TestRangeCheckExceptionHandlerLoopMain.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/rangechecks/TestRangeCheckExceptionHandlerLoopMain.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/*
--- a/hotspot/test/compiler/regalloc/TestVectorRegAlloc.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/regalloc/TestVectorRegAlloc.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/rtm/cli/RTMGenericCommandLineOptionTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/rtm/cli/RTMGenericCommandLineOptionTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
package compiler.rtm.cli;
--- a/hotspot/test/compiler/rtm/cli/RTMLockingAwareTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/rtm/cli/RTMLockingAwareTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
package compiler.rtm.cli;
--- a/hotspot/test/compiler/rtm/cli/TestPrintPreciseRTMLockingStatisticsBase.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/rtm/cli/TestPrintPreciseRTMLockingStatisticsBase.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
package compiler.rtm.cli;
--- a/hotspot/test/compiler/rtm/cli/TestPrintPreciseRTMLockingStatisticsOptionOnSupportedConfig.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/rtm/cli/TestPrintPreciseRTMLockingStatisticsOptionOnSupportedConfig.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/rtm/cli/TestPrintPreciseRTMLockingStatisticsOptionOnUnsupportedConfig.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/rtm/cli/TestPrintPreciseRTMLockingStatisticsOptionOnUnsupportedConfig.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/rtm/cli/TestRTMAbortRatioOptionOnSupportedConfig.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/rtm/cli/TestRTMAbortRatioOptionOnSupportedConfig.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/rtm/cli/TestRTMAbortRatioOptionOnUnsupportedConfig.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/rtm/cli/TestRTMAbortRatioOptionOnUnsupportedConfig.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/rtm/cli/TestRTMAbortThresholdOption.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/rtm/cli/TestRTMAbortThresholdOption.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/rtm/cli/TestRTMLockingCalculationDelayOption.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/rtm/cli/TestRTMLockingCalculationDelayOption.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/rtm/cli/TestRTMLockingThresholdOption.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/rtm/cli/TestRTMLockingThresholdOption.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/rtm/cli/TestRTMRetryCountOption.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/rtm/cli/TestRTMRetryCountOption.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/rtm/cli/TestRTMSpinLoopCountOption.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/rtm/cli/TestRTMSpinLoopCountOption.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/rtm/cli/TestRTMTotalCountIncrRateOptionOnSupportedConfig.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/rtm/cli/TestRTMTotalCountIncrRateOptionOnSupportedConfig.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/rtm/cli/TestRTMTotalCountIncrRateOptionOnUnsupportedConfig.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/rtm/cli/TestRTMTotalCountIncrRateOptionOnUnsupportedConfig.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/rtm/cli/TestUseRTMDeoptOptionOnSupportedConfig.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/rtm/cli/TestUseRTMDeoptOptionOnSupportedConfig.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/rtm/cli/TestUseRTMDeoptOptionOnUnsupportedConfig.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/rtm/cli/TestUseRTMDeoptOptionOnUnsupportedConfig.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/rtm/cli/TestUseRTMForStackLocksOptionOnSupportedConfig.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/rtm/cli/TestUseRTMForStackLocksOptionOnSupportedConfig.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/rtm/cli/TestUseRTMForStackLocksOptionOnUnsupportedConfig.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/rtm/cli/TestUseRTMForStackLocksOptionOnUnsupportedConfig.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/rtm/cli/TestUseRTMLockingOptionOnSupportedConfig.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/rtm/cli/TestUseRTMLockingOptionOnSupportedConfig.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/rtm/cli/TestUseRTMLockingOptionOnUnsupportedCPU.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/rtm/cli/TestUseRTMLockingOptionOnUnsupportedCPU.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/rtm/cli/TestUseRTMLockingOptionOnUnsupportedVM.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/rtm/cli/TestUseRTMLockingOptionOnUnsupportedVM.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/rtm/cli/TestUseRTMLockingOptionWithBiasedLocking.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/rtm/cli/TestUseRTMLockingOptionWithBiasedLocking.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/rtm/cli/TestUseRTMXendForLockBusyOption.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/rtm/cli/TestUseRTMXendForLockBusyOption.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/rtm/locking/TestRTMAbortRatio.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/rtm/locking/TestRTMAbortRatio.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/rtm/locking/TestRTMAbortThreshold.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/rtm/locking/TestRTMAbortThreshold.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/rtm/locking/TestRTMAfterNonRTMDeopt.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/rtm/locking/TestRTMAfterNonRTMDeopt.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/rtm/locking/TestRTMDeoptOnHighAbortRatio.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/rtm/locking/TestRTMDeoptOnHighAbortRatio.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/rtm/locking/TestRTMDeoptOnLowAbortRatio.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/rtm/locking/TestRTMDeoptOnLowAbortRatio.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/rtm/locking/TestRTMLockingCalculationDelay.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/rtm/locking/TestRTMLockingCalculationDelay.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/rtm/locking/TestRTMLockingThreshold.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/rtm/locking/TestRTMLockingThreshold.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/rtm/locking/TestRTMRetryCount.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/rtm/locking/TestRTMRetryCount.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/rtm/locking/TestRTMSpinLoopCount.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/rtm/locking/TestRTMSpinLoopCount.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/rtm/locking/TestRTMTotalCountIncrRate.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/rtm/locking/TestRTMTotalCountIncrRate.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/rtm/locking/TestUseRTMAfterLockInflation.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/rtm/locking/TestUseRTMAfterLockInflation.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/rtm/locking/TestUseRTMDeopt.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/rtm/locking/TestUseRTMDeopt.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/rtm/locking/TestUseRTMForInflatedLocks.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/rtm/locking/TestUseRTMForInflatedLocks.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/rtm/locking/TestUseRTMForStackLocks.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/rtm/locking/TestUseRTMForStackLocks.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/rtm/locking/TestUseRTMXendForLockBusy.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/rtm/locking/TestUseRTMXendForLockBusy.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/rtm/method_options/TestNoRTMLockElidingOption.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/rtm/method_options/TestNoRTMLockElidingOption.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/rtm/method_options/TestUseRTMLockElidingOption.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/rtm/method_options/TestUseRTMLockElidingOption.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/rtm/print/TestPrintPreciseRTMLockingStatistics.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/rtm/print/TestPrintPreciseRTMLockingStatistics.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/runtime/StackOverflowBug.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/runtime/StackOverflowBug.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/runtime/Test6778657.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/runtime/Test6778657.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/*
--- a/hotspot/test/compiler/runtime/Test6826736.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/runtime/Test6826736.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/runtime/Test6859338.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/runtime/Test6859338.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/runtime/Test6892265.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/runtime/Test6892265.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/runtime/Test7088020.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/runtime/Test7088020.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/runtime/Test7196199.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/runtime/Test7196199.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/runtime/cr6891750/Test6891750.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/runtime/cr6891750/Test6891750.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/runtime/safepoints/TestRegisterRestoring.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/runtime/safepoints/TestRegisterRestoring.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,10 +19,8 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
-
/**
* @test
* @bug 8148490
--- a/hotspot/test/compiler/stable/TestStableMismatched.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/stable/TestStableMismatched.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/*
--- a/hotspot/test/compiler/testlibrary/rtm/AbortProvoker.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/testlibrary/rtm/AbortProvoker.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
package compiler.testlibrary.rtm;
--- a/hotspot/test/compiler/testlibrary/rtm/AbortType.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/testlibrary/rtm/AbortType.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
package compiler.testlibrary.rtm;
--- a/hotspot/test/compiler/testlibrary/rtm/BufferOverflowProvoker.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/testlibrary/rtm/BufferOverflowProvoker.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
package compiler.testlibrary.rtm;
--- a/hotspot/test/compiler/testlibrary/rtm/BusyLock.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/testlibrary/rtm/BusyLock.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
package compiler.testlibrary.rtm;
--- a/hotspot/test/compiler/testlibrary/rtm/CompilableTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/testlibrary/rtm/CompilableTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
package compiler.testlibrary.rtm;
--- a/hotspot/test/compiler/testlibrary/rtm/MemoryConflictProvoker.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/testlibrary/rtm/MemoryConflictProvoker.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
package compiler.testlibrary.rtm;
--- a/hotspot/test/compiler/testlibrary/rtm/NestedAbortProvoker.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/testlibrary/rtm/NestedAbortProvoker.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
package compiler.testlibrary.rtm;
--- a/hotspot/test/compiler/testlibrary/rtm/RTMLockingStatistics.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/testlibrary/rtm/RTMLockingStatistics.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
package compiler.testlibrary.rtm;
--- a/hotspot/test/compiler/testlibrary/rtm/RTMTestBase.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/testlibrary/rtm/RTMTestBase.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
package compiler.testlibrary.rtm;
--- a/hotspot/test/compiler/testlibrary/rtm/XAbortProvoker.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/testlibrary/rtm/XAbortProvoker.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
package compiler.testlibrary.rtm;
--- a/hotspot/test/compiler/testlibrary/rtm/predicate/SupportedCPU.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/testlibrary/rtm/predicate/SupportedCPU.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
package compiler.testlibrary.rtm.predicate;
--- a/hotspot/test/compiler/testlibrary/rtm/predicate/SupportedVM.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/testlibrary/rtm/predicate/SupportedVM.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
package compiler.testlibrary.rtm.predicate;
--- a/hotspot/test/compiler/types/TestPhiElimination.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/types/TestPhiElimination.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/uncommontrap/UncommonTrapStackBang.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/uncommontrap/UncommonTrapStackBang.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/**
--- a/hotspot/test/compiler/whitebox/AllocationCodeBlobTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/whitebox/AllocationCodeBlobTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/*
--- a/hotspot/test/compiler/whitebox/ForceNMethodSweepTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/whitebox/ForceNMethodSweepTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/*
--- a/hotspot/test/compiler/whitebox/GetCodeHeapEntriesTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/whitebox/GetCodeHeapEntriesTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/*
--- a/hotspot/test/compiler/whitebox/GetNMethodTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/compiler/whitebox/GetNMethodTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/*
--- a/hotspot/test/gc/TestCardTablePageCommits.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/gc/TestCardTablePageCommits.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,25 +1,25 @@
/*
-* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
import jdk.test.lib.JDKToolFinder;
import jdk.test.lib.process.ProcessTools;
--- a/hotspot/test/gc/TestHumongousReferenceObject.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/gc/TestHumongousReferenceObject.java Wed Nov 09 10:04:43 2016 -0800
@@ -3,16 +3,16 @@
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General License version 2 only, as
+ * under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General License
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
- * You should have received a copy of the GNU General License version
+ * You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
--- a/hotspot/test/gc/TestSystemGC.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/gc/TestSystemGC.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,25 +1,25 @@
/*
-* Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
/*
* @test TestSystemGC
--- a/hotspot/test/gc/arguments/AllocationHelper.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/gc/arguments/AllocationHelper.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,25 +1,25 @@
/*
-* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
import java.util.LinkedList;
import java.util.concurrent.Callable;
--- a/hotspot/test/gc/arguments/FlagsValue.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/gc/arguments/FlagsValue.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,25 +1,25 @@
/*
-* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
import java.util.regex.*;
--- a/hotspot/test/gc/arguments/GCTypes.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/gc/arguments/GCTypes.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,25 +1,25 @@
/*
-* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
import java.lang.management.GarbageCollectorMXBean;
import java.lang.management.ManagementFactory;
--- a/hotspot/test/gc/arguments/HeapRegionUsageTool.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/gc/arguments/HeapRegionUsageTool.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,25 +1,25 @@
/*
-* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
import java.lang.management.ManagementFactory;
import java.lang.management.MemoryPoolMXBean;
--- a/hotspot/test/gc/arguments/TestCMSHeapSizeFlags.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/gc/arguments/TestCMSHeapSizeFlags.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,25 +1,25 @@
/*
-* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
/*
* @test TestCMSHeapSizeFlags
--- a/hotspot/test/gc/arguments/TestG1ConcMarkStepDurationMillis.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/gc/arguments/TestG1ConcMarkStepDurationMillis.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,25 +1,25 @@
/*
-* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
/*
* @test TestG1ConcMarkStepDurationMillis
--- a/hotspot/test/gc/arguments/TestG1ConcRefinementThreads.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/gc/arguments/TestG1ConcRefinementThreads.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,25 +1,25 @@
/*
-* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
/*
* @test TestG1ConcRefinementThreads
--- a/hotspot/test/gc/arguments/TestG1HeapRegionSize.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/gc/arguments/TestG1HeapRegionSize.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,25 +1,25 @@
/*
-* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
/*
* @test TestG1HeapRegionSize
--- a/hotspot/test/gc/arguments/TestG1HeapSizeFlags.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/gc/arguments/TestG1HeapSizeFlags.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,25 +1,25 @@
/*
-* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
/*
* @test TestG1HeapSizeFlags
--- a/hotspot/test/gc/arguments/TestG1PercentageOptions.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/gc/arguments/TestG1PercentageOptions.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,25 +1,25 @@
/*
-* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
/*
* @test TestG1PercentageOptions
--- a/hotspot/test/gc/arguments/TestInitialTenuringThreshold.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/gc/arguments/TestInitialTenuringThreshold.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,25 +1,25 @@
/*
-* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
/*
* @test TestInitialTenuringThreshold
--- a/hotspot/test/gc/arguments/TestMaxHeapSizeTools.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/gc/arguments/TestMaxHeapSizeTools.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,25 +1,25 @@
/*
-* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
import java.util.regex.Matcher;
import java.util.regex.Pattern;
--- a/hotspot/test/gc/arguments/TestMaxMinHeapFreeRatioFlags.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/gc/arguments/TestMaxMinHeapFreeRatioFlags.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,25 +1,25 @@
/*
-* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
/*
* @test TestMaxMinHeapFreeRatioFlags
--- a/hotspot/test/gc/arguments/TestMaxNewSize.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/gc/arguments/TestMaxNewSize.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,25 +1,25 @@
/*
-* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
/*
* @test TestMaxNewSize
--- a/hotspot/test/gc/arguments/TestMinAndInitialSurvivorRatioFlags.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/gc/arguments/TestMinAndInitialSurvivorRatioFlags.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,25 +1,25 @@
/*
-* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
/*
* @test TestMinAndInitialSurvivorRatioFlags
--- a/hotspot/test/gc/arguments/TestMinInitialErgonomics.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/gc/arguments/TestMinInitialErgonomics.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,25 +1,25 @@
/*
-* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
/**
* @test TestMinInitialErgonomics
--- a/hotspot/test/gc/arguments/TestNewRatioFlag.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/gc/arguments/TestNewRatioFlag.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,25 +1,25 @@
/*
-* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
/*
* @test TestNewRatioFlag
--- a/hotspot/test/gc/arguments/TestNewSizeThreadIncrease.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/gc/arguments/TestNewSizeThreadIncrease.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,25 +1,25 @@
/*
-* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
/*
* @test TestNewSizeThreadIncrease
--- a/hotspot/test/gc/arguments/TestObjectTenuringFlags.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/gc/arguments/TestObjectTenuringFlags.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,25 +1,25 @@
/*
-* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
/*
* @test TestObjectTenuringFlags
--- a/hotspot/test/gc/arguments/TestParallelGCThreads.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/gc/arguments/TestParallelGCThreads.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,25 +1,25 @@
/*
-* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
/*
* @test TestParallelGCThreads
--- a/hotspot/test/gc/arguments/TestParallelHeapSizeFlags.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/gc/arguments/TestParallelHeapSizeFlags.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,25 +1,25 @@
/*
-* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
/*
* @test TestParallelHeapSizeFlags
--- a/hotspot/test/gc/arguments/TestSerialHeapSizeFlags.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/gc/arguments/TestSerialHeapSizeFlags.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,25 +1,25 @@
/*
-* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
/*
* @test TestSerialHeapSizeFlags
--- a/hotspot/test/gc/arguments/TestShrinkHeapInSteps.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/gc/arguments/TestShrinkHeapInSteps.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,25 +1,25 @@
/*
-* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
/*
* @test TestShrinkHeapInSteps
--- a/hotspot/test/gc/arguments/TestSurvivorRatioFlag.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/gc/arguments/TestSurvivorRatioFlag.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,25 +1,25 @@
/*
-* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
/*
* @test TestSurvivorRatioFlag
--- a/hotspot/test/gc/arguments/TestTargetSurvivorRatioFlag.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/gc/arguments/TestTargetSurvivorRatioFlag.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,25 +1,25 @@
/*
-* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
/*
* @test TestTargetSurvivorRatioFlag
--- a/hotspot/test/gc/arguments/TestUnrecognizedVMOptionsHandling.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/gc/arguments/TestUnrecognizedVMOptionsHandling.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,25 +1,25 @@
/*
-* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
/*
* @test TestUnrecognizedVMOptionsHandling
--- a/hotspot/test/gc/arguments/TestUseCompressedOopsErgo.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/gc/arguments/TestUseCompressedOopsErgo.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,25 +1,25 @@
/*
-* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
/*
* @test TestUseCompressedOopsErgo
--- a/hotspot/test/gc/arguments/TestUseCompressedOopsErgoTools.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/gc/arguments/TestUseCompressedOopsErgoTools.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,25 +1,25 @@
/*
-* Copyright (c) 2013, 2015,Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
import com.sun.management.HotSpotDiagnosticMXBean;
import com.sun.management.VMOption;
--- a/hotspot/test/gc/arguments/TestVerifyBeforeAndAfterGCFlags.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/gc/arguments/TestVerifyBeforeAndAfterGCFlags.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,25 +1,25 @@
/*
-* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
/*
* @test TestVerifyBeforeAndAfterGCFlags
--- a/hotspot/test/gc/cms/DisableResizePLAB.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/gc/cms/DisableResizePLAB.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,25 +1,25 @@
/*
-* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
/*
* @test DisableResizePLAB
--- a/hotspot/test/gc/cms/TestCMSScavengeBeforeRemark.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/gc/cms/TestCMSScavengeBeforeRemark.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,25 +1,25 @@
/*
-* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
/*
* @test TestCMSScavengeBeforeRemark
--- a/hotspot/test/gc/g1/humongousObjects/ClassLoaderGenerator.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/gc/g1/humongousObjects/ClassLoaderGenerator.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,8 +19,8 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
+
package gc.g1.humongousObjects;
import gc.testlibrary.Helpers;
--- a/hotspot/test/gc/g1/humongousObjects/G1SampleClass.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/gc/g1/humongousObjects/G1SampleClass.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
package gc.g1.humongousObjects;
--- a/hotspot/test/gc/g1/humongousObjects/TestHeapCounters.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/gc/g1/humongousObjects/TestHeapCounters.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
package gc.g1.humongousObjects;
--- a/hotspot/test/gc/g1/humongousObjects/TestHumongousClassLoader.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/gc/g1/humongousObjects/TestHumongousClassLoader.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
package gc.g1.humongousObjects;
--- a/hotspot/test/gc/g1/humongousObjects/TestHumongousMovement.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/gc/g1/humongousObjects/TestHumongousMovement.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
package gc.g1.humongousObjects;
--- a/hotspot/test/gc/g1/humongousObjects/TestHumongousNonArrayAllocation.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/gc/g1/humongousObjects/TestHumongousNonArrayAllocation.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
package gc.g1.humongousObjects;
--- a/hotspot/test/gc/g1/humongousObjects/TestHumongousThreshold.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/gc/g1/humongousObjects/TestHumongousThreshold.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015,2016 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
package gc.g1.humongousObjects;
--- a/hotspot/test/gc/g1/humongousObjects/TestNoAllocationsInHRegions.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/gc/g1/humongousObjects/TestNoAllocationsInHRegions.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
package gc.g1.humongousObjects;
--- a/hotspot/test/gc/g1/humongousObjects/TestObjectCollected.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/gc/g1/humongousObjects/TestObjectCollected.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
package gc.g1.humongousObjects;
--- a/hotspot/test/gc/g1/humongousObjects/objectGraphTest/GC.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/gc/g1/humongousObjects/objectGraphTest/GC.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
package gc.g1.humongousObjects.objectGraphTest;
--- a/hotspot/test/gc/g1/humongousObjects/objectGraphTest/GCTokens.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/gc/g1/humongousObjects/objectGraphTest/GCTokens.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
package gc.g1.humongousObjects.objectGraphTest;
--- a/hotspot/test/gc/g1/humongousObjects/objectGraphTest/ObjectGraph.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/gc/g1/humongousObjects/objectGraphTest/ObjectGraph.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
package gc.g1.humongousObjects.objectGraphTest;
--- a/hotspot/test/gc/g1/humongousObjects/objectGraphTest/ReferenceInfo.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/gc/g1/humongousObjects/objectGraphTest/ReferenceInfo.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
package gc.g1.humongousObjects.objectGraphTest;
--- a/hotspot/test/gc/g1/humongousObjects/objectGraphTest/TestObjectGraphAfterGC.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/gc/g1/humongousObjects/objectGraphTest/TestObjectGraphAfterGC.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
package gc.g1.humongousObjects.objectGraphTest;
--- a/hotspot/test/gc/g1/humongousObjects/objectGraphTest/TestcaseData.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/gc/g1/humongousObjects/objectGraphTest/TestcaseData.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
package gc.g1.humongousObjects.objectGraphTest;
--- a/hotspot/test/gc/logging/TestPrintReferences.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/gc/logging/TestPrintReferences.java Wed Nov 09 10:04:43 2016 -0800
@@ -41,7 +41,7 @@
OutputAnalyzer output = new OutputAnalyzer(pb_enabled.start());
String countRegex = "[0-9]+ refs";
- String timeRegex = "\\([0-9]+[.,][0-9]+s, [0-9]+[.,][0-9]+s\\) [0-9]+[.,][0-9]+ms";
+ String timeRegex = "[0-9]+[.,][0-9]+ms";
output.shouldMatch(".* GC\\([0-9]+\\) SoftReference " + timeRegex + "\n" +
".* GC\\([0-9]+\\) WeakReference " + timeRegex + "\n" +
--- a/hotspot/test/gc/logging/TestUnifiedLoggingSwitchStress.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/gc/logging/TestUnifiedLoggingSwitchStress.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
package gc.logging;
--- a/hotspot/test/gc/startup_warnings/TestCMS.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/gc/startup_warnings/TestCMS.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,31 +1,31 @@
/*
-* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
/*
* @test TestCMS
* @key gc
-* @bug 8006398
-* @summary Test that CMS does not print a warning message
+* @bug 8006398 8155948
+* @summary Test that CMS prints a warning message only for a commercial build
* @library /test/lib
* @modules java.base/jdk.internal.misc
* java.management
@@ -33,16 +33,27 @@
import jdk.test.lib.process.ProcessTools;
import jdk.test.lib.process.OutputAnalyzer;
-
+import jdk.test.lib.BuildHelper;
public class TestCMS {
- public static void main(String args[]) throws Exception {
- ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseConcMarkSweepGC", "-version");
+ public static void runTest(String[] args) throws Exception {
+ boolean isCommercial = BuildHelper.isCommercialBuild();
+ ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(args);
OutputAnalyzer output = new OutputAnalyzer(pb.start());
- output.shouldNotContain("deprecated");
+ if (isCommercial) {
+ output.shouldContain("deprecated");
+ } else {
+ output.shouldNotContain("deprecated");
+ }
output.shouldNotContain("error");
output.shouldHaveExitValue(0);
}
+ public static void main(String args[]) throws Exception {
+ runTest(new String[] {"-XX:+UseConcMarkSweepGC", "-version"});
+ runTest(new String[] {"-Xconcgc", "-version"});
+ runTest(new String[] {"-Xnoconcgc", "-version"});
+ }
+
}
--- a/hotspot/test/gc/startup_warnings/TestDefNewCMS.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/gc/startup_warnings/TestDefNewCMS.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,25 +1,25 @@
/*
-* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
/*
* @test TestDefNewCMS
--- a/hotspot/test/gc/startup_warnings/TestG1.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/gc/startup_warnings/TestG1.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,25 +1,25 @@
/*
-* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
/*
* @test TestG1
--- a/hotspot/test/gc/startup_warnings/TestParNewCMS.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/gc/startup_warnings/TestParNewCMS.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,25 +1,25 @@
/*
-* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
/*
* @test TestParNewCMS
--- a/hotspot/test/gc/startup_warnings/TestParNewSerialOld.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/gc/startup_warnings/TestParNewSerialOld.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,25 +1,25 @@
/*
-* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
/*
* @test TestParNewSerialOld
--- a/hotspot/test/gc/startup_warnings/TestParallelGC.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/gc/startup_warnings/TestParallelGC.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,25 +1,25 @@
/*
-* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
/*
* @test TestParallelGC
--- a/hotspot/test/gc/startup_warnings/TestParallelScavengeSerialOld.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/gc/startup_warnings/TestParallelScavengeSerialOld.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,25 +1,25 @@
/*
-* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
/*
* @test TestParallelScavengeSerialOld
--- a/hotspot/test/gc/startup_warnings/TestSerialGC.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/gc/startup_warnings/TestSerialGC.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,25 +1,25 @@
/*
-* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
/*
* @test TestSerialGC
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/gc/startup_warnings/TestUseAutoGCSelectPolicy.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test TestUseAutoGCSelectPolicy
+ * @key gc
+ * @bug 8166461 8167494
+ * @summary Test that UseAutoGCSelectPolicy and AutoGCSelectPauseMillis do print a warning message
+ * @library /test/lib
+ * @modules java.base/jdk.internal.misc
+ * java.management
+ */
+
+import jdk.test.lib.process.ProcessTools;
+import jdk.test.lib.process.OutputAnalyzer;
+
+public class TestUseAutoGCSelectPolicy {
+
+ public static void main(String args[]) throws Exception {
+ ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseAutoGCSelectPolicy", "-XX:AutoGCSelectPauseMillis=3000", "-version");
+ OutputAnalyzer output = new OutputAnalyzer(pb.start());
+ output.shouldContain("UseAutoGCSelectPolicy was deprecated in version 9.0");
+ output.shouldContain("AutoGCSelectPauseMillis was deprecated in version 9.0");
+ output.shouldNotContain("error");
+ output.shouldHaveExitValue(0);
+ }
+}
--- a/hotspot/test/gc/stress/TestGCOld.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/gc/stress/TestGCOld.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,25 +1,25 @@
/*
-* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
/*
* @test TestGCOld
--- a/hotspot/test/gc/testlibrary/Helpers.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/gc/testlibrary/Helpers.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
package gc.testlibrary;
--- a/hotspot/test/native/GTestWrapper.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/native/GTestWrapper.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/* @test
--- a/hotspot/test/native/classfile/test_symbolTable.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/native/classfile/test_symbolTable.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -26,7 +26,7 @@
#include "classfile/symbolTable.hpp"
#include "unittest.hpp"
-TEST(SymbolTable, temp_new_symbol) {
+TEST_VM(SymbolTable, temp_new_symbol) {
// Assert messages assume these symbols are unique, and the refcounts start at
// one, but code does not rely on this.
JavaThread* THREAD = JavaThread::current();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/native/gc/g1/test_g1BiasedArray.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#include "precompiled.hpp"
+#include "gc/g1/g1BiasedArray.hpp"
+#include "unittest.hpp"
+
+class TestMappedArray : public G1BiasedMappedArray<int> {
+public:
+ virtual int default_value() const {
+ return 0xBAADBABE;
+ }
+ int* my_address_mapped_to(HeapWord* address) {
+ return address_mapped_to(address);
+ }
+};
+
+TEST_VM(G1BiasedArray, simple) {
+ const size_t REGION_SIZE_IN_WORDS = 512;
+ const size_t NUM_REGIONS = 20;
+ // Any value that is non-zero
+ HeapWord* fake_heap =
+ (HeapWord*) LP64_ONLY(0xBAAA00000) NOT_LP64(0xBA000000);
+
+ TestMappedArray array;
+ array.initialize(fake_heap, fake_heap + REGION_SIZE_IN_WORDS * NUM_REGIONS,
+ REGION_SIZE_IN_WORDS * HeapWordSize);
+ const int DEFAULT_VALUE = array.default_value();
+
+ // Check address calculation (bounds)
+ ASSERT_EQ(fake_heap, array.bottom_address_mapped())
+ << "bottom mapped address should be "
+ << p2i(array.bottom_address_mapped())
+ << ", but is "
+ << p2i(fake_heap);
+ ASSERT_EQ(fake_heap + REGION_SIZE_IN_WORDS * NUM_REGIONS,
+ array.end_address_mapped());
+
+ int* bottom = array.my_address_mapped_to(fake_heap);
+ ASSERT_EQ((void*) bottom, (void*) array.base());
+ int* end = array.my_address_mapped_to(fake_heap +
+ REGION_SIZE_IN_WORDS * NUM_REGIONS);
+ ASSERT_EQ((void*) end, (void*) (array.base() + array.length()));
+ // The entire array should contain default value elements
+ for (int* current = bottom; current < end; current++) {
+ ASSERT_EQ(DEFAULT_VALUE, *current);
+ }
+
+ // Test setting values in the table
+ HeapWord* region_start_address =
+ fake_heap + REGION_SIZE_IN_WORDS * (NUM_REGIONS / 2);
+ HeapWord* region_end_address =
+ fake_heap + (REGION_SIZE_IN_WORDS * (NUM_REGIONS / 2) +
+ REGION_SIZE_IN_WORDS - 1);
+
+ // Set/get by address tests: invert some value; first retrieve one
+ int actual_value = array.get_by_index(NUM_REGIONS / 2);
+ array.set_by_index(NUM_REGIONS / 2, ~actual_value);
+ // Get the same value by address, should correspond to the start of the "region"
+ int value = array.get_by_address(region_start_address);
+ ASSERT_EQ(value, ~actual_value);
+ // Get the same value by address, at one HeapWord before the start
+ value = array.get_by_address(region_start_address - 1);
+ ASSERT_EQ(DEFAULT_VALUE, value);
+ // Get the same value by address, at the end of the "region"
+ value = array.get_by_address(region_end_address);
+ ASSERT_EQ(value, ~actual_value);
+ // Make sure the next value maps to another index
+ value = array.get_by_address(region_end_address + 1);
+ ASSERT_EQ(DEFAULT_VALUE, value);
+
+ // Reset the value in the array
+ array.set_by_address(region_start_address +
+ (region_end_address - region_start_address) / 2,
+ actual_value);
+
+ // The entire array should have the default value again
+ for (int* current = bottom; current < end; current++) {
+ ASSERT_EQ(DEFAULT_VALUE, *current);
+ }
+
+ // Set/get by index tests: invert some value
+ size_t index = NUM_REGIONS / 2;
+ actual_value = array.get_by_index(index);
+ array.set_by_index(index, ~actual_value);
+
+ value = array.get_by_index(index);
+ ASSERT_EQ(~actual_value, value);
+
+ value = array.get_by_index(index - 1);
+ ASSERT_EQ(DEFAULT_VALUE, value);
+
+ value = array.get_by_index(index + 1);
+ ASSERT_EQ(DEFAULT_VALUE, value);
+
+ array.set_by_index(0, 0);
+ value = array.get_by_index(0);
+ ASSERT_EQ(0, value);
+
+ array.set_by_index(array.length() - 1, 0);
+ value = array.get_by_index(array.length() - 1);
+ ASSERT_EQ(0, value);
+
+ array.set_by_index(index, 0);
+
+ // The array should have three zeros, and default values otherwise
+ size_t num_zeros = 0;
+ for (int* current = bottom; current < end; current++) {
+ ASSERT_TRUE(*current == DEFAULT_VALUE || *current == 0);
+ if (*current == 0) {
+ num_zeros++;
+ }
+ }
+ ASSERT_EQ((size_t) 3, num_zeros);
+}
+
--- a/hotspot/test/native/gtestLauncher.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/native/gtestLauncher.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
#include "prims/jni.h"
--- a/hotspot/test/native/gtestMain.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/native/gtestMain.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -34,20 +34,34 @@
extern "C" {
-static int init_jvm(int argc, char **argv, bool is_executing_death_test) {
+static bool is_prefix(const char* prefix, const char* str) {
+ return strncmp(str, prefix, strlen(prefix)) == 0;
+}
+
+static bool is_suffix(const char* suffix, const char* str) {
+ size_t suffix_len = strlen(suffix);
+ size_t str_len = strlen(str);
+ if (str_len < suffix_len) {
+ return false;
+ }
+ return strncmp(str + (str_len - suffix_len), suffix, suffix_len) == 0;
+}
+
+
+static int init_jvm(int argc, char **argv, bool disable_error_handling) {
// don't care about the program name
argc--;
argv++;
- int extra_jvm_args = is_executing_death_test ? 4 : 2;
+ int extra_jvm_args = disable_error_handling ? 4 : 2;
int num_jvm_options = argc + extra_jvm_args;
JavaVMOption* options = new JavaVMOption[num_jvm_options];
options[0].optionString = (char*) "-Dsun.java.launcher.is_altjvm=true";
options[1].optionString = (char*) "-XX:+ExecutingUnitTests";
- if (is_executing_death_test) {
- // don't create core files or hs_err files when executing death tests
+ if (disable_error_handling) {
+ // don't create core files or hs_err files executing assert tests
options[2].optionString = (char*) "-XX:+SuppressFatalErrorMessage";
options[3].optionString = (char*) "-XX:-CreateCoredumpOnCrash";
}
@@ -83,17 +97,14 @@
virtual void OnTestStart(const ::testing::TestInfo& test_info) {
const char* name = test_info.name();
- if (strstr(name, "_test_vm") != NULL && !_is_initialized) {
- ASSERT_EQ(init_jvm(_argc, _argv, false), 0) << "Could not initialize the JVM";
+ if (!_is_initialized && is_suffix("_test_vm", name)) {
+ // we want to have hs_err and core files when we execute regular tests
+ ASSERT_EQ(0, init_jvm(_argc, _argv, false)) << "Could not initialize the JVM";
_is_initialized = true;
}
}
};
-static bool is_prefix(const char* prefix, const char* str) {
- return strncmp(str, prefix, strlen(prefix)) == 0;
-}
-
static char* get_java_home_arg(int argc, char** argv) {
for (int i = 0; i < argc; i++) {
if (strncmp(argv[i], "-jdk", strlen(argv[i])) == 0) {
@@ -144,20 +155,24 @@
}
JNIEXPORT void JNICALL runUnitTests(int argc, char** argv) {
- // Must look at googletest options before initializing googletest, since
- // InitGoogleTest removes googletest options from argv.
- bool is_executing_death_test = true;
- for (int i = 0; i < argc; i++) {
- const char* death_test_flag = "--gtest_internal_run_death_test";
- if (is_prefix(death_test_flag, argv[i])) {
- is_executing_death_test = true;
+ ::testing::InitGoogleTest(&argc, argv);
+ ::testing::GTEST_FLAG(death_test_style) = "threadsafe";
+
+ bool is_vmassert_test = false;
+ bool is_othervm_test = false;
+ // death tests facility is used for both regular death tests, other vm and vmassert tests
+ if (::testing::internal::GTEST_FLAG(internal_run_death_test).length() > 0) {
+ // when we execute death test, filter value equals to test name
+ const char* test_name = ::testing::GTEST_FLAG(filter).c_str();
+ const char* const othervm_suffix = "_other_vm_test"; // TEST_OTHER_VM
+ const char* const vmassert_suffix = "_vm_assert_test"; // TEST_VM_ASSERT(_MSG)
+ if (is_suffix(othervm_suffix, test_name)) {
+ is_othervm_test = true;
+ } else if (is_suffix(vmassert_suffix, test_name)) {
+ is_vmassert_test = true;
}
}
- ::testing::InitGoogleTest(&argc, argv);
- ::testing::GTEST_FLAG(death_test_style) = "threadsafe";
-// ::testing::GTEST_FLAG(death_test_output_prefix) = "Other VM";
-
char* java_home = get_java_home_arg(argc, argv);
if (java_home == NULL) {
fprintf(stderr, "ERROR: You must specify a JDK to use for running the unit tests.\n");
@@ -184,8 +199,10 @@
#endif // _WIN32
argv = remove_test_runner_arguments(&argc, argv);
- if (is_executing_death_test) {
- if (init_jvm(argc, argv, true) != 0) {
+ if (is_vmassert_test || is_othervm_test) {
+ // both vmassert and other vm tests require inited jvm
+ // but only vmassert tests disable hs_err and core file generation
+ if (init_jvm(argc, argv, is_vmassert_test) != 0) {
abort();
}
} else {
--- a/hotspot/test/native/logging/logTestFixture.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/native/logging/logTestFixture.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -19,8 +19,8 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
+
#include "precompiled.hpp"
#include "logTestFixture.hpp"
#include "logTestUtils.inline.hpp"
--- a/hotspot/test/native/logging/logTestFixture.hpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/native/logging/logTestFixture.hpp Wed Nov 09 10:04:43 2016 -0800
@@ -19,8 +19,8 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
+
#include "unittest.hpp"
#include "utilities/globalDefinitions.hpp"
--- a/hotspot/test/native/logging/logTestUtils.inline.hpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/native/logging/logTestUtils.inline.hpp Wed Nov 09 10:04:43 2016 -0800
@@ -19,8 +19,12 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
+
+#include "logging/log.hpp"
+#include "logging/logConfiguration.hpp"
+#include "logging/logStream.hpp"
+#include "memory/resourceArea.hpp"
#include "runtime/os.hpp"
#include "unittest.hpp"
@@ -43,3 +47,74 @@
EXPECT_TRUE(ret == 0 || errno == ENOENT) << "failed to remove file '" << filename << "': "
<< os::strerror(errno) << " (" << errno << ")";
}
+
+static inline void create_directory(const char* name) {
+ assert(!file_exists(name), "can't create directory: %s already exists", name);
+ bool failed;
+#ifdef _WINDOWS
+ failed = !CreateDirectory(name, NULL);
+#else
+ failed = mkdir(name, 0777);
+#endif
+ assert(!failed, "failed to create directory %s", name);
+}
+
+static inline void init_log_file(const char* filename, const char* options = "") {
+ LogStreamHandle(Error, logging) stream;
+ bool success = LogConfiguration::parse_log_arguments(filename, "logging=trace", "", options, &stream);
+ guarantee(success, "Failed to initialize log file '%s' with options '%s'", filename, options);
+ log_debug(logging)("%s", LOG_TEST_STRING_LITERAL);
+ success = LogConfiguration::parse_log_arguments(filename, "all=off", "", "", &stream);
+ guarantee(success, "Failed to disable logging to file '%s'", filename);
+}
+
+// Read a complete line from fp and return it as a resource allocated string.
+// Returns NULL on EOF.
+static inline char* read_line(FILE* fp) {
+ assert(fp != NULL, "invalid fp");
+ int buflen = 512;
+ char* buf = NEW_RESOURCE_ARRAY(char, buflen);
+ long pos = ftell(fp);
+
+ char* ret = fgets(buf, buflen, fp);
+ while (ret != NULL && buf[strlen(buf) - 1] != '\n' && !feof(fp)) {
+ // retry with a larger buffer
+ buf = REALLOC_RESOURCE_ARRAY(char, buf, buflen, buflen * 2);
+ buflen *= 2;
+ // rewind to beginning of line
+ fseek(fp, pos, SEEK_SET);
+ // retry read with new buffer
+ ret = fgets(buf, buflen, fp);
+ }
+ return ret;
+}
+
+static bool file_contains_substrings_in_order(const char* filename, const char* substrs[]) {
+ FILE* fp = fopen(filename, "r");
+ assert(fp != NULL, "error opening file %s: %s", filename, strerror(errno));
+
+ size_t idx = 0;
+ while (substrs[idx] != NULL) {
+ ResourceMark rm;
+ char* line = read_line(fp);
+ if (line == NULL) {
+ break;
+ }
+ for (char* match = strstr(line, substrs[idx]); match != NULL;) {
+ size_t match_len = strlen(substrs[idx]);
+ idx++;
+ if (substrs[idx] == NULL) {
+ break;
+ }
+ match = strstr(match + match_len, substrs[idx]);
+ }
+ }
+
+ fclose(fp);
+ return substrs[idx] == NULL;
+}
+
+static inline bool file_contains_substring(const char* filename, const char* substr) {
+ const char* strs[] = {substr, NULL};
+ return file_contains_substrings_in_order(filename, strs);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/native/logging/test_gcTraceTime.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,162 @@
+/*
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+#include "precompiled.hpp"
+#include "gc/shared/gcTraceTime.inline.hpp"
+#include "logTestFixture.hpp"
+#include "logTestUtils.inline.hpp"
+#include "logging/log.hpp"
+#include "runtime/interfaceSupport.hpp"
+#include "unittest.hpp"
+
+class GCTraceTimeTest : public LogTestFixture {
+};
+
+TEST_VM_F(GCTraceTimeTest, full) {
+ set_log_config(TestLogFileName, "gc=debug,gc+start=debug");
+
+ LogTarget(Debug, gc) gc_debug;
+ LogTarget(Debug, gc, start) gc_start_debug;
+
+ EXPECT_TRUE(gc_debug.is_enabled());
+ EXPECT_TRUE(gc_start_debug.is_enabled());
+
+ {
+ ThreadInVMfromNative tvn(JavaThread::current());
+ MutexLocker lock(Heap_lock); // Needed to read heap usage
+ GCTraceTime(Debug, gc) timer("Test GC", NULL, GCCause::_allocation_failure, true);
+ }
+
+ const char* expected[] = {
+ "[gc,start", "] Test GC (Allocation Failure)",
+ "[gc", "] Test GC (Allocation Failure) ", "M) ", "ms",
+ NULL
+ };
+ EXPECT_TRUE(file_contains_substrings_in_order(TestLogFileName, expected));
+}
+
+TEST_VM_F(GCTraceTimeTest, full_multitag) {
+ set_log_config(TestLogFileName, "gc+ref=debug,gc+ref+start=debug");
+
+ LogTarget(Debug, gc, ref) gc_debug;
+ LogTarget(Debug, gc, ref, start) gc_start_debug;
+
+ EXPECT_TRUE(gc_debug.is_enabled());
+ EXPECT_TRUE(gc_start_debug.is_enabled());
+
+ {
+ ThreadInVMfromNative tvn(JavaThread::current());
+ MutexLocker lock(Heap_lock); // Needed to read heap usage
+ GCTraceTime(Debug, gc, ref) timer("Test GC", NULL, GCCause::_allocation_failure, true);
+ }
+
+ const char* expected[] = {
+ "[gc,ref,start", "] Test GC (Allocation Failure)",
+ "[gc,ref", "] Test GC (Allocation Failure) ", "M) ", "ms",
+ NULL
+ };
+ EXPECT_TRUE(file_contains_substrings_in_order(TestLogFileName, expected));
+}
+
+TEST_VM_F(GCTraceTimeTest, no_heap) {
+ set_log_config(TestLogFileName, "gc=debug,gc+start=debug");
+
+ LogTarget(Debug, gc) gc_debug;
+ LogTarget(Debug, gc, start) gc_start_debug;
+
+ EXPECT_TRUE(gc_debug.is_enabled());
+ EXPECT_TRUE(gc_start_debug.is_enabled());
+
+ {
+ GCTraceTime(Debug, gc) timer("Test GC", NULL, GCCause::_allocation_failure, false);
+ }
+
+ const char* expected[] = {
+ // [2.975s][debug][gc,start] Test GC (Allocation Failure)
+ "[gc,start", "] Test GC (Allocation Failure)",
+ // [2.975s][debug][gc ] Test GC (Allocation Failure) 0.026ms
+ "[gc", "] Test GC (Allocation Failure) ", "ms",
+ NULL
+ };
+ EXPECT_TRUE(file_contains_substrings_in_order(TestLogFileName, expected));
+
+ const char* not_expected[] = {
+ // [2.975s][debug][gc ] Test GC 59M->59M(502M) 0.026ms
+ "[gc", "] Test GC ", "M) ", "ms",
+ };
+ EXPECT_FALSE(file_contains_substrings_in_order(TestLogFileName, not_expected));
+}
+
+TEST_VM_F(GCTraceTimeTest, no_cause) {
+ set_log_config(TestLogFileName, "gc=debug,gc+start=debug");
+
+ LogTarget(Debug, gc) gc_debug;
+ LogTarget(Debug, gc, start) gc_start_debug;
+
+ EXPECT_TRUE(gc_debug.is_enabled());
+ EXPECT_TRUE(gc_start_debug.is_enabled());
+
+ {
+ ThreadInVMfromNative tvn(JavaThread::current());
+ MutexLocker lock(Heap_lock); // Needed to read heap usage
+ GCTraceTime(Debug, gc) timer("Test GC", NULL, GCCause::_no_gc, true);
+ }
+
+ const char* expected[] = {
+ // [2.975s][debug][gc,start] Test GC
+ "[gc,start", "] Test GC",
+ // [2.975s][debug][gc ] Test GC 59M->59M(502M) 0.026ms
+ "[gc", "] Test GC ", "M) ", "ms",
+ NULL
+ };
+ EXPECT_TRUE(file_contains_substrings_in_order(TestLogFileName, expected));
+}
+
+TEST_VM_F(GCTraceTimeTest, no_heap_no_cause) {
+ set_log_config(TestLogFileName, "gc=debug,gc+start=debug");
+
+ LogTarget(Debug, gc) gc_debug;
+ LogTarget(Debug, gc, start) gc_start_debug;
+
+ EXPECT_TRUE(gc_debug.is_enabled());
+ EXPECT_TRUE(gc_start_debug.is_enabled());
+
+ {
+ GCTraceTime(Debug, gc) timer("Test GC", NULL, GCCause::_no_gc, false);
+ }
+
+ const char* expected[] = {
+ // [2.975s][debug][gc,start] Test GC
+ "[gc,start", "] Test GC",
+ // [2.975s][debug][gc ] Test GC 0.026ms
+ "[gc", "] Test GC ", "ms",
+ NULL
+ };
+ EXPECT_TRUE(file_contains_substrings_in_order(TestLogFileName, expected));
+
+ const char* not_expected[] = {
+ // [2.975s][debug][gc ] Test GC 59M->59M(502M) 0.026ms
+ "[gc", "] Test GC ", "M) ", "ms",
+ };
+ EXPECT_FALSE(file_contains_substrings_in_order(TestLogFileName, not_expected));
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/native/logging/test_log.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,158 @@
+/*
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+#include "precompiled.hpp"
+#include "gc/shared/gcTraceTime.inline.hpp"
+#include "logTestFixture.hpp"
+#include "logTestUtils.inline.hpp"
+#include "logging/log.hpp"
+#include "unittest.hpp"
+
+class LogTest : public LogTestFixture {
+};
+
+#define LOG_PREFIX_STR "THE_PREFIX "
+#define LOG_LINE_STR "a log line"
+
+size_t Test_log_prefix_prefixer(char* buf, size_t len) {
+ int ret = jio_snprintf(buf, len, LOG_PREFIX_STR);
+ assert(ret > 0, "Failed to print prefix. Log buffer too small?");
+ return (size_t) ret;
+}
+
+#ifdef ASSERT // 'test' tag is debug only
+TEST_F(LogTest, prefix) {
+ set_log_config(TestLogFileName, "logging+test=trace");
+ log_trace(logging, test)(LOG_LINE_STR);
+ EXPECT_TRUE(file_contains_substring(TestLogFileName, LOG_PREFIX_STR LOG_LINE_STR));
+}
+#endif
+
+TEST_F(LogTest, large_message) {
+ char big_msg[4096] = {0};
+ char Xchar = '~';
+
+ set_log_config(TestLogFileName, "logging=trace");
+
+ memset(big_msg, Xchar, sizeof(big_msg) - 1);
+ log_trace(logging)("%s", big_msg);
+
+ ResourceMark rm;
+ FILE* fp = fopen(TestLogFileName, "r");
+ ASSERT_NE((void*)NULL, fp);
+ char* output = read_line(fp);
+ fclose(fp);
+
+ size_t count = 0;
+ for (size_t ps = 0 ; output[ps + count] != '\0'; output[ps + count] == Xchar ? count++ : ps++);
+ EXPECT_EQ(sizeof(big_msg) - 1, count);
+}
+
+TEST_F(LogTest, enabled_logtarget) {
+ set_log_config(TestLogFileName, "gc=debug");
+
+ LogTarget(Debug, gc) log;
+ EXPECT_TRUE(log.is_enabled());
+
+ // Log the line and expect it to be available in the output file.
+ log.print(LOG_TEST_STRING_LITERAL);
+
+ EXPECT_TRUE(file_contains_substring(TestLogFileName, LOG_TEST_STRING_LITERAL));
+}
+
+TEST_F(LogTest, disabled_logtarget) {
+ set_log_config(TestLogFileName, "gc=info");
+
+ LogTarget(Debug, gc) log;
+ EXPECT_FALSE(log.is_enabled());
+
+ // Try to log, but expect this to be filtered out.
+ log.print(LOG_TEST_STRING_LITERAL);
+
+ // Log a dummy line so that fgets doesn't return NULL because the file is empty.
+ log_info(gc)("Dummy line");
+
+ EXPECT_FALSE(file_contains_substring(TestLogFileName, LOG_TEST_STRING_LITERAL));
+}
+
+TEST_F(LogTest, enabled_loghandle) {
+ set_log_config(TestLogFileName, "gc=debug");
+
+ Log(gc) log;
+ LogHandle log_handle(log);
+
+ EXPECT_TRUE(log_handle.is_debug());
+
+ // Try to log through a LogHandle.
+ log_handle.debug("%d workers", 3);
+
+ EXPECT_TRUE(file_contains_substring(TestLogFileName, "3 workers"));
+}
+
+TEST_F(LogTest, disabled_loghandle) {
+ set_log_config(TestLogFileName, "gc=info");
+
+ Log(gc) log;
+ LogHandle log_handle(log);
+
+ EXPECT_FALSE(log_handle.is_debug());
+
+ // Try to log through a LogHandle.
+ log_handle.debug("%d workers", 3);
+
+ // Log a dummy line so that fgets doesn't return NULL because the file is empty.
+ log_info(gc)("Dummy line");
+
+ EXPECT_FALSE(file_contains_substring(TestLogFileName, "3 workers"));
+}
+
+TEST_F(LogTest, enabled_logtargethandle) {
+ set_log_config(TestLogFileName, "gc=debug");
+
+ LogTarget(Debug, gc) log;
+ LogTargetHandle log_handle(log);
+
+ EXPECT_TRUE(log_handle.is_enabled());
+
+ // Try to log through a LogHandle.
+ log_handle.print("%d workers", 3);
+
+ EXPECT_TRUE(file_contains_substring(TestLogFileName, "3 workers"));
+}
+
+TEST_F(LogTest, disabled_logtargethandle) {
+ set_log_config(TestLogFileName, "gc=info");
+
+ LogTarget(Debug, gc) log;
+ LogTargetHandle log_handle(log);
+
+ EXPECT_FALSE(log_handle.is_enabled());
+
+ // Try to log through a LogHandle.
+ log_handle.print("%d workers", 3);
+
+ // Log a dummy line so that fgets doesn't return NULL because the file is empty.
+ log_info(gc)("Dummy line");
+
+ EXPECT_FALSE(file_contains_substring(TestLogFileName, "3 workers"));
+}
--- a/hotspot/test/native/logging/test_logConfiguration.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/native/logging/test_logConfiguration.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -19,8 +19,8 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
+
#include "precompiled.hpp"
#include "logTestFixture.hpp"
#include "logTestUtils.inline.hpp"
@@ -61,7 +61,7 @@
return string_contains_substring(ss.as_string(), text);
}
-TEST_F(LogConfigurationTest, describe) {
+TEST_VM_F(LogConfigurationTest, describe) {
ResourceMark rm;
stringStream ss;
LogConfiguration::describe(&ss);
@@ -115,7 +115,7 @@
}
// Test updating an existing log output
-TEST_F(LogConfigurationTest, update_output) {
+TEST_VM_F(LogConfigurationTest, update_output) {
// Update stdout twice, first using it's name, and the second time its index #
const char* test_outputs[] = { "stdout", "#0" };
for (size_t i = 0; i < ARRAY_SIZE(test_outputs); i++) {
@@ -144,7 +144,7 @@
}
// Test adding a new output to the configuration
-TEST_F(LogConfigurationTest, add_new_output) {
+TEST_VM_F(LogConfigurationTest, add_new_output) {
const char* what = "all=trace";
ASSERT_FALSE(is_described(TestLogFileName));
@@ -160,7 +160,7 @@
}
}
-TEST_F(LogConfigurationTest, disable_logging) {
+TEST_VM_F(LogConfigurationTest, disable_logging) {
// Add TestLogFileName as an output
set_log_config(TestLogFileName, "logging=info");
@@ -185,7 +185,7 @@
}
// Test disabling a particular output
-TEST_F(LogConfigurationTest, disable_output) {
+TEST_VM_F(LogConfigurationTest, disable_output) {
// Disable the default configuration for stdout
set_log_config("stdout", "all=off");
@@ -213,7 +213,7 @@
}
// Test reconfiguration of the selected decorators for an output
-TEST_F(LogConfigurationTest, reconfigure_decorators) {
+TEST_VM_F(LogConfigurationTest, reconfigure_decorators) {
// Configure stderr with all decorators
set_log_config("stderr", "all=off", _all_decorators);
char buf[256];
@@ -227,7 +227,7 @@
}
// Test that invalid options cause configuration errors
-TEST_F(LogConfigurationTest, invalid_configure_options) {
+TEST_VM_F(LogConfigurationTest, invalid_configure_options) {
LogConfiguration::disable_logging();
const char* invalid_outputs[] = { "#2", "invalidtype=123", ":invalid/path}to*file?" };
for (size_t i = 0; i < ARRAY_SIZE(invalid_outputs); i++) {
@@ -240,7 +240,7 @@
}
// Test empty configuration options
-TEST_F(LogConfigurationTest, parse_empty_command_line_arguments) {
+TEST_VM_F(LogConfigurationTest, parse_empty_command_line_arguments) {
const char* empty_variations[] = { "", ":", "::", ":::", "::::" };
for (size_t i = 0; i < ARRAY_SIZE(empty_variations); i++) {
const char* cmdline = empty_variations[i];
@@ -253,7 +253,7 @@
}
// Test basic command line parsing & configuration
-TEST_F(LogConfigurationTest, parse_command_line_arguments) {
+TEST_VM_F(LogConfigurationTest, parse_command_line_arguments) {
// Prepare a command line for logging*=debug on stderr with all decorators
int ret;
char buf[256];
@@ -273,7 +273,7 @@
}
// Test split up log configuration arguments
-TEST_F(LogConfigurationTest, parse_log_arguments) {
+TEST_VM_F(LogConfigurationTest, parse_log_arguments) {
ResourceMark rm;
stringStream ss;
// Verify that it's possible to configure each individual tag
@@ -296,7 +296,82 @@
}
}
-TEST_F(LogConfigurationTest, parse_invalid_tagset) {
+TEST_F(LogConfigurationTest, configure_stdout) {
+ // Start out with all logging disabled
+ LogConfiguration::disable_logging();
+
+ // Enable 'logging=info', verifying it has been set
+ LogConfiguration::configure_stdout(LogLevel::Info, true, LOG_TAGS(logging));
+ EXPECT_TRUE(log_is_enabled(Info, logging));
+ EXPECT_FALSE(log_is_enabled(Debug, logging));
+ EXPECT_FALSE(log_is_enabled(Info, gc));
+ LogTagSet* logging_ts = &LogTagSetMapping<LOG_TAGS(logging)>::tagset();
+ EXPECT_EQ(LogLevel::Info, logging_ts->level_for(LogOutput::Stdout));
+
+ // Enable 'gc=debug' (no wildcard), verifying no other tags are enabled
+ LogConfiguration::configure_stdout(LogLevel::Debug, true, LOG_TAGS(gc));
+ EXPECT_TRUE(log_is_enabled(Debug, gc));
+ EXPECT_TRUE(log_is_enabled(Info, logging));
+ EXPECT_FALSE(log_is_enabled(Debug, gc, heap));
+ for (LogTagSet* ts = LogTagSet::first(); ts != NULL; ts = ts->next()) {
+ if (ts->contains(PREFIX_LOG_TAG(gc))) {
+ if (ts->ntags() == 1) {
+ EXPECT_EQ(LogLevel::Debug, ts->level_for(LogOutput::Stdout));
+ } else {
+ EXPECT_EQ(LogLevel::Off, ts->level_for(LogOutput::Stdout));
+ }
+ }
+ }
+
+ // Enable 'gc*=trace' (with wildcard), verifying that all tag combinations with gc are enabled (gc+...)
+ LogConfiguration::configure_stdout(LogLevel::Trace, false, LOG_TAGS(gc));
+ EXPECT_TRUE(log_is_enabled(Trace, gc));
+ EXPECT_TRUE(log_is_enabled(Trace, gc, heap));
+ for (LogTagSet* ts = LogTagSet::first(); ts != NULL; ts = ts->next()) {
+ if (ts->contains(PREFIX_LOG_TAG(gc))) {
+ EXPECT_EQ(LogLevel::Trace, ts->level_for(LogOutput::Stdout));
+ } else if (ts == logging_ts) {
+ // Previous setting for 'logging' should remain
+ EXPECT_EQ(LogLevel::Info, ts->level_for(LogOutput::Stdout));
+ } else {
+ EXPECT_EQ(LogLevel::Off, ts->level_for(LogOutput::Stdout));
+ }
+ }
+
+ // Disable 'gc*' and 'logging', verifying all logging is properly disabled
+ LogConfiguration::configure_stdout(LogLevel::Off, true, LOG_TAGS(logging));
+ EXPECT_FALSE(log_is_enabled(Error, logging));
+ LogConfiguration::configure_stdout(LogLevel::Off, false, LOG_TAGS(gc));
+ EXPECT_FALSE(log_is_enabled(Error, gc));
+ EXPECT_FALSE(log_is_enabled(Error, gc, heap));
+ for (LogTagSet* ts = LogTagSet::first(); ts != NULL; ts = ts->next()) {
+ EXPECT_EQ(LogLevel::Off, ts->level_for(LogOutput::Stdout));
+ }
+}
+
+static int Test_logconfiguration_subscribe_triggered = 0;
+static void Test_logconfiguration_subscribe_helper() {
+ Test_logconfiguration_subscribe_triggered++;
+}
+
+TEST_F(LogConfigurationTest, subscribe) {
+ ResourceMark rm;
+ Log(logging) log;
+ set_log_config("stdout", "logging*=trace");
+
+ LogConfiguration::register_update_listener(&Test_logconfiguration_subscribe_helper);
+
+ LogConfiguration::parse_log_arguments("stdout", "logging=trace", NULL, NULL, log.error_stream());
+ ASSERT_EQ(1, Test_logconfiguration_subscribe_triggered);
+
+ LogConfiguration::configure_stdout(LogLevel::Debug, true, LOG_TAGS(gc));
+ ASSERT_EQ(2, Test_logconfiguration_subscribe_triggered);
+
+ LogConfiguration::disable_logging();
+ ASSERT_EQ(3, Test_logconfiguration_subscribe_triggered);
+}
+
+TEST_VM_F(LogConfigurationTest, parse_invalid_tagset) {
static const char* invalid_tagset = "logging+start+exit+safepoint+gc"; // Must not exist for test to function.
// Make sure warning is produced if one or more configured tagsets are invalid
@@ -309,7 +384,7 @@
EXPECT_TRUE(string_contains_substring(msg, invalid_tagset));
}
-TEST_F(LogConfigurationTest, output_name_normalization) {
+TEST_VM_F(LogConfigurationTest, output_name_normalization) {
const char* patterns[] = { "%s", "file=%s", "\"%s\"", "file=\"%s\"" };
char buf[1 * K];
for (size_t i = 0; i < ARRAY_SIZE(patterns); i++) {
--- a/hotspot/test/native/logging/test_logDecorations.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/native/logging/test_logDecorations.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -19,8 +19,8 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
+
#include "precompiled.hpp"
#include "logging/logDecorations.hpp"
#include "logging/logTagSet.hpp"
@@ -31,7 +31,7 @@
static const LogTagSet& tagset = LogTagSetMapping<LOG_TAGS(logging, safepoint)>::tagset();
static const LogDecorators default_decorators;
-TEST(LogDecorations, level) {
+TEST_VM(LogDecorations, level) {
for (uint l = LogLevel::First; l <= LogLevel::Last; l++) {
LogLevelType level = static_cast<LogLevelType>(l);
// Create a decorations object for the current level
@@ -52,7 +52,7 @@
}
}
-TEST(LogDecorations, uptime) {
+TEST_VM(LogDecorations, uptime) {
// Verify the format of the decoration
int a, b;
char decimal_point;
@@ -73,7 +73,7 @@
}
}
-TEST(LogDecorations, tags) {
+TEST_VM(LogDecorations, tags) {
char expected_tags[1 * K];
tagset.label(expected_tags, sizeof(expected_tags));
// Verify that the expected tags are included in the tags decoration
@@ -82,7 +82,7 @@
}
// Test each variation of the different timestamp decorations (ms, ns, uptime ms, uptime ns)
-TEST(LogDecorations, timestamps) {
+TEST_VM(LogDecorations, timestamps) {
struct {
const LogDecorators::Decorator decorator;
const char* suffix;
--- a/hotspot/test/native/logging/test_logDecorators.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/native/logging/test_logDecorators.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -19,8 +19,8 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
+
#include "precompiled.hpp"
#include "logging/logDecorators.hpp"
#include "unittest.hpp"
--- a/hotspot/test/native/logging/test_logFileOutput.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/native/logging/test_logFileOutput.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -19,9 +19,10 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
+
#include "precompiled.hpp"
+#include "logTestUtils.inline.hpp"
#include "logging/logFileOutput.hpp"
#include "memory/resourceArea.hpp"
#include "runtime/os.hpp"
@@ -32,7 +33,7 @@
static const char* name = "file=testlog.pid%p.%t.log";
// Test parsing a bunch of valid file output options
-TEST(LogFileOutput, parse_valid) {
+TEST_VM(LogFileOutput, parse_valid) {
const char* valid_options[] = {
"", "filecount=10", "filesize=512",
"filecount=11,filesize=256",
@@ -64,7 +65,7 @@
}
// Test parsing a bunch of invalid file output options
-TEST(LogFileOutput, parse_invalid) {
+TEST_VM(LogFileOutput, parse_invalid) {
const char* invalid_options[] = {
"invalidopt", "filecount=",
"filesize=,filecount=10",
@@ -91,7 +92,7 @@
}
// Test for overflows with filesize
-TEST(LogFileOutput, filesize_overflow) {
+TEST_VM(LogFileOutput, filesize_overflow) {
char buf[256];
int ret = jio_snprintf(buf, sizeof(buf), "filesize=" SIZE_FORMAT "K", SIZE_MAX);
ASSERT_GT(ret, 0) << "Buffer too small";
@@ -101,3 +102,82 @@
LogFileOutput fo(name);
EXPECT_FALSE(fo.initialize(buf, &ss)) << "Accepted filesize that overflows";
}
+
+TEST(LogFileOutput, startup_rotation) {
+ const size_t rotations = 5;
+ const char* filename = "start-rotate-test";
+ char* rotated_file[rotations];
+
+ ResourceMark rm;
+ for (size_t i = 0; i < rotations; i++) {
+ size_t len = strlen(filename) + 3;
+ rotated_file[i] = NEW_RESOURCE_ARRAY(char, len);
+ int ret = jio_snprintf(rotated_file[i], len, "%s." SIZE_FORMAT, filename, i);
+ ASSERT_NE(-1, ret);
+ delete_file(rotated_file[i]);
+ }
+
+ delete_file(filename);
+ init_log_file(filename);
+ ASSERT_TRUE(file_exists(filename))
+ << "configured logging to file '" << filename << "' but file was not found";
+
+ // Initialize the same file a bunch more times to trigger rotations
+ for (size_t i = 0; i < rotations; i++) {
+ init_log_file(filename);
+ EXPECT_TRUE(file_exists(rotated_file[i]));
+ }
+
+ // Remove a file and expect its slot to be re-used
+ delete_file(rotated_file[1]);
+ init_log_file(filename);
+ EXPECT_TRUE(file_exists(rotated_file[1]));
+
+ // Clean up after test
+ delete_file(filename);
+ for (size_t i = 0; i < rotations; i++) {
+ delete_file(rotated_file[i]);
+ }
+}
+
+TEST(LogFileOutput, startup_truncation) {
+ const char* filename = "start-truncate-test";
+ const char* archived_filename = "start-truncate-test.0";
+
+ delete_file(filename);
+ delete_file(archived_filename);
+
+ // Use the same log file twice and expect it to be overwritten/truncated
+ init_log_file(filename, "filecount=0");
+ ASSERT_TRUE(file_exists(filename))
+ << "configured logging to file '" << filename << "' but file was not found";
+
+ init_log_file(filename, "filecount=0");
+ ASSERT_TRUE(file_exists(filename))
+ << "configured logging to file '" << filename << "' but file was not found";
+ EXPECT_FALSE(file_exists(archived_filename))
+ << "existing log file was not properly truncated when filecount was 0";
+
+ // Verify that the file was really truncated and not just appended
+ EXPECT_TRUE(file_contains_substring(filename, LOG_TEST_STRING_LITERAL));
+ const char* repeated[] = { LOG_TEST_STRING_LITERAL, LOG_TEST_STRING_LITERAL };
+ EXPECT_FALSE(file_contains_substrings_in_order(filename, repeated))
+ << "log file " << filename << " appended rather than truncated";
+
+ delete_file(filename);
+ delete_file(archived_filename);
+}
+
+TEST(LogFileOutput, invalid_file) {
+ ResourceMark rm;
+ stringStream ss;
+
+ // Attempt to log to a directory (existing log not a regular file)
+ create_directory("tmplogdir");
+ LogFileOutput bad_file("file=tmplogdir");
+ EXPECT_FALSE(bad_file.initialize("", &ss))
+ << "file was initialized when there was an existing directory with the same name";
+ EXPECT_TRUE(string_contains_substring(ss.as_string(), "tmplogdir is not a regular file"))
+ << "missing expected error message, received msg: %s" << ss.as_string();
+ remove("tmplogdir");
+}
--- a/hotspot/test/native/logging/test_logLevel.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/native/logging/test_logLevel.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -19,8 +19,8 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
+
#include "precompiled.hpp"
#include "logging/logLevel.hpp"
#include "unittest.hpp"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/native/logging/test_logMessageTest.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,252 @@
+/*
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * ac_heapanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+#include "precompiled.hpp"
+#include "logTestFixture.hpp"
+#include "logTestUtils.inline.hpp"
+#include "logging/log.hpp"
+#include "logging/logMessage.hpp"
+#include "unittest.hpp"
+#include "utilities/globalDefinitions.hpp"
+
+class LogMessageTest : public LogTestFixture {
+protected:
+ static Log(logging) _log;
+ static const char* _level_filename[];
+ LogMessageTest();
+ ~LogMessageTest();
+};
+
+const char* LogMessageTest::_level_filename[] = {
+ NULL, // LogLevel::Off
+#define LOG_LEVEL(name, printname) "multiline-" #printname ".log",
+ LOG_LEVEL_LIST
+#undef LOG_LEVEL
+};
+
+LogMessageTest::LogMessageTest() {
+ for (int i = 0; i < LogLevel::Count; i++) {
+ char buf[32];
+ // Attempt to remove possibly pre-existing log files
+ remove(_level_filename[i]);
+
+ jio_snprintf(buf, sizeof(buf), "logging=%s", LogLevel::name(static_cast<LogLevelType>(i)));
+ set_log_config(_level_filename[i], buf);
+ }
+}
+
+LogMessageTest::~LogMessageTest() {
+ // Stop logging to the files and remove them.
+ for (int i = 0; i < LogLevel::Count; i++) {
+ set_log_config(_level_filename[i], "all=off");
+ remove(_level_filename[i]);
+ }
+}
+
+// Verify that messages with multiple levels are written
+// to outputs configured for all the corresponding levels
+TEST_F(LogMessageTest, level_inclusion) {
+ const size_t message_count = 10;
+ LogMessageBuffer msg[message_count];
+
+ struct {
+ int message_number;
+ LogLevelType level;
+ } lines[] = {
+ { 0, LogLevel::Error },
+ { 1, LogLevel::Info },
+ { 2, LogLevel::Info }, { 2, LogLevel::Debug },
+ { 3, LogLevel::Info }, { 3, LogLevel::Warning },
+ { 4, LogLevel::Debug }, { 4, LogLevel::Warning },
+ { 5, LogLevel::Trace }, { 5, LogLevel::Debug },
+ { 6, LogLevel::Warning }, { 6, LogLevel::Error },
+ { 7, LogLevel::Trace }, { 7, LogLevel::Info }, { 7, LogLevel::Debug },
+ { 8, LogLevel::Trace }, { 8, LogLevel::Debug }, { 8, LogLevel::Info },
+ { 8, LogLevel::Warning }, { 8, LogLevel::Error},
+ { 9, LogLevel::Trace }
+ };
+
+ // Fill in messages with the above lines
+ for (size_t i = 0; i < ARRAY_SIZE(lines); i++) {
+ switch (lines[i].level) {
+#define LOG_LEVEL(name, printname) \
+ case LogLevel::name: \
+ msg[lines[i].message_number].printname("msg[%d]: " #printname, lines[i].message_number); \
+ break;
+LOG_LEVEL_LIST
+#undef LOG_LEVEL
+ }
+ }
+
+ for (size_t i = 0; i < message_count; i++) {
+ _log.write(msg[i]);
+ }
+
+ // Verify that lines are written to the expected log files
+ for (size_t i = 0; i < ARRAY_SIZE(lines); i++) {
+ char expected[256];
+ jio_snprintf(expected, sizeof(expected), "msg[%d]: %s",
+ lines[i].message_number, LogLevel::name(lines[i].level));
+ for (int level = lines[i].level; level > 0; level--) {
+ EXPECT_TRUE(file_contains_substring(_level_filename[level], expected))
+ << "line #" << i << " missing from log file " << _level_filename[level];
+ }
+ for (int level = lines[i].level + 1; level < LogLevel::Count; level++) {
+ EXPECT_FALSE(file_contains_substring(_level_filename[level], expected))
+ << "line #" << i << " erroneously included in log file " << _level_filename[level];
+ }
+ }
+}
+
+// Verify that messages are logged in the order they are added to the log message
+TEST_F(LogMessageTest, line_order) {
+ LogMessageBuffer msg;
+ msg.info("info line").error("error line").trace("trace line")
+ .error("another error").warning("warning line").debug("debug line");
+ _log.write(msg);
+
+ const char* expected[] = { "info line", "error line", "trace line",
+ "another error", "warning line", "debug line", NULL };
+ EXPECT_TRUE(file_contains_substrings_in_order(_level_filename[LogLevel::Trace], expected))
+ << "output missing or in incorrect order";
+}
+
+TEST_F(LogMessageTest, long_message) {
+ // Write 10K bytes worth of log data
+ LogMessageBuffer msg;
+ const size_t size = 10 * K;
+ const char* start_marker = "#start#";
+ const char* end_marker = "#the end#";
+ char* data = NEW_C_HEAP_ARRAY(char, size, mtLogging);
+
+ // fill buffer with start_marker...some data...end_marker
+ sprintf(data, "%s", start_marker);
+ for (size_t i = strlen(start_marker); i < size; i++) {
+ data[i] = '0' + (i % 10);
+ }
+ sprintf(data + size - strlen(end_marker) - 1, "%s", end_marker);
+
+ msg.trace("%s", data); // Adds a newline, making the message exactly 10K in length.
+ _log.write(msg);
+
+ const char* expected[] = { start_marker, "0123456789", end_marker, NULL };
+ EXPECT_TRUE(file_contains_substrings_in_order(_level_filename[LogLevel::Trace], expected))
+ << "unable to print long line";
+ FREE_C_HEAP_ARRAY(char, data);
+}
+
+TEST_F(LogMessageTest, message_with_many_lines) {
+ const size_t lines = 100;
+ const size_t line_length = 16;
+
+ LogMessageBuffer msg;
+ for (size_t i = 0; i < lines; i++) {
+ msg.info("Line #" SIZE_FORMAT, i);
+ }
+ _log.write(msg);
+
+ char expected_lines_data[lines][line_length];
+ const char* expected_lines[lines + 1];
+ for (size_t i = 0; i < lines; i++) {
+ jio_snprintf(&expected_lines_data[i][0], line_length, "Line #" SIZE_FORMAT, i);
+ expected_lines[i] = expected_lines_data[i];
+ }
+ expected_lines[lines] = NULL;
+
+ EXPECT_TRUE(file_contains_substrings_in_order(_level_filename[LogLevel::Trace], expected_lines))
+ << "couldn't find all lines in multiline message";
+}
+
+static size_t dummy_prefixer(char* buf, size_t len) {
+ static int i = 0;
+ const char* prefix = "some prefix: ";
+ const size_t prefix_len = strlen(prefix);
+ if (len < prefix_len) {
+ return prefix_len;
+ }
+ jio_snprintf(buf, len, "%s", prefix);
+ return prefix_len;
+}
+
+TEST_F(LogMessageTest, prefixing) {
+ LogMessageBuffer msg;
+ msg.set_prefix(dummy_prefixer);
+ for (int i = 0; i < 3; i++) {
+ msg.info("test %d", i);
+ }
+ msg.set_prefix(NULL);
+ msg.info("test 3");
+ _log.write(msg);
+
+ const char* expected[] = {
+ "] some prefix: test 0",
+ "] some prefix: test 1",
+ "] some prefix: test 2",
+ "] test 3",
+ NULL
+ };
+ EXPECT_TRUE(file_contains_substrings_in_order(_level_filename[LogLevel::Trace], expected))
+ << "error in prefixed output";
+}
+
+TEST_F(LogMessageTest, scoped_messages) {
+ {
+ LogMessage(logging) msg;
+ msg.info("scoped info");
+ msg.warning("scoped warn");
+ EXPECT_FALSE(file_contains_substring(_level_filename[LogLevel::Info], "scoped info"))
+ << "scoped log message written prematurely";
+ }
+ EXPECT_TRUE(file_contains_substring(_level_filename[LogLevel::Info], "scoped info"))
+ << "missing output from scoped log message";
+ EXPECT_TRUE(file_contains_substring(_level_filename[LogLevel::Warning], "scoped warn"))
+ << "missing output from scoped log message";
+}
+
+TEST_F(LogMessageTest, scoped_flushing) {
+ {
+ LogMessage(logging) msg;
+ msg.info("manual flush info");
+ msg.flush();
+ EXPECT_TRUE(file_contains_substring(_level_filename[LogLevel::Info], "manual flush info"))
+ << "missing output from manually flushed scoped log message";
+ }
+ const char* tmp[] = {"manual flush info", "manual flush info", NULL};
+ EXPECT_FALSE(file_contains_substrings_in_order(_level_filename[LogLevel::Info], tmp))
+ << "log file contains duplicate lines from single scoped log message";
+}
+
+TEST_F(LogMessageTest, scoped_reset) {
+ {
+ LogMessage(logging) msg, partial;
+ msg.info("%s", "info reset msg");
+ msg.reset();
+ partial.info("%s", "info reset msg");
+ partial.reset();
+ partial.trace("%s", "trace reset msg");
+ }
+ EXPECT_FALSE(file_contains_substring(_level_filename[LogLevel::Info], "info reset msg"))
+ << "reset message written anyway";
+ EXPECT_TRUE(file_contains_substring(_level_filename[LogLevel::Trace], "trace reset msg"))
+ << "missing message from partially reset scoped log message";
+}
--- a/hotspot/test/native/logging/test_logOutputList.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/native/logging/test_logOutputList.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -19,8 +19,8 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
+
#include "precompiled.hpp"
#include "logging/logLevel.hpp"
#include "logging/logOutput.hpp"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/native/logging/test_logStream.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+#include "precompiled.hpp"
+#include "logTestFixture.hpp"
+#include "logTestUtils.inline.hpp"
+#include "logging/log.hpp"
+#include "logging/logStream.hpp"
+#include "unittest.hpp"
+
+class LogStreamTest : public LogTestFixture {
+ protected:
+ void verify_stream(outputStream* stream);
+};
+
+void LogStreamTest::verify_stream(outputStream* stream) {
+ set_log_config(TestLogFileName, "gc=debug");
+ stream->print("%d ", 3);
+ stream->print("workers");
+ stream->cr();
+ EXPECT_TRUE(file_contains_substring(TestLogFileName, "3 workers\n"));
+}
+
+TEST_F(LogStreamTest, from_log) {
+ Log(gc) log;
+ LogStream stream(log.debug());
+
+ verify_stream(&stream);
+}
+
+TEST_F(LogStreamTest, from_logtarget) {
+ LogTarget(Debug, gc) log;
+ LogStream stream(log);
+
+ verify_stream(&stream);
+}
+
+TEST_F(LogStreamTest, handle) {
+ LogStreamHandle(Debug, gc) stream;
+
+ verify_stream(&stream);
+}
+
+TEST_F(LogStreamTest, no_rm) {
+ ResourceMark rm;
+ outputStream* stream = LogTarget(Debug, gc)::stream();
+
+ verify_stream(stream);
+}
+
+TEST_F(LogStreamTest, c_heap_stream) {
+ Log(gc) log;
+ LogStreamCHeap stream(log.debug());
+
+ verify_stream(&stream);
+}
+
+TEST_F(LogStreamTest, c_heap_stream_target) {
+ LogTarget(Debug, gc) log;
+ LogStreamCHeap stream(log);
+
+ verify_stream(&stream);
+}
--- a/hotspot/test/native/logging/test_logTag.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/native/logging/test_logTag.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -19,8 +19,8 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
+
#include "precompiled.hpp"
#include "logging/logTag.hpp"
#include "unittest.hpp"
--- a/hotspot/test/native/logging/test_logTagLevelExpression.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/native/logging/test_logTagLevelExpression.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -19,8 +19,8 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
+
#include "precompiled.hpp"
#include "logging/logLevel.hpp"
#include "logging/logTagLevelExpression.hpp"
@@ -28,6 +28,12 @@
#include "unittest.hpp"
#include "utilities/globalDefinitions.hpp"
+TEST(LogTagLevelExpression, combination_limit) {
+ size_t max_combinations = LogTagLevelExpression::MaxCombinations;
+ EXPECT_GT(max_combinations, LogTagSet::ntagsets())
+ << "Combination limit not sufficient for configuring all available tag sets";
+}
+
TEST(LogTagLevelExpression, parse) {
char buf[256];
const char* invalid_substr[] = {
--- a/hotspot/test/native/logging/test_logTagSet.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/native/logging/test_logTagSet.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -10,7 +10,7 @@
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
- * ac_heapanied this code).
+ * accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
@@ -19,8 +19,8 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
+
#include "precompiled.hpp"
#include "logging/logLevel.hpp"
#include "logging/logOutput.hpp"
@@ -128,3 +128,46 @@
ASSERT_NE(-1, ts2.label(buf, sizeof(buf)));
EXPECT_STREQ("logging", buf);
}
+
+TEST(LogTagSet, duplicates) {
+ for (LogTagSet* ts = LogTagSet::first(); ts != NULL; ts = ts->next()) {
+ char ts_name[512];
+ ts->label(ts_name, sizeof(ts_name), ",");
+
+ // verify that NO_TAG is never followed by a real tag
+ for (size_t i = 0; i < LogTag::MaxTags; i++) {
+ if (ts->tag(i) == LogTag::__NO_TAG) {
+ for (i++; i < LogTag::MaxTags; i++) {
+ EXPECT_EQ(LogTag::__NO_TAG, ts->tag(i))
+ << "NO_TAG was followed by a real tag (" << LogTag::name(ts->tag(i)) << ") in tagset " << ts_name;
+ }
+ }
+ }
+
+ // verify that there are no duplicate tagsets (same tags in different order)
+ for (LogTagSet* other = ts->next(); other != NULL; other = other->next()) {
+ if (ts->ntags() != other->ntags()) {
+ continue;
+ }
+ bool equal = true;
+ for (size_t i = 0; i < ts->ntags(); i++) {
+ LogTagType tag = ts->tag(i);
+ if (!other->contains(tag)) {
+ equal = false;
+ break;
+ }
+ }
+ // Since tagsets are implemented using template arguments, using both of
+ // the (logically equivalent) tagsets (t1, t2) and (t2, t1) somewhere will
+ // instantiate two different LogTagSetMappings. This causes multiple
+ // tagset instances to be created for the same logical set. We want to
+ // avoid this to save time, memory and prevent any confusion around it.
+ if (equal) {
+ char other_name[512];
+ other->label(other_name, sizeof(other_name), ",");
+ FAIL() << "duplicate LogTagSets found: '" << ts_name << "' vs '" << other_name << "' "
+ << "(tags must always be specified in the same order for each tagset)";
+ }
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/native/logging/test_logTagSetDescriptions.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * ac_heapanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+#include "precompiled.hpp"
+#include "logTestUtils.inline.hpp"
+#include "logging/logConfiguration.hpp"
+#include "logging/logTagSet.hpp"
+#include "logging/logTagSetDescriptions.hpp"
+#include "memory/resourceArea.hpp"
+#include "unittest.hpp"
+#include "utilities/ostream.hpp"
+
+TEST(LogTagSetDescriptions, describe) {
+ for (LogTagSetDescription* d = tagset_descriptions; d->tagset != NULL; d++) {
+ char expected[1 * K];
+ d->tagset->label(expected, sizeof(expected), "+");
+ jio_snprintf(expected + strlen(expected),
+ sizeof(expected) - strlen(expected),
+ ": %s", d->descr);
+
+ ResourceMark rm;
+ stringStream stream;
+ LogConfiguration::describe(&stream);
+ EXPECT_PRED2(string_contains_substring, stream.as_string(), expected)
+ << "missing log tag set descriptions in LogConfiguration::describe";
+ }
+}
+
+TEST(LogTagSetDescriptions, command_line_help) {
+ const char* filename = "logtagset_descriptions";
+ FILE* fp = fopen(filename, "w+");
+ ASSERT_NE((void*)NULL, fp);
+ LogConfiguration::print_command_line_help(fp);
+ fclose(fp);
+
+ for (LogTagSetDescription* d = tagset_descriptions; d->tagset != NULL; d++) {
+ char expected[1 * K];
+ d->tagset->label(expected, sizeof(expected), "+");
+ jio_snprintf(expected + strlen(expected),
+ sizeof(expected) - strlen(expected),
+ ": %s", d->descr);
+
+ EXPECT_TRUE(file_contains_substring(filename, expected)) << "missing log tag set descriptions in -Xlog:help output";
+ }
+ delete_file(filename);
+}
--- a/hotspot/test/native/oops/test_arrayOop.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/native/oops/test_arrayOop.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -43,47 +43,47 @@
return (julong) (size_t) bytes == bytes;
}
-TEST(arrayOopDesc, boolean) {
+TEST_VM(arrayOopDesc, boolean) {
ASSERT_PRED1(check_max_length_overflow, T_BOOLEAN);
}
-TEST(arrayOopDesc, char) {
+TEST_VM(arrayOopDesc, char) {
ASSERT_PRED1(check_max_length_overflow, T_CHAR);
}
-TEST(arrayOopDesc, float) {
+TEST_VM(arrayOopDesc, float) {
ASSERT_PRED1(check_max_length_overflow, T_FLOAT);
}
-TEST(arrayOopDesc, double) {
+TEST_VM(arrayOopDesc, double) {
ASSERT_PRED1(check_max_length_overflow, T_DOUBLE);
}
-TEST(arrayOopDesc, byte) {
+TEST_VM(arrayOopDesc, byte) {
ASSERT_PRED1(check_max_length_overflow, T_BYTE);
}
-TEST(arrayOopDesc, short) {
+TEST_VM(arrayOopDesc, short) {
ASSERT_PRED1(check_max_length_overflow, T_SHORT);
}
-TEST(arrayOopDesc, int) {
+TEST_VM(arrayOopDesc, int) {
ASSERT_PRED1(check_max_length_overflow, T_INT);
}
-TEST(arrayOopDesc, long) {
+TEST_VM(arrayOopDesc, long) {
ASSERT_PRED1(check_max_length_overflow, T_LONG);
}
-TEST(arrayOopDesc, object) {
+TEST_VM(arrayOopDesc, object) {
ASSERT_PRED1(check_max_length_overflow, T_OBJECT);
}
-TEST(arrayOopDesc, array) {
+TEST_VM(arrayOopDesc, array) {
ASSERT_PRED1(check_max_length_overflow, T_ARRAY);
}
-TEST(arrayOopDesc, narrowOop) {
+TEST_VM(arrayOopDesc, narrowOop) {
ASSERT_PRED1(check_max_length_overflow, T_NARROWOOP);
}
// T_VOID and T_ADDRESS are not supported by max_array_length()
--- a/hotspot/test/native/runtime/test_arguments.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/native/runtime/test_arguments.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -19,8 +19,8 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
+
#include "precompiled.hpp"
#include "runtime/arguments.hpp"
#include "unittest.hpp"
--- a/hotspot/test/native/runtime/test_classLoader.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/native/runtime/test_classLoader.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
#include "precompiled.hpp"
--- a/hotspot/test/native/runtime/test_globals.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/native/runtime/test_globals.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
#include "precompiled.hpp"
--- a/hotspot/test/native/runtime/test_os.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/native/runtime/test_os.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
#include "precompiled.hpp"
--- a/hotspot/test/native/unittest.hpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/native/unittest.hpp Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
#ifndef UNITTEST_HPP
--- a/hotspot/test/native/utilities/test_bitMap_setops.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/native/utilities/test_bitMap_setops.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
#include "precompiled.hpp"
--- a/hotspot/test/native/utilities/test_json.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/native/utilities/test_json.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -54,322 +54,322 @@
parse();
}
-TEST(utilities, json_curly_braces) {
+TEST_VM(utilities, json_curly_braces) {
JSON_GTest::test("{}", true);
}
-TEST(utilities, json_brackets) {
+TEST_VM(utilities, json_brackets) {
JSON_GTest::test("[]", true);
}
-TEST(utilities, json_space_braces) {
+TEST_VM(utilities, json_space_braces) {
JSON_GTest::test(" { } ", true);
}
-TEST(utilities, json_space_bracketes) {
+TEST_VM(utilities, json_space_bracketes) {
JSON_GTest::test(" [ ] ", true);
}
-TEST(utilities, json_quoted_error) {
+TEST_VM(utilities, json_quoted_error) {
JSON_GTest::test("\"error\"", false);
}
-TEST(utilities, json_error_string) {
+TEST_VM(utilities, json_error_string) {
JSON_GTest::test("error", false);
}
-TEST(utilities, json_simple_integer) {
+TEST_VM(utilities, json_simple_integer) {
JSON_GTest::test("1", false);
}
-TEST(utilities, json_siple_float) {
+TEST_VM(utilities, json_siple_float) {
JSON_GTest::test("1.2", false);
}
-TEST(utilities, json_simple_boolean_true) {
+TEST_VM(utilities, json_simple_boolean_true) {
JSON_GTest::test("true", false);
}
-TEST(utilities, json_simple_boolean_false) {
+TEST_VM(utilities, json_simple_boolean_false) {
JSON_GTest::test("false", false);
}
-TEST(utilities, json_simple_null) {
+TEST_VM(utilities, json_simple_null) {
JSON_GTest::test("null", false);
}
-TEST(utilities, json_one_element_int_array) {
+TEST_VM(utilities, json_one_element_int_array) {
JSON_GTest::test("[ 1 ]", true);
}
-TEST(utilities, json_int_array) {
+TEST_VM(utilities, json_int_array) {
JSON_GTest::test("[ 1, ]", true);
}
-TEST(utilities, json_one_element_bool_array) {
+TEST_VM(utilities, json_one_element_bool_array) {
JSON_GTest::test("[ true ]", true);
}
-TEST(utilities, json_bool_array) {
+TEST_VM(utilities, json_bool_array) {
JSON_GTest::test("[ true, ]", true);
}
-TEST(utilities, json_one_element_false_array) {
+TEST_VM(utilities, json_one_element_false_array) {
JSON_GTest::test("[ false ]", true);
}
-TEST(utilities, json_false_bool_array) {
+TEST_VM(utilities, json_false_bool_array) {
JSON_GTest::test("[ false, ]", true);
}
-TEST(utilities, json_one_null_array) {
+TEST_VM(utilities, json_one_null_array) {
JSON_GTest::test("[ null ]", true);
}
-TEST(utilities, json_null_array) {
+TEST_VM(utilities, json_null_array) {
JSON_GTest::test("[ null, ]", true);
}
-TEST(utilities, json_one_empty_string_array) {
+TEST_VM(utilities, json_one_empty_string_array) {
JSON_GTest::test("[ \"\" ]", true);
}
-TEST(utilities, json_empty_string_array) {
+TEST_VM(utilities, json_empty_string_array) {
JSON_GTest::test("[ \"\", ]", true);
}
-TEST(utilities, json_single_string_array) {
+TEST_VM(utilities, json_single_string_array) {
JSON_GTest::test("[ \"elem1\" ]", true);
}
-TEST(utilities, json_string_comma_arrray) {
+TEST_VM(utilities, json_string_comma_arrray) {
JSON_GTest::test("[ \"elem1\", ]", true);
}
-TEST(utilities, json_two_strings_array) {
+TEST_VM(utilities, json_two_strings_array) {
JSON_GTest::test("[ \"elem1\", \"elem2\" ]", true);
}
-TEST(utilities, json_two_strings_comma_array) {
+TEST_VM(utilities, json_two_strings_comma_array) {
JSON_GTest::test("[ \"elem1\", \"elem2\", ]", true);
}
-TEST(utilities, json_curly_braces_outside) {
+TEST_VM(utilities, json_curly_braces_outside) {
JSON_GTest::test("[ \"elem1\" ] { }", false);
}
-TEST(utilities, json_element_in_array) {
+TEST_VM(utilities, json_element_in_array) {
JSON_GTest::test("[ elem1, \"elem2\" ]", false);
}
-TEST(utilities, json_incorrect_end_array) {
+TEST_VM(utilities, json_incorrect_end_array) {
JSON_GTest::test("[ \"elem1\"", false);
}
-TEST(utilities, json_incorrect_string_end) {
+TEST_VM(utilities, json_incorrect_string_end) {
JSON_GTest::test("[ \"elem1 ]", false);
}
-TEST(utilities, json_incorrect_end_of_two_elements_array) {
+TEST_VM(utilities, json_incorrect_end_of_two_elements_array) {
JSON_GTest::test("[ \"elem1\", \"elem2\"", false);
}
-TEST(utilities, json_incorrect_bool_true_array) {
+TEST_VM(utilities, json_incorrect_bool_true_array) {
JSON_GTest::test("[ truefoo ]", false);
}
-TEST(utilities, json_incorrect_bool_false_array) {
+TEST_VM(utilities, json_incorrect_bool_false_array) {
JSON_GTest::test("[ falsefoo ]", false);
}
-TEST(utilities, json_incorrect_null_array) {
+TEST_VM(utilities, json_incorrect_null_array) {
JSON_GTest::test("[ nullfoo ]", false);
}
-TEST(utilities, json_key_pair) {
+TEST_VM(utilities, json_key_pair) {
JSON_GTest::test("{ key : 1 }", true);
}
-TEST(utilities, json_key_pair_comma) {
+TEST_VM(utilities, json_key_pair_comma) {
JSON_GTest::test("{ key : 1, }", true);
}
-TEST(utilities, json_bool_true_key) {
+TEST_VM(utilities, json_bool_true_key) {
JSON_GTest::test("{ key : true }", true);
}
-TEST(utilities, json_bool_true_key_comma) {
+TEST_VM(utilities, json_bool_true_key_comma) {
JSON_GTest::test("{ key : true, }", true);
}
-TEST(utilities, json_bool_false_key) {
+TEST_VM(utilities, json_bool_false_key) {
JSON_GTest::test("{ key : false }", true);
}
-TEST(utilities, json_bool_false_key_comma) {
+TEST_VM(utilities, json_bool_false_key_comma) {
JSON_GTest::test("{ key : false, }", true);
}
-TEST(utilities, json_null_key) {
+TEST_VM(utilities, json_null_key) {
JSON_GTest::test("{ key : null }", true);
}
-TEST(utilities, json_null_key_comma) {
+TEST_VM(utilities, json_null_key_comma) {
JSON_GTest::test("{ key : null, }", true);
}
-TEST(utilities, json_pair_of_empty_strings) {
+TEST_VM(utilities, json_pair_of_empty_strings) {
JSON_GTest::test("{ \"\" : \"\" }", true);
}
-TEST(utilities, json_pair_of_empty_strings_comma) {
+TEST_VM(utilities, json_pair_of_empty_strings_comma) {
JSON_GTest::test("{ \"\" : \"\", }", true);
}
-TEST(utilities, json_pair_of_strings) {
+TEST_VM(utilities, json_pair_of_strings) {
JSON_GTest::test("{ \"key1\" : \"val1\" }", true);
}
-TEST(utilities, json_pair_of_strings_comma) {
+TEST_VM(utilities, json_pair_of_strings_comma) {
JSON_GTest::test("{ \"key1\" : \"val1\", }", true);
}
-TEST(utilities, json_two_pairs_of_strings) {
+TEST_VM(utilities, json_two_pairs_of_strings) {
JSON_GTest::test("{ \"key1\" : \"val1\", \"key2\" : \"val2\" }", true);
}
-TEST(utilities, json_two_pairs_of_strings_comma) {
+TEST_VM(utilities, json_two_pairs_of_strings_comma) {
JSON_GTest::test("{ \"key1\" : \"val1\", \"key2\" : \"val2\", }", true);
}
-TEST(utilities, json_array_outside) {
+TEST_VM(utilities, json_array_outside) {
JSON_GTest::test("{ \"key\" : \"val\" } [ \"error\" ]", false);
}
-TEST(utilities, json_incorrect_object_end) {
+TEST_VM(utilities, json_incorrect_object_end) {
JSON_GTest::test("{ \"key\" : \"val\" ", false);
}
-TEST(utilities, json_empty_comment) {
+TEST_VM(utilities, json_empty_comment) {
JSON_GTest::test("/**/ { }", true);
}
-TEST(utilities, json_space_comment) {
+TEST_VM(utilities, json_space_comment) {
JSON_GTest::test("/* */ { }", true);
}
-TEST(utilities, json_comment) {
+TEST_VM(utilities, json_comment) {
JSON_GTest::test("/*foo*/ { }", true);
}
-TEST(utilities, json_star_comment) {
+TEST_VM(utilities, json_star_comment) {
JSON_GTest::test("/* *foo */ { }", true);
}
-TEST(utilities, json_stars_comment) {
+TEST_VM(utilities, json_stars_comment) {
JSON_GTest::test("/* *foo* */ { }", true);
}
-TEST(utilities, json_special_comment) {
+TEST_VM(utilities, json_special_comment) {
JSON_GTest::test("/* /*foo */ { }", true);
}
-TEST(utilities, json_comment_after) {
+TEST_VM(utilities, json_comment_after) {
JSON_GTest::test("{ } /* foo */", true);
}
-TEST(utilities, json_comment_after_and_space) {
+TEST_VM(utilities, json_comment_after_and_space) {
JSON_GTest::test("{ } /* foo */ ", true);
}
-TEST(utilities, json_one_line_empty_comment_after) {
+TEST_VM(utilities, json_one_line_empty_comment_after) {
JSON_GTest::test("{ } //", true);
}
-TEST(utilities, json_one_line_space_comment_after) {
+TEST_VM(utilities, json_one_line_space_comment_after) {
JSON_GTest::test("{ } // ", true);
}
-TEST(utilities, json_one_line_comment_after) {
+TEST_VM(utilities, json_one_line_comment_after) {
JSON_GTest::test("{ } // foo", true);
}
-TEST(utilities, json_incorrect_multiline_comment) {
+TEST_VM(utilities, json_incorrect_multiline_comment) {
JSON_GTest::test("/* * / { }", false);
}
-TEST(utilities, json_incorrect_multiline_comment_begin) {
+TEST_VM(utilities, json_incorrect_multiline_comment_begin) {
JSON_GTest::test("/ * */ { }", false);
}
-TEST(utilities, json_oneline_comment_only) {
+TEST_VM(utilities, json_oneline_comment_only) {
JSON_GTest::test("// { }", false);
}
-TEST(utilities, json_multiline_comment_only) {
+TEST_VM(utilities, json_multiline_comment_only) {
JSON_GTest::test("/* { } */", false);
}
-TEST(utilities, json_multiline_comment_2) {
+TEST_VM(utilities, json_multiline_comment_2) {
JSON_GTest::test("/* { } */ ", false);
}
-TEST(utilities, json_incorrectly_commented_object) {
+TEST_VM(utilities, json_incorrectly_commented_object) {
JSON_GTest::test("/* { } ", false);
}
-TEST(utilities, json_missing_multiline_end) {
+TEST_VM(utilities, json_missing_multiline_end) {
JSON_GTest::test("{ } /* ", false);
}
-TEST(utilities, json_missing_multiline_slash) {
+TEST_VM(utilities, json_missing_multiline_slash) {
JSON_GTest::test("/* { } *", false);
}
-TEST(utilities, json_commented_object_end) {
+TEST_VM(utilities, json_commented_object_end) {
JSON_GTest::test("{ /* } */", false);
}
-TEST(utilities, json_commented_array_end) {
+TEST_VM(utilities, json_commented_array_end) {
JSON_GTest::test("[ /* ] */", false);
}
-TEST(utilities, json_missing_object_end) {
+TEST_VM(utilities, json_missing_object_end) {
JSON_GTest::test("{ key : \"val\", /* } */", false);
}
-TEST(utilities, json_missing_array_end) {
+TEST_VM(utilities, json_missing_array_end) {
JSON_GTest::test("[ \"val\", /* ] */", false);
}
-TEST(utilities, json_key_values_1) {
+TEST_VM(utilities, json_key_values_1) {
JSON_GTest::test("/* comment */{ key1 : { \"key2\" : { \"key3\" : [ \"elem1\", \"elem2\","
"{ \"key4\" : null }, 3 , 2 , 1 , 0 , -1 , -2 , -3 , true, false, null, ] }, \"key5\""
" : true }, \"key6\" : [ \"☃\" ], key7 : \"val\",}", true);
}
-TEST(utilities, json_key_values_2) {
+TEST_VM(utilities, json_key_values_2) {
JSON_GTest::test("/* comment */ { \"key1\" : { \"key2\" : { \"key3\" : [ \"elem1\", \"elem2\","
"{ \"key4\" : null }, 3 , 2 , 1 , 0 , -1 , -2 , -3 , true, false, null, ] }, \"key5\""
" : true }, \"key6\" : [ \"☃\" ], key7 : \"val\",}", true);
}
-TEST(utilities, json_quoted_symbols) {
+TEST_VM(utilities, json_quoted_symbols) {
JSON_GTest::test("/*comment*/{\"ff1 fsd\":{\"☃\":{\"☃\":[\"☃\",\"☃\"]},"
"\"☃\":true},\"☃\":[\"☃\"],\"foo\":\"☃\",}", true);
}
-TEST(utilities, json_incorrect_key) {
+TEST_VM(utilities, json_incorrect_key) {
JSON_GTest::test("/* comment */ { key1 error : { \"☃\" : { \"☃\" : [ \"☃\","
" \"☃\" ] }, \"☃\" : true }, \"baz\" : [ \"☃\" ], foo : \"☃\",}",
false); // first key needs to be quoted since it contains a space
}
-TEST(utilities, json_array_with_newline) {
+TEST_VM(utilities, json_array_with_newline) {
JSON_GTest::test("[\n]", true);
}
-TEST(utilities, json_directives_file) {
+TEST_VM(utilities, json_directives_file) {
JSON_GTest::test(
"[" "\n"
" {"
--- a/hotspot/test/native/utilities/test_quicksort.cpp Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/native/utilities/test_quicksort.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
#include "precompiled.hpp"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/native/utilities/test_resourceHash.cpp Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,226 @@
+/*
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#include "precompiled.hpp"
+#include "memory/allocation.hpp"
+#include "memory/resourceArea.hpp"
+#include "unittest.hpp"
+#include "utilities/debug.hpp"
+#include "utilities/resourceHash.hpp"
+
+class CommonResourceHashtableTest : public ::testing::Test {
+ protected:
+ typedef void* K;
+ typedef int V;
+ const static MEMFLAGS MEM_TYPE = mtInternal;
+
+ static unsigned identity_hash(const K& k) {
+ return (unsigned) (uintptr_t) k;
+ }
+
+ static unsigned bad_hash(const K& k) {
+ return 1;
+ }
+
+ static void* as_K(uintptr_t val) {
+ return (void*) val;
+ }
+
+ class EqualityTestIter {
+ public:
+
+ bool do_entry(K const& k, V const& v) {
+ if ((uintptr_t) k != (uintptr_t) v) {
+ EXPECT_EQ((uintptr_t) k, (uintptr_t) v);
+ return false;
+ } else {
+ return true; // continue iteration
+ }
+ }
+ };
+};
+
+class SmallResourceHashtableTest : public CommonResourceHashtableTest {
+ protected:
+
+ template<
+ unsigned (*HASH) (K const&) = primitive_hash<K>,
+ bool (*EQUALS)(K const&, K const&) = primitive_equals<K>,
+ unsigned SIZE = 256,
+ ResourceObj::allocation_type ALLOC_TYPE = ResourceObj::RESOURCE_AREA
+ >
+ class Runner : public AllStatic {
+ public:
+
+ static void test(V step) {
+ EqualityTestIter et;
+ ResourceHashtable<K, V, HASH, EQUALS, SIZE, ALLOC_TYPE, MEM_TYPE> rh;
+
+ ASSERT_FALSE(rh.contains(as_K(step)));
+
+ ASSERT_TRUE(rh.put(as_K(step), step));
+ ASSERT_TRUE(rh.contains(as_K(step)));
+
+ ASSERT_FALSE(rh.put(as_K(step), step));
+
+ ASSERT_TRUE(rh.put(as_K(2 * step), 2 * step));
+ ASSERT_TRUE(rh.put(as_K(3 * step), 3 * step));
+ ASSERT_TRUE(rh.put(as_K(4 * step), 4 * step));
+ ASSERT_TRUE(rh.put(as_K(5 * step), 5 * step));
+
+ ASSERT_FALSE(rh.remove(as_K(0x0)));
+
+ rh.iterate(&et);
+ if (::testing::Test::HasFailure()) {
+ return;
+ }
+
+ ASSERT_TRUE(rh.remove(as_K(step)));
+ rh.iterate(&et);
+ }
+ };
+};
+
+TEST_VM_F(SmallResourceHashtableTest, default) {
+ ResourceMark rm;
+ Runner<>::test(0x1);
+}
+
+TEST_VM_F(SmallResourceHashtableTest, default_shifted) {
+ ResourceMark rm;
+ Runner<>::test(0x10);
+}
+
+TEST_VM_F(SmallResourceHashtableTest, bad_hash) {
+ ResourceMark rm;
+ Runner<bad_hash>::test(0x1);
+}
+
+TEST_VM_F(SmallResourceHashtableTest, bad_hash_shifted) {
+ ResourceMark rm;
+ Runner<bad_hash>::test(0x10);
+}
+
+TEST_VM_F(SmallResourceHashtableTest, identity_hash) {
+ ResourceMark rm;
+ Runner<identity_hash>::test(0x1);
+}
+
+TEST_VM_F(SmallResourceHashtableTest, identity_hash_shifted) {
+ ResourceMark rm;
+ Runner<identity_hash>::test(0x10);
+}
+
+TEST_VM_F(SmallResourceHashtableTest, primitive_hash_no_rm) {
+ Runner<primitive_hash<K>, primitive_equals<K>, 512, ResourceObj::C_HEAP>::test(0x1);
+}
+
+TEST_VM_F(SmallResourceHashtableTest, primitive_hash_no_rm_shifted) {
+ Runner<primitive_hash<K>, primitive_equals<K>, 512, ResourceObj::C_HEAP>::test(0x10);
+}
+
+TEST_VM_F(SmallResourceHashtableTest, bad_hash_no_rm) {
+ Runner<bad_hash, primitive_equals<K>, 512, ResourceObj::C_HEAP>::test(0x1);
+}
+
+TEST_VM_F(SmallResourceHashtableTest, bad_hash_no_rm_shifted) {
+ Runner<bad_hash, primitive_equals<K>, 512, ResourceObj::C_HEAP>::test(0x10);
+}
+
+TEST_VM_F(SmallResourceHashtableTest, identity_hash_no_rm) {
+ Runner<identity_hash, primitive_equals<K>, 1, ResourceObj::C_HEAP>::test(0x1);
+}
+
+TEST_VM_F(SmallResourceHashtableTest, identity_hash_no_rm_shifted) {
+ Runner<identity_hash, primitive_equals<K>, 1, ResourceObj::C_HEAP>::test(0x10);
+}
+
+class GenericResourceHashtableTest : public CommonResourceHashtableTest {
+ protected:
+
+ template<
+ unsigned (*HASH) (K const&) = primitive_hash<K>,
+ bool (*EQUALS)(K const&, K const&) = primitive_equals<K>,
+ unsigned SIZE = 256,
+ ResourceObj::allocation_type ALLOC_TYPE = ResourceObj::RESOURCE_AREA
+ >
+ class Runner : public AllStatic {
+ public:
+
+ static void test(unsigned num_elements = SIZE) {
+ EqualityTestIter et;
+ ResourceHashtable<K, V, HASH, EQUALS, SIZE, ALLOC_TYPE, MEM_TYPE> rh;
+
+ for (uintptr_t i = 0; i < num_elements; ++i) {
+ ASSERT_TRUE(rh.put(as_K(i), i));
+ }
+
+ rh.iterate(&et);
+ if (::testing::Test::HasFailure()) {
+ return;
+ }
+
+ for (uintptr_t i = num_elements; i > 0; --i) {
+ uintptr_t index = i - 1;
+ ASSERT_TRUE((rh.remove(as_K(index))));
+ }
+
+ rh.iterate(&et);
+ if (::testing::Test::HasFailure()) {
+ return;
+ }
+ for (uintptr_t i = num_elements; i > 0; --i) {
+ uintptr_t index = i - 1;
+ ASSERT_FALSE(rh.remove(as_K(index)));
+ }
+ rh.iterate(&et);
+ }
+ };
+};
+
+TEST_VM_F(GenericResourceHashtableTest, default) {
+ ResourceMark rm;
+ Runner<>::test();
+}
+
+TEST_VM_F(GenericResourceHashtableTest, bad_hash) {
+ ResourceMark rm;
+ Runner<bad_hash>::test();
+}
+
+TEST_VM_F(GenericResourceHashtableTest, identity_hash) {
+ ResourceMark rm;
+ Runner<identity_hash>::test();
+}
+
+TEST_VM_F(GenericResourceHashtableTest, primitive_hash_no_rm) {
+ Runner<primitive_hash<K>, primitive_equals<K>, 512, ResourceObj::C_HEAP>::test();
+}
+
+TEST_VM_F(GenericResourceHashtableTest, bad_hash_no_rm) {
+ Runner<bad_hash, primitive_equals<K>, 512, ResourceObj::C_HEAP>::test();
+}
+
+TEST_VM_F(GenericResourceHashtableTest, identity_hash_no_rm) {
+ Runner<identity_hash, primitive_equals<K>, 1, ResourceObj::C_HEAP>::test(512);
+}
--- a/hotspot/test/runtime/7116786/Test7116786.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/runtime/7116786/Test7116786.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/*
--- a/hotspot/test/runtime/7167069/PrintAsFlag.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/runtime/7167069/PrintAsFlag.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/*
--- a/hotspot/test/runtime/BootClassAppendProp/BootClassPathAppend.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/runtime/BootClassAppendProp/BootClassPathAppend.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/test/runtime/BootClassAppendProp/SunBootClassPath.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/runtime/BootClassAppendProp/SunBootClassPath.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/test/runtime/CommandLine/ObsoleteFlagErrorMessage.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/runtime/CommandLine/ObsoleteFlagErrorMessage.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, 2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/test/runtime/CommandLine/TraceExceptionsTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/runtime/CommandLine/TraceExceptionsTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -8,7 +8,7 @@
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
--- a/hotspot/test/runtime/Final/TestPutMain.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/runtime/Final/TestPutMain.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/*
--- a/hotspot/test/runtime/InternalApi/ThreadCpuTimesDeadlock.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/runtime/InternalApi/ThreadCpuTimesDeadlock.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/*
--- a/hotspot/test/runtime/MirrorFrame/Asmator.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/runtime/MirrorFrame/Asmator.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
import jdk.internal.org.objectweb.asm.*;
--- a/hotspot/test/runtime/MirrorFrame/Test8003720.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/runtime/MirrorFrame/Test8003720.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/*
--- a/hotspot/test/runtime/MirrorFrame/Victim.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/runtime/MirrorFrame/Victim.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
public class Victim implements Test8003720.CallMe {
--- a/hotspot/test/runtime/MirrorFrame/VictimClassLoader.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/runtime/MirrorFrame/VictimClassLoader.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
public class VictimClassLoader extends ClassLoader {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/RedefineTests/RedefineInterfaceMethods.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8081800
+ * @summary Redefine private and default interface methods
+ * @library /test/lib
+ * @modules java.base/jdk.internal.misc
+ * @modules java.compiler
+ * java.instrument
+ * jdk.jartool/sun.tools.jar
+ * @run main RedefineClassHelper
+ * @run main/othervm -javaagent:redefineagent.jar -Xlog:redefine+class*=trace RedefineInterfaceMethods
+ */
+public class RedefineInterfaceMethods {
+
+ static final int RET = -2;
+
+ static interface B {
+ int ORIGINAL_RETURN = 1;
+ int NEW_RETURN = 2;
+ private int privateMethod() {
+ return ORIGINAL_RETURN;
+ }
+ public default int defaultMethod() {
+ return privateMethod();
+ }
+ }
+
+ public static String redefinedPrivateMethod =
+ "interface RedefineInterfaceMethods$B {" +
+ " int ORIGINAL_RETURN = 1;" +
+ " int NEW_RETURN = 2;" +
+ " private int privateMethod() {" +
+ " return NEW_RETURN;" +
+ " }" +
+ " public default int defaultMethod() {" +
+ " return privateMethod();" +
+ " }" +
+ "}";
+
+ public static String redefinedDefaultMethod =
+ "interface RedefineInterfaceMethods$B {" +
+ " int ORIGINAL_RETURN = 1;" +
+ " int NEW_RETURN = 2;" +
+ " private int privateMethod() {" +
+ " return ORIGINAL_RETURN;" +
+ " }" +
+ " public default int defaultMethod() {" +
+ " return RedefineInterfaceMethods.RET;" +
+ " }" +
+ "}";
+
+ static class Impl implements B {
+ }
+
+
+ public static void main(String[] args) throws Exception {
+
+ Impl impl = new Impl();
+
+ int res = impl.defaultMethod();
+ if (res != B.ORIGINAL_RETURN)
+ throw new Error("defaultMethod returned " + res +
+ " expected " + B.ORIGINAL_RETURN);
+
+ RedefineClassHelper.redefineClass(B.class, redefinedPrivateMethod);
+
+ res = impl.defaultMethod();
+ if (res != B.NEW_RETURN)
+ throw new Error("defaultMethod returned " + res +
+ " expected " + B.NEW_RETURN);
+
+ System.gc();
+
+ RedefineClassHelper.redefineClass(B.class, redefinedDefaultMethod);
+
+ res = impl.defaultMethod();
+ if (res != RET)
+ throw new Error("defaultMethod returned " + res +
+ " expected " + RET);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/RedefineTests/RedefineLeak.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @library /test/lib
+ * @summary Test that redefinition reuses metaspace blocks that are freed
+ * @modules java.base/jdk.internal.misc
+ * @modules java.instrument
+ * jdk.jartool/sun.tools.jar
+ * @run main RedefineLeak buildagent
+ * @run main/othervm/timeout=6000 RedefineLeak runtest
+ */
+
+import java.io.FileNotFoundException;
+import java.io.PrintWriter;
+import java.lang.RuntimeException;
+import java.lang.instrument.ClassFileTransformer;
+import java.lang.instrument.Instrumentation;
+import java.security.ProtectionDomain;
+import java.lang.instrument.IllegalClassFormatException;
+import jdk.test.lib.process.ProcessTools;
+import jdk.test.lib.process.OutputAnalyzer;
+
+public class RedefineLeak {
+ static class Tester {}
+
+ static class LoggingTransformer implements ClassFileTransformer {
+ static int transformCount = 0;
+
+ public LoggingTransformer() {}
+
+ public byte[] transform(ClassLoader loader, String className, Class classBeingRedefined,
+ ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException {
+
+ transformCount++;
+ if (transformCount % 1000 == 0) System.out.println("transformCount:" + transformCount);
+ return null;
+ }
+ }
+
+ public static void premain(String agentArgs, Instrumentation inst) throws Exception {
+ LoggingTransformer t = new LoggingTransformer();
+ inst.addTransformer(t, true);
+ {
+ Class demoClass = Class.forName("RedefineLeak$Tester");
+
+ for (int i = 0; i < 10000; i++) {
+ inst.retransformClasses(demoClass);
+ }
+ }
+ System.gc();
+ }
+ private static void buildAgent() {
+ try {
+ ClassFileInstaller.main("RedefineLeak");
+ } catch (Exception e) {
+ throw new RuntimeException("Could not write agent classfile", e);
+ }
+
+ try {
+ PrintWriter pw = new PrintWriter("MANIFEST.MF");
+ pw.println("Premain-Class: RedefineLeak");
+ pw.println("Agent-Class: RedefineLeak");
+ pw.println("Can-Redefine-Classes: true");
+ pw.println("Can-Retransform-Classes: true");
+ pw.close();
+ } catch (FileNotFoundException e) {
+ throw new RuntimeException("Could not write manifest file for the agent", e);
+ }
+
+ sun.tools.jar.Main jarTool = new sun.tools.jar.Main(System.out, System.err, "jar");
+ if (!jarTool.run(new String[] { "-cmf", "MANIFEST.MF", "redefineagent.jar", "RedefineLeak.class" })) {
+ throw new RuntimeException("Could not write the agent jar file");
+ }
+ }
+ public static void main(String argv[]) throws Exception {
+ if (argv.length == 1 && argv[0].equals("buildagent")) {
+ buildAgent();
+ return;
+ }
+ if (argv.length == 1 && argv[0].equals("runtest")) {
+ // run outside of jtreg to not OOM on jtreg classes that are loaded after metaspace is full
+ String[] javaArgs1 = { "-XX:MetaspaceSize=12m", "-XX:MaxMetaspaceSize=12m",
+ "-javaagent:redefineagent.jar", "RedefineLeak"};
+ ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(javaArgs1);
+
+ OutputAnalyzer output = new OutputAnalyzer(pb.start());
+ output.shouldContain("transformCount:10000");
+ }
+ }
+}
--- a/hotspot/test/runtime/SelectionResolution/AbstractMethodErrorTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/runtime/SelectionResolution/AbstractMethodErrorTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
+ *
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
--- a/hotspot/test/runtime/SelectionResolution/classes/selectionresolution/Builder.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/runtime/SelectionResolution/classes/selectionresolution/Builder.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
package selectionresolution;
--- a/hotspot/test/runtime/SelectionResolution/classes/selectionresolution/ByteCodeClassLoader.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/runtime/SelectionResolution/classes/selectionresolution/ByteCodeClassLoader.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
package selectionresolution;
--- a/hotspot/test/runtime/SelectionResolution/classes/selectionresolution/ClassBuilder.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/runtime/SelectionResolution/classes/selectionresolution/ClassBuilder.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
package selectionresolution;
--- a/hotspot/test/runtime/SelectionResolution/classes/selectionresolution/ClassConstruct.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/runtime/SelectionResolution/classes/selectionresolution/ClassConstruct.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
package selectionresolution;
--- a/hotspot/test/runtime/SelectionResolution/classes/selectionresolution/Clazz.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/runtime/SelectionResolution/classes/selectionresolution/Clazz.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
package selectionresolution;
--- a/hotspot/test/runtime/SelectionResolution/classes/selectionresolution/HierarchyShape.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/runtime/SelectionResolution/classes/selectionresolution/HierarchyShape.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
package selectionresolution;
--- a/hotspot/test/runtime/SelectionResolution/classes/selectionresolution/Interface.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/runtime/SelectionResolution/classes/selectionresolution/Interface.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
package selectionresolution;
--- a/hotspot/test/runtime/SelectionResolution/classes/selectionresolution/Method.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/runtime/SelectionResolution/classes/selectionresolution/Method.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
package selectionresolution;
--- a/hotspot/test/runtime/SelectionResolution/classes/selectionresolution/MethodData.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/runtime/SelectionResolution/classes/selectionresolution/MethodData.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
package selectionresolution;
--- a/hotspot/test/runtime/SelectionResolution/classes/selectionresolution/TestBuilder.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/runtime/SelectionResolution/classes/selectionresolution/TestBuilder.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
package selectionresolution;
--- a/hotspot/test/runtime/SharedArchiveFile/DumpSymbolAndStringTable.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/runtime/SharedArchiveFile/DumpSymbolAndStringTable.java Wed Nov 09 10:04:43 2016 -0800
@@ -12,8 +12,7 @@
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
- * You should have received a copy of the GNU General Public License
- * version
+ * You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
@@ -21,6 +20,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
+
/*
* @test
* @bug 8059510
--- a/hotspot/test/runtime/StackGuardPages/exeinvoke.c Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/runtime/StackGuardPages/exeinvoke.c Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/* This code tests the fact that we actually remove stack guard page when calling
--- a/hotspot/test/runtime/Throwable/StackTraceLogging.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/runtime/Throwable/StackTraceLogging.java Wed Nov 09 10:04:43 2016 -0800
@@ -8,7 +8,7 @@
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
--- a/hotspot/test/runtime/Throwable/ThrowableIntrospectionSegfault.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/runtime/Throwable/ThrowableIntrospectionSegfault.java Wed Nov 09 10:04:43 2016 -0800
@@ -8,7 +8,7 @@
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
--- a/hotspot/test/runtime/classFileParserBug/AnnotationTag.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/runtime/classFileParserBug/AnnotationTag.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/*
--- a/hotspot/test/runtime/classFileParserBug/BadInitMethod.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/runtime/classFileParserBug/BadInitMethod.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/*
--- a/hotspot/test/runtime/classFileParserBug/BadNameAndType.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/runtime/classFileParserBug/BadNameAndType.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/*
--- a/hotspot/test/runtime/classFileParserBug/EnclosingMethod.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/runtime/classFileParserBug/EnclosingMethod.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/*
--- a/hotspot/test/runtime/classFileParserBug/InitInInterface.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/runtime/classFileParserBug/InitInInterface.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/*
--- a/hotspot/test/runtime/classFileParserBug/TestBadClassName.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/runtime/classFileParserBug/TestBadClassName.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/*
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/jni/PrivateInterfaceMethods/PrivateInterfaceMethods.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,179 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+ * @bug 8081800 8165827
+ * @summary Add JNI invocation tests for private interface methods
+ * @run main/native PrivateInterfaceMethods
+ */
+
+public class PrivateInterfaceMethods {
+
+ static {
+ System.loadLibrary("PrivateInterfaceMethods");
+ }
+
+ static native int callIntVoid(Object target, String definingClassName, String methodName, boolean virtual);
+ static native void lookupIntVoid(String definingClassName, String methodName);
+
+ static interface A {
+ static final int AmResult = 1;
+ private int m() { return AmResult; }
+ private int onlyA() { return 0; }
+ }
+
+ static interface B extends A {
+ // No m() here
+ private int onlyB() { return 0; }
+ }
+
+ static interface C extends B {
+ static final int CmResult = 2;
+ private int m() { return CmResult; } // unrelated to A.m
+ private int onlyC() { return 0; }
+ }
+
+ public static class Impl implements C {
+ static final int ImplmResult = 3;
+ private int m() { return ImplmResult; } // unrelated to A.m or C.m
+ }
+
+ // We found that itable/vtable construction was affected by whether or not the
+ // implementation class declared a method with the same signature as the
+ // private interface method, so we test both variants.
+
+ public static class Impl2 implements C {
+ }
+
+ public static void main(String[] args) {
+
+ // JNI getMethodID only works for methods declared in or inherited by a type.
+ // Private interface methods are not inherited and so should only be found
+ // in the declaring interface.
+
+ lookup(A.class.getName(), "onlyA", null); // should succeed
+ lookup(B.class.getName(), "onlyA", NoSuchMethodError.class); // should fail
+ lookup(C.class.getName(), "onlyA", NoSuchMethodError.class); // should fail
+ lookup(Impl.class.getName(), "onlyA", NoSuchMethodError.class); // should fail
+ lookup(Impl2.class.getName(), "onlyA", NoSuchMethodError.class); // should fail
+
+ lookup(B.class.getName(), "onlyB", null); // should succeed
+ lookup(A.class.getName(), "onlyB", NoSuchMethodError.class); // should fail
+ lookup(C.class.getName(), "onlyB", NoSuchMethodError.class); // should fail
+ lookup(Impl.class.getName(), "onlyB", NoSuchMethodError.class); // should fail
+ lookup(Impl2.class.getName(), "onlyB", NoSuchMethodError.class); // should fail
+
+ lookup(C.class.getName(), "onlyC", null); // should succeed
+ lookup(A.class.getName(), "onlyC", NoSuchMethodError.class); // should fail
+ lookup(B.class.getName(), "onlyC", NoSuchMethodError.class); // should fail
+ lookup(Impl.class.getName(), "onlyC", NoSuchMethodError.class); // should fail
+ lookup(Impl2.class.getName(), "onlyC", NoSuchMethodError.class); // should fail
+
+ Impl impl = new Impl();
+
+ // Note: JNI doesn't enforce access control so we can make
+ // private calls not possible in Java code.
+ // Also it doesn't check that the receiver is a type that
+ // defines the method!
+
+ // test: ((A)impl).m() - should succeed
+ test(impl, A.class.getName(), "m", A.AmResult, true, null);
+ test(impl, A.class.getName(), "m", A.AmResult, false, null);
+
+ // test: ((B)impl).m() - should fail: NoSuchMethodError
+ test(impl, B.class.getName(), "m", -1, true, NoSuchMethodError.class);
+ test(impl, B.class.getName(), "m", -1, false, NoSuchMethodError.class);
+
+ // test: ((C)impl).m() - should succeed
+ test(impl, C.class.getName(), "m", C.CmResult, true, null);
+ test(impl, C.class.getName(), "m", C.CmResult, false, null);
+
+ // test: impl.m() - should succeed
+ test(impl, Impl.class.getName(), "m", Impl.ImplmResult, true, null);
+ test(impl, Impl.class.getName(), "m", Impl.ImplmResult, false, null);
+
+ // ---
+
+ Impl2 impl2 = new Impl2();
+
+ // test: ((A)impl2).m() - should succeed
+ test(impl2, A.class.getName(), "m", A.AmResult, true, null);
+ test(impl2, A.class.getName(), "m", A.AmResult, false, null);
+
+ // test: ((B)impl2).m() - should fail: NoSuchMethodError
+ test(impl2, B.class.getName(), "m", -1, true, NoSuchMethodError.class);
+ test(impl2, B.class.getName(), "m", -1, false, NoSuchMethodError.class);
+
+ // test: ((C)impl2).m() - should succeed
+ test(impl2, C.class.getName(), "m", C.CmResult, true, null);
+ test(impl2, C.class.getName(), "m", C.CmResult, false, null);
+
+ // test: impl2.m() - should fail: NoSuchMethodError
+ test(impl2, Impl2.class.getName(), "m", -1, true, NoSuchMethodError.class);
+ test(impl2, Impl2.class.getName(), "m", -1, false, NoSuchMethodError.class);
+ }
+
+ static void lookup(String definingClass, String method, Class<?> expectedException) {
+
+ String desc = "Lookup of " + definingClass + "." + method;
+ try {
+ lookupIntVoid(definingClass, method);
+ if (expectedException != null)
+ throw new Error(desc + " succeeded - but expected exception "
+ + expectedException.getSimpleName());
+ System.out.println(desc + " - passed");
+ }
+ catch (Throwable t) {
+ if (t.getClass() != expectedException)
+ throw new Error(desc + " failed: got exception " + t + " but expected exception "
+ + expectedException.getSimpleName());
+ else
+ System.out.println(desc + " threw " + expectedException.getSimpleName() + " as expected");
+ }
+ }
+
+ static void test(Object target, String definingClass, String method,
+ int expected, boolean virtual, Class<?> expectedException) {
+
+ String desc = (virtual ? "Virtual" : "Nonvirtual") + " Invocation of " +
+ definingClass + "." + method + " on instance of class " +
+ target.getClass().getName();
+ try {
+ int res = callIntVoid(target, definingClass, method, virtual);
+ if (expectedException != null)
+ throw new Error(desc + " succeeded - but expected exception "
+ + expectedException.getSimpleName());
+ if (res != expected)
+ throw new Error(desc + " got wrong result: " + res + " instead of " + expected);
+ System.out.println(desc + " - passed");
+ }
+ catch (Throwable t) {
+ if (t.getClass() != expectedException)
+ throw new Error(desc + " failed: got exception " + t + " but expected exception "
+ + expectedException.getSimpleName());
+ else
+ System.out.println(desc + " threw " + expectedException.getSimpleName() + " as expected");
+ }
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/jni/PrivateInterfaceMethods/libPrivateInterfaceMethods.c Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#include <jni.h>
+
+// Private interface methods call test
+JNIEXPORT jint JNICALL
+Java_PrivateInterfaceMethods_callIntVoid(JNIEnv *env, jclass unused, jobject impl, jstring defining_class_name,
+ jstring method_name, jboolean virtual) {
+
+ // Lookup int method_name() in defining_class_name, and if it exists call impl.method_name()
+ // using a virtual or non-virtual invocation as indicated
+
+ jmethodID m_id = NULL;
+ jclass clazz = NULL;
+ const char* name = NULL;
+
+ name = (*env)->GetStringUTFChars(env, defining_class_name, NULL);
+ if (name == NULL) return -1;
+ clazz = (*env)->FindClass(env, name);
+ (*env)->ReleaseStringUTFChars(env, defining_class_name, name);
+ if ((*env)->ExceptionCheck(env)) return -1;
+
+ name = (*env)->GetStringUTFChars(env, method_name, NULL);
+ if (name == NULL) return -1;
+ m_id = (*env)->GetMethodID(env, clazz, name, "()I");
+ (*env)->ReleaseStringUTFChars(env, method_name, name);
+ if ((*env)->ExceptionCheck(env)) return -1;
+
+ if (!virtual)
+ return (*env)->CallNonvirtualIntMethod(env, impl, clazz, m_id);
+ else
+ return (*env)->CallIntMethod(env, impl, m_id);
+}
+
+// Private interface methods lookup test
+JNIEXPORT void JNICALL
+Java_PrivateInterfaceMethods_lookupIntVoid(JNIEnv *env, jclass unused,
+ jstring defining_class_name, jstring method_name) {
+
+ // Lookup int method_name() in defining_class_name
+
+ jmethodID m_id = NULL;
+ jclass clazz = NULL;
+ const char* name = NULL;
+
+ name = (*env)->GetStringUTFChars(env, defining_class_name, NULL);
+ if (name == NULL) return;
+ clazz = (*env)->FindClass(env, name);
+ (*env)->ReleaseStringUTFChars(env, defining_class_name, name);
+ if ((*env)->ExceptionCheck(env)) return;
+
+ name = (*env)->GetStringUTFChars(env, method_name, NULL);
+ if (name == NULL) return;
+ m_id = (*env)->GetMethodID(env, clazz, name, "()I");
+ (*env)->ReleaseStringUTFChars(env, method_name, name);
+}
+
--- a/hotspot/test/runtime/lambda-features/InvokespecialInterface.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/runtime/lambda-features/InvokespecialInterface.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/*
--- a/hotspot/test/runtime/lambda-features/PublicStaticInterfaceMethodHandling.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/runtime/lambda-features/PublicStaticInterfaceMethodHandling.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/*
--- a/hotspot/test/runtime/lambda-features/TestConcreteClassWithAbstractMethod.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/runtime/lambda-features/TestConcreteClassWithAbstractMethod.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/*
--- a/hotspot/test/runtime/lambda-features/TestInterfaceInit.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/runtime/lambda-features/TestInterfaceInit.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/*
--- a/hotspot/test/runtime/lambda-features/TestInterfaceOrder.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/runtime/lambda-features/TestInterfaceOrder.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/*
--- a/hotspot/test/runtime/lambda-features/TestStaticandInstance.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/runtime/lambda-features/TestStaticandInstance.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/*
--- a/hotspot/test/runtime/logging/BiasedLockingTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/runtime/logging/BiasedLockingTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -8,7 +8,7 @@
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
--- a/hotspot/test/runtime/logging/CompressedOopsTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/runtime/logging/CompressedOopsTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -8,7 +8,7 @@
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
--- a/hotspot/test/runtime/logging/DefaultMethodsTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/runtime/logging/DefaultMethodsTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -8,7 +8,7 @@
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
--- a/hotspot/test/runtime/logging/ExceptionsTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/runtime/logging/ExceptionsTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -8,7 +8,7 @@
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
--- a/hotspot/test/runtime/logging/ItablesTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/runtime/logging/ItablesTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -8,7 +8,7 @@
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
@@ -47,7 +47,7 @@
output.shouldContain(": Initializing itable indices for interface ");
output.shouldContain("itable index ");
output.shouldContain("target: ClassB.Method1()V, method_holder: ClassB target_method flags: public");
- output.shouldContain("invokeinterface resolved method: caller-class");
+ output.shouldContain("invokeinterface resolved interface method: caller-class");
output.shouldContain("invokespecial resolved method: caller-class:ClassB");
output.shouldContain("invokespecial selected method: resolved-class:ClassB");
output.shouldContain("invokeinterface selected method: receiver-class");
--- a/hotspot/test/runtime/logging/ModulesTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/runtime/logging/ModulesTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -8,7 +8,7 @@
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
--- a/hotspot/test/runtime/logging/MonitorInflationTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/runtime/logging/MonitorInflationTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -8,7 +8,7 @@
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
--- a/hotspot/test/runtime/logging/OsCpuLoggingTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/runtime/logging/OsCpuLoggingTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -8,7 +8,7 @@
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
--- a/hotspot/test/runtime/logging/SafepointCleanupTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/runtime/logging/SafepointCleanupTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -8,7 +8,7 @@
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
--- a/hotspot/test/runtime/logging/SafepointTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/runtime/logging/SafepointTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -8,7 +8,7 @@
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/logging/StackWalkTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+/*
+ * @test StackWalkTest
+ * @bug 8160064
+ * @summary -Xlog:stackwalk should produce logging from the source code
+ * @library /test/lib
+ * @run driver StackWalkTest
+ */
+
+import jdk.test.lib.process.ProcessTools;
+import jdk.test.lib.process.OutputAnalyzer;
+
+public class StackWalkTest {
+ static void analyzeOutputOn(ProcessBuilder pb) throws Exception {
+ OutputAnalyzer output = new OutputAnalyzer(pb.start());
+ output.shouldContain("Start walking");
+ output.shouldContain("fill_in_frames");
+ output.shouldHaveExitValue(0);
+ }
+
+ static void analyzeOutputOff(ProcessBuilder pb) throws Exception {
+ OutputAnalyzer output = new OutputAnalyzer(pb.start());
+ output.shouldNotContain("[stackwalk]");
+ output.shouldHaveExitValue(0);
+ }
+
+ public static void main(String... args) throws Exception {
+ ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:stackwalk=debug",
+ InnerClass.class.getName());
+ analyzeOutputOn(pb);
+
+ pb = ProcessTools.createJavaProcessBuilder("-Xlog:stackwalk=off",
+ InnerClass.class.getName());
+ analyzeOutputOff(pb);
+ }
+
+ public static class InnerClass {
+ public static void main(String[] args) throws Exception {
+ System.out.println("Testing stackwalk.");
+ StackWalker sw = StackWalker.getInstance();
+ sw.forEach(System.out::println);
+ }
+ }
+}
--- a/hotspot/test/runtime/logging/StartupTimeTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/runtime/logging/StartupTimeTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -8,7 +8,7 @@
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
--- a/hotspot/test/runtime/logging/VMOperationTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/runtime/logging/VMOperationTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -8,7 +8,7 @@
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
--- a/hotspot/test/runtime/logging/VerificationTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/runtime/logging/VerificationTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -8,7 +8,7 @@
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
--- a/hotspot/test/runtime/logging/VtablesTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/runtime/logging/VtablesTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -8,7 +8,7 @@
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
--- a/hotspot/test/runtime/logging/p1/A.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/runtime/logging/p1/A.java Wed Nov 09 10:04:43 2016 -0800
@@ -8,7 +8,7 @@
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
--- a/hotspot/test/runtime/logging/p1/C.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/runtime/logging/p1/C.java Wed Nov 09 10:04:43 2016 -0800
@@ -8,7 +8,7 @@
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
--- a/hotspot/test/runtime/logging/p2/D.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/runtime/logging/p2/D.java Wed Nov 09 10:04:43 2016 -0800
@@ -8,7 +8,7 @@
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/modules/PatchModule/PatchModuleClassList.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,142 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @summary classes which are not useable during run time should not be included in the classlist
+ * @library /test/lib
+ * @modules java.base/jdk.internal.misc
+ * jdk.jartool/sun.tools.jar
+ * @build PatchModuleMain
+ * @run main PatchModuleClassList
+ */
+
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import jdk.test.lib.InMemoryJavaCompiler;
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
+
+public class PatchModuleClassList {
+ private static final String BOOT_CLASS = "javax/naming/spi/NamingManager";
+ private static final String PLATFORM_CLASS = "javax/transaction/InvalidTransactionException";
+
+ public static void main(String args[]) throws Throwable {
+ // Case 1. A class to be loaded by the boot class loader
+
+ // Create a class file in the module java.naming. This class file
+ // will be put in the javanaming.jar file.
+ String source = "package javax.naming.spi; " +
+ "public class NamingManager { " +
+ " static { " +
+ " System.out.println(\"I pass!\"); " +
+ " } " +
+ "}";
+
+ ClassFileInstaller.writeClassToDisk(BOOT_CLASS,
+ InMemoryJavaCompiler.compile(BOOT_CLASS.replace('/', '.'), source, "-Xmodule:java.naming"),
+ System.getProperty("test.classes"));
+
+ // Build the jar file that will be used for the module "java.naming".
+ BasicJarBuilder.build("javanaming", BOOT_CLASS);
+ String moduleJar = BasicJarBuilder.getTestJar("javanaming.jar");
+
+ String classList = "javanaming.list";
+ ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
+ true,
+ "-XX:DumpLoadedClassList=" + classList,
+ "--patch-module=java.naming=" + moduleJar,
+ "PatchModuleMain", BOOT_CLASS.replace('/', '.'));
+ new OutputAnalyzer(pb.start()).shouldHaveExitValue(0);
+
+ // check the generated classlist file
+ String content = new String(Files.readAllBytes(Paths.get(classList)));
+ if (content.indexOf(BOOT_CLASS) >= 0) {
+ throw new RuntimeException(BOOT_CLASS + " should not be in the classlist");
+ }
+
+ // Case 2. A class to be loaded by the platform class loader
+
+ // Create a class file in the module java.transaction. This class file
+ // will be put in the javatransaction.jar file.
+ source = "package javax.transaction; " +
+ "public class InvalidTransactionException { " +
+ " static { " +
+ " System.out.println(\"I pass!\"); " +
+ " } " +
+ "}";
+
+ ClassFileInstaller.writeClassToDisk(PLATFORM_CLASS,
+ InMemoryJavaCompiler.compile(PLATFORM_CLASS.replace('/', '.'), source, "-Xmodule:java.transaction"),
+ System.getProperty("test.classes"));
+
+ // Build the jar file that will be used for the module "java.transaction".
+ BasicJarBuilder.build("javatransaction", PLATFORM_CLASS);
+ moduleJar = BasicJarBuilder.getTestJar("javatransaction.jar");
+
+ classList = "javatransaction.list";
+ pb = ProcessTools.createJavaProcessBuilder(
+ true,
+ "-XX:DumpLoadedClassList=" + classList,
+ "--patch-module=java.naming=" + moduleJar,
+ "PatchModuleMain", PLATFORM_CLASS.replace('/', '.'));
+ new OutputAnalyzer(pb.start()).shouldHaveExitValue(0);
+
+ // check the generated classlist file
+ content = new String(Files.readAllBytes(Paths.get(classList)));
+ if (content.indexOf(PLATFORM_CLASS) >= 0) {
+ throw new RuntimeException(PLATFORM_CLASS + " should not be in the classlist");
+ }
+
+ // Case 3. A class to be loaded from the bootclasspath/a
+
+ // Create a simple class file
+ source = "public class Hello { " +
+ " public static void main(String args[]) { " +
+ " System.out.println(\"Hello\"); " +
+ " } " +
+ "}";
+
+ ClassFileInstaller.writeClassToDisk("Hello",
+ InMemoryJavaCompiler.compile("Hello", source),
+ System.getProperty("test.classes"));
+
+ // Build hello.jar
+ BasicJarBuilder.build("hello", "Hello");
+ moduleJar = BasicJarBuilder.getTestJar("hello.jar");
+
+ classList = "hello.list";
+ pb = ProcessTools.createJavaProcessBuilder(
+ true,
+ "-XX:DumpLoadedClassList=" + classList,
+ "-Xbootclasspath/a:" + moduleJar,
+ "Hello");
+ new OutputAnalyzer(pb.start()).shouldHaveExitValue(0);
+
+ // check the generated classlist file
+ content = new String(Files.readAllBytes(Paths.get(classList)));
+ if (content.indexOf("Hello") < 0) {
+ throw new RuntimeException("Hello should be in the classlist");
+ }
+ }
+}
--- a/hotspot/test/runtime/stackMapCheck/StackMapCheck.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/runtime/stackMapCheck/StackMapCheck.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,26 +1,25 @@
- /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
/*
* @test
--- a/hotspot/test/runtime/verifier/PrimIntArray.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/runtime/verifier/PrimIntArray.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/*
--- a/hotspot/test/runtime/verifier/TraceClassRes.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/runtime/verifier/TraceClassRes.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/test/sanity/ExecuteInternalVMTests.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/sanity/ExecuteInternalVMTests.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,7 +19,6 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
/* @test ExecuteInternalVMTests
--- a/hotspot/test/serviceability/dcmd/vm/DynLibsTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/serviceability/dcmd/vm/DynLibsTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,11 +1,3 @@
-import org.testng.annotations.Test;
-import org.testng.Assert;
-
-import jdk.test.lib.process.OutputAnalyzer;
-import jdk.test.lib.Platform;
-import jdk.test.lib.dcmd.CommandExecutor;
-import jdk.test.lib.dcmd.JMXExecutor;
-
/*
* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -29,6 +21,14 @@
* questions.
*/
+import org.testng.annotations.Test;
+import org.testng.Assert;
+
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.Platform;
+import jdk.test.lib.dcmd.CommandExecutor;
+import jdk.test.lib.dcmd.JMXExecutor;
+
/*
* @test
* @summary Test of VM.dynlib diagnostic command via MBean
--- a/hotspot/test/serviceability/jvmti/TestLambdaFormRetransformation.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/serviceability/jvmti/TestLambdaFormRetransformation.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,4 +1,3 @@
-
/*
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
--- a/hotspot/test/serviceability/logging/TestLogRotation.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/serviceability/logging/TestLogRotation.java Wed Nov 09 10:04:43 2016 -0800
@@ -41,8 +41,8 @@
public static void main(String[] args) throws Exception {
long sizeOfLog = Long.parseLong(args[0]);
- long lines = sizeOfLog / 80;
- // full.GC generates ad least 1-line which is not shorter then 80 chars
+ long lines = sizeOfLog / 70;
+ // full.GC generates ad least 1-line which is not shorter then 70 chars
// for some GC 2 shorter lines are generated
for (long i = 0; i < lines; i++) {
System.gc();
--- a/hotspot/test/serviceability/tmtools/share/common/TmTool.java Wed Nov 09 15:20:30 2016 +0300
+++ b/hotspot/test/serviceability/tmtools/share/common/TmTool.java Wed Nov 09 10:04:43 2016 -0800
@@ -19,8 +19,8 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
+ */
- */
package common;
import java.nio.file.Path;
--- a/jaxp/.hgtags Wed Nov 09 15:20:30 2016 +0300
+++ b/jaxp/.hgtags Wed Nov 09 10:04:43 2016 -0800
@@ -384,3 +384,5 @@
8991d71c5316bde259e6a417c1199b008ca3cdf0 jdk-9+139
8d100cb9b04819b5bd09f33c7fd5b8628d1a456f jdk-9+140
037c095ba0c345edbeaaab52fda913a76c3930c0 jdk-9+141
+bdafa0cc34a97a2f8db4847a4efd34b407943591 jdk-9+142
+ce81d03ad7320dca3d673374c1a33bc0efd9136a jdk-9+143
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLDocumentScannerImpl.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLDocumentScannerImpl.java Wed Nov 09 10:04:43 2016 -0800
@@ -746,42 +746,18 @@
// scan XMLDecl
try {
if (fEntityScanner.skipString(xmlDecl)) {
- fMarkupDepth++;
- // NOTE: special case where document starts with a PI
- // whose name starts with "xml" (e.g. "xmlfoo")
- if (XMLChar.isName(fEntityScanner.peekChar())) {
- fStringBuffer.clear();
- fStringBuffer.append("xml");
- while (XMLChar.isName(fEntityScanner.peekChar())) {
- fStringBuffer.append((char)fEntityScanner.scanChar(null));
- }
- String target = fSymbolTable.addSymbol(fStringBuffer.ch, fStringBuffer.offset, fStringBuffer.length);
- //this function should fill the data.. and set the fEvent object to this event.
- fContentBuffer.clear() ;
- scanPIData(target, fContentBuffer);
- //REVISIT:where else we can set this value to 'true'
- fEntityManager.fCurrentEntity.mayReadChunks = true;
- //return PI event since PI was encountered
- return XMLEvent.PROCESSING_INSTRUCTION ;
+ if (fEntityScanner.peekChar() == ' ') {
+ fMarkupDepth++;
+ scanXMLDeclOrTextDecl(false);
+ } else {
+ // PI, reset position
+ fEntityManager.fCurrentEntity.position = 0;
}
- // standard XML declaration
- else {
- scanXMLDeclOrTextDecl(false);
- //REVISIT:where else we can set this value to 'true'
- fEntityManager.fCurrentEntity.mayReadChunks = true;
- return XMLEvent.START_DOCUMENT;
- }
- } else{
- //REVISIT:where else we can set this value to 'true'
- fEntityManager.fCurrentEntity.mayReadChunks = true;
- //In both case return the START_DOCUMENT. ony difference is that first block will
- //cosume the XML declaration if any.
- return XMLEvent.START_DOCUMENT;
}
-
//START_OF_THE_DOCUMENT
-
+ fEntityManager.fCurrentEntity.mayReadChunks = true;
+ return XMLEvent.START_DOCUMENT;
}
--- a/jaxp/src/java.xml/share/classes/javax/xml/stream/XMLEventReader.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jaxp/src/java.xml/share/classes/javax/xml/stream/XMLEventReader.java Wed Nov 09 10:04:43 2016 -0800
@@ -46,7 +46,10 @@
*/
public interface XMLEventReader extends Iterator {
/**
- * Get the next XMLEvent
+ * Gets the next XMLEvent. The initial event is
+ * {@link javax.xml.stream.events.StartDocument StartDocument}.
+ *
+ * @return the next XMLEvent
* @see XMLEvent
* @throws XMLStreamException if there is an error with the underlying XML.
* @throws java.util.NoSuchElementException iteration has no more elements.
@@ -58,12 +61,15 @@
* Returns true if there are more events and false otherwise.
* @return true if the event reader has more events, false otherwise
*/
+ @Override
public boolean hasNext();
/**
* Check the next XMLEvent without reading it from the stream.
* Returns null if the stream is at EOF or has no more XMLEvents.
* A call to peek() will be equal to the next return of next().
+ *
+ * @return the next XMLEvent
* @see XMLEvent
* @throws XMLStreamException
*/
@@ -73,6 +79,8 @@
* Reads the content of a text-only element. Precondition:
* the current event is START_ELEMENT. Postcondition:
* The current event is the corresponding END_ELEMENT.
+ *
+ * @return the text of the element
* @throws XMLStreamException if the current event is not a START_ELEMENT
* or if a non text element is encountered
*/
@@ -85,6 +93,8 @@
* be used when processing element-only content because
* the parser is not able to recognize ignorable whitespace if
* the DTD is missing or not interpreted.
+ *
+ * @return a START_ELEMENT or END_ELEMENT
* @throws XMLStreamException if anything other than space characters are encountered
*/
public XMLEvent nextTag() throws XMLStreamException;
--- a/jaxp/src/java.xml/share/classes/javax/xml/stream/XMLStreamReader.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jaxp/src/java.xml/share/classes/javax/xml/stream/XMLStreamReader.java Wed Nov 09 10:04:43 2016 -0800
@@ -28,7 +28,6 @@
package javax.xml.stream;
-import java.io.Reader;
import javax.xml.namespace.NamespaceContext;
import javax.xml.namespace.QName;
@@ -37,19 +36,26 @@
* It is designed to be the lowest level and most efficient way to
* read XML data.
*
- * <p> The XMLStreamReader is designed to iterate over XML using
+ * <p>
+ * The XMLStreamReader is designed to iterate over XML using
* next() and hasNext(). The data can be accessed using methods such as getEventType(),
* getNamespaceURI(), getLocalName() and getText();
*
- * <p> The <a href="#next()">next()</a> method causes the reader to read the next parse event.
- * The next() method returns an integer which identifies the type of event just read.
- * <p> The event type can be determined using <a href="#getEventType()">getEventType()</a>.
- * <p> Parsing events are defined as the XML Declaration, a DTD,
+ * <p>
+ * An XMLStreamReader instance is created with an initial event type START_DOCUMENT.
+ * At any moment in time, it has a current event that the methods of the interface
+ * access and may load the next event through the {@link #next() next()} method.
+ * The current event type can be determined by {@link #getEventType getEventType()}, and
+ * the next returned by the {@link #next() next()} method.
+ *
+ * <p>
+ * Parsing events are defined as the XML Declaration, a DTD,
* start tag, character data, white space, end tag, comment,
* or processing instruction. An attribute or namespace event may be encountered
* at the root level of a document as the result of a query operation.
*
- * <p>For XML 1.0 compliance an XML processor must pass the
+ * <p>
+ * For XML 1.0 compliance an XML processor must pass the
* identifiers of declared unparsed entities, notation declarations and their
* associated identifiers to the application. This information is
* provided through the property API on this interface.
@@ -63,7 +69,8 @@
* These properties can only be accessed during a DTD event and
* are defined to return null if the information is not available.
*
- * <p>The following table describes which methods are valid in what state.
+ * <p>
+ * The following table describes which methods are valid in what state.
* If a method is called in an invalid state the method will throw a
* java.lang.IllegalStateException.
*
@@ -502,8 +509,10 @@
// public void recycle() throws XMLStreamException;
/**
- * Returns an integer code that indicates the type
- * of the event the cursor is pointing to.
+ * Returns an integer code that indicates the type of the event the cursor is
+ * pointing to. The initial event type is {@link #START_DOCUMENT}.
+ *
+ * @return the type of the current event
*/
public int getEventType();
@@ -590,6 +599,8 @@
/**
* Returns the offset into the text character array where the first
* character (of this text event) is stored.
+ *
+ * @return the starting position of the text in the character array
* @throws java.lang.IllegalStateException if this state is not
* a valid text state.
*/
@@ -598,6 +609,8 @@
/**
* Returns the length of the sequence of characters for this
* Text event within the text character array.
+ *
+ * @return the length of the text
* @throws java.lang.IllegalStateException if this state is not
* a valid text state.
*/
@@ -610,9 +623,11 @@
public String getEncoding();
/**
- * Return true if the current event has text, false otherwise
+ * Return a boolean indicating whether the current event has text.
* The following events have text:
* CHARACTERS,DTD ,ENTITY_REFERENCE, COMMENT, SPACE
+ *
+ * @return true if the event has text, false otherwise
*/
public boolean hasText();
@@ -623,6 +638,7 @@
* location and null for the publicId and systemId.
* The location information is only valid until next() is
* called.
+ * @return the location of the cursor
*/
public Location getLocation();
@@ -647,8 +663,10 @@
public String getLocalName();
/**
- * returns true if the current event has a name (is a START_ELEMENT or END_ELEMENT)
- * returns false otherwise
+ * returns a boolean indicating whether the current event has a name
+ * (is a START_ELEMENT or END_ELEMENT).
+ *
+ * @return true if the event has a name, false otherwise
*/
public boolean hasName();
--- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/SAXParserTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/SAXParserTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -24,20 +24,16 @@
package javax.xml.parsers.ptests;
import static javax.xml.parsers.ptests.ParserTestConst.XML_DIR;
-import static jaxp.library.JAXPTestUtilities.USER_DIR;
import static jaxp.library.JAXPTestUtilities.tryRunWithTmpPermission;
import java.io.File;
import java.io.FileInputStream;
-import java.io.FilePermission;
import java.io.IOException;
import java.util.PropertyPermission;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
-import jaxp.library.JAXPTestUtilities;
-
import org.testng.annotations.DataProvider;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test;
@@ -189,8 +185,7 @@
*/
@Test(expectedExceptions = { SAXException.class, IOException.class }, dataProvider = "parser-provider")
public void testParse09(SAXParser saxparser) throws Exception {
- JAXPTestUtilities.tryRunWithTmpPermission(() -> saxparser.parse(" ", new DefaultHandler()),
- new FilePermission(USER_DIR + " ", "read"));
+ saxparser.parse("no-such-file", new DefaultHandler());
}
/**
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogInvalidPathTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package catalog;
+
+import javax.xml.catalog.CatalogFeatures;
+
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+/*
+ * @test
+ * @bug 8151154
+ * @run testng/othervm catalog.CatalogInvalidPathTest
+ * @summary Verifies that the CatalogFeatures' builder throws
+ * IllegalArgumentException on invalid file inputs.
+ * This test was splitted from CatalogTest.java due to
+ * JDK-8168968, it has to only run without SecurityManager
+ * because an ACE will be thrown for invalid path.
+ */
+public class CatalogInvalidPathTest {
+ /*
+ DataProvider: for testing the verification of file paths by
+ the CatalogFeatures builder
+ */
+ @DataProvider(name = "invalidPaths")
+ public Object[][] getFiles() {
+ return new Object[][]{
+ {null},
+ {""},
+ {"file:a/b\\c"},
+ {"file:/../../.."},
+ {"c:/te:t"},
+ {"c:/te?t"},
+ {"c/te*t"},
+ {"in|valid.txt"},
+ {"shema:invalid.txt"},
+ };
+ }
+
+ @Test(dataProvider = "invalidPaths", expectedExceptions = IllegalArgumentException.class)
+ public void testFileInput(String file) {
+ CatalogFeatures features = CatalogFeatures.builder()
+ .with(CatalogFeatures.Feature.FILES, file)
+ .build();
+ }
+}
--- a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -23,18 +23,16 @@
package catalog;
import static jaxp.library.JAXPTestUtilities.clearSystemProperty;
-import static jaxp.library.JAXPTestUtilities.getSystemProperty;
import static jaxp.library.JAXPTestUtilities.setSystemProperty;
import java.io.File;
import java.io.FileInputStream;
-import java.io.FilePermission;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringReader;
import java.io.StringWriter;
import java.nio.file.Paths;
-import java.util.PropertyPermission;
+
import javax.xml.XMLConstants;
import javax.xml.catalog.Catalog;
import javax.xml.catalog.CatalogException;
@@ -57,7 +55,6 @@
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
import javax.xml.validation.Validator;
-import jaxp.library.JAXPTestUtilities;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
@@ -73,7 +70,7 @@
/*
* @test
- * @bug 8081248 8144966 8146606 8146237 8151154 8150969 8151162 8152527 8154220 8163232
+ * @bug 8081248 8144966 8146606 8146237 8150969 8151162 8152527 8154220 8163232
* @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
* @run testng/othervm -DrunSecMngr=true catalog.CatalogTest
* @run testng/othervm catalog.CatalogTest
@@ -459,21 +456,6 @@
Catalog catalog = CatalogManager.catalog(features, catalogFile);
}
- /**
- * @bug 8151154
- * Verifies that the CatalogFeatures' builder throws IllegalArgumentException
- * on invalid file inputs.
- * @param file the file path
- */
- @Test(dataProvider = "invalidPaths", expectedExceptions = IllegalArgumentException.class)
- public void testFileInput(String file) {
- JAXPTestUtilities.runWithTmpPermission(() -> {
- CatalogFeatures features = CatalogFeatures.builder()
- .with(CatalogFeatures.Feature.FILES, file)
- .build();
- }, new FilePermission("/../../..", "read"), new FilePermission("c:\\te:t", "read"),
- new FilePermission("c:\\te?t", "read"), new PropertyPermission("user.dir", "read"));
- }
/**
* @bug 8146237
@@ -736,24 +718,6 @@
};
}
- /*
- DataProvider: for testing the verification of file paths by
- the CatalogFeatures builder
- */
- @DataProvider(name = "invalidPaths")
- public Object[][] getFiles() {
- return new Object[][]{
- {null},
- {""},
- {"file:a/b\\c"},
- {"file:/../../.."},
- {"c:/te:t"},
- {"c:/te?t"},
- {"c/te*t"},
- {"in|valid.txt"},
- {"shema:invalid.txt"},
- };
- }
/*
DataProvider: provides test name, expected string, the catalog, and XML
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/BugTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/BugTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -24,17 +24,20 @@
package stream.XMLStreamReaderTest;
import java.io.StringReader;
+import javax.xml.stream.XMLEventReader;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.XMLStreamReader;
import org.testng.Assert;
+import org.testng.annotations.DataProvider;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test;
/*
* @test
+ * @bug 8069098
* @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
* @run testng/othervm -DrunSecMngr=true stream.XMLStreamReaderTest.BugTest
* @run testng/othervm stream.XMLStreamReaderTest.BugTest
@@ -43,11 +46,70 @@
@Listeners({jaxp.library.BasePolicy.class})
public class BugTest {
- @Test
- public static void test1() throws Exception {
- XMLInputFactory xif = XMLInputFactory.newInstance(); // new
- // com.sun.xml.stream.ZephyrParserFactory();
- XMLStreamReader r = xif.createXMLStreamReader(new StringReader("<foo/>"));
- Assert.assertEquals(XMLStreamConstants.START_DOCUMENT, r.getEventType());
+ /**
+ * Verifies that the initial event of an XMLStreamReader instance is
+ * START_DOCUMENT.
+ *
+ * @param xml the xml input
+ * @param type1 the type of the 1st event
+ * @param type2 the type of the 2nd event
+ * @throws Exception if the test fails to run properly
+ */
+ @Test(dataProvider = "xmls")
+ public static void test1(String xml, int type1, int type2) throws Exception {
+ XMLInputFactory factory = XMLInputFactory.newFactory();
+
+ XMLStreamReader reader = factory.createXMLStreamReader(new StringReader(xml));
+ int type1stEvent = reader.getEventType();
+ int type2ndEvent = reader.next();
+ System.out.println("First event: " + type1stEvent);
+ System.out.println("2nd event: " + type2ndEvent);
+ Assert.assertEquals(type1, type1stEvent);
+ Assert.assertEquals(type2, type2ndEvent);
+ }
+
+
+ /**
+ * Verifies that the initial event of an XMLEventReader instance is
+ * START_DOCUMENT. XMLEventReader depends on XMLStreamReader.
+ *
+ * @param xml the xml input
+ * @param type1 the type of the 1st event
+ * @param type2 the type of the 2nd event
+ * @throws Exception if the test fails to run properly
+ */
+ @Test(dataProvider = "xmls")
+ public static void test2(String xml, int type1, int type2) throws Exception {
+ XMLInputFactory factory = XMLInputFactory.newFactory();
+
+ XMLEventReader reader = factory.createXMLEventReader(new StringReader(xml));
+ int type1stEvent = reader.nextEvent().getEventType();
+ int type2ndEvent = reader.nextEvent().getEventType();
+ System.out.println("First event: " + type1stEvent);
+ System.out.println("2nd event: " + type2ndEvent);
+ Assert.assertEquals(type1, type1stEvent);
+ Assert.assertEquals(type2, type2ndEvent);
+ }
+
+ /*
+ DataProvider: for testing beginning event type
+ Data: xml, 1st event type, 2nd event type
+ */
+ @DataProvider(name = "xmls")
+ public Object[][] getXMLs() {
+
+ return new Object[][]{
+ {"<?xml version='1.0'?><foo/>",
+ XMLStreamConstants.START_DOCUMENT, XMLStreamConstants.START_ELEMENT},
+ {"<foo/>",
+ XMLStreamConstants.START_DOCUMENT, XMLStreamConstants.START_ELEMENT},
+ {"<?xml version='1.0'?>"
+ + "<?xml-stylesheet href=\"bar.xsl\" type=\"text/xsl\"?>" +
+ "<foo/>",
+ XMLStreamConstants.START_DOCUMENT, XMLStreamConstants.PROCESSING_INSTRUCTION},
+ {"<?xml-stylesheet href=\"bar.xsl\" type=\"text/xsl\"?>" +
+ "<foo/>",
+ XMLStreamConstants.START_DOCUMENT, XMLStreamConstants.PROCESSING_INSTRUCTION},
+ };
}
}
--- a/jaxws/.hgtags Wed Nov 09 15:20:30 2016 +0300
+++ b/jaxws/.hgtags Wed Nov 09 10:04:43 2016 -0800
@@ -387,3 +387,5 @@
7a7aadf3c4500cc273c889aa1172d4fe3844bb6b jdk-9+139
9004617323fe99cbe4fad48f373cb2ed4fc50aa6 jdk-9+140
b2c18f755228d1d19a86cd7d5fa1abb6b1495dfb jdk-9+141
+59101416d90160cfcb4f45dfbccaec15e2c27a29 jdk-9+142
+1c988e708a06257119d54d8a57e99e3b0f37ff18 jdk-9+143
--- a/jdk/.hgtags Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/.hgtags Wed Nov 09 10:04:43 2016 -0800
@@ -385,3 +385,4 @@
e93b7ea559759f036c9f69fd2ddaf47bb4e98385 jdk-9+140
8d752af5f61d41f226adf2cda72a20faa9ad620a jdk-9+141
6ce43dd8e954b452f330dd7a412df5107f7e1923 jdk-9+142
+8dbc8594f9d5149bf1c22221272284609408227a jdk-9+143
--- a/jdk/make/GenerateClasslist.gmk Wed Nov 09 15:20:30 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,74 +0,0 @@
-#
-# Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation. Oracle designates this
-# particular file as subject to the "Classpath" exception as provided
-# by Oracle in the LICENSE file that accompanied this code.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-################################################################################
-# Generate classlist
-################################################################################
-
-default: all
-
-include $(SPEC)
-include MakeBase.gmk
-include Tools.gmk
-include JarArchive.gmk
-
-################################################################################
-# Create a jar with our generator class. Using a jar is intentional since it
-# will load more classes
-
-$(eval $(call SetupJarArchive, CLASSLIST_JAR, \
- SRCS := $(BUILDTOOLS_OUTPUTDIR)/jdk_tools_classes, \
- INCLUDES := build/tools/classlist, \
- JAR := $(SUPPORT_OUTPUTDIR)/classlist.jar, \
-))
-
-TARGETS += $(CLASSLIST_JAR)
-
-################################################################################
-
-CLASSLIST_FILE := $(SUPPORT_OUTPUTDIR)/classlist/classlist
-
-JLI_TRACE_FILE := $(SUPPORT_OUTPUTDIR)/classlist/jli_trace.out
-
-# If an external buildjdk has been supplied, we don't build a separate interim
-# image, so just use the external build jdk instead.
-ifeq ($(EXTERNAL_BUILDJDK), true)
- INTERIM_IMAGE_DIR := $(BUILD_JDK)
-endif
-
-$(CLASSLIST_FILE): $(INTERIM_IMAGE_DIR)/bin/java$(EXE_SUFFIX) $(CLASSLIST_JAR)
- $(call MakeDir, $(@D))
- $(call LogInfo, Generating lib/classlist)
- $(FIXPATH) $(INTERIM_IMAGE_DIR)/bin/java -XX:DumpLoadedClassList=$@ \
- -Djava.lang.invoke.MethodHandle.TRACE_RESOLVE=true \
- -cp $(SUPPORT_OUTPUTDIR)/classlist.jar \
- build.tools.classlist.HelloClasslist \
- $(LOG_DEBUG) 2>&1 > $(JLI_TRACE_FILE)
-
-TARGETS += $(CLASSLIST_FILE)
-
-################################################################################
-
-all: $(TARGETS)
--- a/jdk/make/copy/Copy-java.base.gmk Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/make/copy/Copy-java.base.gmk Wed Nov 09 10:04:43 2016 -0800
@@ -33,7 +33,6 @@
#
TARGETS += \
$(INCLUDE_DST_DIR)/jni.h \
- $(INCLUDE_DST_DIR)/jvmti.h \
$(INCLUDE_DST_DIR)/jvmticmlr.h \
$(INCLUDE_DST_DIR)/classfile_constants.h \
$(INCLUDE_DST_OS_DIR)/jni_md.h \
--- a/jdk/make/data/tzdata/VERSION Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/make/data/tzdata/VERSION Wed Nov 09 10:04:43 2016 -0800
@@ -21,4 +21,4 @@
# or visit www.oracle.com if you need additional information or have any
# questions.
#
-tzdata2016h
+tzdata2016i
--- a/jdk/make/data/tzdata/antarctica Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/make/data/tzdata/antarctica Wed Nov 09 10:04:43 2016 -0800
@@ -87,13 +87,18 @@
# Background:
# http://www.timeanddate.com/news/time/antartica-time-changes-2010.html
+# From Steffen Thorsen (2016-10-28):
+# Australian Antarctica Division informed us that Casey changed time
+# zone to UTC+11 in "the morning of 22nd October 2016".
+
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone Antarctica/Casey 0 - -00 1969
8:00 - +08 2009 Oct 18 2:00
11:00 - +11 2010 Mar 5 2:00
8:00 - +08 2011 Oct 28 2:00
11:00 - +11 2012 Feb 21 17:00u
- 8:00 - +08
+ 8:00 - +08 2016 Oct 22
+ 11:00 - +11
Zone Antarctica/Davis 0 - -00 1957 Jan 13
7:00 - +07 1964 Nov
0 - -00 1969 Feb
--- a/jdk/make/data/tzdata/asia Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/make/data/tzdata/asia Wed Nov 09 10:04:43 2016 -0800
@@ -794,9 +794,19 @@
###############################################################################
# Cyprus
-#
+
# Milne says the Eastern Telegraph Company used 2:14:00. Stick with LMT.
+# IATA SSIM (1998-09) has Cyprus using EU rules for the first time.
+
+# From Paul Eggert (2016-09-09):
+# Yesterday's Cyprus Mail reports that Northern Cyprus followed Turkey's
+# lead and switched from +02/+03 to +03 year-round.
+# http://cyprus-mail.com/2016/09/08/two-time-zones-cyprus-turkey-will-not-turn-clocks-back-next-month/
#
+# From Even Scharning (2016-10-31):
+# Looks like the time zone split in Cyprus went through last night.
+# http://cyprus-mail.com/2016/10/30/cyprus-new-division-two-time-zones-now-reality/
+
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
Rule Cyprus 1975 only - Apr 13 0:00 1:00 S
Rule Cyprus 1975 only - Oct 12 0:00 0 -
@@ -811,7 +821,10 @@
Zone Asia/Nicosia 2:13:28 - LMT 1921 Nov 14
2:00 Cyprus EE%sT 1998 Sep
2:00 EUAsia EE%sT
-# IATA SSIM (1998-09) has Cyprus using EU rules for the first time.
+Zone Asia/Famagusta 2:15:48 - LMT 1921 Nov 14
+ 2:00 Cyprus EE%sT 1998 Sep
+ 2:00 EUAsia EE%sT 2016 Sep 8
+ 3:00 - +03
# Classically, Cyprus belongs to Asia; e.g. see Herodotus, Histories, I.72.
# However, for various reasons many users expect to find it under Europe.
--- a/jdk/make/data/tzdata/australasia Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/make/data/tzdata/australasia Wed Nov 09 10:04:43 2016 -0800
@@ -725,11 +725,13 @@
Rule Tonga 2000 only - Mar 19 2:00s 0 -
Rule Tonga 2000 2001 - Nov Sun>=1 2:00 1:00 S
Rule Tonga 2001 2002 - Jan lastSun 2:00 0 -
+Rule Tonga 2016 max - Nov Sun>=1 2:00 1:00 S
+Rule Tonga 2017 max - Jan Sun>=15 3:00 0 -
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone Pacific/Tongatapu 12:19:20 - LMT 1901
- 12:20 - TOT 1941 # Tonga Time
- 13:00 - TOT 1999
- 13:00 Tonga TO%sT
+ 12:20 - +1220 1941
+ 13:00 - +13 1999
+ 13:00 Tonga +13/+14
# Tuvalu
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
@@ -1735,9 +1737,17 @@
# of January the standard time in the Kingdom shall be moved backward by one
# hour to 1:00am.
-# From Pulu 'Anau (2002-11-05):
+# From Pulu ʻAnau (2002-11-05):
# The law was for 3 years, supposedly to get renewed. It wasn't.
+# From Pulu ʻAnau (2016-10-27):
+# http://mic.gov.to/news-today/press-releases/6375-daylight-saving-set-to-run-from-6-november-2016-to-15-january-2017
+# Cannot find anyone who knows the rules, has seen the duration or has seen
+# the cabinet decision, but it appears we are following Fiji's rule set.
+#
+# From Tim Parenti (2016-10-26):
+# Assume Tonga will observe DST from the first Sunday in November at 02:00
+# through the third Sunday in January at 03:00, like Fiji, for now.
# Wake
--- a/jdk/make/data/tzdata/europe Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/make/data/tzdata/europe Wed Nov 09 10:04:43 2016 -0800
@@ -1523,73 +1523,84 @@
# But these events all occurred before the 1970 cutoff,
# so record only the time in Rome.
#
-# From Paul Eggert (2006-03-22):
-# For Italian DST we have three sources: Shanks & Pottenger, Whitman, and
-# F. Pollastri
-# Day-light Saving Time in Italy (2006-02-03)
-# http://toi.iriti.cnr.it/uk/ienitlt.html
-# ('FP' below), taken from an Italian National Electrotechnical Institute
-# publication. When the three sources disagree, guess who's right, as follows:
+# From Michael Deckers (2016-10-24):
+# http://www.ac-ilsestante.it/MERIDIANE/ora_legale quotes a law of 1893-08-10
+# ... [translated as] "The preceding dispositions will enter into
+# force at the instant at which, according to the time specified in
+# the 1st article, the 1st of November 1893 will begin...."
#
-# year FP Shanks&P. (S) Whitman (W) Go with:
-# 1916 06-03 06-03 24:00 06-03 00:00 FP & W
-# 09-30 09-30 24:00 09-30 01:00 FP; guess 24:00s
-# 1917 04-01 03-31 24:00 03-31 00:00 FP & S
-# 09-30 09-29 24:00 09-30 01:00 FP & W
-# 1918 03-09 03-09 24:00 03-09 00:00 FP & S
-# 10-06 10-05 24:00 10-06 01:00 FP & W
-# 1919 03-01 03-01 24:00 03-01 00:00 FP & S
-# 10-04 10-04 24:00 10-04 01:00 FP; guess 24:00s
-# 1920 03-20 03-20 24:00 03-20 00:00 FP & S
-# 09-18 09-18 24:00 10-01 01:00 FP; guess 24:00s
-# 1944 04-02 04-03 02:00 S (see C-Eur)
-# 09-16 10-02 03:00 FP; guess 24:00s
-# 1945 09-14 09-16 24:00 FP; guess 24:00s
-# 1970 05-21 05-31 00:00 S
-# 09-20 09-27 00:00 S
+# From Pierpaolo Bernardi (2016-10-20):
+# The authoritative source for time in Italy is the national metrological
+# institute, which has a summary page of historical DST data at
+# http://www.inrim.it/res/tf/ora_legale_i.shtml
+# (2016-10-24):
+# http://www.renzobaldini.it/le-ore-legali-in-italia/
+# has still different data for 1944. It divides Italy in two, as
+# there were effectively two governments at the time, north of Gothic
+# Line German controlled territory, official government RSI, and south
+# of the Gothic Line, controlled by allied armies.
+#
+# From Brian Inglis (2016-10-23):
+# Viceregal LEGISLATIVE DECREE. 14 September 1944, no. 219.
+# Restoration of Standard Time. (044U0219) (OJ 62 of 30.9.1944) ...
+# Given the R. law decreed on 1944-03-29, no. 92, by which standard time is
+# advanced to sixty minutes later starting at hour two on 1944-04-02; ...
+# Starting at hour three on the date 1944-09-17 standard time will be resumed.
+#
+# From Paul Eggert (2016-10-27):
+# Go with INRiM for DST rules, except as corrected by Inglis for 1944
+# for the Kingdom of Italy. This is consistent with Renzo Baldini.
+# Model Rome's occupation by using using C-Eur rules from 1943-09-10
+# to 1944-06-04; although Rome was an open city during this period, it
+# was effectively controlled by Germany.
#
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
-Rule Italy 1916 only - Jun 3 0:00s 1:00 S
-Rule Italy 1916 only - Oct 1 0:00s 0 -
-Rule Italy 1917 only - Apr 1 0:00s 1:00 S
-Rule Italy 1917 only - Sep 30 0:00s 0 -
-Rule Italy 1918 only - Mar 10 0:00s 1:00 S
-Rule Italy 1918 1919 - Oct Sun>=1 0:00s 0 -
-Rule Italy 1919 only - Mar 2 0:00s 1:00 S
-Rule Italy 1920 only - Mar 21 0:00s 1:00 S
-Rule Italy 1920 only - Sep 19 0:00s 0 -
-Rule Italy 1940 only - Jun 15 0:00s 1:00 S
-Rule Italy 1944 only - Sep 17 0:00s 0 -
-Rule Italy 1945 only - Apr 2 2:00 1:00 S
-Rule Italy 1945 only - Sep 15 0:00s 0 -
-Rule Italy 1946 only - Mar 17 2:00s 1:00 S
-Rule Italy 1946 only - Oct 6 2:00s 0 -
-Rule Italy 1947 only - Mar 16 0:00s 1:00 S
-Rule Italy 1947 only - Oct 5 0:00s 0 -
-Rule Italy 1948 only - Feb 29 2:00s 1:00 S
-Rule Italy 1948 only - Oct 3 2:00s 0 -
-Rule Italy 1966 1968 - May Sun>=22 0:00 1:00 S
-Rule Italy 1966 1969 - Sep Sun>=22 0:00 0 -
-Rule Italy 1969 only - Jun 1 0:00 1:00 S
-Rule Italy 1970 only - May 31 0:00 1:00 S
-Rule Italy 1970 only - Sep lastSun 0:00 0 -
-Rule Italy 1971 1972 - May Sun>=22 0:00 1:00 S
-Rule Italy 1971 only - Sep lastSun 1:00 0 -
-Rule Italy 1972 only - Oct 1 0:00 0 -
-Rule Italy 1973 only - Jun 3 0:00 1:00 S
-Rule Italy 1973 1974 - Sep lastSun 0:00 0 -
-Rule Italy 1974 only - May 26 0:00 1:00 S
-Rule Italy 1975 only - Jun 1 0:00s 1:00 S
-Rule Italy 1975 1977 - Sep lastSun 0:00s 0 -
-Rule Italy 1976 only - May 30 0:00s 1:00 S
-Rule Italy 1977 1979 - May Sun>=22 0:00s 1:00 S
-Rule Italy 1978 only - Oct 1 0:00s 0 -
-Rule Italy 1979 only - Sep 30 0:00s 0 -
+Rule Italy 1916 only - Jun 3 24:00 1:00 S
+Rule Italy 1916 1917 - Sep 30 24:00 0 -
+Rule Italy 1917 only - Mar 31 24:00 1:00 S
+Rule Italy 1918 only - Mar 9 24:00 1:00 S
+Rule Italy 1918 only - Oct 6 24:00 0 -
+Rule Italy 1919 only - Mar 1 24:00 1:00 S
+Rule Italy 1919 only - Oct 4 24:00 0 -
+Rule Italy 1920 only - Mar 20 24:00 1:00 S
+Rule Italy 1920 only - Sep 18 24:00 0 -
+Rule Italy 1940 only - Jun 14 24:00 1:00 S
+Rule Italy 1942 only - Nov 2 2:00s 0 -
+Rule Italy 1943 only - Mar 29 2:00s 1:00 S
+Rule Italy 1943 only - Oct 4 2:00s 0 -
+Rule Italy 1944 only - Apr 2 2:00s 1:00 S
+Rule Italy 1944 only - Sep 17 2:00s 0 -
+Rule Italy 1945 only - Apr 2 2:00 1:00 S
+Rule Italy 1945 only - Sep 15 1:00 0 -
+Rule Italy 1946 only - Mar 17 2:00s 1:00 S
+Rule Italy 1946 only - Oct 6 2:00s 0 -
+Rule Italy 1947 only - Mar 16 0:00s 1:00 S
+Rule Italy 1947 only - Oct 5 0:00s 0 -
+Rule Italy 1948 only - Feb 29 2:00s 1:00 S
+Rule Italy 1948 only - Oct 3 2:00s 0 -
+Rule Italy 1966 1968 - May Sun>=22 0:00s 1:00 S
+Rule Italy 1966 only - Sep 24 24:00 0 -
+Rule Italy 1967 1969 - Sep Sun>=22 0:00s 0 -
+Rule Italy 1969 only - Jun 1 0:00s 1:00 S
+Rule Italy 1970 only - May 31 0:00s 1:00 S
+Rule Italy 1970 only - Sep lastSun 0:00s 0 -
+Rule Italy 1971 1972 - May Sun>=22 0:00s 1:00 S
+Rule Italy 1971 only - Sep lastSun 0:00s 0 -
+Rule Italy 1972 only - Oct 1 0:00s 0 -
+Rule Italy 1973 only - Jun 3 0:00s 1:00 S
+Rule Italy 1973 1974 - Sep lastSun 0:00s 0 -
+Rule Italy 1974 only - May 26 0:00s 1:00 S
+Rule Italy 1975 only - Jun 1 0:00s 1:00 S
+Rule Italy 1975 1977 - Sep lastSun 0:00s 0 -
+Rule Italy 1976 only - May 30 0:00s 1:00 S
+Rule Italy 1977 1979 - May Sun>=22 0:00s 1:00 S
+Rule Italy 1978 only - Oct 1 0:00s 0 -
+Rule Italy 1979 only - Sep 30 0:00s 0 -
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone Europe/Rome 0:49:56 - LMT 1866 Sep 22
- 0:49:56 - RMT 1893 Nov 1 0:00s # Rome Mean
- 1:00 Italy CE%sT 1942 Nov 2 2:00s
- 1:00 C-Eur CE%sT 1944 Jul
+ 0:49:56 - RMT 1893 Oct 31 23:49:56 # Rome Mean
+ 1:00 Italy CE%sT 1943 Sep 10
+ 1:00 C-Eur CE%sT 1944 Jun 4
1:00 Italy CE%sT 1980
1:00 EU CE%sT
@@ -1788,6 +1799,10 @@
# See Europe/Belgrade.
# Malta
+#
+# From Paul Eggert (2016-10-21):
+# Assume 1900-1972 was like Rome, overriding Shanks.
+#
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
Rule Malta 1973 only - Mar 31 0:00s 1:00 S
Rule Malta 1973 only - Sep 29 0:00s 0 -
@@ -1798,8 +1813,6 @@
Rule Malta 1980 only - Mar 31 2:00 1:00 S
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone Europe/Malta 0:58:04 - LMT 1893 Nov 2 0:00s # Valletta
- 1:00 Italy CE%sT 1942 Nov 2 2:00s
- 1:00 C-Eur CE%sT 1945 Apr 2 2:00s
1:00 Italy CE%sT 1973 Mar 31
1:00 Malta CE%sT 1981
1:00 EU CE%sT
@@ -1931,7 +1944,7 @@
# Amsterdam mean time.
# The data entries before 1945 are taken from
-# http://www.staff.science.uu.nl/~gent0113/idl/idl.htm
+# http://www.staff.science.uu.nl/~gent0113/wettijd/wettijd.htm
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
Rule Neth 1916 only - May 1 0:00 1:00 NST # Netherlands Summer Time
--- a/jdk/make/data/tzdata/zone.tab Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/make/data/tzdata/zone.tab Wed Nov 09 10:04:43 2016 -0800
@@ -175,7 +175,8 @@
CV +1455-02331 Atlantic/Cape_Verde
CW +1211-06900 America/Curacao
CX -1025+10543 Indian/Christmas
-CY +3510+03322 Asia/Nicosia
+CY +3510+03322 Asia/Nicosia Cyprus (most areas)
+CY +3507+03357 Asia/Famagusta Northern Cyprus
CZ +5005+01426 Europe/Prague
DE +5230+01322 Europe/Berlin Germany (most areas)
DE +4742+00841 Europe/Busingen Busingen
--- a/jdk/make/mapfiles/libjava/mapfile-vers Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/make/mapfiles/libjava/mapfile-vers Wed Nov 09 10:04:43 2016 -0800
@@ -140,7 +140,6 @@
Java_java_lang_Double_doubleToRawLongBits;
Java_java_lang_Float_intBitsToFloat;
Java_java_lang_Float_floatToRawIntBits;
- Java_java_lang_StackFrameInfo_toStackTraceElement0;
Java_java_lang_StackStreamFactory_checkStackWalkModes;
Java_java_lang_StackStreamFactory_00024AbstractStackWalker_callStackWalk;
Java_java_lang_StackStreamFactory_00024AbstractStackWalker_fetchStackFrames;
@@ -215,6 +214,8 @@
Java_java_lang_SecurityManager_currentLoadedClass0;
Java_java_lang_SecurityManager_getClassContext;
Java_java_lang_Shutdown_halt0;
+ Java_java_lang_StackTraceElement_initStackTraceElement;
+ Java_java_lang_StackTraceElement_initStackTraceElements;
Java_java_lang_String_intern;
Java_java_lang_StringCoding_err;
Java_java_lang_StringUTF16_isBigEndian;
@@ -227,7 +228,6 @@
Java_java_lang_System_setOut0;
Java_java_lang_Thread_registerNatives;
Java_java_lang_Throwable_fillInStackTrace;
- 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;
--- a/jdk/make/mapfiles/libjava/reorder-sparc Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/make/mapfiles/libjava/reorder-sparc Wed Nov 09 10:04:43 2016 -0800
@@ -78,7 +78,7 @@
text: .text%JNU_GetEnv;
text: .text%Java_java_io_UnixFileSystem_checkAccess;
text: .text%Java_java_lang_reflect_Array_newArray;
-text: .text%Java_java_lang_Throwable_getStackTraceElements;
+text: .text%Java_java_lang_StackTraceElement_initStackTraceElements;
text: .text%throwFileNotFoundException;
text: .text%JNU_NotifyAll;
# Test LoadFrame
--- a/jdk/make/mapfiles/libjava/reorder-sparcv9 Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/make/mapfiles/libjava/reorder-sparcv9 Wed Nov 09 10:04:43 2016 -0800
@@ -74,7 +74,7 @@
text: .text%JNU_GetEnv;
text: .text%Java_java_io_UnixFileSystem_checkAccess;
text: .text%Java_java_lang_reflect_Array_newArray;
-text: .text%Java_java_lang_Throwable_getStackTraceElements;
+text: .text%Java_java_lang_StackTraceElement_initStackTraceElements;
text: .text%throwFileNotFoundException: OUTPUTDIR/io_util.o;
text: .text%JNU_NotifyAll;
# Test LoadFrame
--- a/jdk/make/mapfiles/libjava/reorder-x86 Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/make/mapfiles/libjava/reorder-x86 Wed Nov 09 10:04:43 2016 -0800
@@ -78,7 +78,7 @@
text: .text%Java_sun_reflect_NativeMethodAccessorImpl_invoke0;
text: .text%Java_java_io_FileInputStream_available;
text: .text%Java_java_lang_reflect_Array_newArray;
-text: .text%Java_java_lang_Throwable_getStackTraceElements;
+text: .text%Java_java_lang_StackTraceElement_initStackTraceElements;
text: .text%Java_java_lang_System_identityHashCode;
text: .text%JNU_NotifyAll;
# Test LoadFrame
--- a/jdk/make/rmic/Rmic-java.rmi.gmk Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/make/rmic/Rmic-java.rmi.gmk Wed Nov 09 10:04:43 2016 -0800
@@ -33,7 +33,7 @@
#
$(eval $(call SetupRMICompilation,RMI_12, \
- CLASSES := sun.rmi.server.Activation$$$$ActivationSystemImpl \
+ CLASSES := sun.rmi.server.Activation$$ActivationSystemImpl \
java.rmi.activation.ActivationGroup, \
CLASSES_DIR := $(CLASSES_DIR)/java.rmi, \
STUB_CLASSES_DIR := $(STUB_CLASSES_DIR)/java.rmi, \
--- a/jdk/src/java.base/share/classes/java/io/File.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/io/File.java Wed Nov 09 10:04:43 2016 -0800
@@ -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
@@ -1907,16 +1907,10 @@
throws IOException
{
long n = random.nextLong();
- if (n == Long.MIN_VALUE) {
- n = 0; // corner case
- } else {
- n = Math.abs(n);
- }
// Use only the file name from the supplied prefix
prefix = (new File(prefix)).getName();
-
- String name = prefix + Long.toString(n) + suffix;
+ String name = prefix + Long.toUnsignedString(n) + suffix;
File f = new File(dir, name);
if (!name.equals(f.getName()) || f.isInvalid()) {
if (System.getSecurityManager() != null)
--- a/jdk/src/java.base/share/classes/java/lang/Class.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/lang/Class.java Wed Nov 09 10:04:43 2016 -0800
@@ -485,7 +485,7 @@
* can be replaced by
*
* <pre>{@code
- * clazz.getConstructor().newInstance()
+ * clazz.getDeclaredConstructor().newInstance()
* }</pre>
*
* The latter sequence of calls is inferred to be able to throw
--- a/jdk/src/java.base/share/classes/java/lang/ClassLoader.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/lang/ClassLoader.java Wed Nov 09 10:04:43 2016 -0800
@@ -222,6 +222,9 @@
// must be added *after* it.
private final ClassLoader parent;
+ // class loader name
+ private final String name;
+
// the unnamed module for this ClassLoader
private final Module unnamedModule;
@@ -331,6 +334,14 @@
}
private static Void checkCreateClassLoader() {
+ return checkCreateClassLoader(null);
+ }
+
+ private static Void checkCreateClassLoader(String name) {
+ if (name != null && name.isEmpty()) {
+ throw new IllegalArgumentException("name must be non-empty or null");
+ }
+
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkCreateClassLoader();
@@ -338,7 +349,8 @@
return null;
}
- private ClassLoader(Void unused, ClassLoader parent) {
+ private ClassLoader(Void unused, String name, ClassLoader parent) {
+ this.name = name;
this.parent = parent;
this.unnamedModule
= SharedSecrets.getJavaLangReflectModuleAccess()
@@ -356,6 +368,27 @@
}
/**
+ * Creates a new class loader of the specified name and using the
+ * specified parent class loader for delegation.
+ *
+ * @param name class loader name; or {@code null} if not named
+ * @param parent the parent class loader
+ *
+ * @throws IllegalArgumentException if the given name is empty.
+ *
+ * @throws SecurityException
+ * If a security manager exists and its
+ * {@link SecurityManager#checkCreateClassLoader()}
+ * method doesn't allow creation of a new class loader.
+ *
+ * @since 9
+ */
+ protected ClassLoader(String name, ClassLoader parent) {
+ this(checkCreateClassLoader(name), name, parent);
+ }
+
+
+ /**
* Creates a new class loader using the specified parent class loader for
* delegation.
*
@@ -375,9 +408,10 @@
* @since 1.2
*/
protected ClassLoader(ClassLoader parent) {
- this(checkCreateClassLoader(), parent);
+ this(checkCreateClassLoader(), null, parent);
}
+
/**
* Creates a new class loader using the <tt>ClassLoader</tt> returned by
* the method {@link #getSystemClassLoader()
@@ -394,7 +428,31 @@
* of a new class loader.
*/
protected ClassLoader() {
- this(checkCreateClassLoader(), getSystemClassLoader());
+ this(checkCreateClassLoader(), null, getSystemClassLoader());
+ }
+
+
+ /**
+ * Returns the name of this class loader or {@code null} if
+ * this class loader is not named.
+ *
+ * @apiNote This method is non-final for compatibility. If this
+ * method is overridden, this method must return the same name
+ * as specified when this class loader was instantiated.
+ *
+ * @return name of this class loader; or {@code null} if
+ * this class loader is not named.
+ *
+ * @since 9
+ */
+ public String getName() {
+ return name;
+ }
+
+ // package-private used by StackTraceElement to avoid
+ // calling the overrideable getName method
+ final String name() {
+ return name;
}
// -- Class --
@@ -1628,6 +1686,9 @@
* <a href="#builtinLoaders">platform classes</a> are visible to
* the platform class loader.
*
+ * @implNote The name of the builtin platform class loader is
+ * {@code "platform"}.
+ *
* @return The platform {@code ClassLoader}.
*
* @throws SecurityException
@@ -1681,7 +1742,8 @@
* this method during startup should take care not to cache the return
* value until the system is fully initialized.
*
- * <p> The class path used by the built-in system class loader is determined
+ * <p> The name of the built-in system class loader is {@code "app"}.
+ * The class path used by the built-in system class loader is determined
* by the system property "{@code java.class.path}" during early
* initialization of the VM. If the system property is not defined,
* or its value is an empty string, then there is no class path
--- a/jdk/src/java.base/share/classes/java/lang/StackFrameInfo.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/lang/StackFrameInfo.java Wed Nov 09 10:04:43 2016 -0800
@@ -112,11 +112,6 @@
return toStackTraceElement().toString();
}
- /**
- * Fill in the fields of the given StackTraceElement
- */
- private native void toStackTraceElement0(StackTraceElement ste);
-
@Override
public StackTraceElement toStackTraceElement() {
StackTraceElement s = ste;
@@ -124,9 +119,7 @@
synchronized (this) {
s = ste;
if (s == null) {
- s = new StackTraceElement();
- toStackTraceElement0(s);
- ste = s;
+ ste = s = StackTraceElement.of(this);
}
}
}
--- a/jdk/src/java.base/share/classes/java/lang/StackTraceElement.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/lang/StackTraceElement.java Wed Nov 09 10:04:43 2016 -0800
@@ -25,7 +25,18 @@
package java.lang;
+import jdk.internal.loader.BuiltinClassLoader;
+import jdk.internal.misc.SharedSecrets;
+import jdk.internal.misc.VM;
+import jdk.internal.module.ModuleHashes;
+
+import java.lang.module.ModuleDescriptor.Version;
+import java.lang.reflect.Layer;
+import java.lang.reflect.Module;
+import java.util.HashSet;
import java.util.Objects;
+import java.util.Optional;
+import java.util.Set;
/**
* An element in a stack trace, as returned by {@link
@@ -40,7 +51,15 @@
* @author Josh Bloch
*/
public final class StackTraceElement implements java.io.Serializable {
- // Normally initialized by VM (public constructor added in 1.5)
+ // This field is set to the compacted String representation used
+ // by StackTraceElement::toString and stored in serial form.
+ //
+ // This field is of Object type. VM initially sets this field to
+ // the Class object of the declaring class to build the compacted string.
+ private Object classOrLoaderModuleClassName;
+
+ // Normally initialized by VM
+ private String classLoaderName;
private String moduleName;
private String moduleVersion;
private String declaringClass;
@@ -72,19 +91,22 @@
*/
public StackTraceElement(String declaringClass, String methodName,
String fileName, int lineNumber) {
- this(null, null, declaringClass, methodName, fileName, lineNumber);
+ this(null, null, null, declaringClass, methodName, fileName, lineNumber);
}
/**
* Creates a stack trace element representing the specified execution
* point.
*
+ * @param classLoaderName the class loader name if the class loader of
+ * the class containing the execution point represented by
+ * the stack trace is named; otherwise {@code null}
* @param moduleName the module name if the class containing the
* execution point represented by the stack trace is in a named
- * module; can be {@code null}
+ * module; otherwise {@code null}
* @param moduleVersion the module version if the class containing the
* execution point represented by the stack trace is in a named
- * module that has a version; can be {@code null}
+ * module that has a version; otherwise {@code null}
* @param declaringClass the fully qualified name of the class containing
* the execution point represented by the stack trace element
* @param methodName the name of the method containing the execution point
@@ -97,26 +119,30 @@
* a negative number if this information is unavailable. A value
* of -2 indicates that the method containing the execution point
* is a native method
+ *
* @throws NullPointerException if {@code declaringClass} is {@code null}
* or {@code methodName} is {@code null}
+ *
* @since 9
*/
- public StackTraceElement(String moduleName, String moduleVersion,
+ public StackTraceElement(String classLoaderName,
+ String moduleName, String moduleVersion,
String declaringClass, String methodName,
String fileName, int lineNumber) {
- this.moduleName = moduleName;
- this.moduleVersion = moduleVersion;
- this.declaringClass = Objects.requireNonNull(declaringClass, "Declaring class is null");
- this.methodName = Objects.requireNonNull(methodName, "Method name is null");
- this.fileName = fileName;
- this.lineNumber = lineNumber;
+ this.classLoaderName = classLoaderName;
+ this.moduleName = moduleName;
+ this.moduleVersion = moduleVersion;
+ this.declaringClass = Objects.requireNonNull(declaringClass, "Declaring class is null");
+ this.methodName = Objects.requireNonNull(methodName, "Method name is null");
+ this.fileName = fileName;
+ this.lineNumber = lineNumber;
}
-
- /**
- * Creates an empty stack frame element to be filled in by Throwable.
+ /*
+ * Private constructor for the factory methods to create StackTraceElement
+ * for Throwable and StackFrameInfo
*/
- StackTraceElement() { }
+ private StackTraceElement() {}
/**
* Returns the name of the source file containing the execution point
@@ -178,6 +204,21 @@
}
/**
+ * Returns the name of the class loader of the class containing the
+ * execution point represented by this stack trace element.
+ *
+ * @return the name of the class loader of the class containing the execution
+ * point represented by this stack trace element; {@code null}
+ * if the class loader is not named.
+ *
+ * @since 9
+ * @see java.lang.ClassLoader#getName()
+ */
+ public String getClassLoaderName() {
+ return classLoaderName;
+ }
+
+ /**
* Returns the fully qualified name of the class containing the
* execution point represented by this stack trace element.
*
@@ -220,38 +261,83 @@
* examples may be regarded as typical:
* <ul>
* <li>
- * {@code "MyClass.mash(my.module@9.0/MyClass.java:101)"} - Here,
- * {@code "MyClass"} is the <i>fully-qualified name</i> of the class
- * containing the execution point represented by this stack trace element,
- * {@code "mash"} is the name of the method containing the execution
- * point, {@code "my.module"} is the module name, {@code "9.0"} is the
- * module version, and {@code "101"} is the line number of the source
- * line containing the execution point.
+ * "{@code com.foo.loader/foo@9.0/com.foo.Main.run(Main.java:101)}"
+ * - See the description below.
+ * </li>
+ * <li>
+ * "{@code com.foo.loader/foo@9.0/com.foo.Main.run(Main.java)}"
+ * - The line number is unavailable.
+ * </li>
+ * <li>
+ * "{@code com.foo.loader/foo@9.0/com.foo.Main.run(Unknown Source)}"
+ * - Neither the file name nor the line number is available.
+ * </li>
+ * <li>
+ * "{@code com.foo.loader/foo@9.0/com.foo.Main.run(Native Method)}"
+ * - The method containing the execution point is a native method.
+ * </li>
+ * <li>
+ * "{@code com.foo.loader//com.foo.bar.App.run(App.java:12)}"
+ * - The class of the execution point is defined in the unnamed module of
+ * the class loader named {@code com.foo.loader}.
+ * </li>
+ * <li>
+ * "{@code acme@2.1/org.acme.Lib.test(Lib.java:80)}"
+ * - The class of the execution point is defined in {@code acme} module
+ * loaded by by a built-in class loader such as the application class loader.
+ * </li>
* <li>
- * {@code "MyClass.mash(my.module@9.0/MyClass.java)"} - As above, but the
- * line number is unavailable.
- * <li>
- * {@code "MyClass.mash(my.module@9.0/Unknown Source)"} - As above, but
- * neither the file name nor the line number are available.
- * <li>
- * {@code "MyClass.mash(my.module@9.0/Native Method)"} - As above, but
- * neither the file name nor the line number are available, and the
- * method containing the execution point is known to be a native method.
+ * "{@code MyClass.mash(MyClass.java:9)}"
+ * - {@code MyClass} class is on the application class path.
+ * </li>
* </ul>
- * If the execution point is not in a named module, {@code "my.module@9.0/"}
- * will be omitted from the above.
+ *
+ * <p> The first example shows a stack trace element consisting of
+ * three elements, each separated by {@code "/"} followed with
+ * the source file name and the line number of the source line
+ * containing the execution point.
+ *
+ * The first element "{@code com.foo.loader}" is
+ * the name of the class loader. The second element "{@code foo@9.0}"
+ * is the module name and version. The third element is the method
+ * containing the execution point; "{@code com.foo.Main"}" is the
+ * fully-qualified class name and "{@code run}" is the name of the method.
+ * "{@code Main.java}" is the source file name and "{@code 101}" is
+ * the line number.
+ *
+ * <p> If a class is defined in an <em>unnamed module</em>
+ * then the second element is omitted as shown in
+ * "{@code com.foo.loader//com.foo.bar.App.run(App.java:12)}".
+ *
+ * If the class loader is a <a href="ClassLoader.html#builtinLoaders">
+ * built-in class loader</a> or is not named then the first element
+ * and its following {@code "/"} are omitted as shown in
+ * "{@code acme@2.1/org.acme.Lib.test(Lib.java:80)}".
+ * If the first element is omitted and the module is an unnamed module,
+ * the second element and its following {@code "/"} are also omitted
+ * as shown in "{@code MyClass.mash(MyClass.java:9)}".
*
* @see Throwable#printStackTrace()
*/
public String toString() {
- String mid = "";
- if (moduleName != null) {
- mid = moduleName;
- if (moduleVersion != null)
- mid += "@" + moduleVersion;
- mid += "/";
+ String s = buildLoaderModuleClassName();
+ if (s == null) {
+ // all elements will be included
+ s = "";
+ if (classLoaderName != null && !classLoaderName.isEmpty()) {
+ s += classLoaderName + "/";
+ }
+ if (moduleName != null && !moduleName.isEmpty()) {
+ s += moduleName;
+
+ if (moduleVersion != null && !moduleVersion.isEmpty()) {
+ s += "@" + moduleVersion;
+ }
+ }
+ s = s.isEmpty() ? declaringClass : s + "/" + declaringClass;
}
- return getClassName() + "." + methodName + "(" + mid +
+
+ return s + "." + methodName + "(" +
(isNativeMethod() ? "Native Method)" :
(fileName != null && lineNumber >= 0 ?
fileName + ":" + lineNumber + ")" :
@@ -264,12 +350,14 @@
* point as this instance. Two stack trace elements {@code a} and
* {@code b} are equal if and only if:
* <pre>{@code
- * equals(a.getFileName(), b.getFileName()) &&
- * a.getLineNumber() == b.getLineNumber()) &&
+ * equals(a.getClassLoaderName(), b.getClassLoaderName()) &&
* equals(a.getModuleName(), b.getModuleName()) &&
* equals(a.getModuleVersion(), b.getModuleVersion()) &&
* equals(a.getClassName(), b.getClassName()) &&
* equals(a.getMethodName(), b.getMethodName())
+ * equals(a.getFileName(), b.getFileName()) &&
+ * a.getLineNumber() == b.getLineNumber()
+ *
* }</pre>
* where {@code equals} has the semantics of {@link
* java.util.Objects#equals(Object, Object) Objects.equals}.
@@ -285,9 +373,10 @@
if (!(obj instanceof StackTraceElement))
return false;
StackTraceElement e = (StackTraceElement)obj;
- return e.declaringClass.equals(declaringClass) &&
+ return Objects.equals(classLoaderName, e.classLoaderName) &&
Objects.equals(moduleName, e.moduleName) &&
Objects.equals(moduleVersion, e.moduleVersion) &&
+ e.declaringClass.equals(declaringClass) &&
e.lineNumber == lineNumber &&
Objects.equals(methodName, e.methodName) &&
Objects.equals(fileName, e.fileName);
@@ -298,6 +387,7 @@
*/
public int hashCode() {
int result = 31*declaringClass.hashCode() + methodName.hashCode();
+ result = 31*result + Objects.hashCode(classLoaderName);
result = 31*result + Objects.hashCode(moduleName);
result = 31*result + Objects.hashCode(moduleVersion);
result = 31*result + Objects.hashCode(fileName);
@@ -305,5 +395,157 @@
return result;
}
+
+ /**
+ * Build the compacted String representation to be returned by
+ * toString method from the declaring Class object.
+ */
+ synchronized String buildLoaderModuleClassName() {
+ if (classOrLoaderModuleClassName == null)
+ return null;
+
+ if (classOrLoaderModuleClassName instanceof Class) {
+ Class<?> cls = (Class<?>)classOrLoaderModuleClassName;
+ classOrLoaderModuleClassName = toLoaderModuleClassName(cls);
+ }
+ return (String)classOrLoaderModuleClassName;
+ }
+
+ /**
+ * Returns <loader>/<module>/<fully-qualified-classname> string
+ * representation of the given class.
+ * <p>
+ * If the module is a non-upgradeable JDK module then omit
+ * its version string.
+ * <p>
+ * If the loader has no name, or if the loader is one of the built-in
+ * loaders (`boot`, `platform`, or `app`) then drop the first element
+ * (`<loader>/`).
+ * <p>
+ * If the first element has been dropped and the module is unnamed
+ * then drop the second element (`<module>/`).
+ * <p>
+ * If the first element is not dropped and the module is unnamed
+ * then drop `<module>`.
+ */
+ private static String toLoaderModuleClassName(Class<?> cls) {
+ ClassLoader loader = cls.getClassLoader0();
+ Module m = cls.getModule();
+
+ // First element - class loader name
+ // Call package-private ClassLoader::name method
+ String s = "";
+ if (loader != null && loader.name() != null &&
+ !(loader instanceof BuiltinClassLoader)) {
+ s = loader.name() + "/";
+ }
+
+ // Second element - module name and version
+ if (m != null && m.isNamed()) {
+ s += m.getName();
+ // Include version if it is a user module or upgradeable module
+ //
+ // If it is JDK non-upgradeable module which is recorded
+ // in the hashes in java.base, omit the version.
+ if (!isHashedInJavaBase(m)) {
+ Optional<Version> ov = m.getDescriptor().version();
+ if (ov.isPresent()) {
+ String version = "@" + ov.get().toString();
+ s += version;
+ }
+ }
+ }
+
+ // fully-qualified class name
+ return s.isEmpty() ? cls.getName() : s + "/" + cls.getName();
+ }
+
+ /**
+ * Returns true if the module is hashed with java.base.
+ * <p>
+ * This method returns false when running on the exploded image
+ * since JDK modules are not hashed. They have no Version attribute
+ * and so "@<version>" part will be omitted anyway.
+ */
+ private static boolean isHashedInJavaBase(Module m) {
+ // return true if module system is not initialized as the code
+ // must be in java.base
+ if (!VM.isModuleSystemInited())
+ return true;
+
+ return Layer.boot() == m.getLayer() && HashedModules.contains(m);
+ }
+
+ /*
+ * Finds JDK non-upgradeable modules, i.e. the modules that are
+ * included in the hashes in java.base.
+ */
+ private static class HashedModules {
+ static Set<String> HASHED_MODULES = hashedModules();
+
+ static Set<String> hashedModules() {
+ Module javaBase = Layer.boot().findModule("java.base").get();
+ Optional<ModuleHashes> ohashes =
+ SharedSecrets.getJavaLangModuleAccess()
+ .hashes(javaBase.getDescriptor());
+
+ if (ohashes.isPresent()) {
+ Set<String> names = new HashSet<>(ohashes.get().names());
+ names.add("java.base");
+ return names;
+ }
+
+ return Set.of();
+ }
+
+ static boolean contains(Module m) {
+ return HASHED_MODULES.contains(m.getName());
+ }
+ }
+
+
+ /*
+ * Returns an array of StackTraceElements of the given depth
+ * filled from the backtrace of a given Throwable.
+ */
+ static StackTraceElement[] of(Throwable x, int depth) {
+ StackTraceElement[] stackTrace = new StackTraceElement[depth];
+ for (int i = 0; i < depth; i++) {
+ stackTrace[i] = new StackTraceElement();
+ }
+
+ // VM to fill in StackTraceElement
+ initStackTraceElements(stackTrace, x);
+
+ // ensure the proper StackTraceElement initialization
+ for (StackTraceElement ste : stackTrace) {
+ ste.buildLoaderModuleClassName();
+ }
+ return stackTrace;
+ }
+
+ /*
+ * Returns a StackTraceElement from a given StackFrameInfo.
+ */
+ static StackTraceElement of(StackFrameInfo sfi) {
+ StackTraceElement ste = new StackTraceElement();
+ initStackTraceElement(ste, sfi);
+
+ ste.buildLoaderModuleClassName();
+ return ste;
+ }
+
+ /*
+ * Sets the given stack trace elements with the backtrace
+ * of the given Throwable.
+ */
+ private static native void initStackTraceElements(StackTraceElement[] elements,
+ Throwable x);
+ /*
+ * Sets the given stack trace element with the given StackFrameInfo
+ */
+ private static native void initStackTraceElement(StackTraceElement element,
+ StackFrameInfo sfi);
+
private static final long serialVersionUID = 6992337162326171013L;
}
--- a/jdk/src/java.base/share/classes/java/lang/Throwable.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/lang/Throwable.java Wed Nov 09 10:04:43 2016 -0800
@@ -24,7 +24,6 @@
*/
package java.lang;
-import jdk.internal.misc.VM;
import java.io.*;
import java.util.*;
@@ -826,11 +825,7 @@
// backtrace if this is the first call to this method
if (stackTrace == UNASSIGNED_STACK ||
(stackTrace == null && backtrace != null) /* Out of protocol state */) {
- stackTrace = new StackTraceElement[depth];
- for (int i = 0; i < depth; i++) {
- stackTrace[i] = new StackTraceElement();
- }
- getStackTraceElements(stackTrace);
+ stackTrace = StackTraceElement.of(this, depth);
} else if (stackTrace == null) {
return UNASSIGNED_STACK;
}
@@ -882,13 +877,6 @@
}
/**
- * Gets the stack trace elements.
- * @param elements
- * @throws IndexOutOfBoundsException if {@code elements.length != depth }
- */
- private native void getStackTraceElements(StackTraceElement[] elements);
-
- /**
* Reads a {@code Throwable} from a stream, enforcing
* well-formedness constraints on fields. Null entries and
* self-pointers are not allowed in the list of {@code
--- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java Wed Nov 09 10:04:43 2016 -0800
@@ -5347,7 +5347,7 @@
* {@code (V T A...)} must have at least one {@code A} type, and the default iterator
* handle parameter is adjusted to accept the leading {@code A} type, as if by
* the {@link MethodHandle#asType asType} conversion method.
- * The leading {@code A} type must be {@code Iterable} or a subtype thereof, or an array type.
+ * The leading {@code A} type must be {@code Iterable} or a subtype thereof.
* This conversion step, done at loop construction time, must not throw a {@code WrongMethodTypeException}.
* </ul>
* <p>
@@ -5374,7 +5374,8 @@
* V iteratedLoop(A... a...) {
* Iterator<T> it = iterator(a...);
* V v = init(a...);
- * for (T t : it) {
+ * while (it.hasNext()) {
+ * T t = it.next();
* v = body(v, t, a...);
* }
* return v;
@@ -5483,49 +5484,59 @@
Objects.requireNonNull(body);
MethodType bodyType = body.type();
Class<?> returnType = bodyType.returnType();
- List<Class<?>> innerList = bodyType.parameterList();
+ List<Class<?>> internalParamList = bodyType.parameterList();
// strip leading V value if present
int vsize = (returnType == void.class ? 0 : 1);
- if (vsize != 0 && (innerList.size() == 0 || innerList.get(0) != returnType)) {
+ if (vsize != 0 && (internalParamList.size() == 0 || internalParamList.get(0) != returnType)) {
// argument list has no "V" => error
MethodType expected = bodyType.insertParameterTypes(0, returnType);
throw misMatchedTypes("body function", bodyType, expected);
- } else if (innerList.size() <= vsize) {
+ } else if (internalParamList.size() <= vsize) {
// missing T type => error
MethodType expected = bodyType.insertParameterTypes(vsize, Object.class);
throw misMatchedTypes("body function", bodyType, expected);
}
- //Class<?> elementType = innerList.get(vsize); // do not need this
- List<Class<?>> outerList = innerList.subList(vsize + 1, innerList.size());
- if (outerList.isEmpty()) {
- // special case; take lists from iterator handle
- outerList = ((iterator != null)
- ? iterator.type().parameterList()
- : Arrays.asList(Iterable.class));
- innerList = bodyType.insertParameterTypes(vsize + 1, outerList).parameterList();
- }
+ List<Class<?>> externalParamList = internalParamList.subList(vsize + 1, internalParamList.size());
+ Class<?> iterableType = null;
if (iterator != null) {
+ // special case; if the body handle only declares V and T then
+ // the external parameter list is obtained from iterator handle
+ if (externalParamList.isEmpty()) {
+ externalParamList = iterator.type().parameterList();
+ }
MethodType itype = iterator.type();
if (!Iterator.class.isAssignableFrom(itype.returnType())) {
throw newIllegalArgumentException("iteratedLoop first argument must have Iterator return type");
}
- if (!itype.effectivelyIdenticalParameters(0, outerList)) {
- MethodType expected = methodType(itype.returnType(), outerList);
+ if (!itype.effectivelyIdenticalParameters(0, externalParamList)) {
+ MethodType expected = methodType(itype.returnType(), externalParamList);
throw misMatchedTypes("iterator parameters", itype, expected);
}
+ } else {
+ if (externalParamList.isEmpty()) {
+ // special case; if the iterator handle is null and the body handle
+ // only declares V and T then the external parameter list consists
+ // of Iterable
+ externalParamList = Arrays.asList(Iterable.class);
+ iterableType = Iterable.class;
+ } else {
+ // special case; if the iterator handle is null and the external
+ // parameter list is not empty then the first parameter must be
+ // assignable to Iterable
+ iterableType = externalParamList.get(0);
+ if (!Iterable.class.isAssignableFrom(iterableType)) {
+ throw newIllegalArgumentException(
+ "inferred first loop argument must inherit from Iterable: " + iterableType);
+ }
+ }
}
if (init != null) {
MethodType initType = init.type();
if (initType.returnType() != returnType ||
- !initType.effectivelyIdenticalParameters(0, outerList)) {
- throw misMatchedTypes("loop initializer", initType, methodType(returnType, outerList));
+ !initType.effectivelyIdenticalParameters(0, externalParamList)) {
+ throw misMatchedTypes("loop initializer", initType, methodType(returnType, externalParamList));
}
}
- Class<?> iterableType = outerList.isEmpty() ? null : outerList.get(0);
- if (iterableType != null && !Iterable.class.isAssignableFrom(iterableType) && !iterableType.isArray()) {
- throw newIllegalArgumentException(
- "inferred first loop argument must be an array or inherit from Iterable: " + iterableType);
- }
return iterableType; // help the caller a bit
}
--- a/jdk/src/java.base/share/classes/java/net/URLClassLoader.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/net/URLClassLoader.java Wed Nov 09 10:04:43 2016 -0800
@@ -110,19 +110,19 @@
if (security != null) {
security.checkCreateClassLoader();
}
- ucp = new URLClassPath(urls);
+ this.ucp = new URLClassPath(urls);
this.acc = AccessController.getContext();
}
- URLClassLoader(URL[] urls, ClassLoader parent,
+ URLClassLoader(String name, URL[] urls, ClassLoader parent,
AccessControlContext acc) {
- super(parent);
+ super(name, parent);
// this is to make the stack depth consistent with 1.1
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkCreateClassLoader();
}
- ucp = new URLClassPath(urls);
+ this.ucp = new URLClassPath(urls);
this.acc = acc;
}
@@ -154,7 +154,7 @@
if (security != null) {
security.checkCreateClassLoader();
}
- ucp = new URLClassPath(urls);
+ this.ucp = new URLClassPath(urls);
this.acc = AccessController.getContext();
}
@@ -165,7 +165,7 @@
if (security != null) {
security.checkCreateClassLoader();
}
- ucp = new URLClassPath(urls);
+ this.ucp = new URLClassPath(urls);
this.acc = acc;
}
@@ -198,8 +198,76 @@
if (security != null) {
security.checkCreateClassLoader();
}
- ucp = new URLClassPath(urls, factory);
- acc = AccessController.getContext();
+ this.ucp = new URLClassPath(urls, factory);
+ this.acc = AccessController.getContext();
+ }
+
+
+ /**
+ * Constructs a new named {@code URLClassLoader} for the specified URLs.
+ * The URLs will be searched in the order specified for classes
+ * and resources after first searching in the specified parent class loader.
+ * Any URL that ends with a '/' is assumed to refer to a directory.
+ * Otherwise, the URL is assumed to refer to a JAR file which will be
+ * downloaded and opened as needed.
+ *
+ * @param name class loader name; or {@code null} if not named
+ * @param urls the URLs from which to load classes and resources
+ * @param parent the parent class loader for delegation
+ *
+ * @throws IllegalArgumentException if the given name is empty.
+ * @throws NullPointerException if {@code urls} is {@code null}.
+ *
+ * @throws SecurityException if a security manager exists and its
+ * {@link SecurityManager#checkCreateClassLoader()} method doesn't
+ * allow creation of a class loader.
+ *
+ * @since 9
+ */
+ public URLClassLoader(String name,
+ URL[] urls,
+ ClassLoader parent) {
+ super(name, parent);
+ // this is to make the stack depth consistent with 1.1
+ SecurityManager security = System.getSecurityManager();
+ if (security != null) {
+ security.checkCreateClassLoader();
+ }
+ this.ucp = new URLClassPath(urls);
+ this.acc = AccessController.getContext();
+ }
+
+ /**
+ * Constructs a new named {@code URLClassLoader} for the specified URLs,
+ * parent class loader, and URLStreamHandlerFactory.
+ * The parent argument will be used as the parent class loader for delegation.
+ * The factory argument will be used as the stream handler factory to
+ * obtain protocol handlers when creating new jar URLs.
+ *
+ * @param name class loader name; or {@code null} if not named
+ * @param urls the URLs from which to load classes and resources
+ * @param parent the parent class loader for delegation
+ * @param factory the URLStreamHandlerFactory to use when creating URLs
+ *
+ * @throws IllegalArgumentException if the given name is empty.
+ * @throws NullPointerException if {@code urls} is {@code null}.
+ *
+ * @throws SecurityException if a security manager exists and its
+ * {@code checkCreateClassLoader} method doesn't allow
+ * creation of a class loader.
+ *
+ * @since 9
+ */
+ public URLClassLoader(String name, URL[] urls, ClassLoader parent,
+ URLStreamHandlerFactory factory) {
+ super(name, parent);
+ // this is to make the stack depth consistent with 1.1
+ SecurityManager security = System.getSecurityManager();
+ if (security != null) {
+ security.checkCreateClassLoader();
+ }
+ this.ucp = new URLClassPath(urls, factory);
+ this.acc = AccessController.getContext();
}
/* A map (used as a set) to keep track of closeable local resources
@@ -735,7 +803,7 @@
URLClassLoader ucl = AccessController.doPrivileged(
new PrivilegedAction<>() {
public URLClassLoader run() {
- return new FactoryURLClassLoader(urls, parent, acc);
+ return new FactoryURLClassLoader(null, urls, parent, acc);
}
});
return ucl;
@@ -785,9 +853,9 @@
ClassLoader.registerAsParallelCapable();
}
- FactoryURLClassLoader(URL[] urls, ClassLoader parent,
+ FactoryURLClassLoader(String name, URL[] urls, ClassLoader parent,
AccessControlContext acc) {
- super(urls, parent, acc);
+ super(name, urls, parent, acc);
}
FactoryURLClassLoader(URL[] urls, AccessControlContext acc) {
--- a/jdk/src/java.base/share/classes/java/nio/file/TempFileHelper.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/nio/file/TempFileHelper.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -55,8 +55,8 @@
private static final SecureRandom random = new SecureRandom();
private static Path generatePath(String prefix, String suffix, Path dir) {
long n = random.nextLong();
- n = (n == Long.MIN_VALUE) ? 0 : Math.abs(n);
- Path name = dir.getFileSystem().getPath(prefix + Long.toString(n) + suffix);
+ String s = prefix + Long.toUnsignedString(n) + suffix;
+ Path name = dir.getFileSystem().getPath(s);
// the generated name should be a simple file name
if (name.getParent() != null)
throw new IllegalArgumentException("Invalid prefix or suffix");
--- a/jdk/src/java.base/share/classes/java/security/AlgorithmParameterGenerator.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/security/AlgorithmParameterGenerator.java Wed Nov 09 10:04:43 2016 -0800
@@ -26,6 +26,7 @@
package java.security;
import java.security.spec.AlgorithmParameterSpec;
+import java.util.Objects;
/**
* The {@code AlgorithmParameterGenerator} class is used to generate a
@@ -153,16 +154,19 @@
* Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard algorithm names.
*
- * @return the new AlgorithmParameterGenerator object.
+ * @return the new {@code AlgorithmParameterGenerator} object
*
- * @exception NoSuchAlgorithmException if no Provider supports an
- * AlgorithmParameterGeneratorSpi implementation for the
- * specified algorithm.
+ * @throws NoSuchAlgorithmException if no {@code Provider} supports an
+ * {@code AlgorithmParameterGeneratorSpi} implementation for the
+ * specified algorithm
+ *
+ * @throws NullPointerException if {@code algorithm} is {@code null}
*
* @see Provider
*/
public static AlgorithmParameterGenerator getInstance(String algorithm)
throws NoSuchAlgorithmException {
+ Objects.requireNonNull(algorithm, "null algorithm name");
try {
Object[] objs = Security.getImpl(algorithm,
"AlgorithmParameterGenerator",
@@ -197,17 +201,20 @@
*
* @param provider the string name of the Provider.
*
- * @return the new AlgorithmParameterGenerator object.
+ * @return the new {@code AlgorithmParameterGenerator} object
*
- * @exception NoSuchAlgorithmException if an AlgorithmParameterGeneratorSpi
- * implementation for the specified algorithm is not
- * available from the specified provider.
+ * @throws IllegalArgumentException if the provider name is {@code null}
+ * or empty
*
- * @exception NoSuchProviderException if the specified provider is not
- * registered in the security provider list.
+ * @throws NoSuchAlgorithmException if an
+ * {@code AlgorithmParameterGeneratorSpi}
+ * implementation for the specified algorithm is not
+ * available from the specified provider
*
- * @exception IllegalArgumentException if the provider name is null
- * or empty.
+ * @throws NoSuchProviderException if the specified provider is not
+ * registered in the security provider list
+ *
+ * @throws NullPointerException if {@code algorithm} is {@code null}
*
* @see Provider
*/
@@ -215,6 +222,7 @@
String provider)
throws NoSuchAlgorithmException, NoSuchProviderException
{
+ Objects.requireNonNull(algorithm, "null algorithm name");
if (provider == null || provider.length() == 0)
throw new IllegalArgumentException("missing provider");
Object[] objs = Security.getImpl(algorithm,
@@ -241,15 +249,19 @@
* Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard algorithm names.
*
- * @param provider the Provider object.
+ * @param provider the {@code Provider} object.
*
- * @return the new AlgorithmParameterGenerator object.
+ * @return the new {@code AlgorithmParameterGenerator} object
+ *
+ * @throws IllegalArgumentException if the specified provider is
+ * {@code null}
*
- * @exception NoSuchAlgorithmException if an AlgorithmParameterGeneratorSpi
- * implementation for the specified algorithm is not available
- * from the specified Provider object.
+ * @throws NoSuchAlgorithmException if an
+ * {@code AlgorithmParameterGeneratorSpi}
+ * implementation for the specified algorithm is not available
+ * from the specified {@code Provider} object
*
- * @exception IllegalArgumentException if the specified provider is null.
+ * @throws NullPointerException if {@code algorithm} is {@code null}
*
* @see Provider
*
@@ -259,6 +271,7 @@
Provider provider)
throws NoSuchAlgorithmException
{
+ Objects.requireNonNull(algorithm, "null algorithm name");
if (provider == null)
throw new IllegalArgumentException("missing provider");
Object[] objs = Security.getImpl(algorithm,
--- a/jdk/src/java.base/share/classes/java/security/AlgorithmParameters.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/security/AlgorithmParameters.java Wed Nov 09 10:04:43 2016 -0800
@@ -28,6 +28,7 @@
import java.io.*;
import java.security.spec.AlgorithmParameterSpec;
import java.security.spec.InvalidParameterSpecException;
+import java.util.Objects;
/**
* This class is used as an opaque representation of cryptographic parameters.
@@ -140,16 +141,19 @@
* Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard algorithm names.
*
- * @return the new parameter object.
+ * @return the new parameter object
*
- * @exception NoSuchAlgorithmException if no Provider supports an
- * AlgorithmParametersSpi implementation for the
- * specified algorithm.
+ * @throws NoSuchAlgorithmException if no {@code Provider} supports an
+ * {@code AlgorithmParametersSpi} implementation for the
+ * specified algorithm
+ *
+ * @throws NullPointerException if {@code algorithm} is {@code null}
*
* @see Provider
*/
public static AlgorithmParameters getInstance(String algorithm)
throws NoSuchAlgorithmException {
+ Objects.requireNonNull(algorithm, "null algorithm name");
try {
Object[] objs = Security.getImpl(algorithm, "AlgorithmParameters",
(String)null);
@@ -184,17 +188,19 @@
*
* @param provider the name of the provider.
*
- * @return the new parameter object.
+ * @return the new parameter object
*
- * @exception NoSuchAlgorithmException if an AlgorithmParametersSpi
- * implementation for the specified algorithm is not
- * available from the specified provider.
+ * @throws IllegalArgumentException if the provider name is {@code null}
+ * or empty
*
- * @exception NoSuchProviderException if the specified provider is not
- * registered in the security provider list.
+ * @throws NoSuchAlgorithmException if an {@code AlgorithmParametersSpi}
+ * implementation for the specified algorithm is not
+ * available from the specified provider
*
- * @exception IllegalArgumentException if the provider name is null
- * or empty.
+ * @throws NoSuchProviderException if the specified provider is not
+ * registered in the security provider list
+ *
+ * @throws NullPointerException if {@code algorithm} is {@code null}
*
* @see Provider
*/
@@ -202,6 +208,7 @@
String provider)
throws NoSuchAlgorithmException, NoSuchProviderException
{
+ Objects.requireNonNull(algorithm, "null algorithm name");
if (provider == null || provider.length() == 0)
throw new IllegalArgumentException("missing provider");
Object[] objs = Security.getImpl(algorithm, "AlgorithmParameters",
@@ -231,13 +238,16 @@
*
* @param provider the name of the provider.
*
- * @return the new parameter object.
+ * @return the new parameter object
+ *
+ * @throws IllegalArgumentException if the provider is {@code null}
*
- * @exception NoSuchAlgorithmException if an AlgorithmParameterGeneratorSpi
- * implementation for the specified algorithm is not available
- * from the specified Provider object.
+ * @throws NoSuchAlgorithmException if an
+ * {@code AlgorithmParameterGeneratorSpi}
+ * implementation for the specified algorithm is not available
+ * from the specified {@code Provider} object
*
- * @exception IllegalArgumentException if the provider is null.
+ * @throws NullPointerException if {@code algorithm} is {@code null}
*
* @see Provider
*
@@ -247,6 +257,7 @@
Provider provider)
throws NoSuchAlgorithmException
{
+ Objects.requireNonNull(algorithm, "null algorithm name");
if (provider == null)
throw new IllegalArgumentException("missing provider");
Object[] objs = Security.getImpl(algorithm, "AlgorithmParameters",
--- a/jdk/src/java.base/share/classes/java/security/KeyFactory.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/security/KeyFactory.java Wed Nov 09 10:04:43 2016 -0800
@@ -167,16 +167,19 @@
* Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard algorithm names.
*
- * @return the new KeyFactory object.
+ * @return the new {@code KeyFactory} object
*
- * @exception NoSuchAlgorithmException if no Provider supports a
- * KeyFactorySpi implementation for the
- * specified algorithm.
+ * @throws NoSuchAlgorithmException if no {@code Provider} supports a
+ * {@code KeyFactorySpi} implementation for the
+ * specified algorithm
+ *
+ * @throws NullPointerException if {@code algorithm} is {@code null}
*
* @see Provider
*/
public static KeyFactory getInstance(String algorithm)
throws NoSuchAlgorithmException {
+ Objects.requireNonNull(algorithm, "null algorithm name");
return new KeyFactory(algorithm);
}
@@ -200,22 +203,25 @@
*
* @param provider the name of the provider.
*
- * @return the new KeyFactory object.
+ * @return the new {@code KeyFactory} object
*
- * @exception NoSuchAlgorithmException if a KeyFactorySpi
- * implementation for the specified algorithm is not
- * available from the specified provider.
+ * @throws IllegalArgumentException if the provider name is {@code null}
+ * or empty
*
- * @exception NoSuchProviderException if the specified provider is not
- * registered in the security provider list.
+ * @throws NoSuchAlgorithmException if a {@code KeyFactorySpi}
+ * implementation for the specified algorithm is not
+ * available from the specified provider
*
- * @exception IllegalArgumentException if the provider name is null
- * or empty.
+ * @throws NoSuchProviderException if the specified provider is not
+ * registered in the security provider list
+ *
+ * @throws NullPointerException if {@code algorithm} is {@code null}
*
* @see Provider
*/
public static KeyFactory getInstance(String algorithm, String provider)
throws NoSuchAlgorithmException, NoSuchProviderException {
+ Objects.requireNonNull(algorithm, "null algorithm name");
Instance instance = GetInstance.getInstance("KeyFactory",
KeyFactorySpi.class, algorithm, provider);
return new KeyFactory((KeyFactorySpi)instance.impl,
@@ -239,13 +245,16 @@
*
* @param provider the provider.
*
- * @return the new KeyFactory object.
+ * @return the new {@code KeyFactory} object
+ *
+ * @throws IllegalArgumentException if the specified provider is
+ * {@code null}
*
- * @exception NoSuchAlgorithmException if a KeyFactorySpi
- * implementation for the specified algorithm is not available
- * from the specified Provider object.
+ * @throws NoSuchAlgorithmException if a {@code KeyFactorySpi}
+ * implementation for the specified algorithm is not available
+ * from the specified {@code Provider} object
*
- * @exception IllegalArgumentException if the specified provider is null.
+ * @throws NullPointerException if {@code algorithm} is {@code null}
*
* @see Provider
*
@@ -253,6 +262,7 @@
*/
public static KeyFactory getInstance(String algorithm, Provider provider)
throws NoSuchAlgorithmException {
+ Objects.requireNonNull(algorithm, "null algorithm name");
Instance instance = GetInstance.getInstance("KeyFactory",
KeyFactorySpi.class, algorithm, provider);
return new KeyFactory((KeyFactorySpi)instance.impl,
--- a/jdk/src/java.base/share/classes/java/security/KeyPairGenerator.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/security/KeyPairGenerator.java Wed Nov 09 10:04:43 2016 -0800
@@ -209,16 +209,19 @@
* Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard algorithm names.
*
- * @return the new KeyPairGenerator object.
+ * @return the new {@code KeyPairGenerator} object
*
- * @exception NoSuchAlgorithmException if no Provider supports a
- * KeyPairGeneratorSpi implementation for the
- * specified algorithm.
+ * @throws NoSuchAlgorithmException if no {@code Provider} supports a
+ * {@code KeyPairGeneratorSpi} implementation for the
+ * specified algorithm
+ *
+ * @throws NullPointerException if {@code algorithm} is {@code null}
*
* @see Provider
*/
public static KeyPairGenerator getInstance(String algorithm)
throws NoSuchAlgorithmException {
+ Objects.requireNonNull(algorithm, "null algorithm name");
List<Service> list =
GetInstance.getServices("KeyPairGenerator", algorithm);
Iterator<Service> t = list.iterator();
@@ -267,23 +270,26 @@
*
* @param provider the string name of the provider.
*
- * @return the new KeyPairGenerator object.
+ * @return the new {@code KeyPairGenerator} object
*
- * @exception NoSuchAlgorithmException if a KeyPairGeneratorSpi
- * implementation for the specified algorithm is not
- * available from the specified provider.
+ * @throws IllegalArgumentException if the provider name is {@code null}
+ * or empty
*
- * @exception NoSuchProviderException if the specified provider is not
- * registered in the security provider list.
+ * @throws NoSuchAlgorithmException if a {@code KeyPairGeneratorSpi}
+ * implementation for the specified algorithm is not
+ * available from the specified provider
*
- * @exception IllegalArgumentException if the provider name is null
- * or empty.
+ * @throws NoSuchProviderException if the specified provider is not
+ * registered in the security provider list
+ *
+ * @throws NullPointerException if {@code algorithm} is {@code null}
*
* @see Provider
*/
public static KeyPairGenerator getInstance(String algorithm,
String provider)
throws NoSuchAlgorithmException, NoSuchProviderException {
+ Objects.requireNonNull(algorithm, "null algorithm name");
Instance instance = GetInstance.getInstance("KeyPairGenerator",
KeyPairGeneratorSpi.class, algorithm, provider);
return getInstance(instance, algorithm);
@@ -306,13 +312,16 @@
*
* @param provider the provider.
*
- * @return the new KeyPairGenerator object.
+ * @return the new {@code KeyPairGenerator} object
+ *
+ * @throws IllegalArgumentException if the specified provider is
+ * {@code null}
*
- * @exception NoSuchAlgorithmException if a KeyPairGeneratorSpi
- * implementation for the specified algorithm is not available
- * from the specified Provider object.
+ * @throws NoSuchAlgorithmException if a {@code KeyPairGeneratorSpi}
+ * implementation for the specified algorithm is not available
+ * from the specified {@code Provider} object
*
- * @exception IllegalArgumentException if the specified provider is null.
+ * @throws NullPointerException if {@code algorithm} is {@code null}
*
* @see Provider
*
@@ -320,6 +329,7 @@
*/
public static KeyPairGenerator getInstance(String algorithm,
Provider provider) throws NoSuchAlgorithmException {
+ Objects.requireNonNull(algorithm, "null algorithm name");
Instance instance = GetInstance.getInstance("KeyPairGenerator",
KeyPairGeneratorSpi.class, algorithm, provider);
return getInstance(instance, algorithm);
--- a/jdk/src/java.base/share/classes/java/security/KeyStore.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/security/KeyStore.java Wed Nov 09 10:04:43 2016 -0800
@@ -26,7 +26,6 @@
package java.security;
import java.io.*;
-import java.net.URI;
import java.security.cert.Certificate;
import java.security.cert.X509Certificate;
import java.security.cert.CertificateException;
@@ -855,17 +854,20 @@
* Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard keystore types.
*
- * @return a keystore object of the specified type.
+ * @return a keystore object of the specified type
*
- * @exception KeyStoreException if no Provider supports a
- * KeyStoreSpi implementation for the
- * specified type.
+ * @throws KeyStoreException if no {@code Provider} supports a
+ * {@code KeyStoreSpi} implementation for the
+ * specified type
+ *
+ * @throws NullPointerException if {@code type} is {@code null}
*
* @see Provider
*/
public static KeyStore getInstance(String type)
throws KeyStoreException
{
+ Objects.requireNonNull(type, "null type name");
try {
Object[] objs = Security.getImpl(type, "KeyStore", (String)null);
return new KeyStore((KeyStoreSpi)objs[0], (Provider)objs[1], type);
@@ -895,23 +897,26 @@
*
* @param provider the name of the provider.
*
- * @return a keystore object of the specified type.
+ * @return a keystore object of the specified type
*
- * @exception KeyStoreException if a KeyStoreSpi
- * implementation for the specified type is not
- * available from the specified provider.
+ * @throws IllegalArgumentException if the provider name is {@code null}
+ * or empty
*
- * @exception NoSuchProviderException if the specified provider is not
- * registered in the security provider list.
+ * @throws KeyStoreException if a {@code KeyStoreSpi}
+ * implementation for the specified type is not
+ * available from the specified provider
*
- * @exception IllegalArgumentException if the provider name is null
- * or empty.
+ * @throws NoSuchProviderException if the specified provider is not
+ * registered in the security provider list
+ *
+ * @throws NullPointerException if {@code type} is {@code null}
*
* @see Provider
*/
public static KeyStore getInstance(String type, String provider)
throws KeyStoreException, NoSuchProviderException
{
+ Objects.requireNonNull(type, "null type name");
if (provider == null || provider.length() == 0)
throw new IllegalArgumentException("missing provider");
try {
@@ -938,13 +943,16 @@
*
* @param provider the provider.
*
- * @return a keystore object of the specified type.
+ * @return a keystore object of the specified type
+ *
+ * @throws IllegalArgumentException if the specified provider is
+ * {@code null}
*
- * @exception KeyStoreException if KeyStoreSpi
- * implementation for the specified type is not available
- * from the specified Provider object.
+ * @throws KeyStoreException if {@code KeyStoreSpi}
+ * implementation for the specified type is not available
+ * from the specified {@code Provider} object
*
- * @exception IllegalArgumentException if the specified provider is null.
+ * @throws NullPointerException if {@code type} is {@code null}
*
* @see Provider
*
@@ -953,6 +961,7 @@
public static KeyStore getInstance(String type, Provider provider)
throws KeyStoreException
{
+ Objects.requireNonNull(type, "null type name");
if (provider == null)
throw new IllegalArgumentException("missing provider");
try {
--- a/jdk/src/java.base/share/classes/java/security/MessageDigest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/security/MessageDigest.java Wed Nov 09 10:04:43 2016 -0800
@@ -26,13 +26,8 @@
package java.security;
import java.util.*;
-import java.lang.*;
-import java.io.IOException;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
-import java.io.InputStream;
-import java.io.ByteArrayInputStream;
-import java.security.InvalidKeyException;
import java.nio.ByteBuffer;
import sun.security.util.Debug;
@@ -163,16 +158,20 @@
* Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard algorithm names.
*
- * @return a Message Digest object that implements the specified algorithm.
+ * @return a {@code MessageDigest} object that implements the
+ * specified algorithm
*
- * @exception NoSuchAlgorithmException if no Provider supports a
- * MessageDigestSpi implementation for the
- * specified algorithm.
+ * @throws NoSuchAlgorithmException if no {@code Provider} supports a
+ * {@code MessageDigestSpi} implementation for the
+ * specified algorithm
+ *
+ * @throws NullPointerException if {@code algorithm} is {@code null}
*
* @see Provider
*/
public static MessageDigest getInstance(String algorithm)
throws NoSuchAlgorithmException {
+ Objects.requireNonNull(algorithm, "null algorithm name");
try {
MessageDigest md;
Object[] objs = Security.getImpl(algorithm, "MessageDigest",
@@ -216,23 +215,27 @@
*
* @param provider the name of the provider.
*
- * @return a MessageDigest object that implements the specified algorithm.
+ * @return a {@code MessageDigest} object that implements the
+ * specified algorithm
*
- * @exception NoSuchAlgorithmException if a MessageDigestSpi
- * implementation for the specified algorithm is not
- * available from the specified provider.
+ * @throws IllegalArgumentException if the provider name is {@code null}
+ * or empty
*
- * @exception NoSuchProviderException if the specified provider is not
- * registered in the security provider list.
+ * @throws NoSuchAlgorithmException if a {@code MessageDigestSpi}
+ * implementation for the specified algorithm is not
+ * available from the specified provider
*
- * @exception IllegalArgumentException if the provider name is null
- * or empty.
+ * @throws NoSuchProviderException if the specified provider is not
+ * registered in the security provider list
+ *
+ * @throws NullPointerException if {@code algorithm} is {@code null}
*
* @see Provider
*/
public static MessageDigest getInstance(String algorithm, String provider)
throws NoSuchAlgorithmException, NoSuchProviderException
{
+ Objects.requireNonNull(algorithm, "null algorithm name");
if (provider == null || provider.length() == 0)
throw new IllegalArgumentException("missing provider");
Object[] objs = Security.getImpl(algorithm, "MessageDigest", provider);
@@ -265,13 +268,17 @@
*
* @param provider the provider.
*
- * @return a MessageDigest object that implements the specified algorithm.
+ * @return a {@code MessageDigest} object that implements the
+ * specified algorithm
+ *
+ * @throws IllegalArgumentException if the specified provider is
+ * {@code null}
*
- * @exception NoSuchAlgorithmException if a MessageDigestSpi
- * implementation for the specified algorithm is not available
- * from the specified Provider object.
+ * @throws NoSuchAlgorithmException if a {@code MessageDigestSpi}
+ * implementation for the specified algorithm is not available
+ * from the specified {@code Provider} object
*
- * @exception IllegalArgumentException if the specified provider is null.
+ * @throws NullPointerException if {@code algorithm} is {@code null}
*
* @see Provider
*
@@ -281,6 +288,7 @@
Provider provider)
throws NoSuchAlgorithmException
{
+ Objects.requireNonNull(algorithm, "null algorithm name");
if (provider == null)
throw new IllegalArgumentException("missing provider");
Object[] objs = Security.getImpl(algorithm, "MessageDigest", provider);
--- a/jdk/src/java.base/share/classes/java/security/Policy.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/security/Policy.java Wed Nov 09 10:04:43 2016 -0800
@@ -29,6 +29,7 @@
import java.util.Enumeration;
import java.util.WeakHashMap;
import java.util.concurrent.atomic.AtomicReference;
+import java.util.Objects;
import sun.security.jca.GetInstance;
import sun.security.util.Debug;
import sun.security.util.SecurityConstants;
@@ -372,26 +373,26 @@
*
* @param params parameters for the Policy, which may be null.
*
- * @return the new Policy object.
+ * @return the new {@code Policy} object
*
- * @exception SecurityException if the caller does not have permission
- * to get a Policy instance for the specified type.
- *
- * @exception NullPointerException if the specified type is null.
+ * @throws IllegalArgumentException if the specified parameters
+ * are not understood by the {@code PolicySpi} implementation
+ * from the selected {@code Provider}
*
- * @exception IllegalArgumentException if the specified parameters
- * are not understood by the PolicySpi implementation
- * from the selected Provider.
+ * @throws NoSuchAlgorithmException if no {@code Provider} supports
+ * a {@code PolicySpi} implementation for the specified type
*
- * @exception NoSuchAlgorithmException if no Provider supports a PolicySpi
- * implementation for the specified type.
+ * @throws NullPointerException if {@code type} is {@code null}
+ *
+ * @throws SecurityException if the caller does not have permission
+ * to get a {@code Policy} instance for the specified type.
*
* @see Provider
* @since 1.6
*/
public static Policy getInstance(String type, Policy.Parameters params)
throws NoSuchAlgorithmException {
-
+ Objects.requireNonNull(type, "null type name");
checkPermission(type);
try {
GetInstance.Instance instance = GetInstance.getInstance("Policy",
@@ -428,23 +429,24 @@
*
* @param provider the provider.
*
- * @return the new Policy object.
+ * @return the new {@code Policy} object
*
- * @exception SecurityException if the caller does not have permission
- * to get a Policy instance for the specified type.
- *
- * @exception NullPointerException if the specified type is null.
+ * @throws IllegalArgumentException if the specified provider
+ * is {@code null} or empty, or if the specified parameters are
+ * not understood by the {@code PolicySpi} implementation from
+ * the specified provider
*
- * @exception IllegalArgumentException if the specified provider
- * is null or empty,
- * or if the specified parameters are not understood by
- * the PolicySpi implementation from the specified provider.
+ * @throws NoSuchAlgorithmException if the specified provider does not
+ * support a {@code PolicySpi} implementation for the specified
+ * type
*
- * @exception NoSuchProviderException if the specified provider is not
- * registered in the security provider list.
+ * @throws NoSuchProviderException if the specified provider is not
+ * registered in the security provider list
*
- * @exception NoSuchAlgorithmException if the specified provider does not
- * support a PolicySpi implementation for the specified type.
+ * @throws NullPointerException if {@code type} is {@code null}
+ *
+ * @throws SecurityException if the caller does not have permission
+ * to get a {@code Policy} instance for the specified type
*
* @see Provider
* @since 1.6
@@ -454,6 +456,7 @@
String provider)
throws NoSuchProviderException, NoSuchAlgorithmException {
+ Objects.requireNonNull(type, "null type name");
if (provider == null || provider.length() == 0) {
throw new IllegalArgumentException("missing provider");
}
@@ -492,19 +495,21 @@
*
* @param provider the Provider.
*
- * @return the new Policy object.
+ * @return the new {@code Policy} object
*
- * @exception SecurityException if the caller does not have permission
- * to get a Policy instance for the specified type.
- *
- * @exception NullPointerException if the specified type is null.
+ * @throws IllegalArgumentException if the specified {@code Provider}
+ * is {@code null}, or if the specified parameters are not
+ * understood by the {@code PolicySpi} implementation from the
+ * specified {@code Provider}
*
- * @exception IllegalArgumentException if the specified Provider is null,
- * or if the specified parameters are not understood by
- * the PolicySpi implementation from the specified Provider.
+ * @throws NoSuchAlgorithmException if the specified {@code Provider}
+ * does not support a {@code PolicySpi} implementation for
+ * the specified type
*
- * @exception NoSuchAlgorithmException if the specified Provider does not
- * support a PolicySpi implementation for the specified type.
+ * @throws NullPointerException if {@code type} is {@code null}
+ *
+ * @throws SecurityException if the caller does not have permission
+ * to get a {@code Policy} instance for the specified type
*
* @see Provider
* @since 1.6
@@ -514,6 +519,7 @@
Provider provider)
throws NoSuchAlgorithmException {
+ Objects.requireNonNull(type, "null type name");
if (provider == null) {
throw new IllegalArgumentException("missing provider");
}
--- a/jdk/src/java.base/share/classes/java/security/SecureClassLoader.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/security/SecureClassLoader.java Wed Nov 09 10:04:43 2016 -0800
@@ -25,8 +25,6 @@
package java.security;
-import java.net.URL;
-import java.util.ArrayList;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
@@ -114,6 +112,30 @@
}
/**
+ * Creates a new {@code SecureClassLoader} of the specified name and
+ * using the specified parent class loader for delegation.
+ *
+ * @param name class loader name; or {@code null} if not named
+ * @param parent the parent class loader
+ *
+ * @throws IllegalArgumentException if the given name is empty.
+ *
+ * @throws SecurityException if a security manager exists and its
+ * {@link SecurityManager#checkCreateClassLoader()} method
+ * doesn't allow creation of a class loader.
+ *
+ * @since 9
+ */
+ protected SecureClassLoader(String name, ClassLoader parent) {
+ super(name, parent);
+ SecurityManager security = System.getSecurityManager();
+ if (security != null) {
+ security.checkCreateClassLoader();
+ }
+ initialized = true;
+ }
+
+ /**
* Converts an array of bytes into an instance of class Class,
* with an optional CodeSource. Before the
* class can be used it must be resolved.
--- a/jdk/src/java.base/share/classes/java/security/SecureRandom.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/security/SecureRandom.java Wed Nov 09 10:04:43 2016 -0800
@@ -303,11 +303,13 @@
* Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard RNG algorithm names.
*
- * @return the new {@code SecureRandom} object.
+ * @return the new {@code SecureRandom} object
*
- * @exception NoSuchAlgorithmException if no Provider supports a
- * {@code SecureRandomSpi} implementation for the
- * specified algorithm.
+ * @throws NoSuchAlgorithmException if no {@code Provider} supports a
+ * {@code SecureRandomSpi} implementation for the
+ * specified algorithm
+ *
+ * @throws NullPointerException if {@code algorithm} is {@code null}
*
* @see Provider
*
@@ -315,6 +317,7 @@
*/
public static SecureRandom getInstance(String algorithm)
throws NoSuchAlgorithmException {
+ Objects.requireNonNull(algorithm, "null algorithm name");
Instance instance = GetInstance.getInstance("SecureRandom",
SecureRandomSpi.class, algorithm);
return new SecureRandom((SecureRandomSpi)instance.impl,
@@ -341,17 +344,19 @@
*
* @param provider the name of the provider.
*
- * @return the new {@code SecureRandom} object.
+ * @return the new {@code SecureRandom} object
+ *
+ * @throws IllegalArgumentException if the provider name is {@code null}
+ * or empty
*
* @throws NoSuchAlgorithmException if a {@code SecureRandomSpi}
* implementation for the specified algorithm is not
- * available from the specified provider.
+ * available from the specified provider
*
* @throws NoSuchProviderException if the specified provider is not
- * registered in the security provider list.
+ * registered in the security provider list
*
- * @throws IllegalArgumentException if the provider name is null
- * or empty.
+ * @throws NullPointerException if {@code algorithm} is {@code null}
*
* @see Provider
*
@@ -359,6 +364,7 @@
*/
public static SecureRandom getInstance(String algorithm, String provider)
throws NoSuchAlgorithmException, NoSuchProviderException {
+ Objects.requireNonNull(algorithm, "null algorithm name");
Instance instance = GetInstance.getInstance("SecureRandom",
SecureRandomSpi.class, algorithm, provider);
return new SecureRandom((SecureRandomSpi)instance.impl,
@@ -382,13 +388,16 @@
*
* @param provider the provider.
*
- * @return the new {@code SecureRandom} object.
+ * @return the new {@code SecureRandom} object
+ *
+ * @throws IllegalArgumentException if the specified provider is
+ * {@code null}
*
* @throws NoSuchAlgorithmException if a {@code SecureRandomSpi}
* implementation for the specified algorithm is not available
- * from the specified {@code Provider} object.
+ * from the specified {@code Provider} object
*
- * @throws IllegalArgumentException if the specified provider is null.
+ * @throws NullPointerException if {@code algorithm} is {@code null}
*
* @see Provider
*
@@ -396,6 +405,7 @@
*/
public static SecureRandom getInstance(String algorithm,
Provider provider) throws NoSuchAlgorithmException {
+ Objects.requireNonNull(algorithm, "null algorithm name");
Instance instance = GetInstance.getInstance("SecureRandom",
SecureRandomSpi.class, algorithm, provider);
return new SecureRandom((SecureRandomSpi)instance.impl,
@@ -433,13 +443,16 @@
* @param params the {@code SecureRandomParameters}
* the newly created {@code SecureRandom} object must support.
*
- * @return the new {@code SecureRandom} object.
+ * @return the new {@code SecureRandom} object
+ *
+ * @throws IllegalArgumentException if the specified params is
+ * {@code null}
*
* @throws NoSuchAlgorithmException if no Provider supports a
* {@code SecureRandomSpi} implementation for the specified
- * algorithm and parameters.
+ * algorithm and parameters
*
- * @throws IllegalArgumentException if the specified params is null.
+ * @throws NullPointerException if {@code algorithm} is {@code null}
*
* @see Provider
*
@@ -448,6 +461,7 @@
public static SecureRandom getInstance(
String algorithm, SecureRandomParameters params)
throws NoSuchAlgorithmException {
+ Objects.requireNonNull(algorithm, "null algorithm name");
if (params == null) {
throw new IllegalArgumentException("params cannot be null");
}
@@ -481,17 +495,19 @@
*
* @param provider the name of the provider.
*
- * @return the new {@code SecureRandom} object.
+ * @return the new {@code SecureRandom} object
+ *
+ * @throws IllegalArgumentException if the provider name is {@code null}
+ * or empty, or params is {@code null}
*
* @throws NoSuchAlgorithmException if the specified provider does not
* support a {@code SecureRandomSpi} implementation for the
- * specified algorithm and parameters.
+ * specified algorithm and parameters
*
* @throws NoSuchProviderException if the specified provider is not
- * registered in the security provider list.
+ * registered in the security provider list
*
- * @throws IllegalArgumentException if the provider name is null
- * or empty, or params is null.
+ * @throws NullPointerException if {@code algorithm} is {@code null}
*
* @see Provider
*
@@ -500,6 +516,7 @@
public static SecureRandom getInstance(String algorithm,
SecureRandomParameters params, String provider)
throws NoSuchAlgorithmException, NoSuchProviderException {
+ Objects.requireNonNull(algorithm, "null algorithm name");
if (params == null) {
throw new IllegalArgumentException("params cannot be null");
}
@@ -531,14 +548,16 @@
*
* @param provider the provider.
*
- * @return the new {@code SecureRandom} object.
+ * @return the new {@code SecureRandom} object
+ *
+ * @throws IllegalArgumentException if the specified provider or params
+ * is {@code null}
*
* @throws NoSuchAlgorithmException if the specified provider does not
* support a {@code SecureRandomSpi} implementation for the
- * specified algorithm and parameters.
+ * specified algorithm and parameters
*
- * @throws IllegalArgumentException if the specified provider or params
- * is null.
+ * @throws NullPointerException if {@code algorithm} is {@code null}
*
* @see Provider
*
@@ -547,6 +566,7 @@
public static SecureRandom getInstance(String algorithm,
SecureRandomParameters params, Provider provider)
throws NoSuchAlgorithmException {
+ Objects.requireNonNull(algorithm, "null algorithm name");
if (params == null) {
throw new IllegalArgumentException("params cannot be null");
}
--- a/jdk/src/java.base/share/classes/java/security/Signature.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/security/Signature.java Wed Nov 09 10:04:43 2016 -0800
@@ -213,16 +213,19 @@
* Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard algorithm names.
*
- * @return the new Signature object.
+ * @return the new {@code Signature} object
*
- * @exception NoSuchAlgorithmException if no Provider supports a
- * Signature implementation for the
- * specified algorithm.
+ * @throws NoSuchAlgorithmException if no {@code Provider} supports a
+ * {@code Signature} implementation for the
+ * specified algorithm
+ *
+ * @throws NullPointerException if {@code algorithm} is {@code null}
*
* @see Provider
*/
public static Signature getInstance(String algorithm)
throws NoSuchAlgorithmException {
+ Objects.requireNonNull(algorithm, "null algorithm name");
List<Service> list;
if (algorithm.equalsIgnoreCase(RSA_SIGNATURE)) {
list = GetInstance.getServices(rsaIds);
@@ -335,22 +338,25 @@
*
* @param provider the name of the provider.
*
- * @return the new Signature object.
+ * @return the new {@code Signature} object
*
- * @exception NoSuchAlgorithmException if a SignatureSpi
- * implementation for the specified algorithm is not
- * available from the specified provider.
+ * @throws IllegalArgumentException if the provider name is {@code null}
+ * or empty
*
- * @exception NoSuchProviderException if the specified provider is not
- * registered in the security provider list.
+ * @throws NoSuchAlgorithmException if a {@code SignatureSpi}
+ * implementation for the specified algorithm is not
+ * available from the specified provider
*
- * @exception IllegalArgumentException if the provider name is null
- * or empty.
+ * @throws NoSuchProviderException if the specified provider is not
+ * registered in the security provider list
+ *
+ * @throws NullPointerException if {@code algorithm} is {@code null}
*
* @see Provider
*/
public static Signature getInstance(String algorithm, String provider)
throws NoSuchAlgorithmException, NoSuchProviderException {
+ Objects.requireNonNull(algorithm, "null algorithm name");
if (algorithm.equalsIgnoreCase(RSA_SIGNATURE)) {
// exception compatibility with existing code
if ((provider == null) || (provider.length() == 0)) {
@@ -385,13 +391,15 @@
*
* @param provider the provider.
*
- * @return the new Signature object.
+ * @return the new {@code Signature} object
+ *
+ * @throws IllegalArgumentException if the provider is {@code null}
*
- * @exception NoSuchAlgorithmException if a SignatureSpi
- * implementation for the specified algorithm is not available
- * from the specified Provider object.
+ * @throws NoSuchAlgorithmException if a {@code SignatureSpi}
+ * implementation for the specified algorithm is not available
+ * from the specified {@code Provider} object
*
- * @exception IllegalArgumentException if the provider is null.
+ * @throws NullPointerException if {@code algorithm} is {@code null}
*
* @see Provider
*
@@ -399,6 +407,7 @@
*/
public static Signature getInstance(String algorithm, Provider provider)
throws NoSuchAlgorithmException {
+ Objects.requireNonNull(algorithm, "null algorithm name");
if (algorithm.equalsIgnoreCase(RSA_SIGNATURE)) {
// exception compatibility with existing code
if (provider == null) {
--- a/jdk/src/java.base/share/classes/java/security/cert/CertPathBuilder.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/security/cert/CertPathBuilder.java Wed Nov 09 10:04:43 2016 -0800
@@ -32,7 +32,7 @@
import java.security.PrivilegedAction;
import java.security.Provider;
import java.security.Security;
-import sun.security.util.Debug;
+import java.util.Objects;
import sun.security.jca.*;
import sun.security.jca.GetInstance.Instance;
@@ -157,16 +157,19 @@
* for information about standard algorithm names.
*
* @return a {@code CertPathBuilder} object that implements the
- * specified algorithm.
+ * specified algorithm
*
- * @throws NoSuchAlgorithmException if no Provider supports a
- * CertPathBuilderSpi implementation for the
- * specified algorithm.
+ * @throws NoSuchAlgorithmException if no {@code Provider} supports a
+ * {@code CertPathBuilderSpi} implementation for the
+ * specified algorithm
+ *
+ * @throws NullPointerException if {@code algorithm} is {@code null}
*
* @see java.security.Provider
*/
public static CertPathBuilder getInstance(String algorithm)
throws NoSuchAlgorithmException {
+ Objects.requireNonNull(algorithm, "null algorithm name");
Instance instance = GetInstance.getInstance("CertPathBuilder",
CertPathBuilderSpi.class, algorithm);
return new CertPathBuilder((CertPathBuilderSpi)instance.impl,
@@ -194,22 +197,25 @@
* @param provider the name of the provider.
*
* @return a {@code CertPathBuilder} object that implements the
- * specified algorithm.
+ * specified algorithm
*
- * @throws NoSuchAlgorithmException if a CertPathBuilderSpi
- * implementation for the specified algorithm is not
- * available from the specified provider.
+ * @throws IllegalArgumentException if the {@code provider} is
+ * {@code null} or empty
+ *
+ * @throws NoSuchAlgorithmException if a {@code CertPathBuilderSpi}
+ * implementation for the specified algorithm is not
+ * available from the specified provider
*
* @throws NoSuchProviderException if the specified provider is not
- * registered in the security provider list.
+ * registered in the security provider list
*
- * @exception IllegalArgumentException if the {@code provider} is
- * null or empty.
+ * @throws NullPointerException if {@code algorithm} is {@code null}
*
* @see java.security.Provider
*/
public static CertPathBuilder getInstance(String algorithm, String provider)
throws NoSuchAlgorithmException, NoSuchProviderException {
+ Objects.requireNonNull(algorithm, "null algorithm name");
Instance instance = GetInstance.getInstance("CertPathBuilder",
CertPathBuilderSpi.class, algorithm, provider);
return new CertPathBuilder((CertPathBuilderSpi)instance.impl,
@@ -234,19 +240,22 @@
* @param provider the provider.
*
* @return a {@code CertPathBuilder} object that implements the
- * specified algorithm.
+ * specified algorithm
+ *
+ * @throws IllegalArgumentException if the {@code provider} is
+ * {@code null}
*
- * @exception NoSuchAlgorithmException if a CertPathBuilderSpi
- * implementation for the specified algorithm is not available
- * from the specified Provider object.
+ * @throws NoSuchAlgorithmException if a {@code CertPathBuilderSpi}
+ * implementation for the specified algorithm is not available
+ * from the specified {@code Provider} object
*
- * @exception IllegalArgumentException if the {@code provider} is
- * null.
+ * @throws NullPointerException if {@code algorithm} is {@code null}
*
* @see java.security.Provider
*/
public static CertPathBuilder getInstance(String algorithm,
Provider provider) throws NoSuchAlgorithmException {
+ Objects.requireNonNull(algorithm, "null algorithm name");
Instance instance = GetInstance.getInstance("CertPathBuilder",
CertPathBuilderSpi.class, algorithm, provider);
return new CertPathBuilder((CertPathBuilderSpi)instance.impl,
--- a/jdk/src/java.base/share/classes/java/security/cert/CertPathValidator.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/security/cert/CertPathValidator.java Wed Nov 09 10:04:43 2016 -0800
@@ -32,7 +32,7 @@
import java.security.PrivilegedAction;
import java.security.Provider;
import java.security.Security;
-import sun.security.util.Debug;
+import java.util.Objects;
import sun.security.jca.*;
import sun.security.jca.GetInstance.Instance;
@@ -158,16 +158,19 @@
* for information about standard algorithm names.
*
* @return a {@code CertPathValidator} object that implements the
- * specified algorithm.
+ * specified algorithm
*
- * @exception NoSuchAlgorithmException if no Provider supports a
- * CertPathValidatorSpi implementation for the
- * specified algorithm.
+ * @throws NoSuchAlgorithmException if no {@code Provider} supports a
+ * {@code CertPathValidatorSpi} implementation for the
+ * specified algorithm
+ *
+ * @throws NullPointerException if {@code algorithm} is {@code null}
*
* @see java.security.Provider
*/
public static CertPathValidator getInstance(String algorithm)
throws NoSuchAlgorithmException {
+ Objects.requireNonNull(algorithm, "null algorithm name");
Instance instance = GetInstance.getInstance("CertPathValidator",
CertPathValidatorSpi.class, algorithm);
return new CertPathValidator((CertPathValidatorSpi)instance.impl,
@@ -195,23 +198,26 @@
* @param provider the name of the provider.
*
* @return a {@code CertPathValidator} object that implements the
- * specified algorithm.
+ * specified algorithm
*
- * @exception NoSuchAlgorithmException if a CertPathValidatorSpi
- * implementation for the specified algorithm is not
- * available from the specified provider.
+ * @throws IllegalArgumentException if the {@code provider} is
+ * {@code null} or empty
*
- * @exception NoSuchProviderException if the specified provider is not
- * registered in the security provider list.
+ * @throws NoSuchAlgorithmException if a {@code CertPathValidatorSpi}
+ * implementation for the specified algorithm is not
+ * available from the specified provider
*
- * @exception IllegalArgumentException if the {@code provider} is
- * null or empty.
+ * @throws NoSuchProviderException if the specified provider is not
+ * registered in the security provider list
+ *
+ * @throws NullPointerException if {@code algorithm} is {@code null}
*
* @see java.security.Provider
*/
public static CertPathValidator getInstance(String algorithm,
String provider) throws NoSuchAlgorithmException,
NoSuchProviderException {
+ Objects.requireNonNull(algorithm, "null algorithm name");
Instance instance = GetInstance.getInstance("CertPathValidator",
CertPathValidatorSpi.class, algorithm, provider);
return new CertPathValidator((CertPathValidatorSpi)instance.impl,
@@ -236,19 +242,22 @@
* @param provider the provider.
*
* @return a {@code CertPathValidator} object that implements the
- * specified algorithm.
+ * specified algorithm
+ *
+ * @throws IllegalArgumentException if the {@code provider} is
+ * {@code null}
*
- * @exception NoSuchAlgorithmException if a CertPathValidatorSpi
- * implementation for the specified algorithm is not available
- * from the specified Provider object.
+ * @throws NoSuchAlgorithmException if a {@code CertPathValidatorSpi}
+ * implementation for the specified algorithm is not available
+ * from the specified Provider object
*
- * @exception IllegalArgumentException if the {@code provider} is
- * null.
+ * @throws NullPointerException if {@code algorithm} is {@code null}
*
* @see java.security.Provider
*/
public static CertPathValidator getInstance(String algorithm,
Provider provider) throws NoSuchAlgorithmException {
+ Objects.requireNonNull(algorithm, "null algorithm name");
Instance instance = GetInstance.getInstance("CertPathValidator",
CertPathValidatorSpi.class, algorithm, provider);
return new CertPathValidator((CertPathValidatorSpi)instance.impl,
--- a/jdk/src/java.base/share/classes/java/security/cert/CertStore.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/security/cert/CertStore.java Wed Nov 09 10:04:43 2016 -0800
@@ -33,6 +33,7 @@
import java.security.Provider;
import java.security.Security;
import java.util.Collection;
+import java.util.Objects;
import sun.security.jca.*;
import sun.security.jca.GetInstance.Instance;
@@ -218,20 +219,23 @@
* @param params the initialization parameters (may be {@code null}).
*
* @return a {@code CertStore} object that implements the specified
- * {@code CertStore} type.
- *
- * @throws NoSuchAlgorithmException if no Provider supports a
- * CertStoreSpi implementation for the specified type.
+ * {@code CertStore} type
*
* @throws InvalidAlgorithmParameterException if the specified
- * initialization parameters are inappropriate for this
- * {@code CertStore}.
+ * initialization parameters are inappropriate for this
+ * {@code CertStore}
+ *
+ * @throws NoSuchAlgorithmException if no {@code Provider} supports a
+ * {@code CertStoreSpi} implementation for the specified type
+ *
+ * @throws NullPointerException if {@code type} is {@code null}
*
* @see java.security.Provider
*/
public static CertStore getInstance(String type, CertStoreParameters params)
throws InvalidAlgorithmParameterException,
NoSuchAlgorithmException {
+ Objects.requireNonNull(type, "null type name");
try {
Instance instance = GetInstance.getInstance("CertStore",
CertStoreSpi.class, type, params);
@@ -243,7 +247,8 @@
}
private static CertStore handleException(NoSuchAlgorithmException e)
- throws NoSuchAlgorithmException, InvalidAlgorithmParameterException {
+ throws NoSuchAlgorithmException,
+ InvalidAlgorithmParameterException {
Throwable cause = e.getCause();
if (cause instanceof InvalidAlgorithmParameterException) {
throw (InvalidAlgorithmParameterException)cause;
@@ -280,21 +285,23 @@
* @param provider the name of the provider.
*
* @return a {@code CertStore} object that implements the
- * specified type.
+ * specified type
*
- * @throws NoSuchAlgorithmException if a CertStoreSpi
- * implementation for the specified type is not
- * available from the specified provider.
+ * @throws IllegalArgumentException if the {@code provider} is
+ * {@code null} or empty
*
* @throws InvalidAlgorithmParameterException if the specified
- * initialization parameters are inappropriate for this
- * {@code CertStore}.
+ * initialization parameters are inappropriate for this
+ * {@code CertStore}
+ *
+ * @throws NoSuchAlgorithmException if a {@code CertStoreSpi}
+ * implementation for the specified type is not
+ * available from the specified provider
*
* @throws NoSuchProviderException if the specified provider is not
- * registered in the security provider list.
+ * registered in the security provider list
*
- * @exception IllegalArgumentException if the {@code provider} is
- * null or empty.
+ * @throws NullPointerException if {@code type} is {@code null}
*
* @see java.security.Provider
*/
@@ -302,6 +309,7 @@
CertStoreParameters params, String provider)
throws InvalidAlgorithmParameterException,
NoSuchAlgorithmException, NoSuchProviderException {
+ Objects.requireNonNull(type, "null type name");
try {
Instance instance = GetInstance.getInstance("CertStore",
CertStoreSpi.class, type, params, provider);
@@ -338,24 +346,27 @@
* @param provider the provider.
*
* @return a {@code CertStore} object that implements the
- * specified type.
+ * specified type
*
- * @exception NoSuchAlgorithmException if a CertStoreSpi
- * implementation for the specified type is not available
- * from the specified Provider object.
+ * @throws IllegalArgumentException if the {@code provider} is
+ * null
*
* @throws InvalidAlgorithmParameterException if the specified
- * initialization parameters are inappropriate for this
- * {@code CertStore}
+ * initialization parameters are inappropriate for this
+ * {@code CertStore}
*
- * @exception IllegalArgumentException if the {@code provider} is
- * null.
+ * @throws NoSuchAlgorithmException if a {@code CertStoreSpi}
+ * implementation for the specified type is not available
+ * from the specified Provider object
+ *
+ * @throws NullPointerException if {@code type} is {@code null}
*
* @see java.security.Provider
*/
public static CertStore getInstance(String type, CertStoreParameters params,
Provider provider) throws NoSuchAlgorithmException,
InvalidAlgorithmParameterException {
+ Objects.requireNonNull(type, "null type name");
try {
Instance instance = GetInstance.getInstance("CertStore",
CertStoreSpi.class, type, params, provider);
--- a/jdk/src/java.base/share/classes/java/security/cert/CertificateFactory.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/security/cert/CertificateFactory.java Wed Nov 09 10:04:43 2016 -0800
@@ -29,10 +29,9 @@
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
+import java.util.Objects;
import java.security.Provider;
import java.security.Security;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
@@ -177,16 +176,19 @@
* Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard certificate types.
*
- * @return a certificate factory object for the specified type.
+ * @return a certificate factory object for the specified type
*
- * @exception CertificateException if no Provider supports a
- * CertificateFactorySpi implementation for the
- * specified type.
+ * @throws CertificateException if no {@code Provider} supports a
+ * {@code CertificateFactorySpi} implementation for the
+ * specified type
+ *
+ * @throws NullPointerException if {@code type} is {@code null}
*
* @see java.security.Provider
*/
public static final CertificateFactory getInstance(String type)
throws CertificateException {
+ Objects.requireNonNull(type, "null type name");
try {
Instance instance = GetInstance.getInstance("CertificateFactory",
CertificateFactorySpi.class, type);
@@ -217,23 +219,26 @@
*
* @param provider the name of the provider.
*
- * @return a certificate factory object for the specified type.
+ * @return a certificate factory object for the specified type
*
- * @exception CertificateException if a CertificateFactorySpi
- * implementation for the specified algorithm is not
- * available from the specified provider.
+ * @throws CertificateException if a {@code CertificateFactorySpi}
+ * implementation for the specified algorithm is not
+ * available from the specified provider
*
- * @exception NoSuchProviderException if the specified provider is not
- * registered in the security provider list.
+ * @throws IllegalArgumentException if the provider name is {@code null}
+ * or empty
*
- * @exception IllegalArgumentException if the provider name is null
- * or empty.
+ * @throws NoSuchProviderException if the specified provider is not
+ * registered in the security provider list
+ *
+ * @throws NullPointerException if {@code type} is {@code null}
*
* @see java.security.Provider
*/
public static final CertificateFactory getInstance(String type,
String provider) throws CertificateException,
NoSuchProviderException {
+ Objects.requireNonNull(type, "null type name");
try {
Instance instance = GetInstance.getInstance("CertificateFactory",
CertificateFactorySpi.class, type, provider);
@@ -260,14 +265,16 @@
* for information about standard certificate types.
* @param provider the provider.
*
- * @return a certificate factory object for the specified type.
+ * @return a certificate factory object for the specified type
*
- * @exception CertificateException if a CertificateFactorySpi
- * implementation for the specified algorithm is not available
- * from the specified Provider object.
+ * @throws CertificateException if a {@code CertificateFactorySpi}
+ * implementation for the specified algorithm is not available
+ * from the specified {@code Provider} object
*
- * @exception IllegalArgumentException if the {@code provider} is
- * null.
+ * @throws IllegalArgumentException if the {@code provider} is
+ * {@code null}
+ *
+ * @throws NullPointerException if {@code type} is {@code null}
*
* @see java.security.Provider
*
@@ -275,6 +282,7 @@
*/
public static final CertificateFactory getInstance(String type,
Provider provider) throws CertificateException {
+ Objects.requireNonNull(type, "null type name");
try {
Instance instance = GetInstance.getInstance("CertificateFactory",
CertificateFactorySpi.class, type, provider);
--- a/jdk/src/java.base/share/classes/java/util/ImmutableCollections.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/util/ImmutableCollections.java Wed Nov 09 10:04:43 2016 -0800
@@ -53,7 +53,8 @@
*/
static final int SALT;
static {
- SALT = new Random().nextInt();
+ long nt = System.nanoTime();
+ SALT = (int)((nt >>> 32) ^ nt);
}
/** No instances. */
@@ -63,7 +64,7 @@
* The reciprocal of load factor. Given a number of elements
* to store, multiply by this factor to get the table size.
*/
- static final double EXPAND_FACTOR = 2.0;
+ static final int EXPAND_FACTOR = 2;
static UnsupportedOperationException uoe() { return new UnsupportedOperationException(); }
@@ -84,7 +85,14 @@
}
static final class List0<E> extends AbstractImmutableList<E> {
- List0() { }
+ private static final List0<?> INSTANCE = new List0<>();
+
+ @SuppressWarnings("unchecked")
+ static <T> List0<T> instance() {
+ return (List0<T>) INSTANCE;
+ }
+
+ private List0() { }
@Override
public int size() {
@@ -214,7 +222,14 @@
}
static final class Set0<E> extends AbstractImmutableSet<E> {
- Set0() { }
+ private static final Set0<?> INSTANCE = new Set0<>();
+
+ @SuppressWarnings("unchecked")
+ static <T> Set0<T> instance() {
+ return (Set0<T>) INSTANCE;
+ }
+
+ private Set0() { }
@Override
public int size() {
@@ -351,7 +366,7 @@
SetN(E... input) {
size = input.length; // implicit nullcheck of input
- elements = (E[])new Object[(int)Math.ceil(EXPAND_FACTOR * input.length)];
+ elements = (E[])new Object[EXPAND_FACTOR * input.length];
for (int i = 0; i < input.length; i++) {
E e = Objects.requireNonNull(input[i]);
int idx = probe(e);
@@ -450,7 +465,14 @@
}
static final class Map0<K,V> extends AbstractImmutableMap<K,V> {
- Map0() { }
+ private static final Map0<?,?> INSTANCE = new Map0<>();
+
+ @SuppressWarnings("unchecked")
+ static <K,V> Map0<K,V> instance() {
+ return (Map0<K,V>) INSTANCE;
+ }
+
+ private Map0() { }
@Override
public Set<Map.Entry<K,V>> entrySet() {
@@ -529,7 +551,7 @@
}
size = input.length >> 1;
- int len = (int)Math.ceil(EXPAND_FACTOR * input.length);
+ int len = EXPAND_FACTOR * input.length;
len = (len + 1) & ~1; // ensure table is even length
table = new Object[len];
@@ -789,7 +811,7 @@
return Set.of(array);
case IMM_MAP:
if (array.length == 0) {
- return new ImmutableCollections.Map0<>();
+ return ImmutableCollections.Map0.instance();
} else if (array.length == 2) {
return new ImmutableCollections.Map1<>(array[0], array[1]);
} else {
--- a/jdk/src/java.base/share/classes/java/util/List.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/util/List.java Wed Nov 09 10:04:43 2016 -0800
@@ -786,7 +786,7 @@
* @since 9
*/
static <E> List<E> of() {
- return new ImmutableCollections.List0<>();
+ return ImmutableCollections.List0.instance();
}
/**
@@ -1030,7 +1030,7 @@
Objects.requireNonNull(elements);
switch (elements.length) {
case 0:
- return new ImmutableCollections.List0<>();
+ return ImmutableCollections.List0.instance();
case 1:
return new ImmutableCollections.List1<>(elements[0]);
case 2:
--- a/jdk/src/java.base/share/classes/java/util/Map.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/util/Map.java Wed Nov 09 10:04:43 2016 -0800
@@ -1286,7 +1286,7 @@
* @since 9
*/
static <K, V> Map<K, V> of() {
- return new ImmutableCollections.Map0<>();
+ return ImmutableCollections.Map0.instance();
}
/**
@@ -1604,7 +1604,7 @@
static <K, V> Map<K, V> ofEntries(Entry<? extends K, ? extends V>... entries) {
Objects.requireNonNull(entries);
if (entries.length == 0) {
- return new ImmutableCollections.Map0<>();
+ return ImmutableCollections.Map0.instance();
} else if (entries.length == 1) {
return new ImmutableCollections.Map1<>(entries[0].getKey(),
entries[0].getValue());
--- a/jdk/src/java.base/share/classes/java/util/Set.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/util/Set.java Wed Nov 09 10:04:43 2016 -0800
@@ -448,7 +448,7 @@
* @since 9
*/
static <E> Set<E> of() {
- return new ImmutableCollections.Set0<>();
+ return ImmutableCollections.Set0.instance();
}
/**
@@ -692,7 +692,7 @@
Objects.requireNonNull(elements);
switch (elements.length) {
case 0:
- return new ImmutableCollections.Set0<>();
+ return ImmutableCollections.Set0.instance();
case 1:
return new ImmutableCollections.Set1<>(elements[0]);
case 2:
--- a/jdk/src/java.base/share/classes/java/util/jar/JarFile.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/util/jar/JarFile.java Wed Nov 09 10:04:43 2016 -0800
@@ -192,9 +192,10 @@
public static final String MANIFEST_NAME = META_INF + "MANIFEST.MF";
/**
- * The version that represents the unversioned configuration of a multi-release jar file.
+ * Returns the version that represents the unversioned configuration of a
+ * multi-release jar file.
*
- * @return Runtime.Version that represents the unversioned configuration
+ * @return the version that represents the unversioned configuration
*
* @since 9
*/
@@ -203,13 +204,16 @@
}
/**
- * The version that represents the effective runtime versioned configuration of a
- * multi-release jar file. In most cases, {@code runtimeVersion()} is equal to
- * {@code Runtime.version()}. However, if the {@code jdk.util.jar.version} property is set,
- * {@code runtimeVersion()} is derived from that property and may not be equal to
- * {@code Runtime.version()}.
+ * Returns the version that represents the effective runtime versioned
+ * configuration of a multi-release jar file.
+ * <p>
+ * By default the major version number of the returned {@code Version} will
+ * be equal to the major version number of {@code Runtime.version()}.
+ * However, if the {@code jdk.util.jar.version} property is set, the
+ * returned {@code Version} is derived from that property and major version
+ * numbers may not be equal.
*
- * @return Runtime.Version that represents the runtime versioned configuration
+ * @return the version that represents the runtime versioned configuration
*
* @since 9
*/
@@ -335,6 +339,10 @@
/**
* Returns the maximum version used when searching for versioned entries.
+ * <p>
+ * If this {@code JarFile} is not a multi-release jar file or is not
+ * configured to be processed as such, then the version returned will be the
+ * same as that returned from {@link #baseVersion()}.
*
* @return the maximum version
* @since 9
--- a/jdk/src/java.base/share/classes/java/util/stream/Collectors.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/util/stream/Collectors.java Wed Nov 09 10:04:43 2016 -0800
@@ -508,7 +508,7 @@
* transformation. For example, one could adapt the {@link #toList()}
* collector to always produce an immutable list with:
* <pre>{@code
- * List<String> people
+ * List<String> list
* = people.stream().collect(collectingAndThen(toList(), Collections::unmodifiableList));
* }</pre>
*
--- a/jdk/src/java.base/share/classes/javax/crypto/Cipher.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.base/share/classes/javax/crypto/Cipher.java Wed Nov 09 10:04:43 2016 -0800
@@ -493,21 +493,24 @@
* Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard transformation names.
*
- * @return a cipher that implements the requested transformation.
+ * @return a cipher that implements the requested transformation
*
- * @exception NoSuchAlgorithmException if {@code transformation}
- * is null, empty, in an invalid format,
- * or if no Provider supports a CipherSpi implementation for the
- * specified algorithm.
+ * @throws NoSuchAlgorithmException if {@code transformation}
+ * is {@code null}, empty, in an invalid format,
+ * or if no {@code Provider} supports a {@code CipherSpi}
+ * implementation for the specified algorithm
*
- * @exception NoSuchPaddingException if {@code transformation}
- * contains a padding scheme that is not available.
+ * @throws NoSuchPaddingException if {@code transformation}
+ * contains a padding scheme that is not available
*
* @see java.security.Provider
*/
public static final Cipher getInstance(String transformation)
throws NoSuchAlgorithmException, NoSuchPaddingException
{
+ if ((transformation == null) || transformation.equals("")) {
+ throw new NoSuchAlgorithmException("Null or empty transformation");
+ }
List<Transform> transforms = getTransforms(transformation);
List<ServiceId> cipherServices = new ArrayList<>(transforms.size());
for (Transform transform : transforms) {
@@ -570,21 +573,22 @@
*
* @param provider the name of the provider.
*
- * @return a cipher that implements the requested transformation.
+ * @return a cipher that implements the requested transformation
*
- * @exception NoSuchAlgorithmException if {@code transformation}
- * is null, empty, in an invalid format,
- * or if a CipherSpi implementation for the specified algorithm
- * is not available from the specified provider.
+ * @throws IllegalArgumentException if the {@code provider}
+ * is {@code null} or empty
*
- * @exception NoSuchProviderException if the specified provider is not
- * registered in the security provider list.
+ * @throws NoSuchAlgorithmException if {@code transformation}
+ * is {@code null}, empty, in an invalid format,
+ * or if a {@code CipherSpi} implementation for the
+ * specified algorithm is not available from the specified
+ * provider
*
- * @exception NoSuchPaddingException if {@code transformation}
- * contains a padding scheme that is not available.
+ * @throws NoSuchPaddingException if {@code transformation}
+ * contains a padding scheme that is not available
*
- * @exception IllegalArgumentException if the {@code provider}
- * is null or empty.
+ * @throws NoSuchProviderException if the specified provider is not
+ * registered in the security provider list
*
* @see java.security.Provider
*/
@@ -593,6 +597,9 @@
throws NoSuchAlgorithmException, NoSuchProviderException,
NoSuchPaddingException
{
+ if ((transformation == null) || transformation.equals("")) {
+ throw new NoSuchAlgorithmException("Null or empty transformation");
+ }
if ((provider == null) || (provider.length() == 0)) {
throw new IllegalArgumentException("Missing provider");
}
@@ -622,18 +629,19 @@
*
* @param provider the provider.
*
- * @return a cipher that implements the requested transformation.
+ * @return a cipher that implements the requested transformation
+ *
+ * @throws IllegalArgumentException if the {@code provider}
+ * is {@code null}
*
- * @exception NoSuchAlgorithmException if {@code transformation}
- * is null, empty, in an invalid format,
- * or if a CipherSpi implementation for the specified algorithm
- * is not available from the specified Provider object.
+ * @throws NoSuchAlgorithmException if {@code transformation}
+ * is {@code null}, empty, in an invalid format,
+ * or if a {@code CipherSpi} implementation for the
+ * specified algorithm is not available from the specified
+ * {@code Provider} object
*
- * @exception NoSuchPaddingException if {@code transformation}
- * contains a padding scheme that is not available.
- *
- * @exception IllegalArgumentException if the {@code provider}
- * is null.
+ * @throws NoSuchPaddingException if {@code transformation}
+ * contains a padding scheme that is not available
*
* @see java.security.Provider
*/
@@ -641,6 +649,9 @@
Provider provider)
throws NoSuchAlgorithmException, NoSuchPaddingException
{
+ if ((transformation == null) || transformation.equals("")) {
+ throw new NoSuchAlgorithmException("Null or empty transformation");
+ }
if (provider == null) {
throw new IllegalArgumentException("Missing provider");
}
--- a/jdk/src/java.base/share/classes/javax/crypto/ExemptionMechanism.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.base/share/classes/javax/crypto/ExemptionMechanism.java Wed Nov 09 10:04:43 2016 -0800
@@ -34,6 +34,7 @@
import java.security.InvalidKeyException;
import java.security.InvalidAlgorithmParameterException;
import java.security.spec.AlgorithmParameterSpec;
+import java.util.Objects;
import sun.security.jca.GetInstance.Instance;
@@ -128,19 +129,19 @@
* Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard exemption mechanism names.
*
- * @return the new <code>ExemptionMechanism</code> object.
+ * @return the new {@code ExemptionMechanism} object
*
- * @exception NullPointerException if <code>algorithm</code>
- * is null.
+ * @throws NoSuchAlgorithmException if no {@code Provider} supports an
+ * {@code ExemptionMechanismSpi} implementation for the
+ * specified algorithm
*
- * @exception NoSuchAlgorithmException if no Provider supports an
- * ExemptionMechanismSpi implementation for the
- * specified algorithm.
+ * @throws NullPointerException if {@code algorithm} is {@code null}
*
* @see java.security.Provider
*/
public static final ExemptionMechanism getInstance(String algorithm)
throws NoSuchAlgorithmException {
+ Objects.requireNonNull(algorithm, "null algorithm name");
Instance instance = JceSecurity.getInstance("ExemptionMechanism",
ExemptionMechanismSpi.class, algorithm);
return new ExemptionMechanism((ExemptionMechanismSpi)instance.impl,
@@ -169,26 +170,26 @@
*
* @param provider the name of the provider.
*
- * @return the new <code>ExemptionMechanism</code> object.
+ * @return the new {@code ExemptionMechanism} object
*
- * @exception NullPointerException if <code>algorithm</code>
- * is null.
+ * @throws IllegalArgumentException if the {@code provider}
+ * is {@code null} or empty
*
- * @exception NoSuchAlgorithmException if an ExemptionMechanismSpi
- * implementation for the specified algorithm is not
- * available from the specified provider.
+ * @throws NoSuchAlgorithmException if an {@code ExemptionMechanismSpi}
+ * implementation for the specified algorithm is not
+ * available from the specified provider
*
- * @exception NoSuchProviderException if the specified provider is not
- * registered in the security provider list.
+ * @throws NoSuchProviderException if the specified provider is not
+ * registered in the security provider list
*
- * @exception IllegalArgumentException if the <code>provider</code>
- * is null or empty.
+ * @throws NullPointerException if {@code algorithm} is {@code null}
*
* @see java.security.Provider
*/
public static final ExemptionMechanism getInstance(String algorithm,
String provider) throws NoSuchAlgorithmException,
NoSuchProviderException {
+ Objects.requireNonNull(algorithm, "null algorithm name");
Instance instance = JceSecurity.getInstance("ExemptionMechanism",
ExemptionMechanismSpi.class, algorithm, provider);
return new ExemptionMechanism((ExemptionMechanismSpi)instance.impl,
@@ -213,22 +214,22 @@
*
* @param provider the provider.
*
- * @return the new <code>ExemptionMechanism</code> object.
+ * @return the new {@code ExemptionMechanism} object
*
- * @exception NullPointerException if <code>algorithm</code>
- * is null.
+ * @throws IllegalArgumentException if the {@code provider}
+ * is null
*
- * @exception NoSuchAlgorithmException if an ExemptionMechanismSpi
- * implementation for the specified algorithm is not available
- * from the specified Provider object.
+ * @throws NoSuchAlgorithmException if an {@code ExemptionMechanismSpi}
+ * implementation for the specified algorithm is not available
+ * from the specified {@code Provider object}
*
- * @exception IllegalArgumentException if the <code>provider</code>
- * is null.
+ * @exception NullPointerException if {@code algorithm} is {@code null}
*
* @see java.security.Provider
*/
public static final ExemptionMechanism getInstance(String algorithm,
Provider provider) throws NoSuchAlgorithmException {
+ Objects.requireNonNull(algorithm, "null algorithm name");
Instance instance = JceSecurity.getInstance("ExemptionMechanism",
ExemptionMechanismSpi.class, algorithm, provider);
return new ExemptionMechanism((ExemptionMechanismSpi)instance.impl,
--- a/jdk/src/java.base/share/classes/javax/crypto/KeyAgreement.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.base/share/classes/javax/crypto/KeyAgreement.java Wed Nov 09 10:04:43 2016 -0800
@@ -165,19 +165,19 @@
* Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard algorithm names.
*
- * @return the new {@code KeyAgreement} object.
+ * @return the new {@code KeyAgreement} object
*
- * @exception NullPointerException if the specified algorithm
- * is null.
+ * @throws NoSuchAlgorithmException if no {@code Provider} supports a
+ * {@code KeyAgreementSpi} implementation for the
+ * specified algorithm
*
- * @exception NoSuchAlgorithmException if no Provider supports a
- * KeyAgreementSpi implementation for the
- * specified algorithm.
+ * @throws NullPointerException if {@code algorithm} is {@code null}
*
* @see java.security.Provider
*/
public static final KeyAgreement getInstance(String algorithm)
throws NoSuchAlgorithmException {
+ Objects.requireNonNull(algorithm, "null algorithm name");
List<Service> services =
GetInstance.getServices("KeyAgreement", algorithm);
// make sure there is at least one service from a signed provider
@@ -214,26 +214,26 @@
*
* @param provider the name of the provider.
*
- * @return the new {@code KeyAgreement} object.
+ * @return the new {@code KeyAgreement} object
*
- * @exception NullPointerException if the specified algorithm
- * is null.
+ * @throws IllegalArgumentException if the {@code provider}
+ * is {@code null} or empty
*
- * @exception NoSuchAlgorithmException if a KeyAgreementSpi
- * implementation for the specified algorithm is not
- * available from the specified provider.
+ * @throws NoSuchAlgorithmException if a {@code KeyAgreementSpi}
+ * implementation for the specified algorithm is not
+ * available from the specified provider
*
- * @exception NoSuchProviderException if the specified provider is not
- * registered in the security provider list.
+ * @throws NoSuchProviderException if the specified provider is not
+ * registered in the security provider list
*
- * @exception IllegalArgumentException if the {@code provider}
- * is null or empty.
+ * @throws NullPointerException if {@code algorithm} is {@code null}
*
* @see java.security.Provider
*/
public static final KeyAgreement getInstance(String algorithm,
String provider) throws NoSuchAlgorithmException,
NoSuchProviderException {
+ Objects.requireNonNull(algorithm, "null algorithm name");
Instance instance = JceSecurity.getInstance
("KeyAgreement", KeyAgreementSpi.class, algorithm, provider);
return new KeyAgreement((KeyAgreementSpi)instance.impl,
@@ -258,22 +258,22 @@
*
* @param provider the provider.
*
- * @return the new {@code KeyAgreement} object.
+ * @return the new {@code KeyAgreement} object
*
- * @exception NullPointerException if the specified algorithm
- * is null.
+ * @throws IllegalArgumentException if the {@code provider}
+ * is {@code null}
*
- * @exception NoSuchAlgorithmException if a KeyAgreementSpi
- * implementation for the specified algorithm is not available
- * from the specified Provider object.
+ * @throws NoSuchAlgorithmException if a {@code KeyAgreementSpi}
+ * implementation for the specified algorithm is not available
+ * from the specified Provider object
*
- * @exception IllegalArgumentException if the {@code provider}
- * is null.
+ * @throws NullPointerException if {@code algorithm} is {@code null}
*
* @see java.security.Provider
*/
public static final KeyAgreement getInstance(String algorithm,
Provider provider) throws NoSuchAlgorithmException {
+ Objects.requireNonNull(algorithm, "null algorithm name");
Instance instance = JceSecurity.getInstance
("KeyAgreement", KeyAgreementSpi.class, algorithm, provider);
return new KeyAgreement((KeyAgreementSpi)instance.impl,
--- a/jdk/src/java.base/share/classes/javax/crypto/KeyGenerator.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.base/share/classes/javax/crypto/KeyGenerator.java Wed Nov 09 10:04:43 2016 -0800
@@ -216,18 +216,19 @@
* Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard algorithm names.
*
- * @return the new {@code KeyGenerator} object.
- *
- * @exception NullPointerException if the specified algorithm is null.
+ * @return the new {@code KeyGenerator} object
*
- * @exception NoSuchAlgorithmException if no Provider supports a
- * KeyGeneratorSpi implementation for the
- * specified algorithm.
+ * @throws NoSuchAlgorithmException if no {@code Provider} supports a
+ * {@code KeyGeneratorSpi} implementation for the
+ * specified algorithm
+ *
+ * @throws NullPointerException if {@code algorithm} is {@code null}
*
* @see java.security.Provider
*/
public static final KeyGenerator getInstance(String algorithm)
throws NoSuchAlgorithmException {
+ Objects.requireNonNull(algorithm, "null algorithm name");
return new KeyGenerator(algorithm);
}
@@ -251,25 +252,26 @@
*
* @param provider the name of the provider.
*
- * @return the new {@code KeyGenerator} object.
+ * @return the new {@code KeyGenerator} object
*
- * @exception NullPointerException if the specified algorithm is null.
+ * @throws IllegalArgumentException if the {@code provider}
+ * is {@code null} or empty
*
- * @exception NoSuchAlgorithmException if a KeyGeneratorSpi
- * implementation for the specified algorithm is not
- * available from the specified provider.
+ * @throws NoSuchAlgorithmException if a {@code KeyGeneratorSpi}
+ * implementation for the specified algorithm is not
+ * available from the specified provider
*
- * @exception NoSuchProviderException if the specified provider is not
- * registered in the security provider list.
+ * @throws NoSuchProviderException if the specified provider is not
+ * registered in the security provider list
*
- * @exception IllegalArgumentException if the {@code provider}
- * is null or empty.
+ * @throws NullPointerException if {@code algorithm} is {@code null}
*
* @see java.security.Provider
*/
public static final KeyGenerator getInstance(String algorithm,
String provider) throws NoSuchAlgorithmException,
NoSuchProviderException {
+ Objects.requireNonNull(algorithm, "null algorithm name");
Instance instance = JceSecurity.getInstance("KeyGenerator",
KeyGeneratorSpi.class, algorithm, provider);
return new KeyGenerator((KeyGeneratorSpi)instance.impl,
@@ -293,21 +295,22 @@
*
* @param provider the provider.
*
- * @return the new {@code KeyGenerator} object.
+ * @return the new {@code KeyGenerator} object
*
- * @exception NullPointerException if the specified algorithm is null.
+ * @throws IllegalArgumentException if the {@code provider}
+ * is {@code null}
*
- * @exception NoSuchAlgorithmException if a KeyGeneratorSpi
- * implementation for the specified algorithm is not available
- * from the specified Provider object.
+ * @throws NoSuchAlgorithmException if a {@code KeyGeneratorSpi}
+ * implementation for the specified algorithm is not available
+ * from the specified {@code Provider} object
*
- * @exception IllegalArgumentException if the {@code provider}
- * is null.
+ * @throws NullPointerException if {@code algorithm} is {@code null}
*
* @see java.security.Provider
*/
public static final KeyGenerator getInstance(String algorithm,
Provider provider) throws NoSuchAlgorithmException {
+ Objects.requireNonNull(algorithm, "null algorithm name");
Instance instance = JceSecurity.getInstance("KeyGenerator",
KeyGeneratorSpi.class, algorithm, provider);
return new KeyGenerator((KeyGeneratorSpi)instance.impl,
--- a/jdk/src/java.base/share/classes/javax/crypto/Mac.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.base/share/classes/javax/crypto/Mac.java Wed Nov 09 10:04:43 2016 -0800
@@ -166,16 +166,18 @@
* Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard algorithm names.
*
- * @return the new {@code Mac} object.
+ * @return the new {@code Mac} object
*
- * @exception NoSuchAlgorithmException if no Provider supports a
- * MacSpi implementation for the
- * specified algorithm.
+ * @throws NoSuchAlgorithmException if no {@code Provider} supports a
+ * {@code MacSpi} implementation for the specified algorithm
+ *
+ * @throws NullPointerException if {@code algorithm} is {@code null}
*
* @see java.security.Provider
*/
public static final Mac getInstance(String algorithm)
throws NoSuchAlgorithmException {
+ Objects.requireNonNull(algorithm, "null algorithm name");
List<Service> services = GetInstance.getServices("Mac", algorithm);
// make sure there is at least one service from a signed provider
Iterator<Service> t = services.iterator();
@@ -210,22 +212,25 @@
*
* @param provider the name of the provider.
*
- * @return the new {@code Mac} object.
+ * @return the new {@code Mac} object
*
- * @exception NoSuchAlgorithmException if a MacSpi
- * implementation for the specified algorithm is not
- * available from the specified provider.
+ * @throws IllegalArgumentException if the {@code provider}
+ * is {@code null} or empty
*
- * @exception NoSuchProviderException if the specified provider is not
- * registered in the security provider list.
+ * @throws NoSuchAlgorithmException if a {@code MacSpi}
+ * implementation for the specified algorithm is not
+ * available from the specified provider
*
- * @exception IllegalArgumentException if the {@code provider}
- * is null or empty.
+ * @throws NoSuchProviderException if the specified provider is not
+ * registered in the security provider list
+ *
+ * @throws NullPointerException if {@code algorithm} is {@code null}
*
* @see java.security.Provider
*/
public static final Mac getInstance(String algorithm, String provider)
throws NoSuchAlgorithmException, NoSuchProviderException {
+ Objects.requireNonNull(algorithm, "null algorithm name");
Instance instance = JceSecurity.getInstance
("Mac", MacSpi.class, algorithm, provider);
return new Mac((MacSpi)instance.impl, instance.provider, algorithm);
@@ -248,19 +253,22 @@
*
* @param provider the provider.
*
- * @return the new {@code Mac} object.
+ * @return the new {@code Mac} object
+ *
+ * @throws IllegalArgumentException if the {@code provider} is
+ * {@code null}
*
- * @exception NoSuchAlgorithmException if a MacSpi
- * implementation for the specified algorithm is not available
- * from the specified Provider object.
+ * @throws NoSuchAlgorithmException if a {@code MacSpi}
+ * implementation for the specified algorithm is not available
+ * from the specified {@code Provider} object
*
- * @exception IllegalArgumentException if the {@code provider}
- * is null.
+ * @throws NullPointerException if {@code algorithm} is {@code null}
*
* @see java.security.Provider
*/
public static final Mac getInstance(String algorithm, Provider provider)
throws NoSuchAlgorithmException {
+ Objects.requireNonNull(algorithm, "null algorithm name");
Instance instance = JceSecurity.getInstance
("Mac", MacSpi.class, algorithm, provider);
return new Mac((MacSpi)instance.impl, instance.provider, algorithm);
--- a/jdk/src/java.base/share/classes/javax/crypto/SecretKeyFactory.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.base/share/classes/javax/crypto/SecretKeyFactory.java Wed Nov 09 10:04:43 2016 -0800
@@ -152,19 +152,19 @@
* Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard algorithm names.
*
- * @return the new {@code SecretKeyFactory} object.
+ * @return the new {@code SecretKeyFactory} object
*
- * @exception NullPointerException if the specified algorithm
- * is null.
+ * @throws NoSuchAlgorithmException if no {@code Provider} supports a
+ * {@code SecretKeyFactorySpi} implementation for the
+ * specified algorithm
*
- * @exception NoSuchAlgorithmException if no Provider supports a
- * SecretKeyFactorySpi implementation for the
- * specified algorithm.
+ * @throws NullPointerException if {@code algorithm} is {@code null}
*
* @see java.security.Provider
*/
public static final SecretKeyFactory getInstance(String algorithm)
throws NoSuchAlgorithmException {
+ Objects.requireNonNull(algorithm, "null algorithm name");
return new SecretKeyFactory(algorithm);
}
@@ -189,26 +189,26 @@
*
* @param provider the name of the provider.
*
- * @return the new {@code SecretKeyFactory} object.
+ * @return the new {@code SecretKeyFactory} object
*
- * @exception NoSuchAlgorithmException if a SecretKeyFactorySpi
- * implementation for the specified algorithm is not
- * available from the specified provider.
+ * @throws IllegalArgumentException if the {@code provider}
+ * is {@code null} or empty
*
- * @exception NullPointerException if the specified algorithm
- * is null.
+ * @throws NoSuchAlgorithmException if a {@code SecretKeyFactorySpi}
+ * implementation for the specified algorithm is not
+ * available from the specified provider
*
* @throws NoSuchProviderException if the specified provider is not
- * registered in the security provider list.
+ * registered in the security provider list
*
- * @exception IllegalArgumentException if the {@code provider}
- * is null or empty.
+ * @throws NullPointerException if {@code algorithm} is {@code null}
*
* @see java.security.Provider
*/
public static final SecretKeyFactory getInstance(String algorithm,
String provider) throws NoSuchAlgorithmException,
NoSuchProviderException {
+ Objects.requireNonNull(algorithm, "null algorithm name");
Instance instance = JceSecurity.getInstance("SecretKeyFactory",
SecretKeyFactorySpi.class, algorithm, provider);
return new SecretKeyFactory((SecretKeyFactorySpi)instance.impl,
@@ -233,22 +233,22 @@
*
* @param provider the provider.
*
- * @return the new {@code SecretKeyFactory} object.
+ * @return the new {@code SecretKeyFactory} object
*
- * @exception NullPointerException if the specified algorithm
- * is null.
+ * @throws IllegalArgumentException if the {@code provider}
+ * is {@code null}
*
- * @exception NoSuchAlgorithmException if a SecretKeyFactorySpi
- * implementation for the specified algorithm is not available
- * from the specified Provider object.
+ * @throws NoSuchAlgorithmException if a {@code SecretKeyFactorySpi}
+ * implementation for the specified algorithm is not available
+ * from the specified {@code Provider} object
*
- * @exception IllegalArgumentException if the {@code provider}
- * is null.
+ * @throws NullPointerException if {@code algorithm} is {@code null}
*
* @see java.security.Provider
*/
public static final SecretKeyFactory getInstance(String algorithm,
Provider provider) throws NoSuchAlgorithmException {
+ Objects.requireNonNull(algorithm, "null algorithm name");
Instance instance = JceSecurity.getInstance("SecretKeyFactory",
SecretKeyFactorySpi.class, algorithm, provider);
return new SecretKeyFactory((SecretKeyFactorySpi)instance.impl,
--- a/jdk/src/java.base/share/classes/javax/net/ssl/KeyManagerFactory.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.base/share/classes/javax/net/ssl/KeyManagerFactory.java Wed Nov 09 10:04:43 2016 -0800
@@ -27,6 +27,7 @@
import java.security.Security;
import java.security.*;
+import java.util.Objects;
import sun.security.jca.GetInstance;
@@ -130,17 +131,19 @@
* Java Secure Socket Extension Reference Guide </a>
* for information about standard algorithm names.
*
- * @return the new <code>KeyManagerFactory</code> object.
+ * @return the new {@code KeyManagerFactory} object
*
- * @exception NoSuchAlgorithmException if no Provider supports a
- * KeyManagerFactorySpi implementation for the
- * specified algorithm.
- * @exception NullPointerException if <code>algorithm</code> is null.
+ * @throws NoSuchAlgorithmException if no {@code Provider} supports a
+ * {@code KeyManagerFactorySpi} implementation for the
+ * specified algorithm
+ *
+ * @throws NullPointerException if {@code algorithm} is {@code null}
*
* @see java.security.Provider
*/
public static final KeyManagerFactory getInstance(String algorithm)
throws NoSuchAlgorithmException {
+ Objects.requireNonNull(algorithm, "null algorithm name");
GetInstance.Instance instance = GetInstance.getInstance
("KeyManagerFactory", KeyManagerFactorySpi.class,
algorithm);
@@ -168,23 +171,26 @@
*
* @param provider the name of the provider.
*
- * @return the new <code>KeyManagerFactory</code> object.
+ * @return the new {@code KeyManagerFactory} object
*
- * @throws NoSuchAlgorithmException if a KeyManagerFactorySpi
- * implementation for the specified algorithm is not
- * available from the specified provider.
+ * @throws IllegalArgumentException if the provider name is {@code null}
+ * or empty
+ *
+ * @throws NoSuchAlgorithmException if a {@code KeyManagerFactorySpi}
+ * implementation for the specified algorithm is not
+ * available from the specified provider
*
* @throws NoSuchProviderException if the specified provider is not
- * registered in the security provider list.
+ * registered in the security provider list
*
- * @throws IllegalArgumentException if the provider name is null or empty.
- * @throws NullPointerException if <code>algorithm</code> is null.
+ * @throws NullPointerException if {@code algorithm} is {@code null}
*
* @see java.security.Provider
*/
public static final KeyManagerFactory getInstance(String algorithm,
String provider) throws NoSuchAlgorithmException,
NoSuchProviderException {
+ Objects.requireNonNull(algorithm, "null algorithm name");
GetInstance.Instance instance = GetInstance.getInstance
("KeyManagerFactory", KeyManagerFactorySpi.class,
algorithm, provider);
@@ -209,19 +215,21 @@
*
* @param provider an instance of the provider.
*
- * @return the new <code>KeyManagerFactory</code> object.
+ * @return the new {@code KeyManagerFactory} object
+ *
+ * @throws IllegalArgumentException if provider is {@code null}
*
- * @throws NoSuchAlgorithmException if a KeyManagerFactorySpi
- * implementation for the specified algorithm is not available
- * from the specified Provider object.
+ * @throws NoSuchAlgorithmException if a {@code @KeyManagerFactorySpi}
+ * implementation for the specified algorithm is not available
+ * from the specified Provider object
*
- * @throws IllegalArgumentException if provider is null.
- * @throws NullPointerException if <code>algorithm</code> is null.
+ * @throws NullPointerException if {@code algorithm} is {@code null}
*
* @see java.security.Provider
*/
public static final KeyManagerFactory getInstance(String algorithm,
Provider provider) throws NoSuchAlgorithmException {
+ Objects.requireNonNull(algorithm, "null algorithm name");
GetInstance.Instance instance = GetInstance.getInstance
("KeyManagerFactory", KeyManagerFactorySpi.class,
algorithm, provider);
--- a/jdk/src/java.base/share/classes/javax/net/ssl/SSLContext.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.base/share/classes/javax/net/ssl/SSLContext.java Wed Nov 09 10:04:43 2016 -0800
@@ -26,6 +26,7 @@
package javax.net.ssl;
import java.security.*;
+import java.util.Objects;
import sun.security.jca.GetInstance;
@@ -151,17 +152,19 @@
* Documentation</a>
* for information about standard protocol names.
*
- * @return the new {@code SSLContext} object.
+ * @return the new {@code SSLContext} object
*
- * @exception NoSuchAlgorithmException if no Provider supports a
- * SSLContextSpi implementation for the
- * specified protocol.
- * @exception NullPointerException if protocol is null.
+ * @throws NoSuchAlgorithmException if no {@code Provider} supports a
+ * {@code SSLContextSpi} implementation for the
+ * specified protocol
+ *
+ * @throws NullPointerException if {@code protocol} is {@code null}
*
* @see java.security.Provider
*/
public static SSLContext getInstance(String protocol)
throws NoSuchAlgorithmException {
+ Objects.requireNonNull(protocol, "null protocol name");
GetInstance.Instance instance = GetInstance.getInstance
("SSLContext", SSLContextSpi.class, protocol);
return new SSLContext((SSLContextSpi)instance.impl, instance.provider,
@@ -189,22 +192,25 @@
*
* @param provider the name of the provider.
*
- * @return the new {@code SSLContext} object.
+ * @return the new {@code SSLContext} object
*
- * @throws NoSuchAlgorithmException if a SSLContextSpi
- * implementation for the specified protocol is not
- * available from the specified provider.
+ * @throws IllegalArgumentException if the provider name is
+ * {@code null} or empty
+ *
+ * @throws NoSuchAlgorithmException if a {@code SSLContextSpi}
+ * implementation for the specified protocol is not
+ * available from the specified provider
*
* @throws NoSuchProviderException if the specified provider is not
- * registered in the security provider list.
+ * registered in the security provider list
*
- * @throws IllegalArgumentException if the provider name is null or empty.
- * @throws NullPointerException if protocol is null.
+ * @throws NullPointerException if {@code protocol} is {@code null}
*
* @see java.security.Provider
*/
public static SSLContext getInstance(String protocol, String provider)
throws NoSuchAlgorithmException, NoSuchProviderException {
+ Objects.requireNonNull(protocol, "null protocol name");
GetInstance.Instance instance = GetInstance.getInstance
("SSLContext", SSLContextSpi.class, protocol, provider);
return new SSLContext((SSLContextSpi)instance.impl, instance.provider,
@@ -229,19 +235,21 @@
*
* @param provider an instance of the provider.
*
- * @return the new {@code SSLContext} object.
+ * @return the new {@code SSLContext} object
+ *
+ * @throws IllegalArgumentException if the provider is {@code null}
*
- * @throws NoSuchAlgorithmException if a SSLContextSpi
- * implementation for the specified protocol is not available
- * from the specified Provider object.
+ * @throws NoSuchAlgorithmException if a {@code SSLContextSpi}
+ * implementation for the specified protocol is not available
+ * from the specified {@code Provider} object
*
- * @throws IllegalArgumentException if the provider is null.
- * @throws NullPointerException if protocol is null.
+ * @throws NullPointerException if {@code protocol} is {@code null}
*
* @see java.security.Provider
*/
public static SSLContext getInstance(String protocol, Provider provider)
throws NoSuchAlgorithmException {
+ Objects.requireNonNull(protocol, "null protocol name");
GetInstance.Instance instance = GetInstance.getInstance
("SSLContext", SSLContextSpi.class, protocol, provider);
return new SSLContext((SSLContextSpi)instance.impl, instance.provider,
--- a/jdk/src/java.base/share/classes/javax/net/ssl/TrustManagerFactory.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.base/share/classes/javax/net/ssl/TrustManagerFactory.java Wed Nov 09 10:04:43 2016 -0800
@@ -27,6 +27,7 @@
import java.security.Security;
import java.security.*;
+import java.util.Objects;
import sun.security.jca.GetInstance;
@@ -144,17 +145,19 @@
* Java Secure Socket Extension Reference Guide </a>
* for information about standard algorithm names.
*
- * @return the new <code>TrustManagerFactory</code> object.
+ * @return the new {@code TrustManagerFactory} object
*
- * @exception NoSuchAlgorithmException if no Provider supports a
- * TrustManagerFactorySpi implementation for the
- * specified algorithm.
- * @exception NullPointerException if algorithm is null.
+ * @throws NoSuchAlgorithmException if no {@code Provider} supports a
+ * {@code TrustManagerFactorySpi} implementation for the
+ * specified algorithm
+ *
+ * @throws NullPointerException if {@code algorithm} is {@code null}
*
* @see java.security.Provider
*/
public static final TrustManagerFactory getInstance(String algorithm)
throws NoSuchAlgorithmException {
+ Objects.requireNonNull(algorithm, "null algorithm name");
GetInstance.Instance instance = GetInstance.getInstance
("TrustManagerFactory", TrustManagerFactorySpi.class,
algorithm);
@@ -182,23 +185,26 @@
*
* @param provider the name of the provider.
*
- * @return the new <code>TrustManagerFactory</code> object
+ * @return the new {@code TrustManagerFactory} object
*
- * @throws NoSuchAlgorithmException if a TrustManagerFactorySpi
- * implementation for the specified algorithm is not
- * available from the specified provider.
+ * @throws IllegalArgumentException if the provider name is
+ * {@code null} or empty
+ *
+ * @throws NoSuchAlgorithmException if a {@code TrustManagerFactorySpi}
+ * implementation for the specified algorithm is not
+ * available from the specified provider
*
* @throws NoSuchProviderException if the specified provider is not
- * registered in the security provider list.
+ * registered in the security provider list
*
- * @throws IllegalArgumentException if the provider name is null or empty.
- * @throws NullPointerException if algorithm is null.
+ * @throws NullPointerException if {@code algorithm} is {@code null}
*
* @see java.security.Provider
*/
public static final TrustManagerFactory getInstance(String algorithm,
String provider) throws NoSuchAlgorithmException,
NoSuchProviderException {
+ Objects.requireNonNull(algorithm, "null algorithm name");
GetInstance.Instance instance = GetInstance.getInstance
("TrustManagerFactory", TrustManagerFactorySpi.class,
algorithm, provider);
@@ -223,19 +229,21 @@
*
* @param provider an instance of the provider.
*
- * @return the new <code>TrustManagerFactory</code> object.
+ * @return the new {@code TrustManagerFactory} object
+ *
+ * @throws IllegalArgumentException if the provider is {@code null}
*
- * @throws NoSuchAlgorithmException if a TrustManagerFactorySpi
- * implementation for the specified algorithm is not available
- * from the specified Provider object.
+ * @throws NoSuchAlgorithmException if a {@code TrustManagerFactorySpi}
+ * implementation for the specified algorithm is not available
+ * from the specified {@code Provider} object
*
- * @throws IllegalArgumentException if the provider is null.
- * @throws NullPointerException if algorithm is null.
+ * @throws NullPointerException if {@code algorithm} is {@code null}
*
* @see java.security.Provider
*/
public static final TrustManagerFactory getInstance(String algorithm,
Provider provider) throws NoSuchAlgorithmException {
+ Objects.requireNonNull(algorithm, "null algorithm name");
GetInstance.Instance instance = GetInstance.getInstance
("TrustManagerFactory", TrustManagerFactorySpi.class,
algorithm, provider);
--- a/jdk/src/java.base/share/classes/javax/security/auth/login/Configuration.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.base/share/classes/javax/security/auth/login/Configuration.java Wed Nov 09 10:04:43 2016 -0800
@@ -329,27 +329,29 @@
*
* @param params parameters for the Configuration, which may be null.
*
- * @return the new Configuration object.
+ * @return the new {@code Configuration} object
*
- * @exception SecurityException if the caller does not have permission
- * to get a Configuration instance for the specified type.
- *
- * @exception NullPointerException if the specified type is null.
+ * @throws IllegalArgumentException if the specified parameters
+ * are not understood by the {@code ConfigurationSpi}
+ * implementation from the selected {@code Provider}
*
- * @exception IllegalArgumentException if the specified parameters
- * are not understood by the ConfigurationSpi implementation
- * from the selected Provider.
+ * @throws NoSuchAlgorithmException if no {@code Provider} supports a
+ * {@code ConfigurationSpi} implementation for the specified type
*
- * @exception NoSuchAlgorithmException if no Provider supports a
- * ConfigurationSpi implementation for the specified type.
+ * @throws NullPointerException if {@code type} is {@code null}
+ *
+ * @throws SecurityException if the caller does not have permission
+ * to get a {@code Configuration} instance for the specified type
*
* @see Provider
+ *
* @since 1.6
*/
public static Configuration getInstance(String type,
Configuration.Parameters params)
throws NoSuchAlgorithmException {
+ Objects.requireNonNull(type, "null type name");
checkPermission(type);
try {
GetInstance.Instance instance = GetInstance.getInstance
@@ -387,24 +389,24 @@
*
* @param provider the provider.
*
- * @return the new Configuration object.
+ * @return the new {@code Configuration} object
*
- * @exception SecurityException if the caller does not have permission
- * to get a Configuration instance for the specified type.
- *
- * @exception NullPointerException if the specified type is null.
+ * @throws IllegalArgumentException if the specified provider
+ * is {@code null} or empty, or if the specified parameters
+ * are not understood by the {@code ConfigurationSpi}
+ * implementation from the specified provider
*
- * @exception IllegalArgumentException if the specified provider
- * is null or empty,
- * or if the specified parameters are not understood by
- * the ConfigurationSpi implementation from the specified provider.
+ * @throws NoSuchProviderException if the specified provider is not
+ * registered in the security provider list
*
- * @exception NoSuchProviderException if the specified provider is not
- * registered in the security provider list.
+ * @throws NoSuchAlgorithmException if the specified provider does not
+ * support a {@code ConfigurationSpi} implementation for the
+ * specified type
*
- * @exception NoSuchAlgorithmException if the specified provider does not
- * support a ConfigurationSpi implementation for the specified
- * type.
+ * @throws NullPointerException if {@code type} is {@code null}
+ *
+ * @throws SecurityException if the caller does not have permission
+ * to get a {@code Configuration} instance for the specified type
*
* @see Provider
* @since 1.6
@@ -414,6 +416,7 @@
String provider)
throws NoSuchProviderException, NoSuchAlgorithmException {
+ Objects.requireNonNull(type, "null type name");
if (provider == null || provider.length() == 0) {
throw new IllegalArgumentException("missing provider");
}
@@ -453,20 +456,21 @@
*
* @param provider the Provider.
*
- * @return the new Configuration object.
+ * @return the new {@code Configuration} object
*
- * @exception SecurityException if the caller does not have permission
- * to get a Configuration instance for the specified type.
- *
- * @exception NullPointerException if the specified type is null.
+ * @throws IllegalArgumentException if the specified {@code Provider}
+ * is {@code null}, or if the specified parameters are not
+ * understood by the {@code ConfigurationSpi} implementation
+ * from the specified Provider
*
- * @exception IllegalArgumentException if the specified Provider is null,
- * or if the specified parameters are not understood by
- * the ConfigurationSpi implementation from the specified Provider.
+ * @throws NoSuchAlgorithmException if the specified {@code Provider}
+ * does not support a {@code ConfigurationSpi} implementation
+ * for the specified type
*
- * @exception NoSuchAlgorithmException if the specified Provider does not
- * support a ConfigurationSpi implementation for the specified
- * type.
+ * @throws NullPointerException if {@code type} is {@code null}
+ *
+ * @throws SecurityException if the caller does not have permission
+ * to get a {@code Configuration} instance for the specified type
*
* @see Provider
* @since 1.6
@@ -476,6 +480,7 @@
Provider provider)
throws NoSuchAlgorithmException {
+ Objects.requireNonNull(type, "null type name");
if (provider == null) {
throw new IllegalArgumentException("missing provider");
}
--- a/jdk/src/java.base/share/classes/jdk/internal/loader/BuiltinClassLoader.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.base/share/classes/jdk/internal/loader/BuiltinClassLoader.java Wed Nov 09 10:04:43 2016 -0800
@@ -145,9 +145,9 @@
/**
* Create a new instance.
*/
- BuiltinClassLoader(BuiltinClassLoader parent, URLClassPath ucp) {
+ BuiltinClassLoader(String name, BuiltinClassLoader parent, URLClassPath ucp) {
// ensure getParent() returns null when the parent is the boot loader
- super(parent == null || parent == ClassLoaders.bootLoader() ? null : parent);
+ super(name, parent == null || parent == ClassLoaders.bootLoader() ? null : parent);
this.parent = parent;
this.ucp = ucp;
--- a/jdk/src/java.base/share/classes/jdk/internal/loader/ClassLoaders.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.base/share/classes/jdk/internal/loader/ClassLoaders.java Wed Nov 09 10:04:43 2016 -0800
@@ -118,7 +118,7 @@
*/
private static class BootClassLoader extends BuiltinClassLoader {
BootClassLoader(URLClassPath bcp) {
- super(null, bcp);
+ super(null, null, bcp);
}
@Override
@@ -138,7 +138,7 @@
}
PlatformClassLoader(BootClassLoader parent) {
- super(parent, null);
+ super("platform", parent, null);
}
/**
@@ -165,7 +165,7 @@
final URLClassPath ucp;
AppClassLoader(PlatformClassLoader parent, URLClassPath ucp) {
- super(parent, ucp);
+ super("app", parent, ucp);
this.ucp = ucp;
}
--- a/jdk/src/java.base/share/classes/jdk/internal/reflect/ReflectionFactory.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/ReflectionFactory.java Wed Nov 09 10:04:43 2016 -0800
@@ -364,6 +364,16 @@
}
}
+ public final Constructor<?> newConstructorForSerialization(Class<?> cl,
+ Constructor<?> constructorToCall)
+ {
+ if (constructorToCall.getDeclaringClass() == cl) {
+ constructorToCall.setAccessible(true);
+ return constructorToCall;
+ }
+ return generateConstructor(cl, constructorToCall);
+ }
+
public final Constructor<?> newConstructorForSerialization(Class<?> cl) {
Class<?> initCl = cl;
while (Serializable.class.isAssignableFrom(initCl)) {
@@ -383,6 +393,12 @@
} catch (NoSuchMethodException ex) {
return null;
}
+ return generateConstructor(cl, constructorToCall);
+ }
+
+ private final Constructor<?> generateConstructor(Class<?> cl,
+ Constructor<?> constructorToCall) {
+
ConstructorAccessor acc = new MethodAccessorGenerator().
generateSerializationConstructor(cl,
--- a/jdk/src/java.base/share/classes/module-info.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.base/share/classes/module-info.java Wed Nov 09 10:04:43 2016 -0800
@@ -196,7 +196,8 @@
jdk.vm.ci;
exports jdk.internal.util.jar to
jdk.jartool,
- jdk.jdeps;
+ jdk.jdeps,
+ jdk.jlink;
exports jdk.internal.vm to
java.management,
jdk.jvmstat;
--- a/jdk/src/java.base/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.base/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java Wed Nov 09 10:04:43 2016 -0800
@@ -253,20 +253,20 @@
}
private static String toSourceString(char c) {
- StringBuilder sb = new StringBuilder();
- sb.append("'");
+ StringBuilder sb = new StringBuilder(4);
+ sb.append('\'');
if (c == '\'')
sb.append("\\'");
else
sb.append(c);
- sb.append("'");
- return sb.toString();
+ return sb.append('\'')
+ .toString();
}
private static String toSourceString(long ell) {
- return (Math.abs(ell) <= Integer.MAX_VALUE) ?
- String.valueOf(ell) :
- (String.valueOf(ell) + "L");
+ String str = String.valueOf(ell);
+ return (ell < Integer.MIN_VALUE || ell > Integer.MAX_VALUE)
+ ? (str + 'L') : str;
}
/**
@@ -278,10 +278,7 @@
sb.append('"');
// Escape embedded quote characters, if present, but don't do
// anything more heroic.
- if (s.indexOf('"') != -1) {
- s = s.replace("\"", "\\\"");
- }
- sb.append(s);
+ sb.append(s.replace("\"", "\\\""));
sb.append('"');
return sb.toString();
}
--- a/jdk/src/java.base/share/classes/sun/security/ssl/RSAClientKeyExchange.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/RSAClientKeyExchange.java Wed Nov 09 10:04:43 2016 -0800
@@ -257,7 +257,13 @@
@Override
void print(PrintStream s) throws IOException {
- s.println("*** ClientKeyExchange, RSA PreMasterSecret, " +
- protocolVersion);
+ String version = "version not available/extractable";
+
+ byte[] ba = preMaster.getEncoded();
+ if (ba != null && ba.length >= 2) {
+ version = ProtocolVersion.valueOf(ba[0], ba[1]).name;
+ }
+
+ s.println("*** ClientKeyExchange, RSA PreMasterSecret, " + version);
}
}
--- a/jdk/src/java.base/share/classes/sun/security/ssl/SSLEngineImpl.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/SSLEngineImpl.java Wed Nov 09 10:04:43 2016 -0800
@@ -1715,12 +1715,17 @@
synchronized void fatal(byte description, String diagnostic)
throws SSLException {
- fatal(description, diagnostic, null);
+ fatal(description, diagnostic, null, false);
}
synchronized void fatal(byte description, Throwable cause)
throws SSLException {
- fatal(description, null, cause);
+ fatal(description, null, cause, false);
+ }
+
+ synchronized void fatal(byte description, String diagnostic,
+ Throwable cause) throws SSLException {
+ fatal(description, diagnostic, cause, false);
}
/*
@@ -1732,12 +1737,12 @@
* levels which then call here. This code needs to determine
* if one of the lower levels has already started the process.
*
- * We won't worry about Error's, if we have one of those,
+ * We won't worry about Errors, if we have one of those,
* we're in worse trouble. Note: the networking code doesn't
* deal with Errors either.
*/
synchronized void fatal(byte description, String diagnostic,
- Throwable cause) throws SSLException {
+ Throwable cause, boolean recvFatalAlert) throws SSLException {
/*
* If we have no further information, make a general-purpose
@@ -1798,10 +1803,11 @@
}
/*
- * If we haven't even started handshaking yet, no need
- * to generate the fatal close alert.
+ * If we haven't even started handshaking yet, or we are the
+ * recipient of a fatal alert, no need to generate a fatal close
+ * alert.
*/
- if (oldState != cs_START) {
+ if (oldState != cs_START && !recvFatalAlert) {
sendAlert(Alerts.alert_fatal, description);
}
@@ -1841,10 +1847,6 @@
byte level = fragment.get();
byte description = fragment.get();
- if (description == -1) { // check for short message
- fatal(Alerts.alert_illegal_parameter, "Short alert message");
- }
-
if (debug != null && (Debug.isOn("record") ||
Debug.isOn("handshake"))) {
synchronized (System.out) {
@@ -1862,7 +1864,9 @@
}
if (level == Alerts.alert_warning) {
- if (description == Alerts.alert_close_notify) {
+ if (description == -1) { // check for short message
+ fatal(Alerts.alert_illegal_parameter, "Short alert message");
+ } else if (description == Alerts.alert_close_notify) {
if (connectionState == cs_HANDSHAKE) {
fatal(Alerts.alert_unexpected_message,
"Received close_notify during handshake");
@@ -1885,10 +1889,14 @@
} else { // fatal or unknown level
String reason = "Received fatal alert: "
+ Alerts.alertDescription(description);
- if (closeReason == null) {
- closeReason = Alerts.getSSLException(description, reason);
- }
- fatal(Alerts.alert_unexpected_message, reason);
+
+ // The inbound and outbound queues will be closed as part of
+ // the call to fatal. The handhaker to needs to be set to null
+ // so subsequent calls to getHandshakeStatus will return
+ // NOT_HANDSHAKING.
+ handshaker = null;
+ Throwable cause = Alerts.getSSLException(description, reason);
+ fatal(description, null, cause, true);
}
}
--- a/jdk/src/java.base/share/classes/sun/security/tools/keytool/Main.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.base/share/classes/sun/security/tools/keytool/Main.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -84,8 +84,10 @@
import sun.security.x509.*;
import static java.security.KeyStore.*;
+import java.security.Security;
import static sun.security.tools.keytool.Main.Command.*;
import static sun.security.tools.keytool.Main.Option.*;
+import sun.security.util.DisabledAlgorithmConstraints;
/**
* This tool manages keystores.
@@ -2428,6 +2430,10 @@
private void doPrintCert(final PrintStream out) throws Exception {
if (jarfile != null) {
+ // reset "jdk.certpath.disabledAlgorithms" security property
+ // to be able to read jars which were signed with weak algorithms
+ Security.setProperty(DisabledAlgorithmConstraints.PROPERTY_JAR_DISABLED_ALGS, "");
+
JarFile jf = new JarFile(jarfile, true);
Enumeration<JarEntry> entries = jf.entries();
Set<CodeSigner> ss = new HashSet<>();
--- a/jdk/src/java.base/share/classes/sun/security/util/AbstractAlgorithmConstraints.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.base/share/classes/sun/security/util/AbstractAlgorithmConstraints.java Wed Nov 09 10:04:43 2016 -0800
@@ -46,8 +46,12 @@
// Get algorithm constraints from the specified security property.
static String[] getAlgorithms(String propertyName) {
String property = AccessController.doPrivileged(
- (PrivilegedAction<String>) () -> Security.getProperty(
- propertyName));
+ new PrivilegedAction<String>() {
+ @Override
+ public String run() {
+ return Security.getProperty(propertyName);
+ }
+ });
String[] algorithmsInProperty = null;
if (property != null && !property.isEmpty()) {
--- a/jdk/src/java.base/share/classes/sun/security/util/AlgorithmDecomposer.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.base/share/classes/sun/security/util/AlgorithmDecomposer.java Wed Nov 09 10:04:43 2016 -0800
@@ -34,20 +34,18 @@
*/
public class AlgorithmDecomposer {
- private static final Pattern transPattern = Pattern.compile("/");
-
// '(?<!padd)in': match 'in' but not preceded with 'padd'.
- private static final Pattern pattern =
+ private static final Pattern PATTERN =
Pattern.compile("with|and|(?<!padd)in", Pattern.CASE_INSENSITIVE);
private static Set<String> decomposeImpl(String algorithm) {
+ Set<String> elements = new HashSet<>();
// algorithm/mode/padding
- String[] transTockens = transPattern.split(algorithm);
+ String[] transTokens = algorithm.split("/");
- Set<String> elements = new HashSet<>();
- for (String transTocken : transTockens) {
- if (transTocken == null || transTocken.length() == 0) {
+ for (String transToken : transTokens) {
+ if (transToken == null || transToken.isEmpty()) {
continue;
}
@@ -57,10 +55,10 @@
// <digest>with<encryption>
// <digest>with<encryption>and<mgf>
// <digest>with<encryption>in<format>
- String[] tokens = pattern.split(transTocken);
+ String[] tokens = PATTERN.split(transToken);
for (String token : tokens) {
- if (token == null || token.length() == 0) {
+ if (token == null || token.isEmpty()) {
continue;
}
--- a/jdk/src/java.base/share/classes/sun/security/util/DisabledAlgorithmConstraints.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.base/share/classes/sun/security/util/DisabledAlgorithmConstraints.java Wed Nov 09 10:04:43 2016 -0800
@@ -39,6 +39,7 @@
import java.util.Locale;
import java.util.Map;
import java.util.Set;
+import java.util.StringTokenizer;
import java.util.TimeZone;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
@@ -240,10 +241,11 @@
private static class Constraints {
private Map<String, Set<Constraint>> constraintsMap = new HashMap<>();
- private static final Pattern keySizePattern = Pattern.compile(
- "keySize\\s*(<=|<|==|!=|>|>=)\\s*(\\d+)");
- private static final Pattern denyAfterPattern = Pattern.compile(
- "denyAfter\\s+(\\d{4})-(\\d{2})-(\\d{2})");
+
+ private static class Holder {
+ private static final Pattern DENY_AFTER_PATTERN = Pattern.compile(
+ "denyAfter\\s+(\\d{4})-(\\d{2})-(\\d{2})");
+ }
public Constraints(String[] constraintArray) {
for (String constraintEntry : constraintArray) {
@@ -267,9 +269,11 @@
toUpperCase(Locale.ENGLISH));
policy = constraintEntry.substring(space + 1);
} else {
- constraintsMap.computeIfAbsent(
- constraintEntry.toUpperCase(Locale.ENGLISH),
- k -> new HashSet<>());
+ algorithm = constraintEntry.toUpperCase(Locale.ENGLISH);
+ if (!constraintsMap.containsKey(algorithm)) {
+ constraintsMap.putIfAbsent(algorithm,
+ new HashSet<>());
+ }
continue;
}
@@ -283,15 +287,21 @@
for (String entry : policy.split("&")) {
entry = entry.trim();
- Matcher matcher = keySizePattern.matcher(entry);
- if (matcher.matches()) {
+ Matcher matcher;
+ if (entry.startsWith("keySize")) {
if (debug != null) {
debug.println("Constraints set to keySize: " +
entry);
}
+ StringTokenizer tokens = new StringTokenizer(entry);
+ if (!"keySize".equals(tokens.nextToken())) {
+ throw new IllegalArgumentException("Error in " +
+ "security property. Constraint unknown: " +
+ entry);
+ }
c = new KeySizeConstraint(algorithm,
- KeySizeConstraint.Operator.of(matcher.group(1)),
- Integer.parseInt(matcher.group(2)));
+ KeySizeConstraint.Operator.of(tokens.nextToken()),
+ Integer.parseInt(tokens.nextToken()));
} else if (entry.equalsIgnoreCase("jdkCA")) {
if (debug != null) {
@@ -305,7 +315,9 @@
c = new jdkCAConstraint(algorithm);
jdkCALimit = true;
- } else if(matcher.usePattern(denyAfterPattern).matches()) {
+ } else if(entry.startsWith("denyAfter") &&
+ (matcher = Holder.DENY_AFTER_PATTERN.matcher(entry))
+ .matches()) {
if (debug != null) {
debug.println("Constraints set to denyAfter");
}
--- a/jdk/src/java.base/share/classes/sun/util/locale/LocaleMatcher.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.base/share/classes/sun/util/locale/LocaleMatcher.java Wed Nov 09 10:04:43 2016 -0800
@@ -365,7 +365,7 @@
continue;
}
- String rangeForRegex = range.replaceAll("\\x2A", "\\\\p{Alnum}*");
+ String rangeForRegex = range.replace("*", "\\p{Alnum}*");
while (rangeForRegex.length() > 0) {
for (String tag : tags) {
tag = tag.toLowerCase(Locale.ROOT);
@@ -399,7 +399,7 @@
continue;
}
- String rangeForRegex = range.replaceAll("\\x2A", "\\\\p{Alnum}*");
+ String rangeForRegex = range.replace("*", "\\p{Alnum}*");
while (rangeForRegex.length() > 0) {
if (tag.matches(rangeForRegex)) {
return true;
@@ -447,7 +447,7 @@
}
public static List<LanguageRange> parse(String ranges) {
- ranges = ranges.replaceAll(" ", "").toLowerCase(Locale.ROOT);
+ ranges = ranges.replace(" ", "").toLowerCase(Locale.ROOT);
if (ranges.startsWith("accept-language:")) {
ranges = ranges.substring(16); // delete unnecessary prefix
}
@@ -536,6 +536,21 @@
return list;
}
+ /**
+ * A faster alternative approach to String.replaceFirst(), if the given
+ * string is a literal String, not a regex.
+ */
+ private static String replaceFirstSubStringMatch(String range,
+ String substr, String replacement) {
+ int pos = range.indexOf(substr);
+ if (pos == -1) {
+ return range;
+ } else {
+ return range.substring(0, pos) + replacement
+ + range.substring(pos + substr.length());
+ }
+ }
+
private static String[] getEquivalentsForLanguage(String range) {
String r = range;
@@ -544,13 +559,16 @@
String equiv = LocaleEquivalentMaps.singleEquivMap.get(r);
// Return immediately for performance if the first matching
// subtag is found.
- return new String[] {range.replaceFirst(r, equiv)};
+ return new String[]{replaceFirstSubStringMatch(range,
+ r, equiv)};
} else if (LocaleEquivalentMaps.multiEquivsMap.containsKey(r)) {
String[] equivs = LocaleEquivalentMaps.multiEquivsMap.get(r);
+ String[] result = new String[equivs.length];
for (int i = 0; i < equivs.length; i++) {
- equivs[i] = range.replaceFirst(r, equivs[i]);
+ result[i] = replaceFirstSubStringMatch(range,
+ r, equivs[i]);
}
- return equivs;
+ return result;
}
// Truncate the last subtag simply.
@@ -578,7 +596,9 @@
int len = index + subtag.length();
if (range.length() == len || range.charAt(len) == '-') {
- return range.replaceFirst(subtag, LocaleEquivalentMaps.regionVariantEquivMap.get(subtag));
+ return replaceFirstSubStringMatch(range, subtag,
+ LocaleEquivalentMaps.regionVariantEquivMap
+ .get(subtag));
}
}
}
--- a/jdk/src/java.base/share/lib/security/default.policy Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.base/share/lib/security/default.policy Wed Nov 09 10:04:43 2016 -0800
@@ -181,6 +181,6 @@
grant codeBase "jrt:/jdk.zipfs" {
permission java.io.FilePermission "<<ALL FILES>>", "read,write,delete";
permission java.lang.RuntimePermission "fileSystemProvider";
- permission java.util.PropertyPermission "*", "read";
+ permission java.util.PropertyPermission "os.name", "read";
};
--- a/jdk/src/java.base/share/native/include/jvm.h Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.base/share/native/include/jvm.h Wed Nov 09 10:04:43 2016 -0800
@@ -165,14 +165,24 @@
JNIEXPORT jboolean JNICALL
JVM_IsSupportedJNIVersion(jint version);
+JNIEXPORT jobjectArray JNICALL
+JVM_GetVmArguments(JNIEnv *env);
+
+
/*
* java.lang.Throwable
*/
JNIEXPORT void JNICALL
JVM_FillInStackTrace(JNIEnv *env, jobject throwable);
+/*
+ * java.lang.StackTraceElement
+ */
JNIEXPORT void JNICALL
-JVM_GetStackTraceElements(JNIEnv *env, jobject throwable, jobjectArray elements);
+JVM_InitStackTraceElementArray(JNIEnv *env, jobjectArray elements, jobject throwable);
+
+JNIEXPORT void JNICALL
+JVM_InitStackTraceElement(JNIEnv* env, jobject element, jobject stackFrameInfo);
/*
* java.lang.StackWalker
@@ -194,12 +204,6 @@
jint frame_count, jint start_index,
jobjectArray frames);
-JNIEXPORT void JNICALL
-JVM_ToStackTraceElement(JNIEnv* env, jobject frame, jobject stackElement);
-
-JNIEXPORT jobjectArray JNICALL
-JVM_GetVmArguments(JNIEnv *env);
-
/*
* java.lang.Thread
*/
--- a/jdk/src/java.base/share/native/include/jvmti.h Wed Nov 09 15:20:30 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2551 +0,0 @@
-/*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
- /* AUTOMATICALLY GENERATED FILE - DO NOT EDIT */
-
- /* Include file for the Java(tm) Virtual Machine Tool Interface */
-
-#ifndef _JAVA_JVMTI_H_
-#define _JAVA_JVMTI_H_
-
-#include "jni.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-enum {
- JVMTI_VERSION_1 = 0x30010000,
- JVMTI_VERSION_1_0 = 0x30010000,
- JVMTI_VERSION_1_1 = 0x30010100,
- JVMTI_VERSION_1_2 = 0x30010200,
- JVMTI_VERSION_9 = 0x30090000,
-
- JVMTI_VERSION = 0x30000000 + (9 * 0x10000) + (0 * 0x100) + 0 /* version: 9.0.0 */
-};
-
-JNIEXPORT jint JNICALL
-Agent_OnLoad(JavaVM *vm, char *options, void *reserved);
-
-JNIEXPORT jint JNICALL
-Agent_OnAttach(JavaVM* vm, char* options, void* reserved);
-
-JNIEXPORT void JNICALL
-Agent_OnUnload(JavaVM *vm);
-
- /* Forward declaration of the environment */
-
-struct _jvmtiEnv;
-
-struct jvmtiInterface_1_;
-
-#ifdef __cplusplus
-typedef _jvmtiEnv jvmtiEnv;
-#else
-typedef const struct jvmtiInterface_1_ *jvmtiEnv;
-#endif /* __cplusplus */
-
-/* Derived Base Types */
-
-typedef jobject jthread;
-typedef jobject jthreadGroup;
-typedef jlong jlocation;
-struct _jrawMonitorID;
-typedef struct _jrawMonitorID *jrawMonitorID;
-typedef struct JNINativeInterface_ jniNativeInterface;
-
- /* Constants */
-
-
- /* Thread State Flags */
-
-enum {
- JVMTI_THREAD_STATE_ALIVE = 0x0001,
- JVMTI_THREAD_STATE_TERMINATED = 0x0002,
- JVMTI_THREAD_STATE_RUNNABLE = 0x0004,
- JVMTI_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER = 0x0400,
- JVMTI_THREAD_STATE_WAITING = 0x0080,
- JVMTI_THREAD_STATE_WAITING_INDEFINITELY = 0x0010,
- JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT = 0x0020,
- JVMTI_THREAD_STATE_SLEEPING = 0x0040,
- JVMTI_THREAD_STATE_IN_OBJECT_WAIT = 0x0100,
- JVMTI_THREAD_STATE_PARKED = 0x0200,
- JVMTI_THREAD_STATE_SUSPENDED = 0x100000,
- JVMTI_THREAD_STATE_INTERRUPTED = 0x200000,
- JVMTI_THREAD_STATE_IN_NATIVE = 0x400000,
- JVMTI_THREAD_STATE_VENDOR_1 = 0x10000000,
- JVMTI_THREAD_STATE_VENDOR_2 = 0x20000000,
- JVMTI_THREAD_STATE_VENDOR_3 = 0x40000000
-};
-
- /* java.lang.Thread.State Conversion Masks */
-
-enum {
- JVMTI_JAVA_LANG_THREAD_STATE_MASK = JVMTI_THREAD_STATE_TERMINATED | JVMTI_THREAD_STATE_ALIVE | JVMTI_THREAD_STATE_RUNNABLE | JVMTI_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER | JVMTI_THREAD_STATE_WAITING | JVMTI_THREAD_STATE_WAITING_INDEFINITELY | JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT,
- JVMTI_JAVA_LANG_THREAD_STATE_NEW = 0,
- JVMTI_JAVA_LANG_THREAD_STATE_TERMINATED = JVMTI_THREAD_STATE_TERMINATED,
- JVMTI_JAVA_LANG_THREAD_STATE_RUNNABLE = JVMTI_THREAD_STATE_ALIVE | JVMTI_THREAD_STATE_RUNNABLE,
- JVMTI_JAVA_LANG_THREAD_STATE_BLOCKED = JVMTI_THREAD_STATE_ALIVE | JVMTI_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER,
- JVMTI_JAVA_LANG_THREAD_STATE_WAITING = JVMTI_THREAD_STATE_ALIVE | JVMTI_THREAD_STATE_WAITING | JVMTI_THREAD_STATE_WAITING_INDEFINITELY,
- JVMTI_JAVA_LANG_THREAD_STATE_TIMED_WAITING = JVMTI_THREAD_STATE_ALIVE | JVMTI_THREAD_STATE_WAITING | JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT
-};
-
- /* Thread Priority Constants */
-
-enum {
- JVMTI_THREAD_MIN_PRIORITY = 1,
- JVMTI_THREAD_NORM_PRIORITY = 5,
- JVMTI_THREAD_MAX_PRIORITY = 10
-};
-
- /* Heap Filter Flags */
-
-enum {
- JVMTI_HEAP_FILTER_TAGGED = 0x4,
- JVMTI_HEAP_FILTER_UNTAGGED = 0x8,
- JVMTI_HEAP_FILTER_CLASS_TAGGED = 0x10,
- JVMTI_HEAP_FILTER_CLASS_UNTAGGED = 0x20
-};
-
- /* Heap Visit Control Flags */
-
-enum {
- JVMTI_VISIT_OBJECTS = 0x100,
- JVMTI_VISIT_ABORT = 0x8000
-};
-
- /* Heap Reference Enumeration */
-
-typedef enum {
- JVMTI_HEAP_REFERENCE_CLASS = 1,
- JVMTI_HEAP_REFERENCE_FIELD = 2,
- JVMTI_HEAP_REFERENCE_ARRAY_ELEMENT = 3,
- JVMTI_HEAP_REFERENCE_CLASS_LOADER = 4,
- JVMTI_HEAP_REFERENCE_SIGNERS = 5,
- JVMTI_HEAP_REFERENCE_PROTECTION_DOMAIN = 6,
- JVMTI_HEAP_REFERENCE_INTERFACE = 7,
- JVMTI_HEAP_REFERENCE_STATIC_FIELD = 8,
- JVMTI_HEAP_REFERENCE_CONSTANT_POOL = 9,
- JVMTI_HEAP_REFERENCE_SUPERCLASS = 10,
- JVMTI_HEAP_REFERENCE_JNI_GLOBAL = 21,
- JVMTI_HEAP_REFERENCE_SYSTEM_CLASS = 22,
- JVMTI_HEAP_REFERENCE_MONITOR = 23,
- JVMTI_HEAP_REFERENCE_STACK_LOCAL = 24,
- JVMTI_HEAP_REFERENCE_JNI_LOCAL = 25,
- JVMTI_HEAP_REFERENCE_THREAD = 26,
- JVMTI_HEAP_REFERENCE_OTHER = 27
-} jvmtiHeapReferenceKind;
-
- /* Primitive Type Enumeration */
-
-typedef enum {
- JVMTI_PRIMITIVE_TYPE_BOOLEAN = 90,
- JVMTI_PRIMITIVE_TYPE_BYTE = 66,
- JVMTI_PRIMITIVE_TYPE_CHAR = 67,
- JVMTI_PRIMITIVE_TYPE_SHORT = 83,
- JVMTI_PRIMITIVE_TYPE_INT = 73,
- JVMTI_PRIMITIVE_TYPE_LONG = 74,
- JVMTI_PRIMITIVE_TYPE_FLOAT = 70,
- JVMTI_PRIMITIVE_TYPE_DOUBLE = 68
-} jvmtiPrimitiveType;
-
- /* Heap Object Filter Enumeration */
-
-typedef enum {
- JVMTI_HEAP_OBJECT_TAGGED = 1,
- JVMTI_HEAP_OBJECT_UNTAGGED = 2,
- JVMTI_HEAP_OBJECT_EITHER = 3
-} jvmtiHeapObjectFilter;
-
- /* Heap Root Kind Enumeration */
-
-typedef enum {
- JVMTI_HEAP_ROOT_JNI_GLOBAL = 1,
- JVMTI_HEAP_ROOT_SYSTEM_CLASS = 2,
- JVMTI_HEAP_ROOT_MONITOR = 3,
- JVMTI_HEAP_ROOT_STACK_LOCAL = 4,
- JVMTI_HEAP_ROOT_JNI_LOCAL = 5,
- JVMTI_HEAP_ROOT_THREAD = 6,
- JVMTI_HEAP_ROOT_OTHER = 7
-} jvmtiHeapRootKind;
-
- /* Object Reference Enumeration */
-
-typedef enum {
- JVMTI_REFERENCE_CLASS = 1,
- JVMTI_REFERENCE_FIELD = 2,
- JVMTI_REFERENCE_ARRAY_ELEMENT = 3,
- JVMTI_REFERENCE_CLASS_LOADER = 4,
- JVMTI_REFERENCE_SIGNERS = 5,
- JVMTI_REFERENCE_PROTECTION_DOMAIN = 6,
- JVMTI_REFERENCE_INTERFACE = 7,
- JVMTI_REFERENCE_STATIC_FIELD = 8,
- JVMTI_REFERENCE_CONSTANT_POOL = 9
-} jvmtiObjectReferenceKind;
-
- /* Iteration Control Enumeration */
-
-typedef enum {
- JVMTI_ITERATION_CONTINUE = 1,
- JVMTI_ITERATION_IGNORE = 2,
- JVMTI_ITERATION_ABORT = 0
-} jvmtiIterationControl;
-
- /* Class Status Flags */
-
-enum {
- JVMTI_CLASS_STATUS_VERIFIED = 1,
- JVMTI_CLASS_STATUS_PREPARED = 2,
- JVMTI_CLASS_STATUS_INITIALIZED = 4,
- JVMTI_CLASS_STATUS_ERROR = 8,
- JVMTI_CLASS_STATUS_ARRAY = 16,
- JVMTI_CLASS_STATUS_PRIMITIVE = 32
-};
-
- /* Event Enable/Disable */
-
-typedef enum {
- JVMTI_ENABLE = 1,
- JVMTI_DISABLE = 0
-} jvmtiEventMode;
-
- /* Extension Function/Event Parameter Types */
-
-typedef enum {
- JVMTI_TYPE_JBYTE = 101,
- JVMTI_TYPE_JCHAR = 102,
- JVMTI_TYPE_JSHORT = 103,
- JVMTI_TYPE_JINT = 104,
- JVMTI_TYPE_JLONG = 105,
- JVMTI_TYPE_JFLOAT = 106,
- JVMTI_TYPE_JDOUBLE = 107,
- JVMTI_TYPE_JBOOLEAN = 108,
- JVMTI_TYPE_JOBJECT = 109,
- JVMTI_TYPE_JTHREAD = 110,
- JVMTI_TYPE_JCLASS = 111,
- JVMTI_TYPE_JVALUE = 112,
- JVMTI_TYPE_JFIELDID = 113,
- JVMTI_TYPE_JMETHODID = 114,
- JVMTI_TYPE_CCHAR = 115,
- JVMTI_TYPE_CVOID = 116,
- JVMTI_TYPE_JNIENV = 117
-} jvmtiParamTypes;
-
- /* Extension Function/Event Parameter Kinds */
-
-typedef enum {
- JVMTI_KIND_IN = 91,
- JVMTI_KIND_IN_PTR = 92,
- JVMTI_KIND_IN_BUF = 93,
- JVMTI_KIND_ALLOC_BUF = 94,
- JVMTI_KIND_ALLOC_ALLOC_BUF = 95,
- JVMTI_KIND_OUT = 96,
- JVMTI_KIND_OUT_BUF = 97
-} jvmtiParamKind;
-
- /* Timer Kinds */
-
-typedef enum {
- JVMTI_TIMER_USER_CPU = 30,
- JVMTI_TIMER_TOTAL_CPU = 31,
- JVMTI_TIMER_ELAPSED = 32
-} jvmtiTimerKind;
-
- /* Phases of execution */
-
-typedef enum {
- JVMTI_PHASE_ONLOAD = 1,
- JVMTI_PHASE_PRIMORDIAL = 2,
- JVMTI_PHASE_START = 6,
- JVMTI_PHASE_LIVE = 4,
- JVMTI_PHASE_DEAD = 8
-} jvmtiPhase;
-
- /* Version Interface Types */
-
-enum {
- JVMTI_VERSION_INTERFACE_JNI = 0x00000000,
- JVMTI_VERSION_INTERFACE_JVMTI = 0x30000000
-};
-
- /* Version Masks */
-
-enum {
- JVMTI_VERSION_MASK_INTERFACE_TYPE = 0x70000000,
- JVMTI_VERSION_MASK_MAJOR = 0x0FFF0000,
- JVMTI_VERSION_MASK_MINOR = 0x0000FF00,
- JVMTI_VERSION_MASK_MICRO = 0x000000FF
-};
-
- /* Version Shifts */
-
-enum {
- JVMTI_VERSION_SHIFT_MAJOR = 16,
- JVMTI_VERSION_SHIFT_MINOR = 8,
- JVMTI_VERSION_SHIFT_MICRO = 0
-};
-
- /* Verbose Flag Enumeration */
-
-typedef enum {
- JVMTI_VERBOSE_OTHER = 0,
- JVMTI_VERBOSE_GC = 1,
- JVMTI_VERBOSE_CLASS = 2,
- JVMTI_VERBOSE_JNI = 4
-} jvmtiVerboseFlag;
-
- /* JLocation Format Enumeration */
-
-typedef enum {
- JVMTI_JLOCATION_JVMBCI = 1,
- JVMTI_JLOCATION_MACHINEPC = 2,
- JVMTI_JLOCATION_OTHER = 0
-} jvmtiJlocationFormat;
-
- /* Resource Exhaustion Flags */
-
-enum {
- JVMTI_RESOURCE_EXHAUSTED_OOM_ERROR = 0x0001,
- JVMTI_RESOURCE_EXHAUSTED_JAVA_HEAP = 0x0002,
- JVMTI_RESOURCE_EXHAUSTED_THREADS = 0x0004
-};
-
- /* Errors */
-
-typedef enum {
- JVMTI_ERROR_NONE = 0,
- JVMTI_ERROR_INVALID_THREAD = 10,
- JVMTI_ERROR_INVALID_THREAD_GROUP = 11,
- JVMTI_ERROR_INVALID_PRIORITY = 12,
- JVMTI_ERROR_THREAD_NOT_SUSPENDED = 13,
- JVMTI_ERROR_THREAD_SUSPENDED = 14,
- JVMTI_ERROR_THREAD_NOT_ALIVE = 15,
- JVMTI_ERROR_INVALID_OBJECT = 20,
- JVMTI_ERROR_INVALID_CLASS = 21,
- JVMTI_ERROR_CLASS_NOT_PREPARED = 22,
- JVMTI_ERROR_INVALID_METHODID = 23,
- JVMTI_ERROR_INVALID_LOCATION = 24,
- JVMTI_ERROR_INVALID_FIELDID = 25,
- JVMTI_ERROR_NO_MORE_FRAMES = 31,
- JVMTI_ERROR_OPAQUE_FRAME = 32,
- JVMTI_ERROR_TYPE_MISMATCH = 34,
- JVMTI_ERROR_INVALID_SLOT = 35,
- JVMTI_ERROR_DUPLICATE = 40,
- JVMTI_ERROR_NOT_FOUND = 41,
- JVMTI_ERROR_INVALID_MONITOR = 50,
- JVMTI_ERROR_NOT_MONITOR_OWNER = 51,
- JVMTI_ERROR_INTERRUPT = 52,
- JVMTI_ERROR_INVALID_CLASS_FORMAT = 60,
- JVMTI_ERROR_CIRCULAR_CLASS_DEFINITION = 61,
- JVMTI_ERROR_FAILS_VERIFICATION = 62,
- JVMTI_ERROR_UNSUPPORTED_REDEFINITION_METHOD_ADDED = 63,
- JVMTI_ERROR_UNSUPPORTED_REDEFINITION_SCHEMA_CHANGED = 64,
- JVMTI_ERROR_INVALID_TYPESTATE = 65,
- JVMTI_ERROR_UNSUPPORTED_REDEFINITION_HIERARCHY_CHANGED = 66,
- JVMTI_ERROR_UNSUPPORTED_REDEFINITION_METHOD_DELETED = 67,
- JVMTI_ERROR_UNSUPPORTED_VERSION = 68,
- JVMTI_ERROR_NAMES_DONT_MATCH = 69,
- JVMTI_ERROR_UNSUPPORTED_REDEFINITION_CLASS_MODIFIERS_CHANGED = 70,
- JVMTI_ERROR_UNSUPPORTED_REDEFINITION_METHOD_MODIFIERS_CHANGED = 71,
- JVMTI_ERROR_UNMODIFIABLE_CLASS = 79,
- JVMTI_ERROR_NOT_AVAILABLE = 98,
- JVMTI_ERROR_MUST_POSSESS_CAPABILITY = 99,
- JVMTI_ERROR_NULL_POINTER = 100,
- JVMTI_ERROR_ABSENT_INFORMATION = 101,
- JVMTI_ERROR_INVALID_EVENT_TYPE = 102,
- JVMTI_ERROR_ILLEGAL_ARGUMENT = 103,
- JVMTI_ERROR_NATIVE_METHOD = 104,
- JVMTI_ERROR_CLASS_LOADER_UNSUPPORTED = 106,
- JVMTI_ERROR_OUT_OF_MEMORY = 110,
- JVMTI_ERROR_ACCESS_DENIED = 111,
- JVMTI_ERROR_WRONG_PHASE = 112,
- JVMTI_ERROR_INTERNAL = 113,
- JVMTI_ERROR_UNATTACHED_THREAD = 115,
- JVMTI_ERROR_INVALID_ENVIRONMENT = 116,
- JVMTI_ERROR_MAX = 116
-} jvmtiError;
-
- /* Event IDs */
-
-typedef enum {
- JVMTI_MIN_EVENT_TYPE_VAL = 50,
- JVMTI_EVENT_VM_INIT = 50,
- JVMTI_EVENT_VM_DEATH = 51,
- JVMTI_EVENT_THREAD_START = 52,
- JVMTI_EVENT_THREAD_END = 53,
- JVMTI_EVENT_CLASS_FILE_LOAD_HOOK = 54,
- JVMTI_EVENT_CLASS_LOAD = 55,
- JVMTI_EVENT_CLASS_PREPARE = 56,
- JVMTI_EVENT_VM_START = 57,
- JVMTI_EVENT_EXCEPTION = 58,
- JVMTI_EVENT_EXCEPTION_CATCH = 59,
- JVMTI_EVENT_SINGLE_STEP = 60,
- JVMTI_EVENT_FRAME_POP = 61,
- JVMTI_EVENT_BREAKPOINT = 62,
- JVMTI_EVENT_FIELD_ACCESS = 63,
- JVMTI_EVENT_FIELD_MODIFICATION = 64,
- JVMTI_EVENT_METHOD_ENTRY = 65,
- JVMTI_EVENT_METHOD_EXIT = 66,
- JVMTI_EVENT_NATIVE_METHOD_BIND = 67,
- JVMTI_EVENT_COMPILED_METHOD_LOAD = 68,
- JVMTI_EVENT_COMPILED_METHOD_UNLOAD = 69,
- JVMTI_EVENT_DYNAMIC_CODE_GENERATED = 70,
- JVMTI_EVENT_DATA_DUMP_REQUEST = 71,
- JVMTI_EVENT_MONITOR_WAIT = 73,
- JVMTI_EVENT_MONITOR_WAITED = 74,
- JVMTI_EVENT_MONITOR_CONTENDED_ENTER = 75,
- JVMTI_EVENT_MONITOR_CONTENDED_ENTERED = 76,
- JVMTI_EVENT_RESOURCE_EXHAUSTED = 80,
- JVMTI_EVENT_GARBAGE_COLLECTION_START = 81,
- JVMTI_EVENT_GARBAGE_COLLECTION_FINISH = 82,
- JVMTI_EVENT_OBJECT_FREE = 83,
- JVMTI_EVENT_VM_OBJECT_ALLOC = 84,
- JVMTI_MAX_EVENT_TYPE_VAL = 84
-} jvmtiEvent;
-
-
- /* Pre-Declarations */
-struct _jvmtiThreadInfo;
-typedef struct _jvmtiThreadInfo jvmtiThreadInfo;
-struct _jvmtiMonitorStackDepthInfo;
-typedef struct _jvmtiMonitorStackDepthInfo jvmtiMonitorStackDepthInfo;
-struct _jvmtiThreadGroupInfo;
-typedef struct _jvmtiThreadGroupInfo jvmtiThreadGroupInfo;
-struct _jvmtiFrameInfo;
-typedef struct _jvmtiFrameInfo jvmtiFrameInfo;
-struct _jvmtiStackInfo;
-typedef struct _jvmtiStackInfo jvmtiStackInfo;
-struct _jvmtiHeapReferenceInfoField;
-typedef struct _jvmtiHeapReferenceInfoField jvmtiHeapReferenceInfoField;
-struct _jvmtiHeapReferenceInfoArray;
-typedef struct _jvmtiHeapReferenceInfoArray jvmtiHeapReferenceInfoArray;
-struct _jvmtiHeapReferenceInfoConstantPool;
-typedef struct _jvmtiHeapReferenceInfoConstantPool jvmtiHeapReferenceInfoConstantPool;
-struct _jvmtiHeapReferenceInfoStackLocal;
-typedef struct _jvmtiHeapReferenceInfoStackLocal jvmtiHeapReferenceInfoStackLocal;
-struct _jvmtiHeapReferenceInfoJniLocal;
-typedef struct _jvmtiHeapReferenceInfoJniLocal jvmtiHeapReferenceInfoJniLocal;
-struct _jvmtiHeapReferenceInfoReserved;
-typedef struct _jvmtiHeapReferenceInfoReserved jvmtiHeapReferenceInfoReserved;
-union _jvmtiHeapReferenceInfo;
-typedef union _jvmtiHeapReferenceInfo jvmtiHeapReferenceInfo;
-struct _jvmtiHeapCallbacks;
-typedef struct _jvmtiHeapCallbacks jvmtiHeapCallbacks;
-struct _jvmtiClassDefinition;
-typedef struct _jvmtiClassDefinition jvmtiClassDefinition;
-struct _jvmtiMonitorUsage;
-typedef struct _jvmtiMonitorUsage jvmtiMonitorUsage;
-struct _jvmtiLineNumberEntry;
-typedef struct _jvmtiLineNumberEntry jvmtiLineNumberEntry;
-struct _jvmtiLocalVariableEntry;
-typedef struct _jvmtiLocalVariableEntry jvmtiLocalVariableEntry;
-struct _jvmtiParamInfo;
-typedef struct _jvmtiParamInfo jvmtiParamInfo;
-struct _jvmtiExtensionFunctionInfo;
-typedef struct _jvmtiExtensionFunctionInfo jvmtiExtensionFunctionInfo;
-struct _jvmtiExtensionEventInfo;
-typedef struct _jvmtiExtensionEventInfo jvmtiExtensionEventInfo;
-struct _jvmtiTimerInfo;
-typedef struct _jvmtiTimerInfo jvmtiTimerInfo;
-struct _jvmtiAddrLocationMap;
-typedef struct _jvmtiAddrLocationMap jvmtiAddrLocationMap;
-
- /* Function Types */
-
-typedef void (JNICALL *jvmtiStartFunction)
- (jvmtiEnv* jvmti_env, JNIEnv* jni_env, void* arg);
-
-typedef jint (JNICALL *jvmtiHeapIterationCallback)
- (jlong class_tag, jlong size, jlong* tag_ptr, jint length, void* user_data);
-
-typedef jint (JNICALL *jvmtiHeapReferenceCallback)
- (jvmtiHeapReferenceKind reference_kind, const jvmtiHeapReferenceInfo* reference_info, jlong class_tag, jlong referrer_class_tag, jlong size, jlong* tag_ptr, jlong* referrer_tag_ptr, jint length, void* user_data);
-
-typedef jint (JNICALL *jvmtiPrimitiveFieldCallback)
- (jvmtiHeapReferenceKind kind, const jvmtiHeapReferenceInfo* info, jlong object_class_tag, jlong* object_tag_ptr, jvalue value, jvmtiPrimitiveType value_type, void* user_data);
-
-typedef jint (JNICALL *jvmtiArrayPrimitiveValueCallback)
- (jlong class_tag, jlong size, jlong* tag_ptr, jint element_count, jvmtiPrimitiveType element_type, const void* elements, void* user_data);
-
-typedef jint (JNICALL *jvmtiStringPrimitiveValueCallback)
- (jlong class_tag, jlong size, jlong* tag_ptr, const jchar* value, jint value_length, void* user_data);
-
-typedef jint (JNICALL *jvmtiReservedCallback)
- ();
-
-typedef jvmtiIterationControl (JNICALL *jvmtiHeapObjectCallback)
- (jlong class_tag, jlong size, jlong* tag_ptr, void* user_data);
-
-typedef jvmtiIterationControl (JNICALL *jvmtiHeapRootCallback)
- (jvmtiHeapRootKind root_kind, jlong class_tag, jlong size, jlong* tag_ptr, void* user_data);
-
-typedef jvmtiIterationControl (JNICALL *jvmtiStackReferenceCallback)
- (jvmtiHeapRootKind root_kind, jlong class_tag, jlong size, jlong* tag_ptr, jlong thread_tag, jint depth, jmethodID method, jint slot, void* user_data);
-
-typedef jvmtiIterationControl (JNICALL *jvmtiObjectReferenceCallback)
- (jvmtiObjectReferenceKind reference_kind, jlong class_tag, jlong size, jlong* tag_ptr, jlong referrer_tag, jint referrer_index, void* user_data);
-
-typedef jvmtiError (JNICALL *jvmtiExtensionFunction)
- (jvmtiEnv* jvmti_env, ...);
-
-typedef void (JNICALL *jvmtiExtensionEvent)
- (jvmtiEnv* jvmti_env, ...);
-
-
- /* Structure Types */
-struct _jvmtiThreadInfo {
- char* name;
- jint priority;
- jboolean is_daemon;
- jthreadGroup thread_group;
- jobject context_class_loader;
-};
-struct _jvmtiMonitorStackDepthInfo {
- jobject monitor;
- jint stack_depth;
-};
-struct _jvmtiThreadGroupInfo {
- jthreadGroup parent;
- char* name;
- jint max_priority;
- jboolean is_daemon;
-};
-struct _jvmtiFrameInfo {
- jmethodID method;
- jlocation location;
-};
-struct _jvmtiStackInfo {
- jthread thread;
- jint state;
- jvmtiFrameInfo* frame_buffer;
- jint frame_count;
-};
-struct _jvmtiHeapReferenceInfoField {
- jint index;
-};
-struct _jvmtiHeapReferenceInfoArray {
- jint index;
-};
-struct _jvmtiHeapReferenceInfoConstantPool {
- jint index;
-};
-struct _jvmtiHeapReferenceInfoStackLocal {
- jlong thread_tag;
- jlong thread_id;
- jint depth;
- jmethodID method;
- jlocation location;
- jint slot;
-};
-struct _jvmtiHeapReferenceInfoJniLocal {
- jlong thread_tag;
- jlong thread_id;
- jint depth;
- jmethodID method;
-};
-struct _jvmtiHeapReferenceInfoReserved {
- jlong reserved1;
- jlong reserved2;
- jlong reserved3;
- jlong reserved4;
- jlong reserved5;
- jlong reserved6;
- jlong reserved7;
- jlong reserved8;
-};
-union _jvmtiHeapReferenceInfo {
- jvmtiHeapReferenceInfoField field;
- jvmtiHeapReferenceInfoArray array;
- jvmtiHeapReferenceInfoConstantPool constant_pool;
- jvmtiHeapReferenceInfoStackLocal stack_local;
- jvmtiHeapReferenceInfoJniLocal jni_local;
- jvmtiHeapReferenceInfoReserved other;
-};
-struct _jvmtiHeapCallbacks {
- jvmtiHeapIterationCallback heap_iteration_callback;
- jvmtiHeapReferenceCallback heap_reference_callback;
- jvmtiPrimitiveFieldCallback primitive_field_callback;
- jvmtiArrayPrimitiveValueCallback array_primitive_value_callback;
- jvmtiStringPrimitiveValueCallback string_primitive_value_callback;
- jvmtiReservedCallback reserved5;
- jvmtiReservedCallback reserved6;
- jvmtiReservedCallback reserved7;
- jvmtiReservedCallback reserved8;
- jvmtiReservedCallback reserved9;
- jvmtiReservedCallback reserved10;
- jvmtiReservedCallback reserved11;
- jvmtiReservedCallback reserved12;
- jvmtiReservedCallback reserved13;
- jvmtiReservedCallback reserved14;
- jvmtiReservedCallback reserved15;
-};
-struct _jvmtiClassDefinition {
- jclass klass;
- jint class_byte_count;
- const unsigned char* class_bytes;
-};
-struct _jvmtiMonitorUsage {
- jthread owner;
- jint entry_count;
- jint waiter_count;
- jthread* waiters;
- jint notify_waiter_count;
- jthread* notify_waiters;
-};
-struct _jvmtiLineNumberEntry {
- jlocation start_location;
- jint line_number;
-};
-struct _jvmtiLocalVariableEntry {
- jlocation start_location;
- jint length;
- char* name;
- char* signature;
- char* generic_signature;
- jint slot;
-};
-struct _jvmtiParamInfo {
- char* name;
- jvmtiParamKind kind;
- jvmtiParamTypes base_type;
- jboolean null_ok;
-};
-struct _jvmtiExtensionFunctionInfo {
- jvmtiExtensionFunction func;
- char* id;
- char* short_description;
- jint param_count;
- jvmtiParamInfo* params;
- jint error_count;
- jvmtiError* errors;
-};
-struct _jvmtiExtensionEventInfo {
- jint extension_event_index;
- char* id;
- char* short_description;
- jint param_count;
- jvmtiParamInfo* params;
-};
-struct _jvmtiTimerInfo {
- jlong max_value;
- jboolean may_skip_forward;
- jboolean may_skip_backward;
- jvmtiTimerKind kind;
- jlong reserved1;
- jlong reserved2;
-};
-struct _jvmtiAddrLocationMap {
- const void* start_address;
- jlocation location;
-};
-
-typedef struct {
- unsigned int can_tag_objects : 1;
- unsigned int can_generate_field_modification_events : 1;
- unsigned int can_generate_field_access_events : 1;
- unsigned int can_get_bytecodes : 1;
- unsigned int can_get_synthetic_attribute : 1;
- unsigned int can_get_owned_monitor_info : 1;
- unsigned int can_get_current_contended_monitor : 1;
- unsigned int can_get_monitor_info : 1;
- unsigned int can_pop_frame : 1;
- unsigned int can_redefine_classes : 1;
- unsigned int can_signal_thread : 1;
- unsigned int can_get_source_file_name : 1;
- unsigned int can_get_line_numbers : 1;
- unsigned int can_get_source_debug_extension : 1;
- unsigned int can_access_local_variables : 1;
- unsigned int can_maintain_original_method_order : 1;
- unsigned int can_generate_single_step_events : 1;
- unsigned int can_generate_exception_events : 1;
- unsigned int can_generate_frame_pop_events : 1;
- unsigned int can_generate_breakpoint_events : 1;
- unsigned int can_suspend : 1;
- unsigned int can_redefine_any_class : 1;
- unsigned int can_get_current_thread_cpu_time : 1;
- unsigned int can_get_thread_cpu_time : 1;
- unsigned int can_generate_method_entry_events : 1;
- unsigned int can_generate_method_exit_events : 1;
- unsigned int can_generate_all_class_hook_events : 1;
- unsigned int can_generate_compiled_method_load_events : 1;
- unsigned int can_generate_monitor_events : 1;
- unsigned int can_generate_vm_object_alloc_events : 1;
- unsigned int can_generate_native_method_bind_events : 1;
- unsigned int can_generate_garbage_collection_events : 1;
- unsigned int can_generate_object_free_events : 1;
- unsigned int can_force_early_return : 1;
- unsigned int can_get_owned_monitor_stack_depth_info : 1;
- unsigned int can_get_constant_pool : 1;
- unsigned int can_set_native_method_prefix : 1;
- unsigned int can_retransform_classes : 1;
- unsigned int can_retransform_any_class : 1;
- unsigned int can_generate_resource_exhaustion_heap_events : 1;
- unsigned int can_generate_resource_exhaustion_threads_events : 1;
- unsigned int can_generate_early_vmstart : 1;
- unsigned int can_generate_early_class_hook_events : 1;
- unsigned int : 5;
- unsigned int : 16;
- unsigned int : 16;
- unsigned int : 16;
- unsigned int : 16;
- unsigned int : 16;
-} jvmtiCapabilities;
-
-
- /* Event Definitions */
-
-typedef void (JNICALL *jvmtiEventReserved)(void);
-
-
-typedef void (JNICALL *jvmtiEventBreakpoint)
- (jvmtiEnv *jvmti_env,
- JNIEnv* jni_env,
- jthread thread,
- jmethodID method,
- jlocation location);
-
-typedef void (JNICALL *jvmtiEventClassFileLoadHook)
- (jvmtiEnv *jvmti_env,
- JNIEnv* jni_env,
- jclass class_being_redefined,
- jobject loader,
- const char* name,
- jobject protection_domain,
- jint class_data_len,
- const unsigned char* class_data,
- jint* new_class_data_len,
- unsigned char** new_class_data);
-
-typedef void (JNICALL *jvmtiEventClassLoad)
- (jvmtiEnv *jvmti_env,
- JNIEnv* jni_env,
- jthread thread,
- jclass klass);
-
-typedef void (JNICALL *jvmtiEventClassPrepare)
- (jvmtiEnv *jvmti_env,
- JNIEnv* jni_env,
- jthread thread,
- jclass klass);
-
-typedef void (JNICALL *jvmtiEventCompiledMethodLoad)
- (jvmtiEnv *jvmti_env,
- jmethodID method,
- jint code_size,
- const void* code_addr,
- jint map_length,
- const jvmtiAddrLocationMap* map,
- const void* compile_info);
-
-typedef void (JNICALL *jvmtiEventCompiledMethodUnload)
- (jvmtiEnv *jvmti_env,
- jmethodID method,
- const void* code_addr);
-
-typedef void (JNICALL *jvmtiEventDataDumpRequest)
- (jvmtiEnv *jvmti_env);
-
-typedef void (JNICALL *jvmtiEventDynamicCodeGenerated)
- (jvmtiEnv *jvmti_env,
- const char* name,
- const void* address,
- jint length);
-
-typedef void (JNICALL *jvmtiEventException)
- (jvmtiEnv *jvmti_env,
- JNIEnv* jni_env,
- jthread thread,
- jmethodID method,
- jlocation location,
- jobject exception,
- jmethodID catch_method,
- jlocation catch_location);
-
-typedef void (JNICALL *jvmtiEventExceptionCatch)
- (jvmtiEnv *jvmti_env,
- JNIEnv* jni_env,
- jthread thread,
- jmethodID method,
- jlocation location,
- jobject exception);
-
-typedef void (JNICALL *jvmtiEventFieldAccess)
- (jvmtiEnv *jvmti_env,
- JNIEnv* jni_env,
- jthread thread,
- jmethodID method,
- jlocation location,
- jclass field_klass,
- jobject object,
- jfieldID field);
-
-typedef void (JNICALL *jvmtiEventFieldModification)
- (jvmtiEnv *jvmti_env,
- JNIEnv* jni_env,
- jthread thread,
- jmethodID method,
- jlocation location,
- jclass field_klass,
- jobject object,
- jfieldID field,
- char signature_type,
- jvalue new_value);
-
-typedef void (JNICALL *jvmtiEventFramePop)
- (jvmtiEnv *jvmti_env,
- JNIEnv* jni_env,
- jthread thread,
- jmethodID method,
- jboolean was_popped_by_exception);
-
-typedef void (JNICALL *jvmtiEventGarbageCollectionFinish)
- (jvmtiEnv *jvmti_env);
-
-typedef void (JNICALL *jvmtiEventGarbageCollectionStart)
- (jvmtiEnv *jvmti_env);
-
-typedef void (JNICALL *jvmtiEventMethodEntry)
- (jvmtiEnv *jvmti_env,
- JNIEnv* jni_env,
- jthread thread,
- jmethodID method);
-
-typedef void (JNICALL *jvmtiEventMethodExit)
- (jvmtiEnv *jvmti_env,
- JNIEnv* jni_env,
- jthread thread,
- jmethodID method,
- jboolean was_popped_by_exception,
- jvalue return_value);
-
-typedef void (JNICALL *jvmtiEventMonitorContendedEnter)
- (jvmtiEnv *jvmti_env,
- JNIEnv* jni_env,
- jthread thread,
- jobject object);
-
-typedef void (JNICALL *jvmtiEventMonitorContendedEntered)
- (jvmtiEnv *jvmti_env,
- JNIEnv* jni_env,
- jthread thread,
- jobject object);
-
-typedef void (JNICALL *jvmtiEventMonitorWait)
- (jvmtiEnv *jvmti_env,
- JNIEnv* jni_env,
- jthread thread,
- jobject object,
- jlong timeout);
-
-typedef void (JNICALL *jvmtiEventMonitorWaited)
- (jvmtiEnv *jvmti_env,
- JNIEnv* jni_env,
- jthread thread,
- jobject object,
- jboolean timed_out);
-
-typedef void (JNICALL *jvmtiEventNativeMethodBind)
- (jvmtiEnv *jvmti_env,
- JNIEnv* jni_env,
- jthread thread,
- jmethodID method,
- void* address,
- void** new_address_ptr);
-
-typedef void (JNICALL *jvmtiEventObjectFree)
- (jvmtiEnv *jvmti_env,
- jlong tag);
-
-typedef void (JNICALL *jvmtiEventResourceExhausted)
- (jvmtiEnv *jvmti_env,
- JNIEnv* jni_env,
- jint flags,
- const void* reserved,
- const char* description);
-
-typedef void (JNICALL *jvmtiEventSingleStep)
- (jvmtiEnv *jvmti_env,
- JNIEnv* jni_env,
- jthread thread,
- jmethodID method,
- jlocation location);
-
-typedef void (JNICALL *jvmtiEventThreadEnd)
- (jvmtiEnv *jvmti_env,
- JNIEnv* jni_env,
- jthread thread);
-
-typedef void (JNICALL *jvmtiEventThreadStart)
- (jvmtiEnv *jvmti_env,
- JNIEnv* jni_env,
- jthread thread);
-
-typedef void (JNICALL *jvmtiEventVMDeath)
- (jvmtiEnv *jvmti_env,
- JNIEnv* jni_env);
-
-typedef void (JNICALL *jvmtiEventVMInit)
- (jvmtiEnv *jvmti_env,
- JNIEnv* jni_env,
- jthread thread);
-
-typedef void (JNICALL *jvmtiEventVMObjectAlloc)
- (jvmtiEnv *jvmti_env,
- JNIEnv* jni_env,
- jthread thread,
- jobject object,
- jclass object_klass,
- jlong size);
-
-typedef void (JNICALL *jvmtiEventVMStart)
- (jvmtiEnv *jvmti_env,
- JNIEnv* jni_env);
-
- /* Event Callback Structure */
-
-typedef struct {
- /* 50 : VM Initialization Event */
- jvmtiEventVMInit VMInit;
- /* 51 : VM Death Event */
- jvmtiEventVMDeath VMDeath;
- /* 52 : Thread Start */
- jvmtiEventThreadStart ThreadStart;
- /* 53 : Thread End */
- jvmtiEventThreadEnd ThreadEnd;
- /* 54 : Class File Load Hook */
- jvmtiEventClassFileLoadHook ClassFileLoadHook;
- /* 55 : Class Load */
- jvmtiEventClassLoad ClassLoad;
- /* 56 : Class Prepare */
- jvmtiEventClassPrepare ClassPrepare;
- /* 57 : VM Start Event */
- jvmtiEventVMStart VMStart;
- /* 58 : Exception */
- jvmtiEventException Exception;
- /* 59 : Exception Catch */
- jvmtiEventExceptionCatch ExceptionCatch;
- /* 60 : Single Step */
- jvmtiEventSingleStep SingleStep;
- /* 61 : Frame Pop */
- jvmtiEventFramePop FramePop;
- /* 62 : Breakpoint */
- jvmtiEventBreakpoint Breakpoint;
- /* 63 : Field Access */
- jvmtiEventFieldAccess FieldAccess;
- /* 64 : Field Modification */
- jvmtiEventFieldModification FieldModification;
- /* 65 : Method Entry */
- jvmtiEventMethodEntry MethodEntry;
- /* 66 : Method Exit */
- jvmtiEventMethodExit MethodExit;
- /* 67 : Native Method Bind */
- jvmtiEventNativeMethodBind NativeMethodBind;
- /* 68 : Compiled Method Load */
- jvmtiEventCompiledMethodLoad CompiledMethodLoad;
- /* 69 : Compiled Method Unload */
- jvmtiEventCompiledMethodUnload CompiledMethodUnload;
- /* 70 : Dynamic Code Generated */
- jvmtiEventDynamicCodeGenerated DynamicCodeGenerated;
- /* 71 : Data Dump Request */
- jvmtiEventDataDumpRequest DataDumpRequest;
- /* 72 */
- jvmtiEventReserved reserved72;
- /* 73 : Monitor Wait */
- jvmtiEventMonitorWait MonitorWait;
- /* 74 : Monitor Waited */
- jvmtiEventMonitorWaited MonitorWaited;
- /* 75 : Monitor Contended Enter */
- jvmtiEventMonitorContendedEnter MonitorContendedEnter;
- /* 76 : Monitor Contended Entered */
- jvmtiEventMonitorContendedEntered MonitorContendedEntered;
- /* 77 */
- jvmtiEventReserved reserved77;
- /* 78 */
- jvmtiEventReserved reserved78;
- /* 79 */
- jvmtiEventReserved reserved79;
- /* 80 : Resource Exhausted */
- jvmtiEventResourceExhausted ResourceExhausted;
- /* 81 : Garbage Collection Start */
- jvmtiEventGarbageCollectionStart GarbageCollectionStart;
- /* 82 : Garbage Collection Finish */
- jvmtiEventGarbageCollectionFinish GarbageCollectionFinish;
- /* 83 : Object Free */
- jvmtiEventObjectFree ObjectFree;
- /* 84 : VM Object Allocation */
- jvmtiEventVMObjectAlloc VMObjectAlloc;
-} jvmtiEventCallbacks;
-
-
- /* Function Interface */
-
-typedef struct jvmtiInterface_1_ {
-
- /* 1 : RESERVED */
- void *reserved1;
-
- /* 2 : Set Event Notification Mode */
- jvmtiError (JNICALL *SetEventNotificationMode) (jvmtiEnv* env,
- jvmtiEventMode mode,
- jvmtiEvent event_type,
- jthread event_thread,
- ...);
-
- /* 3 : Get All Modules */
- jvmtiError (JNICALL *GetAllModules) (jvmtiEnv* env,
- jint* module_count_ptr,
- jobject** modules_ptr);
-
- /* 4 : Get All Threads */
- jvmtiError (JNICALL *GetAllThreads) (jvmtiEnv* env,
- jint* threads_count_ptr,
- jthread** threads_ptr);
-
- /* 5 : Suspend Thread */
- jvmtiError (JNICALL *SuspendThread) (jvmtiEnv* env,
- jthread thread);
-
- /* 6 : Resume Thread */
- jvmtiError (JNICALL *ResumeThread) (jvmtiEnv* env,
- jthread thread);
-
- /* 7 : Stop Thread */
- jvmtiError (JNICALL *StopThread) (jvmtiEnv* env,
- jthread thread,
- jobject exception);
-
- /* 8 : Interrupt Thread */
- jvmtiError (JNICALL *InterruptThread) (jvmtiEnv* env,
- jthread thread);
-
- /* 9 : Get Thread Info */
- jvmtiError (JNICALL *GetThreadInfo) (jvmtiEnv* env,
- jthread thread,
- jvmtiThreadInfo* info_ptr);
-
- /* 10 : Get Owned Monitor Info */
- jvmtiError (JNICALL *GetOwnedMonitorInfo) (jvmtiEnv* env,
- jthread thread,
- jint* owned_monitor_count_ptr,
- jobject** owned_monitors_ptr);
-
- /* 11 : Get Current Contended Monitor */
- jvmtiError (JNICALL *GetCurrentContendedMonitor) (jvmtiEnv* env,
- jthread thread,
- jobject* monitor_ptr);
-
- /* 12 : Run Agent Thread */
- jvmtiError (JNICALL *RunAgentThread) (jvmtiEnv* env,
- jthread thread,
- jvmtiStartFunction proc,
- const void* arg,
- jint priority);
-
- /* 13 : Get Top Thread Groups */
- jvmtiError (JNICALL *GetTopThreadGroups) (jvmtiEnv* env,
- jint* group_count_ptr,
- jthreadGroup** groups_ptr);
-
- /* 14 : Get Thread Group Info */
- jvmtiError (JNICALL *GetThreadGroupInfo) (jvmtiEnv* env,
- jthreadGroup group,
- jvmtiThreadGroupInfo* info_ptr);
-
- /* 15 : Get Thread Group Children */
- jvmtiError (JNICALL *GetThreadGroupChildren) (jvmtiEnv* env,
- jthreadGroup group,
- jint* thread_count_ptr,
- jthread** threads_ptr,
- jint* group_count_ptr,
- jthreadGroup** groups_ptr);
-
- /* 16 : Get Frame Count */
- jvmtiError (JNICALL *GetFrameCount) (jvmtiEnv* env,
- jthread thread,
- jint* count_ptr);
-
- /* 17 : Get Thread State */
- jvmtiError (JNICALL *GetThreadState) (jvmtiEnv* env,
- jthread thread,
- jint* thread_state_ptr);
-
- /* 18 : Get Current Thread */
- jvmtiError (JNICALL *GetCurrentThread) (jvmtiEnv* env,
- jthread* thread_ptr);
-
- /* 19 : Get Frame Location */
- jvmtiError (JNICALL *GetFrameLocation) (jvmtiEnv* env,
- jthread thread,
- jint depth,
- jmethodID* method_ptr,
- jlocation* location_ptr);
-
- /* 20 : Notify Frame Pop */
- jvmtiError (JNICALL *NotifyFramePop) (jvmtiEnv* env,
- jthread thread,
- jint depth);
-
- /* 21 : Get Local Variable - Object */
- jvmtiError (JNICALL *GetLocalObject) (jvmtiEnv* env,
- jthread thread,
- jint depth,
- jint slot,
- jobject* value_ptr);
-
- /* 22 : Get Local Variable - Int */
- jvmtiError (JNICALL *GetLocalInt) (jvmtiEnv* env,
- jthread thread,
- jint depth,
- jint slot,
- jint* value_ptr);
-
- /* 23 : Get Local Variable - Long */
- jvmtiError (JNICALL *GetLocalLong) (jvmtiEnv* env,
- jthread thread,
- jint depth,
- jint slot,
- jlong* value_ptr);
-
- /* 24 : Get Local Variable - Float */
- jvmtiError (JNICALL *GetLocalFloat) (jvmtiEnv* env,
- jthread thread,
- jint depth,
- jint slot,
- jfloat* value_ptr);
-
- /* 25 : Get Local Variable - Double */
- jvmtiError (JNICALL *GetLocalDouble) (jvmtiEnv* env,
- jthread thread,
- jint depth,
- jint slot,
- jdouble* value_ptr);
-
- /* 26 : Set Local Variable - Object */
- jvmtiError (JNICALL *SetLocalObject) (jvmtiEnv* env,
- jthread thread,
- jint depth,
- jint slot,
- jobject value);
-
- /* 27 : Set Local Variable - Int */
- jvmtiError (JNICALL *SetLocalInt) (jvmtiEnv* env,
- jthread thread,
- jint depth,
- jint slot,
- jint value);
-
- /* 28 : Set Local Variable - Long */
- jvmtiError (JNICALL *SetLocalLong) (jvmtiEnv* env,
- jthread thread,
- jint depth,
- jint slot,
- jlong value);
-
- /* 29 : Set Local Variable - Float */
- jvmtiError (JNICALL *SetLocalFloat) (jvmtiEnv* env,
- jthread thread,
- jint depth,
- jint slot,
- jfloat value);
-
- /* 30 : Set Local Variable - Double */
- jvmtiError (JNICALL *SetLocalDouble) (jvmtiEnv* env,
- jthread thread,
- jint depth,
- jint slot,
- jdouble value);
-
- /* 31 : Create Raw Monitor */
- jvmtiError (JNICALL *CreateRawMonitor) (jvmtiEnv* env,
- const char* name,
- jrawMonitorID* monitor_ptr);
-
- /* 32 : Destroy Raw Monitor */
- jvmtiError (JNICALL *DestroyRawMonitor) (jvmtiEnv* env,
- jrawMonitorID monitor);
-
- /* 33 : Raw Monitor Enter */
- jvmtiError (JNICALL *RawMonitorEnter) (jvmtiEnv* env,
- jrawMonitorID monitor);
-
- /* 34 : Raw Monitor Exit */
- jvmtiError (JNICALL *RawMonitorExit) (jvmtiEnv* env,
- jrawMonitorID monitor);
-
- /* 35 : Raw Monitor Wait */
- jvmtiError (JNICALL *RawMonitorWait) (jvmtiEnv* env,
- jrawMonitorID monitor,
- jlong millis);
-
- /* 36 : Raw Monitor Notify */
- jvmtiError (JNICALL *RawMonitorNotify) (jvmtiEnv* env,
- jrawMonitorID monitor);
-
- /* 37 : Raw Monitor Notify All */
- jvmtiError (JNICALL *RawMonitorNotifyAll) (jvmtiEnv* env,
- jrawMonitorID monitor);
-
- /* 38 : Set Breakpoint */
- jvmtiError (JNICALL *SetBreakpoint) (jvmtiEnv* env,
- jmethodID method,
- jlocation location);
-
- /* 39 : Clear Breakpoint */
- jvmtiError (JNICALL *ClearBreakpoint) (jvmtiEnv* env,
- jmethodID method,
- jlocation location);
-
- /* 40 : Get Named Module */
- jvmtiError (JNICALL *GetNamedModule) (jvmtiEnv* env,
- jobject class_loader,
- const char* package_name,
- jobject* module_ptr);
-
- /* 41 : Set Field Access Watch */
- jvmtiError (JNICALL *SetFieldAccessWatch) (jvmtiEnv* env,
- jclass klass,
- jfieldID field);
-
- /* 42 : Clear Field Access Watch */
- jvmtiError (JNICALL *ClearFieldAccessWatch) (jvmtiEnv* env,
- jclass klass,
- jfieldID field);
-
- /* 43 : Set Field Modification Watch */
- jvmtiError (JNICALL *SetFieldModificationWatch) (jvmtiEnv* env,
- jclass klass,
- jfieldID field);
-
- /* 44 : Clear Field Modification Watch */
- jvmtiError (JNICALL *ClearFieldModificationWatch) (jvmtiEnv* env,
- jclass klass,
- jfieldID field);
-
- /* 45 : Is Modifiable Class */
- jvmtiError (JNICALL *IsModifiableClass) (jvmtiEnv* env,
- jclass klass,
- jboolean* is_modifiable_class_ptr);
-
- /* 46 : Allocate */
- jvmtiError (JNICALL *Allocate) (jvmtiEnv* env,
- jlong size,
- unsigned char** mem_ptr);
-
- /* 47 : Deallocate */
- jvmtiError (JNICALL *Deallocate) (jvmtiEnv* env,
- unsigned char* mem);
-
- /* 48 : Get Class Signature */
- jvmtiError (JNICALL *GetClassSignature) (jvmtiEnv* env,
- jclass klass,
- char** signature_ptr,
- char** generic_ptr);
-
- /* 49 : Get Class Status */
- jvmtiError (JNICALL *GetClassStatus) (jvmtiEnv* env,
- jclass klass,
- jint* status_ptr);
-
- /* 50 : Get Source File Name */
- jvmtiError (JNICALL *GetSourceFileName) (jvmtiEnv* env,
- jclass klass,
- char** source_name_ptr);
-
- /* 51 : Get Class Modifiers */
- jvmtiError (JNICALL *GetClassModifiers) (jvmtiEnv* env,
- jclass klass,
- jint* modifiers_ptr);
-
- /* 52 : Get Class Methods */
- jvmtiError (JNICALL *GetClassMethods) (jvmtiEnv* env,
- jclass klass,
- jint* method_count_ptr,
- jmethodID** methods_ptr);
-
- /* 53 : Get Class Fields */
- jvmtiError (JNICALL *GetClassFields) (jvmtiEnv* env,
- jclass klass,
- jint* field_count_ptr,
- jfieldID** fields_ptr);
-
- /* 54 : Get Implemented Interfaces */
- jvmtiError (JNICALL *GetImplementedInterfaces) (jvmtiEnv* env,
- jclass klass,
- jint* interface_count_ptr,
- jclass** interfaces_ptr);
-
- /* 55 : Is Interface */
- jvmtiError (JNICALL *IsInterface) (jvmtiEnv* env,
- jclass klass,
- jboolean* is_interface_ptr);
-
- /* 56 : Is Array Class */
- jvmtiError (JNICALL *IsArrayClass) (jvmtiEnv* env,
- jclass klass,
- jboolean* is_array_class_ptr);
-
- /* 57 : Get Class Loader */
- jvmtiError (JNICALL *GetClassLoader) (jvmtiEnv* env,
- jclass klass,
- jobject* classloader_ptr);
-
- /* 58 : Get Object Hash Code */
- jvmtiError (JNICALL *GetObjectHashCode) (jvmtiEnv* env,
- jobject object,
- jint* hash_code_ptr);
-
- /* 59 : Get Object Monitor Usage */
- jvmtiError (JNICALL *GetObjectMonitorUsage) (jvmtiEnv* env,
- jobject object,
- jvmtiMonitorUsage* info_ptr);
-
- /* 60 : Get Field Name (and Signature) */
- jvmtiError (JNICALL *GetFieldName) (jvmtiEnv* env,
- jclass klass,
- jfieldID field,
- char** name_ptr,
- char** signature_ptr,
- char** generic_ptr);
-
- /* 61 : Get Field Declaring Class */
- jvmtiError (JNICALL *GetFieldDeclaringClass) (jvmtiEnv* env,
- jclass klass,
- jfieldID field,
- jclass* declaring_class_ptr);
-
- /* 62 : Get Field Modifiers */
- jvmtiError (JNICALL *GetFieldModifiers) (jvmtiEnv* env,
- jclass klass,
- jfieldID field,
- jint* modifiers_ptr);
-
- /* 63 : Is Field Synthetic */
- jvmtiError (JNICALL *IsFieldSynthetic) (jvmtiEnv* env,
- jclass klass,
- jfieldID field,
- jboolean* is_synthetic_ptr);
-
- /* 64 : Get Method Name (and Signature) */
- jvmtiError (JNICALL *GetMethodName) (jvmtiEnv* env,
- jmethodID method,
- char** name_ptr,
- char** signature_ptr,
- char** generic_ptr);
-
- /* 65 : Get Method Declaring Class */
- jvmtiError (JNICALL *GetMethodDeclaringClass) (jvmtiEnv* env,
- jmethodID method,
- jclass* declaring_class_ptr);
-
- /* 66 : Get Method Modifiers */
- jvmtiError (JNICALL *GetMethodModifiers) (jvmtiEnv* env,
- jmethodID method,
- jint* modifiers_ptr);
-
- /* 67 : RESERVED */
- void *reserved67;
-
- /* 68 : Get Max Locals */
- jvmtiError (JNICALL *GetMaxLocals) (jvmtiEnv* env,
- jmethodID method,
- jint* max_ptr);
-
- /* 69 : Get Arguments Size */
- jvmtiError (JNICALL *GetArgumentsSize) (jvmtiEnv* env,
- jmethodID method,
- jint* size_ptr);
-
- /* 70 : Get Line Number Table */
- jvmtiError (JNICALL *GetLineNumberTable) (jvmtiEnv* env,
- jmethodID method,
- jint* entry_count_ptr,
- jvmtiLineNumberEntry** table_ptr);
-
- /* 71 : Get Method Location */
- jvmtiError (JNICALL *GetMethodLocation) (jvmtiEnv* env,
- jmethodID method,
- jlocation* start_location_ptr,
- jlocation* end_location_ptr);
-
- /* 72 : Get Local Variable Table */
- jvmtiError (JNICALL *GetLocalVariableTable) (jvmtiEnv* env,
- jmethodID method,
- jint* entry_count_ptr,
- jvmtiLocalVariableEntry** table_ptr);
-
- /* 73 : Set Native Method Prefix */
- jvmtiError (JNICALL *SetNativeMethodPrefix) (jvmtiEnv* env,
- const char* prefix);
-
- /* 74 : Set Native Method Prefixes */
- jvmtiError (JNICALL *SetNativeMethodPrefixes) (jvmtiEnv* env,
- jint prefix_count,
- char** prefixes);
-
- /* 75 : Get Bytecodes */
- jvmtiError (JNICALL *GetBytecodes) (jvmtiEnv* env,
- jmethodID method,
- jint* bytecode_count_ptr,
- unsigned char** bytecodes_ptr);
-
- /* 76 : Is Method Native */
- jvmtiError (JNICALL *IsMethodNative) (jvmtiEnv* env,
- jmethodID method,
- jboolean* is_native_ptr);
-
- /* 77 : Is Method Synthetic */
- jvmtiError (JNICALL *IsMethodSynthetic) (jvmtiEnv* env,
- jmethodID method,
- jboolean* is_synthetic_ptr);
-
- /* 78 : Get Loaded Classes */
- jvmtiError (JNICALL *GetLoadedClasses) (jvmtiEnv* env,
- jint* class_count_ptr,
- jclass** classes_ptr);
-
- /* 79 : Get Classloader Classes */
- jvmtiError (JNICALL *GetClassLoaderClasses) (jvmtiEnv* env,
- jobject initiating_loader,
- jint* class_count_ptr,
- jclass** classes_ptr);
-
- /* 80 : Pop Frame */
- jvmtiError (JNICALL *PopFrame) (jvmtiEnv* env,
- jthread thread);
-
- /* 81 : Force Early Return - Object */
- jvmtiError (JNICALL *ForceEarlyReturnObject) (jvmtiEnv* env,
- jthread thread,
- jobject value);
-
- /* 82 : Force Early Return - Int */
- jvmtiError (JNICALL *ForceEarlyReturnInt) (jvmtiEnv* env,
- jthread thread,
- jint value);
-
- /* 83 : Force Early Return - Long */
- jvmtiError (JNICALL *ForceEarlyReturnLong) (jvmtiEnv* env,
- jthread thread,
- jlong value);
-
- /* 84 : Force Early Return - Float */
- jvmtiError (JNICALL *ForceEarlyReturnFloat) (jvmtiEnv* env,
- jthread thread,
- jfloat value);
-
- /* 85 : Force Early Return - Double */
- jvmtiError (JNICALL *ForceEarlyReturnDouble) (jvmtiEnv* env,
- jthread thread,
- jdouble value);
-
- /* 86 : Force Early Return - Void */
- jvmtiError (JNICALL *ForceEarlyReturnVoid) (jvmtiEnv* env,
- jthread thread);
-
- /* 87 : Redefine Classes */
- jvmtiError (JNICALL *RedefineClasses) (jvmtiEnv* env,
- jint class_count,
- const jvmtiClassDefinition* class_definitions);
-
- /* 88 : Get Version Number */
- jvmtiError (JNICALL *GetVersionNumber) (jvmtiEnv* env,
- jint* version_ptr);
-
- /* 89 : Get Capabilities */
- jvmtiError (JNICALL *GetCapabilities) (jvmtiEnv* env,
- jvmtiCapabilities* capabilities_ptr);
-
- /* 90 : Get Source Debug Extension */
- jvmtiError (JNICALL *GetSourceDebugExtension) (jvmtiEnv* env,
- jclass klass,
- char** source_debug_extension_ptr);
-
- /* 91 : Is Method Obsolete */
- jvmtiError (JNICALL *IsMethodObsolete) (jvmtiEnv* env,
- jmethodID method,
- jboolean* is_obsolete_ptr);
-
- /* 92 : Suspend Thread List */
- jvmtiError (JNICALL *SuspendThreadList) (jvmtiEnv* env,
- jint request_count,
- const jthread* request_list,
- jvmtiError* results);
-
- /* 93 : Resume Thread List */
- jvmtiError (JNICALL *ResumeThreadList) (jvmtiEnv* env,
- jint request_count,
- const jthread* request_list,
- jvmtiError* results);
-
- /* 94 : RESERVED */
- void *reserved94;
-
- /* 95 : RESERVED */
- void *reserved95;
-
- /* 96 : RESERVED */
- void *reserved96;
-
- /* 97 : RESERVED */
- void *reserved97;
-
- /* 98 : RESERVED */
- void *reserved98;
-
- /* 99 : RESERVED */
- void *reserved99;
-
- /* 100 : Get All Stack Traces */
- jvmtiError (JNICALL *GetAllStackTraces) (jvmtiEnv* env,
- jint max_frame_count,
- jvmtiStackInfo** stack_info_ptr,
- jint* thread_count_ptr);
-
- /* 101 : Get Thread List Stack Traces */
- jvmtiError (JNICALL *GetThreadListStackTraces) (jvmtiEnv* env,
- jint thread_count,
- const jthread* thread_list,
- jint max_frame_count,
- jvmtiStackInfo** stack_info_ptr);
-
- /* 102 : Get Thread Local Storage */
- jvmtiError (JNICALL *GetThreadLocalStorage) (jvmtiEnv* env,
- jthread thread,
- void** data_ptr);
-
- /* 103 : Set Thread Local Storage */
- jvmtiError (JNICALL *SetThreadLocalStorage) (jvmtiEnv* env,
- jthread thread,
- const void* data);
-
- /* 104 : Get Stack Trace */
- jvmtiError (JNICALL *GetStackTrace) (jvmtiEnv* env,
- jthread thread,
- jint start_depth,
- jint max_frame_count,
- jvmtiFrameInfo* frame_buffer,
- jint* count_ptr);
-
- /* 105 : RESERVED */
- void *reserved105;
-
- /* 106 : Get Tag */
- jvmtiError (JNICALL *GetTag) (jvmtiEnv* env,
- jobject object,
- jlong* tag_ptr);
-
- /* 107 : Set Tag */
- jvmtiError (JNICALL *SetTag) (jvmtiEnv* env,
- jobject object,
- jlong tag);
-
- /* 108 : Force Garbage Collection */
- jvmtiError (JNICALL *ForceGarbageCollection) (jvmtiEnv* env);
-
- /* 109 : Iterate Over Objects Reachable From Object */
- jvmtiError (JNICALL *IterateOverObjectsReachableFromObject) (jvmtiEnv* env,
- jobject object,
- jvmtiObjectReferenceCallback object_reference_callback,
- const void* user_data);
-
- /* 110 : Iterate Over Reachable Objects */
- jvmtiError (JNICALL *IterateOverReachableObjects) (jvmtiEnv* env,
- jvmtiHeapRootCallback heap_root_callback,
- jvmtiStackReferenceCallback stack_ref_callback,
- jvmtiObjectReferenceCallback object_ref_callback,
- const void* user_data);
-
- /* 111 : Iterate Over Heap */
- jvmtiError (JNICALL *IterateOverHeap) (jvmtiEnv* env,
- jvmtiHeapObjectFilter object_filter,
- jvmtiHeapObjectCallback heap_object_callback,
- const void* user_data);
-
- /* 112 : Iterate Over Instances Of Class */
- jvmtiError (JNICALL *IterateOverInstancesOfClass) (jvmtiEnv* env,
- jclass klass,
- jvmtiHeapObjectFilter object_filter,
- jvmtiHeapObjectCallback heap_object_callback,
- const void* user_data);
-
- /* 113 : RESERVED */
- void *reserved113;
-
- /* 114 : Get Objects With Tags */
- jvmtiError (JNICALL *GetObjectsWithTags) (jvmtiEnv* env,
- jint tag_count,
- const jlong* tags,
- jint* count_ptr,
- jobject** object_result_ptr,
- jlong** tag_result_ptr);
-
- /* 115 : Follow References */
- jvmtiError (JNICALL *FollowReferences) (jvmtiEnv* env,
- jint heap_filter,
- jclass klass,
- jobject initial_object,
- const jvmtiHeapCallbacks* callbacks,
- const void* user_data);
-
- /* 116 : Iterate Through Heap */
- jvmtiError (JNICALL *IterateThroughHeap) (jvmtiEnv* env,
- jint heap_filter,
- jclass klass,
- const jvmtiHeapCallbacks* callbacks,
- const void* user_data);
-
- /* 117 : RESERVED */
- void *reserved117;
-
- /* 118 : RESERVED */
- void *reserved118;
-
- /* 119 : RESERVED */
- void *reserved119;
-
- /* 120 : Set JNI Function Table */
- jvmtiError (JNICALL *SetJNIFunctionTable) (jvmtiEnv* env,
- const jniNativeInterface* function_table);
-
- /* 121 : Get JNI Function Table */
- jvmtiError (JNICALL *GetJNIFunctionTable) (jvmtiEnv* env,
- jniNativeInterface** function_table);
-
- /* 122 : Set Event Callbacks */
- jvmtiError (JNICALL *SetEventCallbacks) (jvmtiEnv* env,
- const jvmtiEventCallbacks* callbacks,
- jint size_of_callbacks);
-
- /* 123 : Generate Events */
- jvmtiError (JNICALL *GenerateEvents) (jvmtiEnv* env,
- jvmtiEvent event_type);
-
- /* 124 : Get Extension Functions */
- jvmtiError (JNICALL *GetExtensionFunctions) (jvmtiEnv* env,
- jint* extension_count_ptr,
- jvmtiExtensionFunctionInfo** extensions);
-
- /* 125 : Get Extension Events */
- jvmtiError (JNICALL *GetExtensionEvents) (jvmtiEnv* env,
- jint* extension_count_ptr,
- jvmtiExtensionEventInfo** extensions);
-
- /* 126 : Set Extension Event Callback */
- jvmtiError (JNICALL *SetExtensionEventCallback) (jvmtiEnv* env,
- jint extension_event_index,
- jvmtiExtensionEvent callback);
-
- /* 127 : Dispose Environment */
- jvmtiError (JNICALL *DisposeEnvironment) (jvmtiEnv* env);
-
- /* 128 : Get Error Name */
- jvmtiError (JNICALL *GetErrorName) (jvmtiEnv* env,
- jvmtiError error,
- char** name_ptr);
-
- /* 129 : Get JLocation Format */
- jvmtiError (JNICALL *GetJLocationFormat) (jvmtiEnv* env,
- jvmtiJlocationFormat* format_ptr);
-
- /* 130 : Get System Properties */
- jvmtiError (JNICALL *GetSystemProperties) (jvmtiEnv* env,
- jint* count_ptr,
- char*** property_ptr);
-
- /* 131 : Get System Property */
- jvmtiError (JNICALL *GetSystemProperty) (jvmtiEnv* env,
- const char* property,
- char** value_ptr);
-
- /* 132 : Set System Property */
- jvmtiError (JNICALL *SetSystemProperty) (jvmtiEnv* env,
- const char* property,
- const char* value_ptr);
-
- /* 133 : Get Phase */
- jvmtiError (JNICALL *GetPhase) (jvmtiEnv* env,
- jvmtiPhase* phase_ptr);
-
- /* 134 : Get Current Thread CPU Timer Information */
- jvmtiError (JNICALL *GetCurrentThreadCpuTimerInfo) (jvmtiEnv* env,
- jvmtiTimerInfo* info_ptr);
-
- /* 135 : Get Current Thread CPU Time */
- jvmtiError (JNICALL *GetCurrentThreadCpuTime) (jvmtiEnv* env,
- jlong* nanos_ptr);
-
- /* 136 : Get Thread CPU Timer Information */
- jvmtiError (JNICALL *GetThreadCpuTimerInfo) (jvmtiEnv* env,
- jvmtiTimerInfo* info_ptr);
-
- /* 137 : Get Thread CPU Time */
- jvmtiError (JNICALL *GetThreadCpuTime) (jvmtiEnv* env,
- jthread thread,
- jlong* nanos_ptr);
-
- /* 138 : Get Timer Information */
- jvmtiError (JNICALL *GetTimerInfo) (jvmtiEnv* env,
- jvmtiTimerInfo* info_ptr);
-
- /* 139 : Get Time */
- jvmtiError (JNICALL *GetTime) (jvmtiEnv* env,
- jlong* nanos_ptr);
-
- /* 140 : Get Potential Capabilities */
- jvmtiError (JNICALL *GetPotentialCapabilities) (jvmtiEnv* env,
- jvmtiCapabilities* capabilities_ptr);
-
- /* 141 : RESERVED */
- void *reserved141;
-
- /* 142 : Add Capabilities */
- jvmtiError (JNICALL *AddCapabilities) (jvmtiEnv* env,
- const jvmtiCapabilities* capabilities_ptr);
-
- /* 143 : Relinquish Capabilities */
- jvmtiError (JNICALL *RelinquishCapabilities) (jvmtiEnv* env,
- const jvmtiCapabilities* capabilities_ptr);
-
- /* 144 : Get Available Processors */
- jvmtiError (JNICALL *GetAvailableProcessors) (jvmtiEnv* env,
- jint* processor_count_ptr);
-
- /* 145 : Get Class Version Numbers */
- jvmtiError (JNICALL *GetClassVersionNumbers) (jvmtiEnv* env,
- jclass klass,
- jint* minor_version_ptr,
- jint* major_version_ptr);
-
- /* 146 : Get Constant Pool */
- jvmtiError (JNICALL *GetConstantPool) (jvmtiEnv* env,
- jclass klass,
- jint* constant_pool_count_ptr,
- jint* constant_pool_byte_count_ptr,
- unsigned char** constant_pool_bytes_ptr);
-
- /* 147 : Get Environment Local Storage */
- jvmtiError (JNICALL *GetEnvironmentLocalStorage) (jvmtiEnv* env,
- void** data_ptr);
-
- /* 148 : Set Environment Local Storage */
- jvmtiError (JNICALL *SetEnvironmentLocalStorage) (jvmtiEnv* env,
- const void* data);
-
- /* 149 : Add To Bootstrap Class Loader Search */
- jvmtiError (JNICALL *AddToBootstrapClassLoaderSearch) (jvmtiEnv* env,
- const char* segment);
-
- /* 150 : Set Verbose Flag */
- jvmtiError (JNICALL *SetVerboseFlag) (jvmtiEnv* env,
- jvmtiVerboseFlag flag,
- jboolean value);
-
- /* 151 : Add To System Class Loader Search */
- jvmtiError (JNICALL *AddToSystemClassLoaderSearch) (jvmtiEnv* env,
- const char* segment);
-
- /* 152 : Retransform Classes */
- jvmtiError (JNICALL *RetransformClasses) (jvmtiEnv* env,
- jint class_count,
- const jclass* classes);
-
- /* 153 : Get Owned Monitor Stack Depth Info */
- jvmtiError (JNICALL *GetOwnedMonitorStackDepthInfo) (jvmtiEnv* env,
- jthread thread,
- jint* monitor_info_count_ptr,
- jvmtiMonitorStackDepthInfo** monitor_info_ptr);
-
- /* 154 : Get Object Size */
- jvmtiError (JNICALL *GetObjectSize) (jvmtiEnv* env,
- jobject object,
- jlong* size_ptr);
-
- /* 155 : Get Local Instance */
- jvmtiError (JNICALL *GetLocalInstance) (jvmtiEnv* env,
- jthread thread,
- jint depth,
- jobject* value_ptr);
-
-} jvmtiInterface_1;
-
-struct _jvmtiEnv {
- const struct jvmtiInterface_1_ *functions;
-#ifdef __cplusplus
-
-
- jvmtiError Allocate(jlong size,
- unsigned char** mem_ptr) {
- return functions->Allocate(this, size, mem_ptr);
- }
-
- jvmtiError Deallocate(unsigned char* mem) {
- return functions->Deallocate(this, mem);
- }
-
- jvmtiError GetThreadState(jthread thread,
- jint* thread_state_ptr) {
- return functions->GetThreadState(this, thread, thread_state_ptr);
- }
-
- jvmtiError GetCurrentThread(jthread* thread_ptr) {
- return functions->GetCurrentThread(this, thread_ptr);
- }
-
- jvmtiError GetAllThreads(jint* threads_count_ptr,
- jthread** threads_ptr) {
- return functions->GetAllThreads(this, threads_count_ptr, threads_ptr);
- }
-
- jvmtiError SuspendThread(jthread thread) {
- return functions->SuspendThread(this, thread);
- }
-
- jvmtiError SuspendThreadList(jint request_count,
- const jthread* request_list,
- jvmtiError* results) {
- return functions->SuspendThreadList(this, request_count, request_list, results);
- }
-
- jvmtiError ResumeThread(jthread thread) {
- return functions->ResumeThread(this, thread);
- }
-
- jvmtiError ResumeThreadList(jint request_count,
- const jthread* request_list,
- jvmtiError* results) {
- return functions->ResumeThreadList(this, request_count, request_list, results);
- }
-
- jvmtiError StopThread(jthread thread,
- jobject exception) {
- return functions->StopThread(this, thread, exception);
- }
-
- jvmtiError InterruptThread(jthread thread) {
- return functions->InterruptThread(this, thread);
- }
-
- jvmtiError GetThreadInfo(jthread thread,
- jvmtiThreadInfo* info_ptr) {
- return functions->GetThreadInfo(this, thread, info_ptr);
- }
-
- jvmtiError GetOwnedMonitorInfo(jthread thread,
- jint* owned_monitor_count_ptr,
- jobject** owned_monitors_ptr) {
- return functions->GetOwnedMonitorInfo(this, thread, owned_monitor_count_ptr, owned_monitors_ptr);
- }
-
- jvmtiError GetOwnedMonitorStackDepthInfo(jthread thread,
- jint* monitor_info_count_ptr,
- jvmtiMonitorStackDepthInfo** monitor_info_ptr) {
- return functions->GetOwnedMonitorStackDepthInfo(this, thread, monitor_info_count_ptr, monitor_info_ptr);
- }
-
- jvmtiError GetCurrentContendedMonitor(jthread thread,
- jobject* monitor_ptr) {
- return functions->GetCurrentContendedMonitor(this, thread, monitor_ptr);
- }
-
- jvmtiError RunAgentThread(jthread thread,
- jvmtiStartFunction proc,
- const void* arg,
- jint priority) {
- return functions->RunAgentThread(this, thread, proc, arg, priority);
- }
-
- jvmtiError SetThreadLocalStorage(jthread thread,
- const void* data) {
- return functions->SetThreadLocalStorage(this, thread, data);
- }
-
- jvmtiError GetThreadLocalStorage(jthread thread,
- void** data_ptr) {
- return functions->GetThreadLocalStorage(this, thread, data_ptr);
- }
-
- jvmtiError GetTopThreadGroups(jint* group_count_ptr,
- jthreadGroup** groups_ptr) {
- return functions->GetTopThreadGroups(this, group_count_ptr, groups_ptr);
- }
-
- jvmtiError GetThreadGroupInfo(jthreadGroup group,
- jvmtiThreadGroupInfo* info_ptr) {
- return functions->GetThreadGroupInfo(this, group, info_ptr);
- }
-
- jvmtiError GetThreadGroupChildren(jthreadGroup group,
- jint* thread_count_ptr,
- jthread** threads_ptr,
- jint* group_count_ptr,
- jthreadGroup** groups_ptr) {
- return functions->GetThreadGroupChildren(this, group, thread_count_ptr, threads_ptr, group_count_ptr, groups_ptr);
- }
-
- jvmtiError GetStackTrace(jthread thread,
- jint start_depth,
- jint max_frame_count,
- jvmtiFrameInfo* frame_buffer,
- jint* count_ptr) {
- return functions->GetStackTrace(this, thread, start_depth, max_frame_count, frame_buffer, count_ptr);
- }
-
- jvmtiError GetAllStackTraces(jint max_frame_count,
- jvmtiStackInfo** stack_info_ptr,
- jint* thread_count_ptr) {
- return functions->GetAllStackTraces(this, max_frame_count, stack_info_ptr, thread_count_ptr);
- }
-
- jvmtiError GetThreadListStackTraces(jint thread_count,
- const jthread* thread_list,
- jint max_frame_count,
- jvmtiStackInfo** stack_info_ptr) {
- return functions->GetThreadListStackTraces(this, thread_count, thread_list, max_frame_count, stack_info_ptr);
- }
-
- jvmtiError GetFrameCount(jthread thread,
- jint* count_ptr) {
- return functions->GetFrameCount(this, thread, count_ptr);
- }
-
- jvmtiError PopFrame(jthread thread) {
- return functions->PopFrame(this, thread);
- }
-
- jvmtiError GetFrameLocation(jthread thread,
- jint depth,
- jmethodID* method_ptr,
- jlocation* location_ptr) {
- return functions->GetFrameLocation(this, thread, depth, method_ptr, location_ptr);
- }
-
- jvmtiError NotifyFramePop(jthread thread,
- jint depth) {
- return functions->NotifyFramePop(this, thread, depth);
- }
-
- jvmtiError ForceEarlyReturnObject(jthread thread,
- jobject value) {
- return functions->ForceEarlyReturnObject(this, thread, value);
- }
-
- jvmtiError ForceEarlyReturnInt(jthread thread,
- jint value) {
- return functions->ForceEarlyReturnInt(this, thread, value);
- }
-
- jvmtiError ForceEarlyReturnLong(jthread thread,
- jlong value) {
- return functions->ForceEarlyReturnLong(this, thread, value);
- }
-
- jvmtiError ForceEarlyReturnFloat(jthread thread,
- jfloat value) {
- return functions->ForceEarlyReturnFloat(this, thread, value);
- }
-
- jvmtiError ForceEarlyReturnDouble(jthread thread,
- jdouble value) {
- return functions->ForceEarlyReturnDouble(this, thread, value);
- }
-
- jvmtiError ForceEarlyReturnVoid(jthread thread) {
- return functions->ForceEarlyReturnVoid(this, thread);
- }
-
- jvmtiError FollowReferences(jint heap_filter,
- jclass klass,
- jobject initial_object,
- const jvmtiHeapCallbacks* callbacks,
- const void* user_data) {
- return functions->FollowReferences(this, heap_filter, klass, initial_object, callbacks, user_data);
- }
-
- jvmtiError IterateThroughHeap(jint heap_filter,
- jclass klass,
- const jvmtiHeapCallbacks* callbacks,
- const void* user_data) {
- return functions->IterateThroughHeap(this, heap_filter, klass, callbacks, user_data);
- }
-
- jvmtiError GetTag(jobject object,
- jlong* tag_ptr) {
- return functions->GetTag(this, object, tag_ptr);
- }
-
- jvmtiError SetTag(jobject object,
- jlong tag) {
- return functions->SetTag(this, object, tag);
- }
-
- jvmtiError GetObjectsWithTags(jint tag_count,
- const jlong* tags,
- jint* count_ptr,
- jobject** object_result_ptr,
- jlong** tag_result_ptr) {
- return functions->GetObjectsWithTags(this, tag_count, tags, count_ptr, object_result_ptr, tag_result_ptr);
- }
-
- jvmtiError ForceGarbageCollection() {
- return functions->ForceGarbageCollection(this);
- }
-
- jvmtiError IterateOverObjectsReachableFromObject(jobject object,
- jvmtiObjectReferenceCallback object_reference_callback,
- const void* user_data) {
- return functions->IterateOverObjectsReachableFromObject(this, object, object_reference_callback, user_data);
- }
-
- jvmtiError IterateOverReachableObjects(jvmtiHeapRootCallback heap_root_callback,
- jvmtiStackReferenceCallback stack_ref_callback,
- jvmtiObjectReferenceCallback object_ref_callback,
- const void* user_data) {
- return functions->IterateOverReachableObjects(this, heap_root_callback, stack_ref_callback, object_ref_callback, user_data);
- }
-
- jvmtiError IterateOverHeap(jvmtiHeapObjectFilter object_filter,
- jvmtiHeapObjectCallback heap_object_callback,
- const void* user_data) {
- return functions->IterateOverHeap(this, object_filter, heap_object_callback, user_data);
- }
-
- jvmtiError IterateOverInstancesOfClass(jclass klass,
- jvmtiHeapObjectFilter object_filter,
- jvmtiHeapObjectCallback heap_object_callback,
- const void* user_data) {
- return functions->IterateOverInstancesOfClass(this, klass, object_filter, heap_object_callback, user_data);
- }
-
- jvmtiError GetLocalObject(jthread thread,
- jint depth,
- jint slot,
- jobject* value_ptr) {
- return functions->GetLocalObject(this, thread, depth, slot, value_ptr);
- }
-
- jvmtiError GetLocalInstance(jthread thread,
- jint depth,
- jobject* value_ptr) {
- return functions->GetLocalInstance(this, thread, depth, value_ptr);
- }
-
- jvmtiError GetLocalInt(jthread thread,
- jint depth,
- jint slot,
- jint* value_ptr) {
- return functions->GetLocalInt(this, thread, depth, slot, value_ptr);
- }
-
- jvmtiError GetLocalLong(jthread thread,
- jint depth,
- jint slot,
- jlong* value_ptr) {
- return functions->GetLocalLong(this, thread, depth, slot, value_ptr);
- }
-
- jvmtiError GetLocalFloat(jthread thread,
- jint depth,
- jint slot,
- jfloat* value_ptr) {
- return functions->GetLocalFloat(this, thread, depth, slot, value_ptr);
- }
-
- jvmtiError GetLocalDouble(jthread thread,
- jint depth,
- jint slot,
- jdouble* value_ptr) {
- return functions->GetLocalDouble(this, thread, depth, slot, value_ptr);
- }
-
- jvmtiError SetLocalObject(jthread thread,
- jint depth,
- jint slot,
- jobject value) {
- return functions->SetLocalObject(this, thread, depth, slot, value);
- }
-
- jvmtiError SetLocalInt(jthread thread,
- jint depth,
- jint slot,
- jint value) {
- return functions->SetLocalInt(this, thread, depth, slot, value);
- }
-
- jvmtiError SetLocalLong(jthread thread,
- jint depth,
- jint slot,
- jlong value) {
- return functions->SetLocalLong(this, thread, depth, slot, value);
- }
-
- jvmtiError SetLocalFloat(jthread thread,
- jint depth,
- jint slot,
- jfloat value) {
- return functions->SetLocalFloat(this, thread, depth, slot, value);
- }
-
- jvmtiError SetLocalDouble(jthread thread,
- jint depth,
- jint slot,
- jdouble value) {
- return functions->SetLocalDouble(this, thread, depth, slot, value);
- }
-
- jvmtiError SetBreakpoint(jmethodID method,
- jlocation location) {
- return functions->SetBreakpoint(this, method, location);
- }
-
- jvmtiError ClearBreakpoint(jmethodID method,
- jlocation location) {
- return functions->ClearBreakpoint(this, method, location);
- }
-
- jvmtiError SetFieldAccessWatch(jclass klass,
- jfieldID field) {
- return functions->SetFieldAccessWatch(this, klass, field);
- }
-
- jvmtiError ClearFieldAccessWatch(jclass klass,
- jfieldID field) {
- return functions->ClearFieldAccessWatch(this, klass, field);
- }
-
- jvmtiError SetFieldModificationWatch(jclass klass,
- jfieldID field) {
- return functions->SetFieldModificationWatch(this, klass, field);
- }
-
- jvmtiError ClearFieldModificationWatch(jclass klass,
- jfieldID field) {
- return functions->ClearFieldModificationWatch(this, klass, field);
- }
-
- jvmtiError GetAllModules(jint* module_count_ptr,
- jobject** modules_ptr) {
- return functions->GetAllModules(this, module_count_ptr, modules_ptr);
- }
-
- jvmtiError GetNamedModule(jobject class_loader,
- const char* package_name,
- jobject* module_ptr) {
- return functions->GetNamedModule(this, class_loader, package_name, module_ptr);
- }
-
- jvmtiError GetLoadedClasses(jint* class_count_ptr,
- jclass** classes_ptr) {
- return functions->GetLoadedClasses(this, class_count_ptr, classes_ptr);
- }
-
- jvmtiError GetClassLoaderClasses(jobject initiating_loader,
- jint* class_count_ptr,
- jclass** classes_ptr) {
- return functions->GetClassLoaderClasses(this, initiating_loader, class_count_ptr, classes_ptr);
- }
-
- jvmtiError GetClassSignature(jclass klass,
- char** signature_ptr,
- char** generic_ptr) {
- return functions->GetClassSignature(this, klass, signature_ptr, generic_ptr);
- }
-
- jvmtiError GetClassStatus(jclass klass,
- jint* status_ptr) {
- return functions->GetClassStatus(this, klass, status_ptr);
- }
-
- jvmtiError GetSourceFileName(jclass klass,
- char** source_name_ptr) {
- return functions->GetSourceFileName(this, klass, source_name_ptr);
- }
-
- jvmtiError GetClassModifiers(jclass klass,
- jint* modifiers_ptr) {
- return functions->GetClassModifiers(this, klass, modifiers_ptr);
- }
-
- jvmtiError GetClassMethods(jclass klass,
- jint* method_count_ptr,
- jmethodID** methods_ptr) {
- return functions->GetClassMethods(this, klass, method_count_ptr, methods_ptr);
- }
-
- jvmtiError GetClassFields(jclass klass,
- jint* field_count_ptr,
- jfieldID** fields_ptr) {
- return functions->GetClassFields(this, klass, field_count_ptr, fields_ptr);
- }
-
- jvmtiError GetImplementedInterfaces(jclass klass,
- jint* interface_count_ptr,
- jclass** interfaces_ptr) {
- return functions->GetImplementedInterfaces(this, klass, interface_count_ptr, interfaces_ptr);
- }
-
- jvmtiError GetClassVersionNumbers(jclass klass,
- jint* minor_version_ptr,
- jint* major_version_ptr) {
- return functions->GetClassVersionNumbers(this, klass, minor_version_ptr, major_version_ptr);
- }
-
- jvmtiError GetConstantPool(jclass klass,
- jint* constant_pool_count_ptr,
- jint* constant_pool_byte_count_ptr,
- unsigned char** constant_pool_bytes_ptr) {
- return functions->GetConstantPool(this, klass, constant_pool_count_ptr, constant_pool_byte_count_ptr, constant_pool_bytes_ptr);
- }
-
- jvmtiError IsInterface(jclass klass,
- jboolean* is_interface_ptr) {
- return functions->IsInterface(this, klass, is_interface_ptr);
- }
-
- jvmtiError IsArrayClass(jclass klass,
- jboolean* is_array_class_ptr) {
- return functions->IsArrayClass(this, klass, is_array_class_ptr);
- }
-
- jvmtiError IsModifiableClass(jclass klass,
- jboolean* is_modifiable_class_ptr) {
- return functions->IsModifiableClass(this, klass, is_modifiable_class_ptr);
- }
-
- jvmtiError GetClassLoader(jclass klass,
- jobject* classloader_ptr) {
- return functions->GetClassLoader(this, klass, classloader_ptr);
- }
-
- jvmtiError GetSourceDebugExtension(jclass klass,
- char** source_debug_extension_ptr) {
- return functions->GetSourceDebugExtension(this, klass, source_debug_extension_ptr);
- }
-
- jvmtiError RetransformClasses(jint class_count,
- const jclass* classes) {
- return functions->RetransformClasses(this, class_count, classes);
- }
-
- jvmtiError RedefineClasses(jint class_count,
- const jvmtiClassDefinition* class_definitions) {
- return functions->RedefineClasses(this, class_count, class_definitions);
- }
-
- jvmtiError GetObjectSize(jobject object,
- jlong* size_ptr) {
- return functions->GetObjectSize(this, object, size_ptr);
- }
-
- jvmtiError GetObjectHashCode(jobject object,
- jint* hash_code_ptr) {
- return functions->GetObjectHashCode(this, object, hash_code_ptr);
- }
-
- jvmtiError GetObjectMonitorUsage(jobject object,
- jvmtiMonitorUsage* info_ptr) {
- return functions->GetObjectMonitorUsage(this, object, info_ptr);
- }
-
- jvmtiError GetFieldName(jclass klass,
- jfieldID field,
- char** name_ptr,
- char** signature_ptr,
- char** generic_ptr) {
- return functions->GetFieldName(this, klass, field, name_ptr, signature_ptr, generic_ptr);
- }
-
- jvmtiError GetFieldDeclaringClass(jclass klass,
- jfieldID field,
- jclass* declaring_class_ptr) {
- return functions->GetFieldDeclaringClass(this, klass, field, declaring_class_ptr);
- }
-
- jvmtiError GetFieldModifiers(jclass klass,
- jfieldID field,
- jint* modifiers_ptr) {
- return functions->GetFieldModifiers(this, klass, field, modifiers_ptr);
- }
-
- jvmtiError IsFieldSynthetic(jclass klass,
- jfieldID field,
- jboolean* is_synthetic_ptr) {
- return functions->IsFieldSynthetic(this, klass, field, is_synthetic_ptr);
- }
-
- jvmtiError GetMethodName(jmethodID method,
- char** name_ptr,
- char** signature_ptr,
- char** generic_ptr) {
- return functions->GetMethodName(this, method, name_ptr, signature_ptr, generic_ptr);
- }
-
- jvmtiError GetMethodDeclaringClass(jmethodID method,
- jclass* declaring_class_ptr) {
- return functions->GetMethodDeclaringClass(this, method, declaring_class_ptr);
- }
-
- jvmtiError GetMethodModifiers(jmethodID method,
- jint* modifiers_ptr) {
- return functions->GetMethodModifiers(this, method, modifiers_ptr);
- }
-
- jvmtiError GetMaxLocals(jmethodID method,
- jint* max_ptr) {
- return functions->GetMaxLocals(this, method, max_ptr);
- }
-
- jvmtiError GetArgumentsSize(jmethodID method,
- jint* size_ptr) {
- return functions->GetArgumentsSize(this, method, size_ptr);
- }
-
- jvmtiError GetLineNumberTable(jmethodID method,
- jint* entry_count_ptr,
- jvmtiLineNumberEntry** table_ptr) {
- return functions->GetLineNumberTable(this, method, entry_count_ptr, table_ptr);
- }
-
- jvmtiError GetMethodLocation(jmethodID method,
- jlocation* start_location_ptr,
- jlocation* end_location_ptr) {
- return functions->GetMethodLocation(this, method, start_location_ptr, end_location_ptr);
- }
-
- jvmtiError GetLocalVariableTable(jmethodID method,
- jint* entry_count_ptr,
- jvmtiLocalVariableEntry** table_ptr) {
- return functions->GetLocalVariableTable(this, method, entry_count_ptr, table_ptr);
- }
-
- jvmtiError GetBytecodes(jmethodID method,
- jint* bytecode_count_ptr,
- unsigned char** bytecodes_ptr) {
- return functions->GetBytecodes(this, method, bytecode_count_ptr, bytecodes_ptr);
- }
-
- jvmtiError IsMethodNative(jmethodID method,
- jboolean* is_native_ptr) {
- return functions->IsMethodNative(this, method, is_native_ptr);
- }
-
- jvmtiError IsMethodSynthetic(jmethodID method,
- jboolean* is_synthetic_ptr) {
- return functions->IsMethodSynthetic(this, method, is_synthetic_ptr);
- }
-
- jvmtiError IsMethodObsolete(jmethodID method,
- jboolean* is_obsolete_ptr) {
- return functions->IsMethodObsolete(this, method, is_obsolete_ptr);
- }
-
- jvmtiError SetNativeMethodPrefix(const char* prefix) {
- return functions->SetNativeMethodPrefix(this, prefix);
- }
-
- jvmtiError SetNativeMethodPrefixes(jint prefix_count,
- char** prefixes) {
- return functions->SetNativeMethodPrefixes(this, prefix_count, prefixes);
- }
-
- jvmtiError CreateRawMonitor(const char* name,
- jrawMonitorID* monitor_ptr) {
- return functions->CreateRawMonitor(this, name, monitor_ptr);
- }
-
- jvmtiError DestroyRawMonitor(jrawMonitorID monitor) {
- return functions->DestroyRawMonitor(this, monitor);
- }
-
- jvmtiError RawMonitorEnter(jrawMonitorID monitor) {
- return functions->RawMonitorEnter(this, monitor);
- }
-
- jvmtiError RawMonitorExit(jrawMonitorID monitor) {
- return functions->RawMonitorExit(this, monitor);
- }
-
- jvmtiError RawMonitorWait(jrawMonitorID monitor,
- jlong millis) {
- return functions->RawMonitorWait(this, monitor, millis);
- }
-
- jvmtiError RawMonitorNotify(jrawMonitorID monitor) {
- return functions->RawMonitorNotify(this, monitor);
- }
-
- jvmtiError RawMonitorNotifyAll(jrawMonitorID monitor) {
- return functions->RawMonitorNotifyAll(this, monitor);
- }
-
- jvmtiError SetJNIFunctionTable(const jniNativeInterface* function_table) {
- return functions->SetJNIFunctionTable(this, function_table);
- }
-
- jvmtiError GetJNIFunctionTable(jniNativeInterface** function_table) {
- return functions->GetJNIFunctionTable(this, function_table);
- }
-
- jvmtiError SetEventCallbacks(const jvmtiEventCallbacks* callbacks,
- jint size_of_callbacks) {
- return functions->SetEventCallbacks(this, callbacks, size_of_callbacks);
- }
-
- jvmtiError SetEventNotificationMode(jvmtiEventMode mode,
- jvmtiEvent event_type,
- jthread event_thread,
- ...) {
- return functions->SetEventNotificationMode(this, mode, event_type, event_thread);
- }
-
- jvmtiError GenerateEvents(jvmtiEvent event_type) {
- return functions->GenerateEvents(this, event_type);
- }
-
- jvmtiError GetExtensionFunctions(jint* extension_count_ptr,
- jvmtiExtensionFunctionInfo** extensions) {
- return functions->GetExtensionFunctions(this, extension_count_ptr, extensions);
- }
-
- jvmtiError GetExtensionEvents(jint* extension_count_ptr,
- jvmtiExtensionEventInfo** extensions) {
- return functions->GetExtensionEvents(this, extension_count_ptr, extensions);
- }
-
- jvmtiError SetExtensionEventCallback(jint extension_event_index,
- jvmtiExtensionEvent callback) {
- return functions->SetExtensionEventCallback(this, extension_event_index, callback);
- }
-
- jvmtiError GetPotentialCapabilities(jvmtiCapabilities* capabilities_ptr) {
- return functions->GetPotentialCapabilities(this, capabilities_ptr);
- }
-
- jvmtiError AddCapabilities(const jvmtiCapabilities* capabilities_ptr) {
- return functions->AddCapabilities(this, capabilities_ptr);
- }
-
- jvmtiError RelinquishCapabilities(const jvmtiCapabilities* capabilities_ptr) {
- return functions->RelinquishCapabilities(this, capabilities_ptr);
- }
-
- jvmtiError GetCapabilities(jvmtiCapabilities* capabilities_ptr) {
- return functions->GetCapabilities(this, capabilities_ptr);
- }
-
- jvmtiError GetCurrentThreadCpuTimerInfo(jvmtiTimerInfo* info_ptr) {
- return functions->GetCurrentThreadCpuTimerInfo(this, info_ptr);
- }
-
- jvmtiError GetCurrentThreadCpuTime(jlong* nanos_ptr) {
- return functions->GetCurrentThreadCpuTime(this, nanos_ptr);
- }
-
- jvmtiError GetThreadCpuTimerInfo(jvmtiTimerInfo* info_ptr) {
- return functions->GetThreadCpuTimerInfo(this, info_ptr);
- }
-
- jvmtiError GetThreadCpuTime(jthread thread,
- jlong* nanos_ptr) {
- return functions->GetThreadCpuTime(this, thread, nanos_ptr);
- }
-
- jvmtiError GetTimerInfo(jvmtiTimerInfo* info_ptr) {
- return functions->GetTimerInfo(this, info_ptr);
- }
-
- jvmtiError GetTime(jlong* nanos_ptr) {
- return functions->GetTime(this, nanos_ptr);
- }
-
- jvmtiError GetAvailableProcessors(jint* processor_count_ptr) {
- return functions->GetAvailableProcessors(this, processor_count_ptr);
- }
-
- jvmtiError AddToBootstrapClassLoaderSearch(const char* segment) {
- return functions->AddToBootstrapClassLoaderSearch(this, segment);
- }
-
- jvmtiError AddToSystemClassLoaderSearch(const char* segment) {
- return functions->AddToSystemClassLoaderSearch(this, segment);
- }
-
- jvmtiError GetSystemProperties(jint* count_ptr,
- char*** property_ptr) {
- return functions->GetSystemProperties(this, count_ptr, property_ptr);
- }
-
- jvmtiError GetSystemProperty(const char* property,
- char** value_ptr) {
- return functions->GetSystemProperty(this, property, value_ptr);
- }
-
- jvmtiError SetSystemProperty(const char* property,
- const char* value_ptr) {
- return functions->SetSystemProperty(this, property, value_ptr);
- }
-
- jvmtiError GetPhase(jvmtiPhase* phase_ptr) {
- return functions->GetPhase(this, phase_ptr);
- }
-
- jvmtiError DisposeEnvironment() {
- return functions->DisposeEnvironment(this);
- }
-
- jvmtiError SetEnvironmentLocalStorage(const void* data) {
- return functions->SetEnvironmentLocalStorage(this, data);
- }
-
- jvmtiError GetEnvironmentLocalStorage(void** data_ptr) {
- return functions->GetEnvironmentLocalStorage(this, data_ptr);
- }
-
- jvmtiError GetVersionNumber(jint* version_ptr) {
- return functions->GetVersionNumber(this, version_ptr);
- }
-
- jvmtiError GetErrorName(jvmtiError error,
- char** name_ptr) {
- return functions->GetErrorName(this, error, name_ptr);
- }
-
- jvmtiError SetVerboseFlag(jvmtiVerboseFlag flag,
- jboolean value) {
- return functions->SetVerboseFlag(this, flag, value);
- }
-
- jvmtiError GetJLocationFormat(jvmtiJlocationFormat* format_ptr) {
- return functions->GetJLocationFormat(this, format_ptr);
- }
-
-#endif /* __cplusplus */
-};
-
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif /* __cplusplus */
-
-#endif /* !_JAVA_JVMTI_H_ */
--- a/jdk/src/java.base/share/native/libjava/StackFrameInfo.c Wed Nov 09 15:20:30 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * Implementation of class StackFrameInfo
- */
-
-#include <stdio.h>
-#include <signal.h>
-
-#include "jni.h"
-#include "jvm.h"
-
-#include "java_lang_StackFrameInfo.h"
-
-
-/*
- * Class: java_lang_StackFrameInfo
- * Method: toStackTraceElement0
- * Signature: (Ljava/lang/StackTraceElement;)V
- */
-JNIEXPORT void JNICALL Java_java_lang_StackFrameInfo_toStackTraceElement0
- (JNIEnv *env, jobject stackframeinfo, jobject stacktraceinfo) {
- JVM_ToStackTraceElement(env, stackframeinfo, stacktraceinfo);
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/native/libjava/StackTraceElement.c Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#include <stdio.h>
+#include <signal.h>
+
+#include "jni.h"
+#include "jvm.h"
+
+#include "java_lang_StackTraceElement.h"
+
+JNIEXPORT void JNICALL Java_java_lang_StackTraceElement_initStackTraceElement
+ (JNIEnv *env, jobject dummy, jobject element, jobject stackframeinfo) {
+ JVM_InitStackTraceElement(env, element, stackframeinfo);
+}
+
+JNIEXPORT void JNICALL Java_java_lang_StackTraceElement_initStackTraceElements
+ (JNIEnv *env, jobject dummy, jobjectArray elements, jobject throwable)
+{
+ JVM_InitStackTraceElementArray(env, elements, throwable);
+}
--- a/jdk/src/java.base/share/native/libjava/Throwable.c Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.base/share/native/libjava/Throwable.c Wed Nov 09 10:04:43 2016 -0800
@@ -49,10 +49,3 @@
JVM_FillInStackTrace(env, throwable);
return throwable;
}
-
-JNIEXPORT void JNICALL
-Java_java_lang_Throwable_getStackTraceElements(JNIEnv *env,
- jobject throwable, jobjectArray elements)
-{
- JVM_GetStackTraceElements(env, throwable, elements);
-}
--- a/jdk/src/java.base/share/native/libnet/net_util.c Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.base/share/native/libnet/net_util.c Wed Nov 09 10:04:43 2016 -0800
@@ -203,7 +203,6 @@
JNIEXPORT jobject JNICALL
NET_SockaddrToInetAddress(JNIEnv *env, struct sockaddr *him, int *port) {
jobject iaObj;
-#ifdef AF_INET6
if (him->sa_family == AF_INET6) {
struct sockaddr_in6 *him6 = (struct sockaddr_in6 *)him;
jbyte *caddr = (jbyte *)&(him6->sin6_addr);
@@ -227,16 +226,14 @@
setInet6Address_scopeid(env, iaObj, scope);
}
*port = ntohs(him6->sin6_port);
- } else
-#endif /* AF_INET6 */
- {
- struct sockaddr_in *him4 = (struct sockaddr_in *)him;
- iaObj = (*env)->NewObject(env, ia4_class, ia4_ctrID);
- CHECK_NULL_RETURN(iaObj, NULL);
- setInetAddress_family(env, iaObj, java_net_InetAddress_IPv4);
- setInetAddress_addr(env, iaObj, ntohl(him4->sin_addr.s_addr));
- *port = ntohs(him4->sin_port);
- }
+ } else {
+ struct sockaddr_in *him4 = (struct sockaddr_in *)him;
+ iaObj = (*env)->NewObject(env, ia4_class, ia4_ctrID);
+ CHECK_NULL_RETURN(iaObj, NULL);
+ setInetAddress_family(env, iaObj, java_net_InetAddress_IPv4);
+ setInetAddress_addr(env, iaObj, ntohl(him4->sin_addr.s_addr));
+ *port = ntohs(him4->sin_port);
+ }
return iaObj;
}
@@ -245,7 +242,6 @@
{
jint family = AF_INET;
-#ifdef AF_INET6
family = getInetAddress_family(env, iaObj) == java_net_InetAddress_IPv4 ?
AF_INET : AF_INET6;
if (him->sa_family == AF_INET6) {
@@ -279,22 +275,20 @@
return JNI_FALSE;
}
}
- } else
-#endif /* AF_INET6 */
- {
- struct sockaddr_in *him4 = (struct sockaddr_in *)him;
- int addrNew, addrCur;
- if (family != AF_INET) {
- return JNI_FALSE;
- }
- addrNew = ntohl(him4->sin_addr.s_addr);
- addrCur = getInetAddress_addr(env, iaObj);
- if (addrNew == addrCur) {
- return JNI_TRUE;
- } else {
- return JNI_FALSE;
- }
+ } else {
+ struct sockaddr_in *him4 = (struct sockaddr_in *)him;
+ int addrNew, addrCur;
+ if (family != AF_INET) {
+ return JNI_FALSE;
}
+ addrNew = ntohl(him4->sin_addr.s_addr);
+ addrCur = getInetAddress_addr(env, iaObj);
+ if (addrNew == addrCur) {
+ return JNI_TRUE;
+ } else {
+ return JNI_FALSE;
+ }
+ }
}
unsigned short
--- a/jdk/src/java.base/unix/native/libnet/Inet6AddressImpl.c Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.base/unix/native/libnet/Inet6AddressImpl.c Wed Nov 09 10:04:43 2016 -0800
@@ -72,7 +72,7 @@
hostname[NI_MAXHOST] = '\0';
}
-#if defined(__solaris__) && defined(AF_INET6)
+#if defined(__solaris__)
if (ret == 0) {
/* Solaris doesn't want to give us a fully qualified domain name.
* We do a reverse lookup to try and get one. This works
@@ -251,9 +251,7 @@
int retLen = 0;
int getaddrinfo_error=0;
-#ifdef AF_INET6
struct addrinfo hints, *res, *resNew = NULL;
-#endif /* AF_INET6 */
initInetAddressIDs(env);
JNU_CHECK_EXCEPTION_RETURN(env, NULL);
@@ -265,7 +263,6 @@
hostname = JNU_GetStringPlatformChars(env, host, JNI_FALSE);
CHECK_NULL_RETURN(hostname, NULL);
-#ifdef AF_INET6
/* Try once, with our static buffer. */
memset(&hints, 0, sizeof(hints));
hints.ai_flags = AI_CANONNAME;
@@ -459,7 +456,6 @@
}
freeaddrinfo(res);
-#endif /* AF_INET6 */
return ret;
}
@@ -475,7 +471,6 @@
jstring ret = NULL;
-#ifdef AF_INET6
char host[NI_MAXHOST+1];
int error = 0;
int len = 0;
@@ -518,7 +513,6 @@
ret = (*env)->NewStringUTF(env, host);
CHECK_NULL_RETURN(ret, NULL);
}
-#endif /* AF_INET6 */
if (ret == NULL) {
JNU_ThrowByName(env, JNU_JAVANETPKG "UnknownHostException", NULL);
@@ -533,7 +527,6 @@
fcntl(fd, F_SETFL, flags); \
}
-#ifdef AF_INET6
static jboolean
ping6(JNIEnv *env, jint fd, struct sockaddr_in6* him, jint timeout,
struct sockaddr_in6* netif, jint ttl) {
@@ -640,7 +633,6 @@
close(fd);
return JNI_FALSE;
}
-#endif /* AF_INET6 */
/*
* Class: java_net_Inet6AddressImpl
@@ -654,7 +646,6 @@
jint timeout,
jbyteArray ifArray,
jint ttl, jint if_scope) {
-#ifdef AF_INET6
jbyte caddr[16];
jint fd, sz;
struct sockaddr_in6 him6;
@@ -803,7 +794,4 @@
close(fd);
return JNI_FALSE;
}
-#else /* AF_INET6 */
- return JNI_FALSE;
-#endif /* AF_INET6 */
}
--- a/jdk/src/java.base/unix/native/libnet/InetAddressImplFactory.c Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.base/unix/native/libnet/InetAddressImplFactory.c Wed Nov 09 10:04:43 2016 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2001, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -37,14 +37,10 @@
* Signature: ()I
*/
JNIEXPORT jboolean JNICALL
-Java_java_net_InetAddressImplFactory_isIPv6Supported(JNIEnv *env, jclass cls)
-{
-#ifdef AF_INET6
+Java_java_net_InetAddressImplFactory_isIPv6Supported(JNIEnv *env, jclass cls) {
if (ipv6_available()) {
return JNI_TRUE;
- } else
-#endif /* AF_INET6 */
- {
- return JNI_FALSE;
- }
+ } else {
+ return JNI_FALSE;
+ }
}
--- a/jdk/src/java.base/unix/native/libnet/NetworkInterface.c Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.base/unix/native/libnet/NetworkInterface.c Wed Nov 09 10:04:43 2016 -0800
@@ -126,10 +126,7 @@
static netif *enumInterfaces(JNIEnv *env);
static netif *enumIPv4Interfaces(JNIEnv *env, int sock, netif *ifs);
-
-#if defined(AF_INET6)
static netif *enumIPv6Interfaces(JNIEnv *env, int sock, netif *ifs);
-#endif
static netif *addif(JNIEnv *env, int sock, const char *if_name, netif *ifs,
struct sockaddr *ifr_addrP,
@@ -312,11 +309,8 @@
(JNIEnv *env, jclass cls, jobject iaObj)
{
netif *ifs, *curr;
-#if defined(AF_INET6)
- int family = (getInetAddress_family(env, iaObj) == java_net_InetAddress_IPv4) ? AF_INET : AF_INET6;
-#else
- int family = AF_INET;
-#endif
+ int family = (getInetAddress_family(env, iaObj) == java_net_InetAddress_IPv4) ?
+ AF_INET : AF_INET6;
jobject obj = NULL;
jboolean match = JNI_FALSE;
@@ -342,9 +336,7 @@
match = JNI_TRUE;
break;
}
- }
-#if defined(AF_INET6)
- if (family == AF_INET6) {
+ } else if (family == AF_INET6) {
jbyte *bytes = (jbyte *)&(
((struct sockaddr_in6*)addrP->addr)->sin6_addr);
jbyte caddr[16];
@@ -362,7 +354,6 @@
break;
}
}
-#endif
}
if (match) {
@@ -706,7 +697,6 @@
return NULL;
}
}
-#if defined(AF_INET6)
if (addrP->family == AF_INET6) {
int scope=0;
iaObj = (*env)->NewObject(env, ia6_class, ia6_ctrID);
@@ -735,7 +725,6 @@
return NULL;
}
}
-#endif
(*env)->SetObjectArrayElement(env, addrArr, addr_index++, iaObj);
addrP = addrP->next;
@@ -796,25 +785,23 @@
}
// If IPv6 is available then enumerate IPv6 addresses.
-#if defined(AF_INET6)
- // User can disable ipv6 explicitly by -Djava.net.preferIPv4Stack=true,
- // so we have to call ipv6_available()
- if (ipv6_available()) {
- sock = openSocket(env, AF_INET6);
- if (sock < 0 && (*env)->ExceptionOccurred(env)) {
- freeif(ifs);
- return NULL;
- }
+ // User can disable ipv6 explicitly by -Djava.net.preferIPv4Stack=true,
+ // so we have to call ipv6_available()
+ if (ipv6_available()) {
+ sock = openSocket(env, AF_INET6);
+ if (sock < 0 && (*env)->ExceptionOccurred(env)) {
+ freeif(ifs);
+ return NULL;
+ }
- ifs = enumIPv6Interfaces(env, sock, ifs);
- close(sock);
+ ifs = enumIPv6Interfaces(env, sock, ifs);
+ close(sock);
- if ((*env)->ExceptionOccurred(env)) {
- freeif(ifs);
- return NULL;
- }
+ if ((*env)->ExceptionOccurred(env)) {
+ freeif(ifs);
+ return NULL;
}
-#endif
+ }
return ifs;
}
@@ -870,12 +857,8 @@
// Allocate for addr and brdcast at once
-#if defined(AF_INET6)
addr_size = (family == AF_INET) ? sizeof(struct sockaddr_in)
: sizeof(struct sockaddr_in6);
-#else
- addr_size = sizeof(struct sockaddr_in);
-#endif
CHECKED_MALLOC3(addrP, netaddr *, sizeof(netaddr) + 2 * addr_size);
addrP->addr = (struct sockaddr *)((char *)addrP + sizeof(netaddr));
@@ -1064,7 +1047,6 @@
/** Linux **/
#if defined(__linux__)
-#if defined(AF_INET6)
/*
* Opens a socket for further ioctl calls. Tries AF_INET socket first and
* if it fails return AF_INET6 socket.
@@ -1090,11 +1072,6 @@
// IPv6 socket regardless of type of address of an interface.
return sock;
}
-#else
-static int openSocketWithFallback(JNIEnv *env, const char *ifname) {
- return openSocket(env, AF_INET);
-}
-#endif
/*
* Enumerates and returns all IPv4 interfaces on Linux.
@@ -1178,8 +1155,6 @@
return ifs;
}
-#if defined(AF_INET6)
-
/*
* Enumerates and returns all IPv6 interfaces on Linux.
*/
@@ -1221,8 +1196,6 @@
return ifs;
}
-#endif /* AF_INET6 */
-
/*
* Try to get the interface index.
*/
@@ -1311,7 +1284,6 @@
/** AIX **/
#if defined(_AIX)
-#if defined(AF_INET6)
/*
* Opens a socket for further ioctl calls. Tries AF_INET socket first and
* if it fails return AF_INET6 socket.
@@ -1335,11 +1307,6 @@
return sock;
}
-#else
-static int openSocketWithFallback(JNIEnv *env, const char *ifname) {
- return openSocket(env, AF_INET);
-}
-#endif
/*
* Enumerates and returns all IPv4 interfaces on AIX.
@@ -1423,8 +1390,6 @@
return ifs;
}
-#if defined(AF_INET6)
-
/*
* Enumerates and returns all IPv6 interfaces on AIX.
*/
@@ -1499,8 +1464,6 @@
return ifs;
}
-#endif /* AF_INET6 */
-
/*
* Try to get the interface index.
*/
@@ -1595,7 +1558,6 @@
/** Solaris **/
#if defined(__solaris__)
-#if defined(AF_INET6)
/*
* Opens a socket for further ioctl calls. Tries AF_INET socket first and
* if it fails return AF_INET6 socket.
@@ -1640,11 +1602,6 @@
return sock;
}
-#else
-static int openSocketWithFallback(JNIEnv *env, const char *ifname) {
- return openSocket(env, AF_INET);
-}
-#endif
/*
* Enumerates and returns all IPv4 interfaces on Solaris.
@@ -1720,8 +1677,6 @@
return ifs;
}
-#if defined(AF_INET6)
-
/*
* Enumerates and returns all IPv6 interfaces on Solaris.
*/
@@ -1784,8 +1739,6 @@
return ifs;
}
-#endif /* AF_INET6 */
-
/*
* Try to get the interface index.
* (Not supported on Solaris 2.6 or 7)
@@ -1957,7 +1910,6 @@
/** BSD **/
#if defined(_ALLBSD_SOURCE)
-#if defined(AF_INET6)
/*
* Opens a socket for further ioctl calls. Tries AF_INET socket first and
* if it fails return AF_INET6 socket.
@@ -1981,11 +1933,6 @@
return sock;
}
-#else
-static int openSocketWithFallback(JNIEnv *env, const char *ifname) {
- return openSocket(env, AF_INET);
-}
-#endif
/*
* Enumerates and returns all IPv4 interfaces on BSD.
@@ -2031,8 +1978,6 @@
return ifs;
}
-#if defined(AF_INET6)
-
/*
* Enumerates and returns all IPv6 interfaces on BSD.
*/
@@ -2073,8 +2018,6 @@
return ifs;
}
-#endif /* AF_INET6 */
-
/*
* Try to get the interface index.
*/
--- a/jdk/src/java.base/unix/native/libnet/PlainDatagramSocketImpl.c Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.base/unix/native/libnet/PlainDatagramSocketImpl.c Wed Nov 09 10:04:43 2016 -0800
@@ -299,13 +299,10 @@
#if defined(__linux__) || defined(_ALLBSD_SOURCE)
memset(&addr, 0, sizeof(addr));
-#ifdef AF_INET6
if (ipv6_available()) {
addr.sa6.sin6_family = AF_UNSPEC;
len = sizeof(struct sockaddr_in6);
- } else
-#endif
- {
+ } else {
addr.sa4.sin_family = AF_UNSPEC;
len = sizeof(struct sockaddr_in);
}
@@ -319,12 +316,9 @@
localPort = NET_GetPortFromSockaddr(&addr.sa);
if (localPort == 0) {
localPort = (*env)->GetIntField(env, this, pdsi_localPortID);
-#ifdef AF_INET6
if (addr.sa.sa_family == AF_INET6) {
addr.sa6.sin6_port = htons(localPort);
- } else
-#endif /* AF_INET6 */
- {
+ } else {
addr.sa4.sin_port = htons(localPort);
}
@@ -432,12 +426,9 @@
(*env)->GetByteArrayRegion(env, packetBuffer, packetBufferOffset, packetBufferLen,
(jbyte *)fullPacket);
-#ifdef AF_INET6
if (trafficClass != 0 && ipv6_available()) {
NET_SetTrafficClass(&rmtaddr.sa, trafficClass);
}
-#endif /* AF_INET6 */
-
/*
* Send the datagram.
@@ -538,12 +529,8 @@
}
iaObj = NET_SockaddrToInetAddress(env, &rmtaddr.sa, &port);
-#ifdef AF_INET6
family = getInetAddress_family(env, iaObj) == java_net_InetAddress_IPv4 ?
AF_INET : AF_INET6;
-#else
- family = AF_INET;
-#endif
if (family == AF_INET) { /* this API can't handle IPV6 addresses */
int address = getInetAddress_addr(env, iaObj);
setInetAddress_addr(env, addressObj, address);
@@ -908,11 +895,7 @@
jobject fdObj = (*env)->GetObjectField(env, this, pdsi_fdID);
int arg, fd, t = 1;
char tmpbuf[1024];
-#ifdef AF_INET6
int domain = ipv6_available() ? AF_INET6 : AF_INET;
-#else
- int domain = AF_INET;
-#endif
if (IS_NULL(fdObj)) {
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
@@ -926,7 +909,6 @@
return;
}
-#ifdef AF_INET6
/* Disable IPV6_V6ONLY to ensure dual-socket support */
if (domain == AF_INET6) {
arg = 0;
@@ -937,7 +919,6 @@
return;
}
}
-#endif /* AF_INET6 */
#ifdef __APPLE__
arg = 65507;
@@ -977,7 +958,7 @@
}
#endif
-#if defined (__linux__) && defined (AF_INET6)
+#if defined (__linux__)
/*
* On Linux for IPv6 sockets we must set the hop limit
* to 1 to be compatible with default TTL of 1 for IPv4 sockets.
@@ -1078,7 +1059,6 @@
* Set outgoing multicast interface designated by a NetworkInterface.
* Throw exception if failed.
*/
-#ifdef AF_INET6
static void mcast_set_if_by_if_v6(JNIEnv *env, jobject this, int fd, jobject value) {
static jfieldID ni_indexID;
int index;
@@ -1103,9 +1083,7 @@
}
return;
}
-
}
-#endif /* AF_INET6 */
/*
* Set outgoing multicast interface designated by an InetAddress.
@@ -1127,7 +1105,6 @@
* Set outgoing multicast interface designated by an InetAddress.
* Throw exception if failed.
*/
-#ifdef AF_INET6
static void mcast_set_if_by_addr_v6(JNIEnv *env, jobject this, int fd, jobject value) {
static jclass ni_class;
if (ni_class == NULL) {
@@ -1149,7 +1126,6 @@
mcast_set_if_by_if_v6(env, this, fd, value);
}
-#endif
/*
* Sets the multicast interface.
@@ -1181,7 +1157,6 @@
/*
* value is an InetAddress.
*/
-#ifdef AF_INET6
#ifdef __linux__
mcast_set_if_by_addr_v4(env, this, fd, value);
if (ipv6_available()) {
@@ -1197,16 +1172,12 @@
mcast_set_if_by_addr_v4(env, this, fd, value);
}
#endif /* __linux__ */
-#else
- mcast_set_if_by_addr_v4(env, this, fd, value);
-#endif /* AF_INET6 */
}
if (opt == java_net_SocketOptions_IP_MULTICAST_IF2) {
/*
* value is a NetworkInterface.
*/
-#ifdef AF_INET6
#ifdef __linux__
mcast_set_if_by_if_v4(env, this, fd, value);
if (ipv6_available()) {
@@ -1222,9 +1193,6 @@
mcast_set_if_by_if_v4(env, this, fd, value);
}
#endif /* __linux__ */
-#else
- mcast_set_if_by_if_v4(env, this, fd, value);
-#endif /* AF_INET6 */
}
}
@@ -1256,7 +1224,6 @@
/*
* Enable/disable local loopback of multicast datagrams.
*/
-#ifdef AF_INET6
static void mcast_set_loop_v6(JNIEnv *env, jobject this, int fd, jobject value) {
jclass cls;
jfieldID fid;
@@ -1279,14 +1246,12 @@
}
}
-#endif /* AF_INET6 */
/*
* Sets the multicast loopback mode.
*/
static void setMulticastLoopbackMode(JNIEnv *env, jobject this, int fd,
jint opt, jobject value) {
-#ifdef AF_INET6
#ifdef __linux__
mcast_set_loop_v4(env, this, fd, value);
if (ipv6_available()) {
@@ -1302,9 +1267,6 @@
mcast_set_loop_v4(env, this, fd, value);
}
#endif /* __linux__ */
-#else
- mcast_set_loop_v4(env, this, fd, value);
-#endif /* AF_INET6 */
}
/*
@@ -1446,11 +1408,9 @@
jobject getMulticastInterface(JNIEnv *env, jobject this, int fd, jint opt) {
jboolean isIPV4 = JNI_TRUE;
-#ifdef AF_INET6
if (ipv6_available()) {
isIPV4 = JNI_FALSE;
}
-#endif
/*
* IPv4 implementation
@@ -1549,7 +1509,6 @@
}
-#ifdef AF_INET6
/*
* IPv6 implementation
*/
@@ -1667,7 +1626,6 @@
}
return ni;
}
-#endif
return NULL;
}
@@ -1805,7 +1763,6 @@
/*
* Set hops limit for a socket. Throw exception if failed.
*/
-#ifdef AF_INET6
static void setHopLimit(JNIEnv *env, int fd, jint ttl) {
int ittl = (int)ttl;
if (setsockopt(fd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS,
@@ -1814,7 +1771,6 @@
(env, JNU_JAVANETPKG "SocketException", "Error setting socket option");
}
}
-#endif
/*
* Class: java_net_PlainDatagramSocketImpl
@@ -1837,7 +1793,6 @@
fd = (*env)->GetIntField(env, fdObj, IO_fd_fdID);
}
/* setsockopt to be correct TTL */
-#ifdef AF_INET6
#ifdef __linux__
setTTL(env, fd, ttl);
JNU_CHECK_EXCEPTION(env);
@@ -1851,9 +1806,6 @@
setTTL(env, fd, ttl);
}
#endif /* __linux__ */
-#else
- setTTL(env, fd, ttl);
-#endif /* AF_INET6 */
}
/*
@@ -1886,7 +1838,6 @@
fd = (*env)->GetIntField(env, fdObj, IO_fd_fdID);
}
/* getsockopt of TTL */
-#ifdef AF_INET6
if (ipv6_available()) {
int ttl = 0;
socklen_t len = sizeof(ttl);
@@ -1898,19 +1849,17 @@
return -1;
}
return (jint)ttl;
- } else
-#endif /* AF_INET6 */
- {
- u_char ttl = 0;
- socklen_t len = sizeof(ttl);
- if (getsockopt(fd, IPPROTO_IP, IP_MULTICAST_TTL,
- (char*)&ttl, &len) < 0) {
- JNU_ThrowByNameWithMessageAndLastError
- (env, JNU_JAVANETPKG "SocketException", "Error getting socket option");
- return -1;
- }
- return (jint)ttl;
+ } else {
+ u_char ttl = 0;
+ socklen_t len = sizeof(ttl);
+ if (getsockopt(fd, IPPROTO_IP, IP_MULTICAST_TTL,
+ (char*)&ttl, &len) < 0) {
+ JNU_ThrowByNameWithMessageAndLastError
+ (env, JNU_JAVANETPKG "SocketException", "Error getting socket option");
+ return -1;
}
+ return (jint)ttl;
+ }
}
@@ -1956,7 +1905,6 @@
/*
* Determine if this is an IPv4 or IPv6 join/leave.
*/
-#ifdef AF_INET6
ipv6_join_leave = ipv6_available();
#ifdef __linux__
@@ -1965,13 +1913,6 @@
}
#endif
-#else
- /*
- * IPv6 not compiled in
- */
- ipv6_join_leave = JNI_FALSE;
-#endif
-
/*
* For IPv4 join use IP_ADD_MEMBERSHIP/IP_DROP_MEMBERSHIP socket option
*
@@ -1996,7 +1937,7 @@
* NetworkInterface
*/
if (niObj != NULL) {
-#if defined(__linux__) && defined(AF_INET6)
+#if defined(__linux__)
if (ipv6_available()) {
static jfieldID ni_indexID;
@@ -2052,7 +1993,7 @@
if (niObj == NULL) {
-#if defined(__linux__) && defined(AF_INET6)
+#if defined(__linux__)
if (ipv6_available()) {
int index;
@@ -2108,7 +2049,7 @@
* should return ENOPROTOOPT. We assume this will be fixed in Linux
* at some stage.
*/
-#if defined(__linux__) && defined(AF_INET6)
+#if defined(__linux__)
if (errno == ENOPROTOOPT) {
if (ipv6_available()) {
ipv6_join_leave = JNI_TRUE;
@@ -2145,7 +2086,6 @@
* IPv6 join. If it's an IPv4 multicast group then we use an IPv4-mapped
* address.
*/
-#ifdef AF_INET6
{
struct ipv6_mreq mname6;
jbyteArray ipaddress;
@@ -2233,7 +2173,6 @@
}
}
}
-#endif
}
/*
--- a/jdk/src/java.base/unix/native/libnet/PlainSocketImpl.c Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.base/unix/native/libnet/PlainSocketImpl.c Wed Nov 09 10:04:43 2016 -0800
@@ -162,11 +162,7 @@
jobject fdObj, ssObj;
int fd;
int type = (stream ? SOCK_STREAM : SOCK_DGRAM);
-#ifdef AF_INET6
int domain = ipv6_available() ? AF_INET6 : AF_INET;
-#else
- int domain = AF_INET;
-#endif
if (socketExceptionCls == NULL) {
jclass c = (*env)->FindClass(env, "java/net/SocketException");
@@ -190,7 +186,6 @@
return;
}
-#ifdef AF_INET6
/* Disable IPV6_V6ONLY to ensure dual-socket support */
if (domain == AF_INET6) {
int arg = 0;
@@ -201,7 +196,6 @@
return;
}
}
-#endif /* AF_INET6 */
/*
* If this is a server socket then enable SO_REUSEADDR
@@ -271,11 +265,10 @@
}
setDefaultScopeID(env, &him.sa);
-#ifdef AF_INET6
if (trafficClass != 0 && ipv6_available()) {
NET_SetTrafficClass(&him.sa, trafficClass);
}
-#endif /* AF_INET6 */
+
if (timeout <= 0) {
connect_rv = NET_Connect(fd, &him.sa, len);
#ifdef __solaris__
--- a/jdk/src/java.base/unix/native/libnet/SdpSupport.c Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.base/unix/native/libnet/SdpSupport.c Wed Nov 09 10:04:43 2016 -0800
@@ -56,11 +56,7 @@
int s;
#if defined(__solaris__)
- #ifdef AF_INET6
int domain = ipv6_available() ? AF_INET6 : AF_INET;
- #else
- int domain = AF_INET;
- #endif
s = socket(domain, SOCK_STREAM, PROTO_SDP);
#elif defined(__linux__)
/**
--- a/jdk/src/java.base/unix/native/libnet/net_util_md.c Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.base/unix/native/libnet/net_util_md.c Wed Nov 09 10:04:43 2016 -0800
@@ -306,11 +306,6 @@
jint IPv6_supported()
{
-#ifndef AF_INET6
- return JNI_FALSE;
-#endif
-
-#ifdef AF_INET6
int fd;
void *ipv6_fn;
SOCKETADDRESS sa;
@@ -415,7 +410,6 @@
} else {
return JNI_TRUE;
}
-#endif /* AF_INET6 */
}
#endif /* DONT_ENABLE_IPV6 */
@@ -466,7 +460,7 @@
}
}
-#if defined(__linux__) && defined(AF_INET6)
+#if defined(__linux__)
/* following code creates a list of addresses from the kernel
* routing table that are routed via the loopback address.
@@ -786,7 +780,6 @@
int *len, jboolean v4MappedAddress) {
jint family;
family = getInetAddress_family(env, iaObj);
-#ifdef AF_INET6
/* needs work. 1. family 2. clean up him6 etc deallocate memory */
if (ipv6_available() && !(family == java_net_InetAddress_IPv4 &&
v4MappedAddress == JNI_FALSE)) {
@@ -794,7 +787,6 @@
jbyte caddr[16];
jint address;
-
if (family == java_net_InetAddress_IPv4) {
// convert to IPv4-mapped address
memset((char *) caddr, 0, 16);
@@ -818,9 +810,9 @@
him6->sin6_port = htons(port);
memcpy((void *)&(him6->sin6_addr), caddr, sizeof(struct in6_addr) );
him6->sin6_family = AF_INET6;
- *len = sizeof(struct sockaddr_in6) ;
+ *len = sizeof(struct sockaddr_in6);
-#if defined(_ALLBSD_SOURCE) && defined(_AF_INET6)
+#if defined(_ALLBSD_SOURCE)
// XXXBSD: should we do something with scope id here ? see below linux comment
/* MMM: Come back to this! */
#endif
@@ -864,11 +856,11 @@
* try determine the appropriate interface.
*/
if (kernelIsV24()) {
- cached_scope_id = getDefaultIPv6Interface( &(him6->sin6_addr) );
+ cached_scope_id = getDefaultIPv6Interface(&(him6->sin6_addr));
} else {
- cached_scope_id = getLocalScopeID( (char *)&(him6->sin6_addr) );
+ cached_scope_id = getLocalScopeID((char *)&(him6->sin6_addr));
if (cached_scope_id == 0) {
- cached_scope_id = getDefaultIPv6Interface( &(him6->sin6_addr) );
+ cached_scope_id = getDefaultIPv6Interface(&(him6->sin6_addr));
}
}
(*env)->SetIntField(env, iaObj, ia6_cachedscopeidID, cached_scope_id);
@@ -896,46 +888,38 @@
}
}
#endif
- } else
-#endif /* AF_INET6 */
- {
- struct sockaddr_in *him4 = (struct sockaddr_in*)him;
- jint address;
- if (family == java_net_InetAddress_IPv6) {
- JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Protocol family unavailable");
- return -1;
- }
- memset((char *) him4, 0, sizeof(struct sockaddr_in));
- address = getInetAddress_addr(env, iaObj);
- him4->sin_port = htons((short) port);
- him4->sin_addr.s_addr = htonl(address);
- him4->sin_family = AF_INET;
- *len = sizeof(struct sockaddr_in);
+ } else {
+ struct sockaddr_in *him4 = (struct sockaddr_in *)him;
+ jint address;
+ if (family == java_net_InetAddress_IPv6) {
+ JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Protocol family unavailable");
+ return -1;
}
+ memset((char *)him4, 0, sizeof(struct sockaddr_in));
+ address = getInetAddress_addr(env, iaObj);
+ him4->sin_port = htons((short) port);
+ him4->sin_addr.s_addr = htonl(address);
+ him4->sin_family = AF_INET;
+ *len = sizeof(struct sockaddr_in);
+ }
return 0;
}
void
NET_SetTrafficClass(struct sockaddr *him, int trafficClass) {
-#ifdef AF_INET6
if (him->sa_family == AF_INET6) {
struct sockaddr_in6 *him6 = (struct sockaddr_in6 *)him;
him6->sin6_flowinfo = htonl((trafficClass & 0xff) << 20);
}
-#endif /* AF_INET6 */
}
JNIEXPORT jint JNICALL
NET_GetPortFromSockaddr(struct sockaddr *him) {
-#ifdef AF_INET6
if (him->sa_family == AF_INET6) {
return ntohs(((struct sockaddr_in6*)him)->sin6_port);
-
- } else
-#endif /* AF_INET6 */
- {
- return ntohs(((struct sockaddr_in*)him)->sin_port);
- }
+ } else {
+ return ntohs(((struct sockaddr_in*)him)->sin_port);
+ }
}
int
@@ -1008,7 +992,6 @@
int i;
-#ifdef AF_INET6
if (ipv6_available()) {
switch (cmd) {
// Different multicast options if IPv6 is enabled
@@ -1031,7 +1014,6 @@
#endif
}
}
-#endif
/*
* Map the Java level option to the native level
@@ -1063,7 +1045,7 @@
* 0 if no matching interface
* >1 interface index to use for the link-local address.
*/
-#if defined(__linux__) && defined(AF_INET6)
+#if defined(__linux__)
int getDefaultIPv6Interface(struct in6_addr *target_addr) {
FILE *f;
char srcp[8][5];
@@ -1300,7 +1282,7 @@
if (level == IPPROTO_IP && opt == IP_TOS) {
int *iptos;
-#if defined(AF_INET6) && defined(__linux__)
+#if defined(__linux__)
if (ipv6_available()) {
int optval = 1;
if (setsockopt(fd, IPPROTO_IPV6, IPV6_FLOWINFO_SEND,
@@ -1504,7 +1486,7 @@
int
NET_Bind(int fd, struct sockaddr *him, int len)
{
-#if defined(__solaris__) && defined(AF_INET6)
+#if defined(__solaris__)
int level = -1;
int exclbind = -1;
#endif
@@ -1568,7 +1550,7 @@
rv = bind(fd, him, len);
-#if defined(__solaris__) && defined(AF_INET6)
+#if defined(__solaris__)
if (rv < 0) {
int en = errno;
/* Restore *_EXCLBIND if the bind fails */
--- a/jdk/src/java.base/unix/native/libnet/net_util_md.h Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.base/unix/native/libnet/net_util_md.h Wed Nov 09 10:04:43 2016 -0800
@@ -84,18 +84,11 @@
#define MAX_HEAP_BUFFER_LEN 65536
#endif
-#ifdef AF_INET6
typedef union {
struct sockaddr sa;
struct sockaddr_in sa4;
struct sockaddr_in6 sa6;
} SOCKETADDRESS;
-#else
-typedef union {
- struct sockaddr sa;
- struct sockaddr_in sa4;
-} SOCKETADDRESS;
-#endif
/************************************************************************
* Utilities
@@ -103,10 +96,8 @@
#ifdef __linux__
int kernelIsV24();
-#ifdef AF_INET6
int getDefaultIPv6Interface(struct in6_addr *target_addr);
#endif
-#endif
#ifdef __solaris__
int net_getParam(char *driver, char *param);
--- a/jdk/src/java.base/windows/native/libnet/Inet6AddressImpl.c Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.base/windows/native/libnet/Inet6AddressImpl.c Wed Nov 09 10:04:43 2016 -0800
@@ -305,8 +305,6 @@
return ret;
}
-#ifdef AF_INET6
-
/**
* ping implementation using tcp port 7 (echo)
*/
@@ -468,7 +466,6 @@
return JNI_FALSE;
}
}
-#endif /* AF_INET6 */
/*
* Class: java_net_Inet6AddressImpl
@@ -482,7 +479,6 @@
jint timeout,
jbyteArray ifArray,
jint ttl, jint if_scope) {
-#ifdef AF_INET6
jbyte caddr[16];
jint sz;
struct sockaddr_in6 him6;
@@ -548,6 +544,5 @@
return ping6(env, netif, &him6, timeout, hIcmpFile);
}
-#endif /* AF_INET6 */
return JNI_FALSE;
}
--- a/jdk/src/java.logging/share/classes/java/util/logging/LogManager.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.logging/share/classes/java/util/logging/LogManager.java Wed Nov 09 10:04:43 2016 -0800
@@ -1449,6 +1449,11 @@
h.close();
} catch (Exception ex) {
// Problems closing a handler? Keep going...
+ } catch (Error e) {
+ // ignore Errors while shutting down
+ if (globalHandlersState != STATE_SHUTDOWN) {
+ throw e;
+ }
}
}
}
--- a/jdk/src/java.management/share/classes/sun/management/StackTraceElementCompositeData.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.management/share/classes/sun/management/StackTraceElementCompositeData.java Wed Nov 09 10:04:43 2016 -0800
@@ -58,7 +58,8 @@
getString(cd, FILE_NAME),
getInt(cd, LINE_NUMBER));
} else {
- return new StackTraceElement(getString(cd, MODULE_NAME),
+ return new StackTraceElement(getString(cd, CLASS_LOADER_NAME),
+ getString(cd, MODULE_NAME),
getString(cd, MODULE_VERSION),
getString(cd, CLASS_NAME),
getString(cd, METHOD_NAME),
@@ -76,13 +77,14 @@
// CONTENTS OF THIS ARRAY MUST BE SYNCHRONIZED WITH
// stackTraceElementItemNames!
final Object[] stackTraceElementItemValues = {
+ ste.getClassLoaderName(),
+ ste.getModuleName(),
+ ste.getModuleVersion(),
ste.getClassName(),
ste.getMethodName(),
ste.getFileName(),
ste.getLineNumber(),
ste.isNativeMethod(),
- ste.getModuleName(),
- ste.getModuleVersion(),
};
try {
return new CompositeDataSupport(stackTraceElementCompositeType,
@@ -95,25 +97,29 @@
}
// Attribute names
- private static final String CLASS_NAME = "className";
- private static final String METHOD_NAME = "methodName";
- private static final String FILE_NAME = "fileName";
- private static final String LINE_NUMBER = "lineNumber";
- private static final String NATIVE_METHOD = "nativeMethod";
- private static final String MODULE_NAME = "moduleName";
- private static final String MODULE_VERSION = "moduleVersion";
+ private static final String CLASS_LOADER_NAME = "classLoaderName";
+ private static final String MODULE_NAME = "moduleName";
+ private static final String MODULE_VERSION = "moduleVersion";
+ private static final String CLASS_NAME = "className";
+ private static final String METHOD_NAME = "methodName";
+ private static final String FILE_NAME = "fileName";
+ private static final String LINE_NUMBER = "lineNumber";
+ private static final String NATIVE_METHOD = "nativeMethod";
+
private static final String[] stackTraceElementItemNames = {
+ CLASS_LOADER_NAME,
+ MODULE_NAME,
+ MODULE_VERSION,
CLASS_NAME,
METHOD_NAME,
FILE_NAME,
LINE_NUMBER,
NATIVE_METHOD,
- MODULE_NAME,
- MODULE_VERSION,
};
private static final String[] stackTraceElementV9ItemNames = {
+ CLASS_LOADER_NAME,
MODULE_NAME,
MODULE_VERSION,
};
--- a/jdk/src/java.rmi/share/classes/sun/rmi/transport/tcp/TCPTransport.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.rmi/share/classes/sun/rmi/transport/tcp/TCPTransport.java Wed Nov 09 10:04:43 2016 -0800
@@ -102,6 +102,11 @@
AccessController.doPrivileged((PrivilegedAction<Long>) () ->
Long.getLong("sun.rmi.transport.tcp.threadKeepAliveTime", 60000));
+ /** enable multiplexing protocol */
+ private static final boolean enableMultiplexProtocol = // default false
+ AccessController.doPrivileged((PrivilegedAction<Boolean>) () ->
+ Boolean.getBoolean("sun.rmi.transport.tcp.enableMultiplexProtocol"));
+
/** thread pool for connection handlers */
private static final ExecutorService connectionThreadPool =
new ThreadPoolExecutor(0, maxConnectionThreads,
@@ -796,6 +801,19 @@
break;
case TransportConstants.MultiplexProtocol:
+
+ if (!enableMultiplexProtocol) {
+ if (tcpLog.isLoggable(Log.VERBOSE)) {
+ tcpLog.log(Log.VERBOSE, "(port " + port +
+ ") rejecting multiplex protocol");
+ }
+
+ // If MultiplexProtocol is disabled, send NACK immediately.
+ out.writeByte(TransportConstants.ProtocolNack);
+ out.flush();
+ break;
+ }
+
if (tcpLog.isLoggable(Log.VERBOSE)) {
tcpLog.log(Log.VERBOSE, "(port " + port +
") accepting multiplex protocol");
--- a/jdk/src/java.security.jgss/share/classes/sun/security/krb5/KrbApReq.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.security.jgss/share/classes/sun/security/krb5/KrbApReq.java Wed Nov 09 10:04:43 2016 -0800
@@ -301,12 +301,13 @@
if (!authenticator.ctime.inClockSkew())
throw new KrbApErrException(Krb5.KRB_AP_ERR_SKEW);
+ String alg = AuthTimeWithHash.DEFAULT_HASH_ALG;
byte[] hash;
try {
- hash = MessageDigest.getInstance("MD5")
+ hash = MessageDigest.getInstance(AuthTimeWithHash.realAlg(alg))
.digest(apReqMessg.authenticator.cipher);
} catch (NoSuchAlgorithmException ex) {
- throw new AssertionError("Impossible");
+ throw new AssertionError("Impossible " + alg);
}
char[] h = new char[hash.length * 2];
@@ -319,6 +320,7 @@
apReqMessg.ticket.sname.toString(),
authenticator.ctime.getSeconds(),
authenticator.cusec,
+ alg,
new String(h));
rcache.checkAndStore(KerberosTime.now(), time);
--- a/jdk/src/java.security.jgss/share/classes/sun/security/krb5/internal/rcache/AuthTime.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.security.jgss/share/classes/sun/security/krb5/internal/rcache/AuthTime.java Wed Nov 09 10:04:43 2016 -0800
@@ -116,14 +116,14 @@
if (st.countTokens() != 6) {
throw new IOException("Incorrect rcache style");
}
- st.nextToken();
+ String hashAlg = st.nextToken();
String hash = st.nextToken();
st.nextToken();
client = st.nextToken();
st.nextToken();
server = st.nextToken();
return new AuthTimeWithHash(
- client, server, ctime, cusec, hash);
+ client, server, ctime, cusec, hashAlg, hash);
} else {
return new AuthTime(
client, server, ctime, cusec);
--- a/jdk/src/java.security.jgss/share/classes/sun/security/krb5/internal/rcache/AuthTimeWithHash.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.security.jgss/share/classes/sun/security/krb5/internal/rcache/AuthTimeWithHash.java Wed Nov 09 10:04:43 2016 -0800
@@ -25,6 +25,8 @@
package sun.security.krb5.internal.rcache;
+import sun.security.action.GetPropertyAction;
+
import java.util.Objects;
/**
@@ -34,14 +36,39 @@
public class AuthTimeWithHash extends AuthTime
implements Comparable<AuthTimeWithHash> {
+ // The hash algorithm can be "HASH" or "SHA256".
+ public static final String DEFAULT_HASH_ALG;
+
+ static {
+ if (GetPropertyAction.privilegedGetProperty(
+ "jdk.krb5.rcache.useMD5", "false").equals("true")) {
+ DEFAULT_HASH_ALG = "HASH";
+ } else {
+ DEFAULT_HASH_ALG = "SHA256";
+ }
+ }
+
+ public static String realAlg(String alg) {
+ switch (alg) {
+ case "HASH":
+ return "MD5";
+ case "SHA256":
+ return "SHA-256";
+ default:
+ throw new AssertionError(alg + " is not HASH or SHA256");
+ }
+ }
+
+ final String hashAlg;
final String hash;
/**
* Constructs a new <code>AuthTimeWithHash</code>.
*/
public AuthTimeWithHash(String client, String server,
- int ctime, int cusec, String hash) {
+ int ctime, int cusec, String hashAlg, String hash) {
super(client, server, ctime, cusec);
+ this.hashAlg = hashAlg;
this.hash = hash;
}
@@ -56,6 +83,7 @@
if (!(o instanceof AuthTimeWithHash)) return false;
AuthTimeWithHash that = (AuthTimeWithHash)o;
return Objects.equals(hash, that.hash)
+ && Objects.equals(hashAlg, that.hashAlg)
&& Objects.equals(client, that.client)
&& Objects.equals(server, that.server)
&& ctime == that.ctime
@@ -91,6 +119,19 @@
/**
* Compares with a possibly old style object. Used
* in DflCache$Storage#loadAndCheck.
+ * @return true if all AuthTime fields are the same but different hash
+ */
+ public boolean sameTimeDiffHash(AuthTimeWithHash old) {
+ if (!this.isSameIgnoresHash(old)) {
+ return false;
+ }
+ return this.hashAlg.equals(old.hashAlg) &&
+ !this.hash.equals(old.hash);
+ }
+
+ /**
+ * Compares with a possibly old style object. Used
+ * in DflCache$Storage#loadAndCheck.
* @return true if all AuthTime fields are the same
*/
public boolean isSameIgnoresHash(AuthTime old) {
@@ -112,7 +153,7 @@
String sstring;
if (withHash) {
cstring = "";
- sstring = String.format("HASH:%s %d:%s %d:%s", hash,
+ sstring = String.format("%s:%s %d:%s %d:%s", hashAlg, hash,
client.length(), client,
server.length(), server);
} else {
--- a/jdk/src/java.security.jgss/share/classes/sun/security/krb5/internal/rcache/DflCache.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.security.jgss/share/classes/sun/security/krb5/internal/rcache/DflCache.java Wed Nov 09 10:04:43 2016 -0800
@@ -96,6 +96,8 @@
* Java also does this way.
*
* See src/lib/krb5/rcache/rc_io.c and src/lib/krb5/rcache/rc_dfl.c.
+ *
+ * Update: New version can use other hash algorithms.
*/
public class DflCache extends ReplayCache {
@@ -300,7 +302,7 @@
if (time.equals(a)) {
// Exact match, must be a replay
throw new KrbApErrException(Krb5.KRB_AP_ERR_REPEAT);
- } else if (time.isSameIgnoresHash(a)) {
+ } else if (time.sameTimeDiffHash((AuthTimeWithHash)a)) {
// Two different authenticators in the same second.
// Remember it
seeNewButNotSame = true;
--- a/jdk/src/java.sql/share/classes/java/sql/CallableStatement.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.sql/share/classes/java/sql/CallableStatement.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -295,7 +295,7 @@
* or <code>getBigDecimal(String parameterName)</code>
* @see #setBigDecimal
*/
- @Deprecated
+ @Deprecated(since="1.2")
BigDecimal getBigDecimal(int parameterIndex, int scale)
throws SQLException;
--- a/jdk/src/java.sql/share/classes/java/sql/Date.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.sql/share/classes/java/sql/Date.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -58,7 +58,7 @@
* @param day 1 to 31
* @deprecated instead use the constructor <code>Date(long date)</code>
*/
- @Deprecated
+ @Deprecated(since="1.2")
public Date(int year, int month, int day) {
super(year, month, day);
}
@@ -199,7 +199,7 @@
* @exception java.lang.IllegalArgumentException if this method is invoked
* @see #setHours
*/
- @Deprecated
+ @Deprecated(since="1.2")
public int getHours() {
throw new java.lang.IllegalArgumentException();
}
@@ -212,7 +212,7 @@
* @exception java.lang.IllegalArgumentException if this method is invoked
* @see #setMinutes
*/
- @Deprecated
+ @Deprecated(since="1.2")
public int getMinutes() {
throw new java.lang.IllegalArgumentException();
}
@@ -225,7 +225,7 @@
* @exception java.lang.IllegalArgumentException if this method is invoked
* @see #setSeconds
*/
- @Deprecated
+ @Deprecated(since="1.2")
public int getSeconds() {
throw new java.lang.IllegalArgumentException();
}
@@ -238,7 +238,7 @@
* @exception java.lang.IllegalArgumentException if this method is invoked
* @see #getHours
*/
- @Deprecated
+ @Deprecated(since="1.2")
public void setHours(int i) {
throw new java.lang.IllegalArgumentException();
}
@@ -251,7 +251,7 @@
* @exception java.lang.IllegalArgumentException if this method is invoked
* @see #getMinutes
*/
- @Deprecated
+ @Deprecated(since="1.2")
public void setMinutes(int i) {
throw new java.lang.IllegalArgumentException();
}
@@ -264,7 +264,7 @@
* @exception java.lang.IllegalArgumentException if this method is invoked
* @see #getSeconds
*/
- @Deprecated
+ @Deprecated(since="1.2")
public void setSeconds(int i) {
throw new java.lang.IllegalArgumentException();
}
--- a/jdk/src/java.sql/share/classes/java/sql/DriverManager.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.sql/share/classes/java/sql/DriverManager.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -515,7 +515,7 @@
* @see SecurityManager#checkPermission
* @see #getLogStream
*/
- @Deprecated
+ @Deprecated(since="1.2")
public static void setLogStream(java.io.PrintStream out) {
SecurityManager sec = System.getSecurityManager();
@@ -538,7 +538,7 @@
* @deprecated Use {@code getLogWriter}
* @see #setLogStream
*/
- @Deprecated
+ @Deprecated(since="1.2")
public static java.io.PrintStream getLogStream() {
return logStream;
}
--- a/jdk/src/java.sql/share/classes/java/sql/PreparedStatement.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.sql/share/classes/java/sql/PreparedStatement.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -344,7 +344,7 @@
* this method
* @deprecated Use {@code setCharacterStream}
*/
- @Deprecated
+ @Deprecated(since="1.2")
void setUnicodeStream(int parameterIndex, java.io.InputStream x,
int length) throws SQLException;
--- a/jdk/src/java.sql/share/classes/java/sql/ResultSet.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.sql/share/classes/java/sql/ResultSet.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -358,7 +358,7 @@
* @deprecated Use {@code getBigDecimal(int columnIndex)}
* or {@code getBigDecimal(String columnLabel)}
*/
- @Deprecated
+ @Deprecated(since="1.2")
BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException;
/**
@@ -478,7 +478,7 @@
* @deprecated use <code>getCharacterStream</code> in place of
* <code>getUnicodeStream</code>
*/
- @Deprecated
+ @Deprecated(since="1.2")
java.io.InputStream getUnicodeStream(int columnIndex) throws SQLException;
/**
@@ -646,7 +646,7 @@
* @deprecated Use {@code getBigDecimal(int columnIndex)}
* or {@code getBigDecimal(String columnLabel)}
*/
- @Deprecated
+ @Deprecated(since="1.2")
BigDecimal getBigDecimal(String columnLabel, int scale) throws SQLException;
/**
@@ -764,7 +764,7 @@
* this method
* @deprecated use <code>getCharacterStream</code> instead
*/
- @Deprecated
+ @Deprecated(since="1.2")
java.io.InputStream getUnicodeStream(String columnLabel) throws SQLException;
/**
--- a/jdk/src/java.sql/share/classes/java/sql/Time.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.sql/share/classes/java/sql/Time.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -60,7 +60,7 @@
* @deprecated Use the constructor that takes a milliseconds value
* in place of this constructor
*/
- @Deprecated
+ @Deprecated(since="1.2")
public Time(int hour, int minute, int second) {
super(70, 0, 1, hour, minute, second);
}
@@ -146,7 +146,7 @@
* method is invoked
* @see #setYear
*/
- @Deprecated
+ @Deprecated(since="1.2")
public int getYear() {
throw new java.lang.IllegalArgumentException();
}
@@ -160,7 +160,7 @@
* method is invoked
* @see #setMonth
*/
- @Deprecated
+ @Deprecated(since="1.2")
public int getMonth() {
throw new java.lang.IllegalArgumentException();
}
@@ -173,7 +173,7 @@
* @exception java.lang.IllegalArgumentException if this
* method is invoked
*/
- @Deprecated
+ @Deprecated(since="1.2")
public int getDay() {
throw new java.lang.IllegalArgumentException();
}
@@ -187,7 +187,7 @@
* method is invoked
* @see #setDate
*/
- @Deprecated
+ @Deprecated(since="1.2")
public int getDate() {
throw new java.lang.IllegalArgumentException();
}
@@ -201,7 +201,7 @@
* method is invoked
* @see #getYear
*/
- @Deprecated
+ @Deprecated(since="1.2")
public void setYear(int i) {
throw new java.lang.IllegalArgumentException();
}
@@ -215,7 +215,7 @@
* method is invoked
* @see #getMonth
*/
- @Deprecated
+ @Deprecated(since="1.2")
public void setMonth(int i) {
throw new java.lang.IllegalArgumentException();
}
@@ -229,7 +229,7 @@
* method is invoked
* @see #getDate
*/
- @Deprecated
+ @Deprecated(since="1.2")
public void setDate(int i) {
throw new java.lang.IllegalArgumentException();
}
--- a/jdk/src/java.sql/share/classes/java/sql/Timestamp.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/java.sql/share/classes/java/sql/Timestamp.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -88,7 +88,7 @@
* @deprecated instead use the constructor {@code Timestamp(long millis)}
* @exception IllegalArgumentException if the nano argument is out of bounds
*/
- @Deprecated
+ @Deprecated(since="1.2")
public Timestamp(int year, int month, int date,
int hour, int minute, int second, int nano) {
super(year, month, date, hour, minute, second);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.editpad/share/classes/jdk/editpad/EditPad.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,149 @@
+/*
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.editpad;
+
+import java.awt.BorderLayout;
+import java.awt.FlowLayout;
+import java.awt.Font;
+import java.awt.event.ActionListener;
+import java.awt.event.KeyEvent;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+import java.util.function.Consumer;
+import javax.swing.JButton;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextArea;
+
+/**
+ * A minimal Swing editor as a fallback when the user does not specify an
+ * external editor.
+ */
+class EditPad implements Runnable {
+
+ private static final String L10N_RB_NAME = "jdk.editpad.resources.l10n";
+ private ResourceBundle rb = null;
+ private final String windowLabel;
+ private final Consumer<String> errorHandler;
+ private final String initialText;
+ private final Runnable closeMark;
+ private final Consumer<String> saveHandler;
+
+ /**
+ * Create an Edit Pad minimal editor.
+ *
+ * @param windowLabel the label string for the Edit Pad window
+ * @param errorHandler a handler for unexpected errors
+ * @param initialText the source to load in the Edit Pad
+ * @param closeMark a Runnable that is run when Edit Pad closes
+ * @param saveHandler a handler for changed source (sent the full source)
+ */
+ EditPad(String windowLabel, Consumer<String> errorHandler, String initialText,
+ Runnable closeMark, Consumer<String> saveHandler) {
+ this.windowLabel = windowLabel;
+ this.errorHandler = errorHandler;
+ this.initialText = initialText;
+ this.closeMark = closeMark;
+ this.saveHandler = saveHandler;
+ }
+
+ @Override
+ public void run() {
+ JFrame jframe = new JFrame(windowLabel == null
+ ? getResourceString("editpad.name")
+ : windowLabel);
+ Runnable closer = () -> {
+ jframe.setVisible(false);
+ jframe.dispose();
+ closeMark.run();
+ };
+ jframe.addWindowListener(new WindowAdapter() {
+ @Override
+ public void windowClosing(WindowEvent e) {
+ closer.run();
+ }
+ });
+ jframe.setLocationRelativeTo(null);
+ jframe.setLayout(new BorderLayout());
+ JTextArea textArea = new JTextArea(initialText);
+ textArea.setFont(new Font("monospaced", Font.PLAIN, 13));
+ jframe.add(new JScrollPane(textArea), BorderLayout.CENTER);
+ jframe.add(buttons(closer, textArea), BorderLayout.SOUTH);
+
+ jframe.setSize(800, 600);
+ jframe.setVisible(true);
+ }
+
+ private JPanel buttons(Runnable closer, JTextArea textArea) {
+ FlowLayout flow = new FlowLayout();
+ flow.setHgap(35);
+ JPanel buttons = new JPanel(flow);
+ addButton(buttons, "editpad.cancel", KeyEvent.VK_C, e -> {
+ closer.run();
+ });
+ addButton(buttons, "editpad.accept", KeyEvent.VK_A, e -> {
+ saveHandler.accept(textArea.getText());
+ });
+ addButton(buttons, "editpad.exit", KeyEvent.VK_X, e -> {
+ saveHandler.accept(textArea.getText());
+ closer.run();
+ });
+ return buttons;
+ }
+
+ private void addButton(JPanel buttons, String rkey, int mnemonic, ActionListener action) {
+ JButton but = new JButton(getResourceString(rkey));
+ but.setMnemonic(mnemonic);
+ buttons.add(but);
+ but.addActionListener(action);
+ }
+
+ private String getResourceString(String key) {
+ if (rb == null) {
+ try {
+ rb = ResourceBundle.getBundle(L10N_RB_NAME);
+ } catch (MissingResourceException mre) {
+ error("Cannot find ResourceBundle: %s", L10N_RB_NAME);
+ return "";
+ }
+ }
+ String s;
+ try {
+ s = rb.getString(key);
+ } catch (MissingResourceException mre) {
+ error("Missing resource: %s in %s", key, L10N_RB_NAME);
+ return "";
+ }
+ return s;
+ }
+
+ private void error(String fmt, Object... args) {
+ errorHandler.accept(String.format(fmt, args));
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.editpad/share/classes/jdk/editpad/EditPadProvider.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.editpad;
+
+import java.util.concurrent.CountDownLatch;
+import java.util.function.Consumer;
+import javax.swing.SwingUtilities;
+import jdk.internal.editor.spi.BuildInEditorProvider;
+
+/**
+ * Defines the provider of an Edit Pad implementation.
+ *
+ * @author Robert Field
+ */
+public class EditPadProvider implements BuildInEditorProvider {
+
+ /**
+ * @return the rank of a provider, greater is better.
+ */
+ @Override
+ public int rank() {
+ return 5;
+ }
+
+ /**
+ * Create an Edit Pad minimal editor.
+ *
+ * @param windowLabel the label string for the Edit Pad window, or null,
+ * for default window label
+ * @param initialText the source to load in the Edit Pad
+ * @param saveHandler a handler for changed source (can be sent the full source)
+ * @param errorHandler a handler for unexpected errors
+ */
+ @Override
+ public void edit(String windowLabel, String initialText,
+ Consumer<String> saveHandler, Consumer<String> errorHandler) {
+ CountDownLatch closeLock = new CountDownLatch(1);
+ SwingUtilities.invokeLater(
+ new EditPad(windowLabel, errorHandler, initialText, closeLock::countDown, saveHandler));
+ do {
+ try {
+ closeLock.await();
+ break;
+ } catch (InterruptedException ex) {
+ // ignore and loop
+ }
+ } while (true);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.editpad/share/classes/jdk/editpad/resources/l10n.properties Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,29 @@
+#
+# Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation. Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+editpad.name = Edit Pad
+editpad.cancel = Cancel
+editpad.accept = Accept
+editpad.exit = Exit
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.editpad/share/classes/module-info.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * Implementation of the edit pad service.
+ */
+module jdk.editpad {
+ requires jdk.internal.ed;
+ requires java.desktop;
+ provides jdk.internal.editor.spi.BuildInEditorProvider
+ with jdk.editpad.EditPadProvider;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.internal.ed/share/classes/jdk/internal/editor/external/ExternalEditor.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,192 @@
+/*
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.internal.editor.external;
+
+import java.io.IOException;
+import java.nio.charset.Charset;
+import java.nio.file.ClosedWatchServiceException;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.WatchKey;
+import java.nio.file.WatchService;
+import java.util.Arrays;
+import java.util.Scanner;
+import java.util.function.Consumer;
+import java.util.stream.Collectors;
+import static java.nio.file.StandardWatchEventKinds.ENTRY_CREATE;
+import static java.nio.file.StandardWatchEventKinds.ENTRY_DELETE;
+import static java.nio.file.StandardWatchEventKinds.ENTRY_MODIFY;
+
+/**
+ * Wrapper for controlling an external editor.
+ */
+public class ExternalEditor {
+ private final Consumer<String> errorHandler;
+ private final Consumer<String> saveHandler;
+ private final boolean wait;
+
+ private final Runnable suspendInteractiveInput;
+ private final Runnable resumeInteractiveInput;
+ private final Runnable promptForNewLineToEndWait;
+
+ private WatchService watcher;
+ private Thread watchedThread;
+ private Path dir;
+ private Path tmpfile;
+
+ /**
+ * Launch an external editor.
+ *
+ * @param cmd the command to launch (with parameters)
+ * @param initialText initial text in the editor buffer
+ * @param errorHandler handler for error messages
+ * @param saveHandler handler sent the buffer contents on save
+ * @param suspendInteractiveInput a callback to suspend caller (shell) input
+ * @param resumeInteractiveInput a callback to resume caller input
+ * @param wait true, if editor process termination cannot be used to
+ * determine when done
+ * @param promptForNewLineToEndWait a callback to prompt for newline if
+ * wait==true
+ */
+ public static void edit(String[] cmd, String initialText,
+ Consumer<String> errorHandler,
+ Consumer<String> saveHandler,
+ Runnable suspendInteractiveInput,
+ Runnable resumeInteractiveInput,
+ boolean wait,
+ Runnable promptForNewLineToEndWait) {
+ ExternalEditor ed = new ExternalEditor(errorHandler, saveHandler, suspendInteractiveInput,
+ resumeInteractiveInput, wait, promptForNewLineToEndWait);
+ ed.edit(cmd, initialText);
+ }
+
+ ExternalEditor(Consumer<String> errorHandler,
+ Consumer<String> saveHandler,
+ Runnable suspendInteractiveInput,
+ Runnable resumeInteractiveInput,
+ boolean wait,
+ Runnable promptForNewLineToEndWait) {
+ this.errorHandler = errorHandler;
+ this.saveHandler = saveHandler;
+ this.wait = wait;
+ this.suspendInteractiveInput = suspendInteractiveInput;
+ this.resumeInteractiveInput = resumeInteractiveInput;
+ this.promptForNewLineToEndWait = promptForNewLineToEndWait;
+ }
+
+ private void edit(String[] cmd, String initialText) {
+ try {
+ setupWatch(initialText);
+ launch(cmd);
+ } catch (IOException ex) {
+ errorHandler.accept(ex.getMessage());
+ }
+ }
+
+ /**
+ * Creates a WatchService and registers the given directory
+ */
+ private void setupWatch(String initialText) throws IOException {
+ this.watcher = FileSystems.getDefault().newWatchService();
+ this.dir = Files.createTempDirectory("extedit");
+ this.tmpfile = Files.createTempFile(dir, null, ".java");
+ Files.write(tmpfile, initialText.getBytes(Charset.forName("UTF-8")));
+ dir.register(watcher,
+ ENTRY_CREATE,
+ ENTRY_DELETE,
+ ENTRY_MODIFY);
+ watchedThread = new Thread(() -> {
+ for (;;) {
+ WatchKey key;
+ try {
+ key = watcher.take();
+ } catch (ClosedWatchServiceException ex) {
+ // The watch service has been closed, we are done
+ break;
+ } catch (InterruptedException ex) {
+ // tolerate an interrupt
+ continue;
+ }
+
+ if (!key.pollEvents().isEmpty()) {
+ saveFile();
+ }
+
+ boolean valid = key.reset();
+ if (!valid) {
+ // The watch service has been closed, we are done
+ break;
+ }
+ }
+ });
+ watchedThread.start();
+ }
+
+ private void launch(String[] cmd) throws IOException {
+ String[] params = Arrays.copyOf(cmd, cmd.length + 1);
+ params[cmd.length] = tmpfile.toString();
+ ProcessBuilder pb = new ProcessBuilder(params);
+ pb = pb.inheritIO();
+
+ try {
+ suspendInteractiveInput.run();
+ Process process = pb.start();
+ // wait to exit edit mode in one of these ways...
+ if (wait) {
+ // -wait option -- ignore process exit, wait for carriage-return
+ Scanner scanner = new Scanner(System.in);
+ promptForNewLineToEndWait.run();
+ scanner.nextLine();
+ } else {
+ // wait for process to exit
+ process.waitFor();
+ }
+ } catch (IOException ex) {
+ errorHandler.accept("process IO failure: " + ex.getMessage());
+ } catch (InterruptedException ex) {
+ errorHandler.accept("process interrupt: " + ex.getMessage());
+ } finally {
+ try {
+ watcher.close();
+ watchedThread.join(); //so that saveFile() is finished.
+ saveFile();
+ } catch (InterruptedException ex) {
+ errorHandler.accept("process interrupt: " + ex.getMessage());
+ } finally {
+ resumeInteractiveInput.run();
+ }
+ }
+ }
+
+ private void saveFile() {
+ try {
+ saveHandler.accept(Files.lines(tmpfile).collect(Collectors.joining("\n", "", "\n")));
+ } catch (IOException ex) {
+ errorHandler.accept("Failure in read edit file: " + ex.getMessage());
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.internal.ed/share/classes/jdk/internal/editor/spi/BuildInEditorProvider.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.internal.editor.spi;
+
+import java.util.function.Consumer;
+
+/**
+ * Defines the provider of a built-in editor.
+ */
+public interface BuildInEditorProvider {
+
+ /**
+ * @return the rank of a provider, greater is better.
+ */
+ int rank();
+
+ /**
+ * Create a simple built-in editor.
+ *
+ * @param windowLabel the label string for the Edit Pad window, or null,
+ * for default window label
+ * @param initialText the source to load in the Edit Pad
+ * @param saveHandler a handler for changed source (can be sent the full source)
+ * @param errorHandler a handler for unexpected errors
+ */
+ void edit(String windowLabel, String initialText,
+ Consumer<String> saveHandler, Consumer<String> errorHandler);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.internal.ed/share/classes/module-info.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * Internal editor support for JDK tools. Includes the Service Provider
+ * Interface to built-in editors.
+ */
+module jdk.internal.ed {
+
+ exports jdk.internal.editor.spi to jdk.editpad, jdk.jshell, jdk.scripting.nashorn.shell;
+ exports jdk.internal.editor.external to jdk.jshell, jdk.scripting.nashorn.shell;
+}
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jimage/JImageTask.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jimage/JImageTask.java Wed Nov 09 10:04:43 2016 -0800
@@ -359,9 +359,9 @@
if (name.endsWith(".class") && !name.endsWith("module-info.class")) {
try {
byte[] bytes = reader.getResource(location);
- ClassReader cr =new ClassReader(bytes);
+ ClassReader cr = new ClassReader(bytes);
ClassNode cn = new ClassNode();
- cr.accept(cn, ClassReader.EXPAND_FRAMES);
+ cr.accept(cn, 0);
} catch (Exception ex) {
log.println("Error(s) in Class: " + name);
}
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/DirArchive.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/DirArchive.java Wed Nov 09 10:04:43 2016 -0800
@@ -92,7 +92,7 @@
public DirArchive(Path dirPath, Consumer<String> log) {
Objects.requireNonNull(dirPath);
if (!Files.isDirectory(dirPath)) {
- throw new IllegalArgumentException("Not a directory");
+ throw new IllegalArgumentException(dirPath + " is not a directory");
}
chop = dirPath.toString().length() + 1;
this.moduleName = Objects.requireNonNull(dirPath.getFileName()).toString();
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JarArchive.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JarArchive.java Wed Nov 09 10:04:43 2016 -0800
@@ -30,9 +30,11 @@
import java.io.UncheckedIOException;
import java.nio.file.Path;
import java.util.Objects;
+import java.util.jar.JarFile;
import java.util.stream.Stream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
+import jdk.internal.util.jar.VersionedStream;
import jdk.tools.jlink.internal.Archive.Entry.EntryType;
/**
@@ -72,8 +74,8 @@
private final Path file;
private final String moduleName;
- // currently processed ZipFile
- protected ZipFile zipFile;
+ // currently processed JarFile
+ private JarFile jarFile;
protected JarArchive(String mn, Path file) {
Objects.requireNonNull(mn);
@@ -95,13 +97,15 @@
@Override
public Stream<Entry> entries() {
try {
- if (zipFile == null) {
+ if (jarFile == null) {
open();
}
} catch (IOException ioe) {
throw new UncheckedIOException(ioe);
}
- return zipFile.stream().map(this::toEntry).filter(n -> n != null);
+ return VersionedStream.stream(jarFile)
+ .filter(je -> !je.isDirectory())
+ .map(this::toEntry);
}
abstract EntryType toEntryType(String entryName);
@@ -112,16 +116,20 @@
@Override
public void close() throws IOException {
- if (zipFile != null) {
- zipFile.close();
+ if (jarFile != null) {
+ jarFile.close();
}
}
@Override
public void open() throws IOException {
- if (zipFile != null) {
- zipFile.close();
+ if (jarFile != null) {
+ jarFile.close();
}
- zipFile = new ZipFile(file.toFile());
+ jarFile = new JarFile(file.toFile(), true, ZipFile.OPEN_READ, JarFile.runtimeVersion());
+ }
+
+ protected JarFile getJarFile() {
+ return jarFile;
}
}
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JlinkTask.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JlinkTask.java Wed Nov 09 10:04:43 2016 -0800
@@ -33,7 +33,6 @@
import java.lang.module.ModuleReference;
import java.lang.module.ResolutionException;
import java.lang.module.ResolvedModule;
-import java.lang.reflect.InvocationTargetException;
import java.net.URI;
import java.nio.ByteOrder;
import java.nio.file.Files;
@@ -41,6 +40,7 @@
import java.nio.file.Paths;
import java.util.*;
import java.util.stream.Collectors;
+import java.util.stream.Stream;
import jdk.tools.jlink.internal.TaskHelper.BadArgs;
import static jdk.tools.jlink.internal.TaskHelper.JLINK_BUNDLE;
@@ -62,20 +62,8 @@
public class JlinkTask {
static final boolean DEBUG = Boolean.getBoolean("jlink.debug");
- private static <T extends Throwable> void fail(Class<T> type,
- String format,
- Object... args) throws T {
- String msg = new Formatter().format(format, args).toString();
- try {
- T t = type.getConstructor(String.class).newInstance(msg);
- throw t;
- } catch (InstantiationException |
- InvocationTargetException |
- NoSuchMethodException |
- IllegalAccessException e) {
- throw new InternalError("Unable to create an instance of " + type, e);
- }
- }
+ // jlink API ignores by default. Remove when signing is implemented.
+ static final boolean IGNORE_SIGNING_DEFAULT = true;
private static final TaskHelper taskHelper
= new TaskHelper(JLINK_BUNDLE);
@@ -143,7 +131,10 @@
}, "--save-opts"),
new Option<JlinkTask>(false, (task, opt, arg) -> {
task.options.fullVersion = true;
- }, true, "--full-version"),};
+ }, true, "--full-version"),
+ new Option<JlinkTask>(false, (task, opt, arg) -> {
+ task.options.ignoreSigning = true;
+ }, true, "--ignore-signing-information"),};
private static final String PROGNAME = "jlink";
private final OptionsValues options = new OptionsValues();
@@ -160,7 +151,8 @@
/**
* Result codes.
*/
- static final int EXIT_OK = 0, // Completed with no errors.
+ static final int
+ EXIT_OK = 0, // Completed with no errors.
EXIT_ERROR = 1, // Completed but reported errors.
EXIT_CMDERR = 2, // Bad command-line arguments
EXIT_SYSERR = 3, // System error or resource exhaustion.
@@ -171,12 +163,13 @@
String saveoptsfile;
boolean version;
boolean fullVersion;
- List<Path> modulePath = new ArrayList<>();
- Set<String> limitMods = new HashSet<>();
- Set<String> addMods = new HashSet<>();
+ final List<Path> modulePath = new ArrayList<>();
+ final Set<String> limitMods = new HashSet<>();
+ final Set<String> addMods = new HashSet<>();
Path output;
Path packagedModulesPath;
ByteOrder endian = ByteOrder.nativeOrder();
+ boolean ignoreSigning = false;
}
int run(String[] args) {
@@ -199,7 +192,7 @@
return EXIT_OK;
}
if (taskHelper.getExistingImage() == null) {
- if (options.modulePath == null || options.modulePath.isEmpty()) {
+ if (options.modulePath.isEmpty()) {
throw taskHelper.newBadArgs("err.modulepath.must.be.specified").showUsage(true);
}
createImage();
@@ -248,20 +241,25 @@
plugins = plugins == null ? new PluginsConfiguration() : plugins;
if (config.getModulepaths().isEmpty()) {
- throw new Exception("Empty module paths");
+ throw new IllegalArgumentException("Empty module paths");
}
ModuleFinder finder = newModuleFinder(config.getModulepaths(),
config.getLimitmods(),
config.getModules());
+ if (config.getModules().isEmpty()) {
+ throw new IllegalArgumentException("No modules to add");
+ }
+
// First create the image provider
- ImageProvider imageProvider
- = createImageProvider(finder,
- checkAddMods(config.getModules()),
- config.getLimitmods(),
- config.getByteOrder(),
- null);
+ ImageProvider imageProvider =
+ createImageProvider(finder,
+ config.getModules(),
+ config.getLimitmods(),
+ config.getByteOrder(),
+ null,
+ IGNORE_SIGNING_DEFAULT);
// Then create the Plugin Stack
ImagePluginStack stack = ImagePluginConfiguration.parseConfiguration(plugins);
@@ -299,19 +297,17 @@
}
ModuleFinder finder
= newModuleFinder(options.modulePath, options.limitMods, options.addMods);
- try {
- options.addMods = checkAddMods(options.addMods);
- } catch (IllegalArgumentException ex) {
+ if (options.addMods.isEmpty()) {
throw taskHelper.newBadArgs("err.mods.must.be.specified", "--add-modules")
.showUsage(true);
}
// First create the image provider
- ImageProvider imageProvider
- = createImageProvider(finder,
+ ImageProvider imageProvider = createImageProvider(finder,
options.addMods,
options.limitMods,
options.endian,
- options.packagedModulesPath);
+ options.packagedModulesPath,
+ options.ignoreSigning);
// Then create the Plugin Stack
ImagePluginStack stack = ImagePluginConfiguration.
@@ -321,13 +317,6 @@
stack.operate(imageProvider);
}
- private static Set<String> checkAddMods(Set<String> addMods) {
- if (addMods.isEmpty()) {
- throw new IllegalArgumentException("no modules to add");
- }
- return addMods;
- }
-
/**
* Returns a module finder to find the observable modules specified in
* the --module-path and --limit-modules options
@@ -343,7 +332,7 @@
return finder;
}
- /**
+ /*
* Returns a module finder of the given module path that limits
* the observable modules to those in the transitive closure of
* the modules specified in {@code limitMods} plus other modules
@@ -376,7 +365,8 @@
Set<String> addMods,
Set<String> limitMods,
ByteOrder order,
- Path retainModulesPath)
+ Path retainModulesPath,
+ boolean ignoreSigning)
throws IOException
{
if (addMods.isEmpty()) {
@@ -390,10 +380,10 @@
Map<String, Path> mods = cf.modules().stream()
.collect(Collectors.toMap(ResolvedModule::name, JlinkTask::toPathLocation));
- return new ImageHelper(cf, mods, order, retainModulesPath);
+ return new ImageHelper(cf, mods, order, retainModulesPath, ignoreSigning);
}
- /**
+ /*
* Returns a ModuleFinder that limits observability to the given root
* modules, their transitive dependences, plus a set of other modules.
*/
@@ -477,36 +467,57 @@
}
private static class ImageHelper implements ImageProvider {
-
- final Set<Archive> archives;
final ByteOrder order;
final Path packagedModulesPath;
+ final boolean ignoreSigning;
+ final Set<Archive> archives;
ImageHelper(Configuration cf,
Map<String, Path> modsPaths,
ByteOrder order,
- Path packagedModulesPath) throws IOException {
- archives = modsPaths.entrySet().stream()
+ Path packagedModulesPath,
+ boolean ignoreSigning) throws IOException {
+ this.order = order;
+ this.packagedModulesPath = packagedModulesPath;
+ this.ignoreSigning = ignoreSigning;
+ this.archives = modsPaths.entrySet().stream()
.map(e -> newArchive(e.getKey(), e.getValue()))
.collect(Collectors.toSet());
- this.order = order;
- this.packagedModulesPath = packagedModulesPath;
}
private Archive newArchive(String module, Path path) {
if (path.toString().endsWith(".jmod")) {
return new JmodArchive(module, path);
} else if (path.toString().endsWith(".jar")) {
- return new ModularJarArchive(module, path);
+ ModularJarArchive modularJarArchive = new ModularJarArchive(module, path);
+
+ Stream<Archive.Entry> signatures = modularJarArchive.entries().filter((entry) -> {
+ String name = entry.name().toUpperCase(Locale.ENGLISH);
+
+ return name.startsWith("META-INF/") && name.indexOf('/', 9) == -1 && (
+ name.endsWith(".SF") ||
+ name.endsWith(".DSA") ||
+ name.endsWith(".RSA") ||
+ name.endsWith(".EC") ||
+ name.startsWith("META-INF/SIG-")
+ );
+ });
+
+ if (signatures.count() != 0) {
+ if (ignoreSigning) {
+ System.err.println(taskHelper.getMessage("warn.signing", path));
+ } else {
+ throw new IllegalArgumentException(taskHelper.getMessage("err.signing", path));
+ }
+ }
+
+ return modularJarArchive;
} else if (Files.isDirectory(path)) {
return new DirArchive(path);
} else {
- fail(RuntimeException.class,
- "Selected module %s (%s) not in jmod or modular jar format",
- module,
- path);
+ throw new IllegalArgumentException(
+ taskHelper.getMessage("err.not.modular.format", module, path));
}
- return null;
}
@Override
@@ -526,30 +537,16 @@
}
private static enum Section {
- NATIVE_LIBS("native", nativeDir()),
- NATIVE_CMDS("bin", "bin"),
- CLASSES("classes", "classes"),
- CONFIG("conf", "conf"),
- UNKNOWN("unknown", "unknown");
-
- private static String nativeDir() {
- if (System.getProperty("os.name").startsWith("Windows")) {
- return "bin";
- } else {
- return "lib";
- }
- }
+ NATIVE_LIBS("native"),
+ NATIVE_CMDS("bin"),
+ CLASSES("classes"),
+ CONFIG("conf"),
+ UNKNOWN("unknown");
private final String jmodDir;
- private final String imageDir;
- Section(String jmodDir, String imageDir) {
+ Section(String jmodDir) {
this.jmodDir = jmodDir;
- this.imageDir = imageDir;
- }
-
- String imageDir() {
- return imageDir;
}
String jmodDir() {
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModularJarArchive.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModularJarArchive.java Wed Nov 09 10:04:43 2016 -0800
@@ -54,13 +54,9 @@
@Override
Entry toEntry(ZipEntry ze) {
- if (ze.isDirectory()) {
- return null;
- }
-
String name = ze.getName();
EntryType type = toEntryType(name);
- return new JarEntry(ze.getName(), getFileName(name), type, zipFile, ze);
+ return new JarEntry(ze.getName(), getFileName(name), type, getJarFile(), ze);
}
@Override
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java Wed Nov 09 10:04:43 2016 -0800
@@ -161,6 +161,7 @@
private static final String POST_PROCESS = "--post-process-path";
private Layer pluginsLayer = Layer.boot();
+ private final List<Plugin> plugins;
private String lastSorter;
private boolean listPlugins;
private Path existingImage;
@@ -184,9 +185,10 @@
pluginsLayer = createPluginsLayer(paths);
}
+ plugins = PluginRepository.getPlugins(pluginsLayer);
+
Set<String> optionsSeen = new HashSet<>();
- for (Plugin plugin : PluginRepository.
- getPlugins(pluginsLayer)) {
+ for (Plugin plugin : plugins) {
if (!Utils.isDisabled(plugin)) {
addOrderedPluginOptions(plugin, optionsSeen);
}
@@ -198,9 +200,19 @@
},
"--plugin-module-path"));
mainOptions.add(new PlugOption(true, (task, opt, arg) -> {
+ for (Plugin plugin : plugins) {
+ if (plugin.getName().equals(arg)) {
+ pluginToMaps.remove(plugin);
+ return;
+ }
+ }
+ throw newBadArgs("err.no.such.plugin", arg);
+ },
+ "--disable-plugin"));
+ mainOptions.add(new PlugOption(true, (task, opt, arg) -> {
Path path = Paths.get(arg);
if (!Files.exists(path) || !Files.isDirectory(path)) {
- throw newBadArgs("err.existing.image.must.exist");
+ throw newBadArgs("err.image.must.exist", path);
}
existingImage = path.toAbsolutePath();
}, true, POST_PROCESS));
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java Wed Nov 09 10:04:43 2016 -0800
@@ -159,13 +159,6 @@
public void configure(Map<String, String> config) {
String mainArgument = config.get(NAME);
- if ("none".equals(mainArgument)) {
- speciesTypes = Set.of();
- invokerTypes = Set.of();
- dmhMethods = Map.of();
- return;
- }
-
// Start with the default configuration
Set<String> defaultBMHSpecies = defaultSpecies();
// Expand BMH species signatures
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink.properties Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink.properties Wed Nov 09 10:04:43 2016 -0800
@@ -62,6 +62,9 @@
main.opt.save-opts=\
\ --save-opts <filename> Save jlink options in the given file
+main.opt.ignore-signing-information=\
+\ --ignore-signing-information Ignore signing information in modular JARs
+
main.msg.bug=\
An exception has occurred in jlink. \
Please file a bug at the Java Bug Database (http://bugreport.java.com/bugreport/) \
@@ -88,7 +91,7 @@
err.mods.must.be.specified:no modules specified to {0}
err.path.not.found=path not found: {0}
err.path.not.valid=invalid path: {0}
-err.existing.image.must.exist=existing image doesn't exists or is not a directory
+err.image.must.exist=image {0} does not exist or is not a directory
err.existing.image.invalid=existing image is not valid
err.file.not.found=cannot find file: {0}
err.file.error=cannot access file: {0}
@@ -104,5 +107,9 @@
err.config.defaults=property {0} is missing from configuration
err.config.defaults.value=wrong value in defaults property: {0}
err.bom.generation=bom file generation failed: {0}
-warn.invalid.arg=Invalid classname or pathname not exist: {0}
+err.not.modular.format=selected module {0} ({1}) not in jmod or modular JAR format
+err.signing=signed modular JAR {0} is currently not supported,\
+\ use --ignore-signing-information to suppress error
+warn.signing=signed modular JAR {0} is currently not supported
+warn.invalid.arg=invalid classname or pathname not exist: {0}
warn.split.package=package {0} defined in {1} {2}
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties Wed Nov 09 10:04:43 2016 -0800
@@ -74,12 +74,11 @@
exclude-jmod-section.description=\
Specify a JMOD section to exclude
-generate-jli-classes.argument=<none|@filename>
+generate-jli-classes.argument=@filename
generate-jli-classes.description=\
Takes a file hinting to jlink what java.lang.invoke classes to pre-generate. If\n\
-this flag is not specified a default set of classes will be generated. To \n\
-disable pre-generation specify none as the argument
+this flag is not specified a default set of classes will be generated.
installed-modules.description=Fast loading of module descriptors (always enabled)
@@ -144,6 +143,9 @@
plugin.opt.plugin-module-path=\
\ --plugin-module-path <modulepath> Custom plugin module path
+plugin.opt.disable-plugin=\
+\ --disable-plugin <pluginname> Disable the plugin mentioned
+
plugin.opt.c=\
\ -c, --compress=<0|1|2> Enable compression of resources\
\n More details in --list-plugins option
@@ -193,6 +195,8 @@
main.plugin.state=\
Functional state
+err.no.such.plugin=No such plugin: {0}
+
err.provider.not.functional=The provider {0} is not functional.
err.plugin.mutiple.options=More than one plugin enabled by {0} option
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/JmodTask.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/JmodTask.java Wed Nov 09 10:04:43 2016 -0800
@@ -47,6 +47,7 @@
import java.lang.module.ResolvedModule;
import java.net.URI;
import java.nio.file.FileSystems;
+import java.nio.file.FileVisitOption;
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
import java.nio.file.InvalidPathException;
@@ -633,7 +634,8 @@
void processSection(JmodOutputStream out, Section section, Path top)
throws IOException
{
- Files.walkFileTree(top, new SimpleFileVisitor<Path>() {
+ Files.walkFileTree(top, Set.of(FileVisitOption.FOLLOW_LINKS),
+ Integer.MAX_VALUE, new SimpleFileVisitor<Path>() {
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
throws IOException
--- a/jdk/src/jdk.unsupported/share/classes/sun/reflect/ReflectionFactory.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/src/jdk.unsupported/share/classes/sun/reflect/ReflectionFactory.java Wed Nov 09 10:04:43 2016 -0800
@@ -85,6 +85,21 @@
}
/**
+ * Returns an accessible constructor capable of creating instances
+ * of the given class, initialized by the given constructor.
+ *
+ * @param cl the class to instantiate
+ * @param constructorToCall the constructor to call
+ * @return an accessible constructor
+ */
+ public Constructor<?> newConstructorForSerialization(Class<?> cl,
+ Constructor<?> constructorToCall)
+ {
+ return delegate.newConstructorForSerialization(cl,
+ constructorToCall);
+ }
+
+ /**
* Returns an accessible no-arg constructor for a class.
* The no-arg constructor is found searching the class and its supertypes.
*
--- a/jdk/test/ProblemList.txt Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/test/ProblemList.txt Wed Nov 09 10:04:43 2016 -0800
@@ -184,6 +184,8 @@
java/nio/file/WatchService/MayFlies.java 7158947 solaris-all Solaris 11
java/nio/file/WatchService/LotsOfEvents.java 7158947 solaris-all Solaris 11
+sun/nio/cs/OLD/TestIBMDB.java 8167525 generic-all
+
############################################################################
# jdk_rmi
@@ -225,6 +227,8 @@
javax/sound/sampled/Mixers/DisabledAssertionCrash.java 7067310 generic-all
+javax/sound/sampled/Clip/OpenNonIntegralNumberOfSampleframes.java 8168881 generic-all
+
############################################################################
# jdk_imageio
--- a/jdk/test/com/sun/jndi/dns/Parser.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/test/com/sun/jndi/dns/Parser.java Wed Nov 09 10:04:43 2016 -0800
@@ -26,6 +26,7 @@
* @bug 8035105
* @summary DNS resource record parsing
* @modules jdk.naming.dns/com.sun.jndi.dns
+ * @compile --add-modules jdk.naming.dns Parser.java
*/
import com.sun.jndi.dns.ResourceRecord;
--- a/jdk/test/com/sun/jndi/rmi/registry/RegistryContext/ContextWithNullProperties.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/test/com/sun/jndi/rmi/registry/RegistryContext/ContextWithNullProperties.java Wed Nov 09 10:04:43 2016 -0800
@@ -28,7 +28,7 @@
* @modules jdk.naming.rmi/com.sun.jndi.rmi.registry java.rmi/sun.rmi.registry
* java.rmi/sun.rmi.server java.rmi/sun.rmi.transport java.rmi/sun.rmi.transport.tcp
* @library ../../../../../../java/rmi/testlibrary
- * @build TestLibrary
+ * @compile --add-modules jdk.naming.rmi ContextWithNullProperties.java
* @run main ContextWithNullProperties
*/
--- a/jdk/test/java/io/Serializable/serialFilter/SerialFilterTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/test/java/io/Serializable/serialFilter/SerialFilterTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -40,7 +40,7 @@
import java.util.Set;
import java.util.concurrent.atomic.LongAdder;
-import javax.lang.model.SourceVersion;
+import javax.net.ssl.SSLEngineResult;
import org.testng.Assert;
import org.testng.annotations.Test;
@@ -82,8 +82,8 @@
Object[][] patterns = new Object[][]{
{"java.util.Hashtable"},
{"java.util.Hash*"},
- {"javax.lang.model.*"},
- {"javax.lang.**"},
+ {"javax.net.ssl.*"},
+ {"javax.net.**"},
{"*"},
{"maxarray=47"},
{"maxdepth=5"},
@@ -543,20 +543,20 @@
static Object genTestObjectWildcard(String pattern, boolean allowed) {
if (pattern.endsWith(".**")) {
// package hierarchy wildcard
- if (pattern.startsWith("javax.lang.")) {
- return SourceVersion.RELEASE_5;
+ if (pattern.startsWith("javax.net.")) {
+ return SSLEngineResult.Status.BUFFER_OVERFLOW;
}
if (pattern.startsWith("java.")) {
return 4;
}
if (pattern.startsWith("javax.")) {
- return SourceVersion.RELEASE_6;
+ return SSLEngineResult.Status.BUFFER_UNDERFLOW;
}
return otherObject;
} else if (pattern.endsWith(".*")) {
// package wildcard
- if (pattern.startsWith("javax.lang.model")) {
- return SourceVersion.RELEASE_6;
+ if (pattern.startsWith("javax.net.ssl")) {
+ return SSLEngineResult.Status.BUFFER_UNDERFLOW;
}
} else {
// class wildcard
--- a/jdk/test/java/lang/ClassLoader/platformClassLoader/DefinePlatformClass.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/test/java/lang/ClassLoader/platformClassLoader/DefinePlatformClass.java Wed Nov 09 10:04:43 2016 -0800
@@ -24,8 +24,9 @@
/*
* @test
* @summary Test java.* class defined by the platform class loader
- * @build jdk.zipfs/java.fake.Fake
* @modules jdk.zipfs/java.fake
+ * @build jdk.zipfs/java.fake.Fake
+ * @compile --add-modules jdk.zipfs DefinePlatformClass.java
* @run main DefinePlatformClass
*/
--- a/jdk/test/java/lang/ProcessBuilder/Basic.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/test/java/lang/ProcessBuilder/Basic.java Wed Nov 09 10:04:43 2016 -0800
@@ -2404,16 +2404,6 @@
fail("Test failed: waitFor didn't take long enough (" + (end - start) + "ns)");
p.destroy();
-
- start = System.nanoTime();
- p.waitFor(8, TimeUnit.SECONDS);
- end = System.nanoTime();
-
- int exitValue = p.exitValue();
-
- if ((end - start) > TimeUnit.SECONDS.toNanos(7))
- fail("Test failed: waitFor took too long on a dead process. (" + (end - start) + "ns)"
- + ", exitValue: " + exitValue);
} catch (Throwable t) { unexpected(t); }
//----------------------------------------------------------------
--- a/jdk/test/java/lang/StackTraceElement/PublicConstructor.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/test/java/lang/StackTraceElement/PublicConstructor.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,43 +23,74 @@
/*
* @test
- * @bug 4712607
+ * @bug 4712607 6479237
* @summary Basic test for StackTraceElementPublic constructor
* @author Josh Bloch
*/
-import java.util.*;
+import java.lang.module.ModuleDescriptor;
+import java.lang.reflect.Module;
public class PublicConstructor {
- public static void main(String args[]) {
+ public static void main(String... args) {
+ testConstructor();
+ testConstructorWithModule();
+ }
+
+ static void testConstructor() {
StackTraceElement ste = new StackTraceElement("com.acme.Widget",
- "frobnicate", "Widget.java", 42);
+ "frobnicate",
+ "Widget.java", 42);
if (!(ste.getClassName().equals("com.acme.Widget") &&
- ste.getFileName().equals("Widget.java") &&
- ste.getMethodName().equals("frobnicate") &&
- ste.getLineNumber() == 42))
+ ste.getFileName().equals("Widget.java") &&
+ ste.getMethodName().equals("frobnicate") &&
+ ste.getLineNumber() == 42))
throw new RuntimeException("1");
+
if (ste.isNativeMethod())
throw new RuntimeException("2");
- StackTraceElement ste2
- = new StackTraceElement("jdk.module",
- "9.0",
- "com.acme.Widget",
- "frobnicate",
- "Widget.java",
- 42);
- if (!(ste2.getClassName().equals("com.acme.Widget") &&
- ste2.getModuleName().equals("jdk.module") &&
- ste2.getModuleVersion().equals("9.0") &&
- ste2.getFileName().equals("Widget.java") &&
- ste2.getMethodName().equals("frobnicate") &&
- ste2.getLineNumber() == 42))
+
+ assertEquals(ste.toString(),
+ "com.acme.Widget.frobnicate(Widget.java:42)");
+
+ StackTraceElement ste1 = new StackTraceElement("com.acme.Widget",
+ "frobnicate",
+ "Widget.java",
+ -2);
+ if (!ste1.isNativeMethod())
throw new RuntimeException("3");
- if (ste2.isNativeMethod())
+
+ assertEquals(ste1.toString(),
+ "com.acme.Widget.frobnicate(Native Method)");
+ }
+
+ static void testConstructorWithModule() {
+ StackTraceElement ste = new StackTraceElement("app",
+ "jdk.module",
+ "9.0",
+ "com.acme.Widget",
+ "frobnicate",
+ "Widget.java",
+ 42);
+ if (!(ste.getClassName().equals("com.acme.Widget") &&
+ ste.getModuleName().equals("jdk.module") &&
+ ste.getModuleVersion().equals("9.0") &&
+ ste.getClassLoaderName().equals("app") &&
+ ste.getFileName().equals("Widget.java") &&
+ ste.getMethodName().equals("frobnicate") &&
+ ste.getLineNumber() == 42))
+ throw new RuntimeException("3");
+
+ if (ste.isNativeMethod())
throw new RuntimeException("4");
- StackTraceElement ste3 = new StackTraceElement("com.acme.Widget",
- "frobnicate", "Widget.java", -2);
- if (!ste3.isNativeMethod())
- throw new RuntimeException("5");
+
+ assertEquals(ste.toString(),
+ "app/jdk.module@9.0/com.acme.Widget.frobnicate(Widget.java:42)");
+ }
+
+ static void assertEquals(String s, String expected) {
+ if (!s.equals(expected)) {
+ throw new RuntimeException("Expected: " + expected + " but found: " + s);
+ }
}
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/StackTraceElement/SerialTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,264 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6479237
+ * @summary Test the format of StackTraceElement::toString and its serial form
+ * @modules java.logging
+ * java.xml.bind
+ * @run main SerialTest
+ */
+
+import javax.xml.bind.JAXBElement;
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.OutputStream;
+import java.io.UncheckedIOException;
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Arrays;
+import java.util.logging.Logger;
+
+public class SerialTest {
+ private static final Path SER_DIR = Paths.get("sers");
+ private static final String JAVA_BASE = "java.base";
+ private static final String JAVA_LOGGING = "java.logging";
+ private static final String JAVA_XML_BIND = "java.xml.bind";
+
+ private static boolean isImage;
+
+ public static void main(String... args) throws Exception {
+ Files.createDirectories(SER_DIR);
+
+ // detect if exploded image build
+ Path home = Paths.get(System.getProperty("java.home"));
+ isImage = Files.exists(home.resolve("lib").resolve("modules"));
+
+ // test stack trace from built-in loaders
+ try {
+ Logger.getLogger(null);
+ } catch (NullPointerException e) {
+ Arrays.stream(e.getStackTrace())
+ .filter(ste -> ste.getClassName().startsWith("java.util.logging.") ||
+ ste.getClassName().equals("SerialTest"))
+ .forEach(SerialTest::test);
+ }
+
+ // test stack trace with upgradeable module
+ try {
+ new JAXBElement(null, null, null);
+ } catch (IllegalArgumentException e) {
+ Arrays.stream(e.getStackTrace())
+ .filter(ste -> ste.getModuleName() != null)
+ .forEach(SerialTest::test);
+ }
+
+ // test stack trace with class loader name from other class loader
+ Loader loader = new Loader("myloader");
+ Class<?> cls = Class.forName("SerialTest", true, loader);
+ Method method = cls.getMethod("throwException");
+ StackTraceElement ste = (StackTraceElement)method.invoke(null);
+ test(ste, loader);
+
+ // verify the class loader name and in the stack trace
+ if (!cls.getClassLoader().getName().equals("myloader.hacked")) {
+ throw new RuntimeException("Unexpected loader name: " +
+ cls.getClassLoader().getName());
+ }
+ if (!ste.getClassLoaderName().equals("myloader")) {
+ throw new RuntimeException("Unexpected loader name: " +
+ ste.getClassLoaderName());
+ }
+ }
+
+ private static void test(StackTraceElement ste) {
+ test(ste, null);
+ }
+
+ private static void test(StackTraceElement ste, ClassLoader loader) {
+ try {
+ SerialTest serialTest = new SerialTest(ste);
+ StackTraceElement ste2 = serialTest.serialize().deserialize();
+ System.out.println(ste2);
+ // verify StackTraceElement::toString returns the same string
+ if (!ste.equals(ste2) || !ste.toString().equals(ste2.toString())) {
+ throw new RuntimeException(ste + " != " + ste2);
+ }
+
+ String mn = ste.getModuleName();
+ if (mn != null) {
+ switch (mn) {
+ case JAVA_BASE:
+ case JAVA_LOGGING:
+ checkNamedModule(ste, loader, false);
+ break;
+ case JAVA_XML_BIND:
+ // for exploded build, no version is shown
+ checkNamedModule(ste, loader, isImage);
+ break;
+ default: // ignore
+ }
+ } else {
+ checkUnnamedModule(ste, loader);
+ }
+ } catch (IOException e) {
+ throw new UncheckedIOException(e);
+ }
+ }
+
+ private static void checkUnnamedModule(StackTraceElement ste, ClassLoader loader) {
+ String mn = ste.getModuleName();
+ String s = ste.toString();
+ int i = s.indexOf('/');
+
+ if (mn != null) {
+ throw new RuntimeException("expected null but got " + mn);
+ }
+
+ if (loader != null) {
+ // Expect <loader>//<classname>.<method>(<src>:<ln>)
+ if (i <= 0) {
+ throw new RuntimeException("loader name missing: " + s);
+ }
+ if (!getLoaderName(loader).equals(s.substring(0, i))) {
+ throw new RuntimeException("unexpected loader name: " + s);
+ }
+ int j = s.substring(i+1).indexOf('/');
+ if (j != 0) {
+ throw new RuntimeException("unexpected element for unnamed module: " + s);
+ }
+ }
+ }
+
+ /*
+ * Loader::getName is overridden to return some other name
+ */
+ private static String getLoaderName(ClassLoader loader) {
+ if (loader == null)
+ return "";
+
+ if (loader instanceof Loader) {
+ return ((Loader) loader).name;
+ } else {
+ return loader.getName();
+ }
+ }
+
+ private static void checkNamedModule(StackTraceElement ste,
+ ClassLoader loader,
+ boolean showVersion) {
+ String loaderName = getLoaderName(loader);
+ String mn = ste.getModuleName();
+ String s = ste.toString();
+ int i = s.indexOf('/');
+
+ if (mn == null) {
+ throw new RuntimeException("expected module name: " + s);
+ }
+
+ if (i <= 0) {
+ throw new RuntimeException("module name missing: " + s);
+ }
+
+ // Expect <module>/<classname>.<method>(<src>:<ln>)
+ if (!loaderName.isEmpty()) {
+ throw new IllegalArgumentException(loaderName);
+ }
+
+ // <module>: name@version
+ int j = s.indexOf('@');
+ if ((showVersion && j <= 0) || (!showVersion && j >= 0)) {
+ throw new RuntimeException("unexpected version: " + s);
+ }
+
+ String name = j < 0 ? s.substring(0, i) : s.substring(0, j);
+ if (!name.equals(mn)) {
+ throw new RuntimeException("unexpected module name: " + s);
+ }
+ }
+
+ private final Path ser;
+ private final StackTraceElement ste;
+ SerialTest(StackTraceElement ste) throws IOException {
+ this.ser = Files.createTempFile(SER_DIR, "SerialTest", ".ser");
+ this.ste = ste;
+ }
+
+ private StackTraceElement deserialize() throws IOException {
+ try (InputStream in = Files.newInputStream(ser);
+ BufferedInputStream bis = new BufferedInputStream(in);
+ ObjectInputStream ois = new ObjectInputStream(bis)) {
+ return (StackTraceElement)ois.readObject();
+ } catch (ClassNotFoundException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private SerialTest serialize() throws IOException {
+ try (OutputStream out = Files.newOutputStream(ser);
+ BufferedOutputStream bos = new BufferedOutputStream(out);
+ ObjectOutputStream oos = new ObjectOutputStream(bos)) {
+ oos.writeObject(ste);
+ }
+ return this;
+ }
+
+
+ public static StackTraceElement throwException() {
+ try {
+ Integer.parseInt(null);
+ } catch (NumberFormatException e) {
+ return Arrays.stream(e.getStackTrace())
+ .filter(ste -> ste.getMethodName().equals("throwException"))
+ .findFirst().get();
+ }
+ return null;
+ }
+
+ public static class Loader extends URLClassLoader {
+ final String name;
+ Loader(String name) throws MalformedURLException {
+ super(name, new URL[] { testClassesURL() } , null);
+ this.name = name;
+ }
+
+ private static URL testClassesURL() throws MalformedURLException {
+ Path path = Paths.get(System.getProperty("test.classes"));
+ return path.toUri().toURL();
+ }
+
+ public String getName() {
+ return name + ".hacked";
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/StackTraceElement/WithClassLoaderName.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6479237
+ * @summary Basic test StackTraceElement with class loader names
+ * @library lib /lib/testlibrary
+ * @build m1/* WithClassLoaderName
+ * @run main/othervm m1/com.app.Main
+ * @run main/othervm WithClassLoaderName
+ */
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import com.app.Utils;
+
+public class WithClassLoaderName {
+ private static final String TEST_SRC = System.getProperty("test.src");
+ private static final String SRC_FILENAME = "WithClassLoaderName.java";
+
+ private static final Path SRC_DIR = Paths.get(TEST_SRC, "src");
+ private static final Path CLASSES_DIR = Paths.get("classes");
+ private static final String THROW_EXCEPTION_CLASS = "p.ThrowException";
+
+ public static void main(String... args) throws Exception {
+ /*
+ * Test the following frames both have the same class loader name "app"
+ * com.app.Test::test
+ * WithClassLoaderName::test
+ */
+ Utils.verify(WithClassLoaderName.class, "app", "main", SRC_FILENAME);
+
+ /*
+ * Test StackTraceElement for a class loaded by a named URLClassLoader
+ */
+ compile();
+ testURLClassLoader("myloader");
+
+ // loader name same as application class loader
+ testURLClassLoader("app");
+ }
+
+ private static void compile() throws Exception {
+ boolean rc = CompilerUtils.compile(SRC_DIR, CLASSES_DIR);
+ if (!rc) {
+ throw new RuntimeException("compilation fails");
+ }
+ }
+
+ public static void testURLClassLoader(String loaderName) throws Exception {
+ System.err.println("---- test URLClassLoader name: " + loaderName);
+
+ URL[] urls = new URL[] { CLASSES_DIR.toUri().toURL() };
+ ClassLoader parent = ClassLoader.getSystemClassLoader();
+ URLClassLoader loader = new URLClassLoader(loaderName, urls, parent);
+
+ Class<?> c = Class.forName(THROW_EXCEPTION_CLASS, true, loader);
+ Method method = c.getMethod("throwError");
+ try {
+ // invoke p.ThrowException::throwError
+ method.invoke(null);
+ } catch (InvocationTargetException x) {
+ Throwable e = x.getCause();
+ e.printStackTrace();
+
+ StackTraceElement[] stes = e.getStackTrace();
+ StackWalker.StackFrame[] frames = new StackWalker.StackFrame[] {
+ Utils.makeStackFrame(c, "throwError", "ThrowException.java"),
+ Utils.makeStackFrame(WithClassLoaderName.class, "testURLClassLoader",
+ SRC_FILENAME),
+ Utils.makeStackFrame(WithClassLoaderName.class, "main", SRC_FILENAME),
+ };
+
+ // p.ThrowException.throwError
+ Utils.checkFrame(loaderName, frames[0], stes[0]);
+ // skip reflection frames
+ int i = 1;
+ while (i < stes.length) {
+ String cn = stes[i].getClassName();
+ if (!cn.startsWith("java.lang.reflect.") &&
+ !cn.startsWith("jdk.internal.reflect."))
+ break;
+ i++;
+ }
+ // WithClassLoaderName.testURLClassLoader
+ Utils.checkFrame("app", frames[1], stes[i]);
+
+ // WithClassLoaderName.main
+ Utils.checkFrame("app", frames[2], stes[i+1]);
+
+ }
+ }
+
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/StackTraceElement/lib/m1/com/app/Main.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.app;
+
+import java.lang.StackWalker.StackFrame;
+
+public class Main {
+ public static void main(String... args) throws Exception {
+ StackFrame frame = Utils.makeStackFrame(Main.class, "main", "Main.java");
+ Utils.checkFrame("app", frame, caller());
+ }
+
+ private static StackTraceElement caller() {
+ StackTraceElement[] stes = Thread.currentThread().getStackTrace();
+ return stes[2];
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/StackTraceElement/lib/m1/com/app/Utils.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.app;
+
+import java.lang.StackWalker.StackFrame;
+import java.lang.module.ModuleDescriptor;
+import java.lang.reflect.Module;
+import java.util.Objects;
+
+public class Utils {
+ public static void verify(Class<?> caller, String loaderName,
+ String methodname, String filename) {
+ StackTraceElement[] stes = Thread.currentThread().getStackTrace();
+ StackWalker.StackFrame[] frames = new StackFrame[] {
+ makeStackFrame(Utils.class, "verify", "Utils.java"),
+ makeStackFrame(caller, methodname, filename)
+ };
+
+ checkFrame("app", frames[0], stes[1]);
+ checkFrame(loaderName, frames[1], stes[2]);
+ }
+
+ public static StackFrame makeStackFrame(Class<?> c, String methodname, String filename) {
+ return new StackFrame() {
+ @Override
+ public String getClassName() {
+ return c.getName();
+ }
+ @Override
+ public String getMethodName() {
+ return methodname;
+ }
+ @Override
+ public Class<?> getDeclaringClass() {
+ return c;
+ }
+ @Override
+ public int getByteCodeIndex() {
+ return 0;
+ }
+ @Override
+ public String getFileName() {
+ return filename;
+ }
+
+ @Override
+ public int getLineNumber() {
+ return 0;
+ }
+ @Override
+ public boolean isNativeMethod() {
+ return false;
+ }
+ @Override
+ public StackTraceElement toStackTraceElement() {
+ return null;
+ }
+
+ private String getClassLoaderName(Class<?> c) {
+ ClassLoader loader = c.getClassLoader();
+ String name = "";
+ if (loader == null) {
+ name = "boot";
+ } else if (loader.getName() != null) {
+ name = loader.getName();
+ }
+ return name;
+ }
+
+ @Override
+ public String toString() {
+ String mid = getClassLoaderName(c);
+ Module module = c.getModule();
+ if (module.isNamed()) {
+ ModuleDescriptor md = module.getDescriptor();
+ mid = md.name();
+ if (md.version().isPresent())
+ mid += "@" + md.version().get().toString();
+ mid += "/";
+ }
+ String fileName = getFileName();
+ int lineNumber = getLineNumber();
+ String sourceinfo = "Unknown Source";
+ if (isNativeMethod()) {
+ sourceinfo = "Native Method";
+ } else if (fileName != null && lineNumber >= 0) {
+ sourceinfo = fileName + ":" + lineNumber;
+ }
+ return String.format("%s/%s.%s(%s)", mid, getClassName(), getMethodName(),
+ sourceinfo);
+
+ }
+ };
+ }
+
+ public static void checkFrame(String loaderName, StackFrame frame,
+ StackTraceElement ste) {
+ System.err.println("checking " + ste.toString() + " expected: " + frame.toString());
+ Class<?> c = frame.getDeclaringClass();
+ Module module = c.getModule();
+ assertEquals(ste.getModuleName(), module.getName(), "module name");
+ assertEquals(ste.getClassLoaderName(), loaderName, "class loader name");
+ assertEquals(ste.getClassLoaderName(), c.getClassLoader().getName(),
+ "class loader name");
+ assertEquals(ste.getClassName(), c.getName(), "class name");
+ assertEquals(ste.getMethodName(), frame.getMethodName(), "method name");
+ assertEquals(ste.getFileName(), frame.getFileName(), "file name");
+
+ }
+ private static void assertEquals(String actual, String expected, String msg) {
+ if (!Objects.equals(actual, expected))
+ throw new AssertionError("Actual: " + actual + " Excepted: " +
+ expected + " mismatched " + msg);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/StackTraceElement/lib/m1/module-info.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+module m1 {
+ exports com.app;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/StackTraceElement/src/p/ThrowException.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package p;
+
+import java.lang.StackWalker.StackFrame;
+
+public class ThrowException {
+ public static void throwError() {
+ throw new Error("testing");
+ }
+}
--- a/jdk/test/java/lang/StackWalker/VerifyStackTrace.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/test/java/lang/StackWalker/VerifyStackTrace.java Wed Nov 09 10:04:43 2016 -0800
@@ -71,7 +71,7 @@
"3: VerifyStackTrace$Handle.run(VerifyStackTrace.java:158)\n" +
"4: VerifyStackTrace.invoke(VerifyStackTrace.java:188)\n" +
"5: VerifyStackTrace$1.run(VerifyStackTrace.java:218)\n" +
- "6: java.security.AccessController.doPrivileged(java.base/Native Method)\n" +
+ "6: java.base/java.security.AccessController.doPrivileged(Native Method)\n" +
"7: VerifyStackTrace.test(VerifyStackTrace.java:227)\n" +
"8: VerifyStackTrace.main(VerifyStackTrace.java:182)\n";
@@ -100,12 +100,12 @@
"2: VerifyStackTrace$Handle.execute(VerifyStackTrace.java:147)\n" +
"3: VerifyStackTrace$Handle.run(VerifyStackTrace.java:160)\n" +
"4: VerifyStackTrace.invoke(VerifyStackTrace.java:190)\n" +
- "5: jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(java.base/Native Method)\n" +
- "6: jdk.internal.reflect.NativeMethodAccessorImpl.invoke(java.base/NativeMethodAccessorImpl.java:62)\n" +
- "7: jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(java.base/DelegatingMethodAccessorImpl.java:43)\n" +
- "8: java.lang.reflect.Method.invoke(java.base/Method.java:520)\n" +
+ "5: java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n" +
+ "6: java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\n" +
+ "7: java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n" +
+ "8: java.base/java.lang.reflect.Method.invoke(Method.java:520)\n" +
"9: VerifyStackTrace$1.run(VerifyStackTrace.java:220)\n" +
- "10: java.security.AccessController.doPrivileged(java.base/Native Method)\n" +
+ "10: java.base/java.security.AccessController.doPrivileged(Native Method)\n" +
"11: VerifyStackTrace.test(VerifyStackTrace.java:229)\n" +
"12: VerifyStackTrace.main(VerifyStackTrace.java:185)\n";
@@ -133,16 +133,16 @@
"1: VerifyStackTrace.lambda$test$1(VerifyStackTrace.java:213)\n" +
"2: VerifyStackTrace$$Lambda$1/662441761.run(Unknown Source)\n" +
"3: VerifyStackTrace$Handle.execute(VerifyStackTrace.java:149)\n" +
- "4: java.lang.invoke.LambdaForm$DMH/2008017533.invokeVirtual_LL_V(java.base/LambdaForm$DMH)\n" +
- "5: java.lang.invoke.LambdaForm$MH/1395089624.invoke_MT(java.base/LambdaForm$MH)\n" +
+ "4: java.base/java.lang.invoke.LambdaForm$DMH/2008017533.invokeVirtual_LL_V(LambdaForm$DMH)\n" +
+ "5: java.base/java.lang.invoke.LambdaForm$MH/1395089624.invoke_MT(LambdaForm$MH)\n" +
"6: VerifyStackTrace$Handle.run(VerifyStackTrace.java:162)\n" +
"7: VerifyStackTrace.invoke(VerifyStackTrace.java:192)\n" +
- "8: jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(java.base/Native Method)\n" +
- "9: jdk.internal.reflect.NativeMethodAccessorImpl.invoke(java.base/NativeMethodAccessorImpl.java:62)\n" +
- "10: jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(java.base/DelegatingMethodAccessorImpl.java:43)\n" +
- "11: java.lang.reflect.Method.invoke(java.base/Method.java:520)\n" +
+ "8: java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n" +
+ "9: java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\n" +
+ "10: java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n" +
+ "11: java.base/java.lang.reflect.Method.invoke(Method.java:520)\n" +
"12: VerifyStackTrace$1.run(VerifyStackTrace.java:222)\n" +
- "13: java.security.AccessController.doPrivileged(java.base/Native Method)\n" +
+ "13: java.base/java.security.AccessController.doPrivileged(Native Method)\n" +
"14: VerifyStackTrace.test(VerifyStackTrace.java:231)\n" +
"15: VerifyStackTrace.main(VerifyStackTrace.java:188)\n";
@@ -201,8 +201,6 @@
// out before comparing. We also erase the hash-like names of
// synthetic frames introduced by lambdas & method handles
return produced.replaceAll(":[1-9][0-9]*\\)", ":00)")
- .replaceAll("-internal/", "/").replaceAll("-ea/", "/")
- .replaceAll("java.base@(\\d+\\.){0,3}(\\d+)/", "java.base/")
.replaceAll("/[0-9]+\\.run", "/xxxxxxxx.run")
.replaceAll("/[0-9]+\\.invoke", "/xxxxxxxx.invoke")
// LFs may or may not be pre-generated, making frames differ
--- a/jdk/test/java/lang/annotation/AnnotationToStringTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/test/java/lang/annotation/AnnotationToStringTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 8162817
+ * @bug 8162817 8168921
* @summary Test of toString on normal annotations
*/
@@ -70,6 +70,8 @@
"d1=1.0/0.0, " +
"l0=5, " +
"l1=9223372036854775807L, " +
+ "l2=-9223372036854775808L, " +
+ "l3=-2147483648, " +
"s0=\"Hello world.\", " +
"s1=\"a\\\"b\", " +
"class0=Obj[].class)")
@@ -84,6 +86,8 @@
d1=2.0/0.0,
l0=5,
l1=Long.MAX_VALUE,
+ l2=Long.MIN_VALUE,
+ l3=Integer.MIN_VALUE,
s0="Hello world.",
s1="a\"b",
class0=Obj[].class
@@ -185,8 +189,10 @@
public int[] f6;
@ExpectedString(
- "@LongArray(value={-2147483647, 2147483648L, 9223372036854775807L})")
- @LongArray(value={-Integer.MAX_VALUE, Integer.MAX_VALUE+1L, Long.MAX_VALUE})
+ "@LongArray(value={-9223372036854775808L, -2147483649L, -2147483648," +
+ " -2147483647, 2147483648L, 9223372036854775807L})")
+ @LongArray(value={Long.MIN_VALUE, Integer.MIN_VALUE-1L, Integer.MIN_VALUE,
+ -Integer.MAX_VALUE, Integer.MAX_VALUE+1L, Long.MAX_VALUE})
public long[] f7;
@ExpectedString(
@@ -287,6 +293,8 @@
double d1();
long l0();
long l1();
+ long l2();
+ long l3();
String s0();
String s1();
Class<?> class0();
--- a/jdk/test/java/lang/invoke/LoopCombinatorTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/test/java/lang/invoke/LoopCombinatorTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -33,6 +33,7 @@
* @bug 8153637
* @bug 8154751
* @bug 8154754
+ * @bug 8167974
* @run testng/othervm -ea -esa test.java.lang.invoke.LoopCombinatorTest
*/
@@ -800,7 +801,8 @@
{l_it, l_i, isl_i, ""},
{l_it, null, sl_v, ""},
{li_it, li_i, isli_i, ""},
- {il_it, null, sil_v, "inferred first loop argument must inherit from Iterable: int"},
+ {null, null, sil_v, "inferred first loop argument must inherit from Iterable: int"},
+ {il_it, null, sil_v, ""},
{li_it, null, sli_v, ""},
{sl_v, null, sl_v, "iteratedLoop first argument must have Iterator return type"},
{li_it, l_it, sl_v,
--- a/jdk/test/java/lang/management/CompositeData/ThreadInfoCompositeData.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/test/java/lang/management/CompositeData/ThreadInfoCompositeData.java Wed Nov 09 10:04:43 2016 -0800
@@ -337,9 +337,10 @@
};
private static final String[] steItemNames = {
- "className",
+ "classLoaderName",
"moduleName",
"moduleVersion",
+ "className",
"methodName",
"fileName",
"lineNumber",
@@ -362,9 +363,10 @@
validItemTypes[STACK_TRACE] = new ArrayType(1, steCType);
final Object[] steValue = {
- ste[0].getClassName(),
+ ste[0].getClassLoaderName(),
ste[0].getModuleName(),
ste[0].getModuleVersion(),
+ ste[0].getClassName(),
ste[0].getMethodName(),
ste[0].getFileName(),
new Integer(ste[0].getLineNumber()),
--- a/jdk/test/java/net/URLClassLoader/NullURLTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/test/java/net/URLClassLoader/NullURLTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -109,7 +109,7 @@
failures++;
}
try {
- loader = new URLClassLoader(null, null, null);
+ loader = new URLClassLoader((URL[])null, null, null);
System.err.println("URLClassLoader(null, null, null) did not throw NPE");
failures++;
} catch (NullPointerException e) {
--- a/jdk/test/java/net/URLPermission/nstest/LookupTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/test/java/net/URLPermission/nstest/LookupTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -22,124 +22,195 @@
*/
/**
- * This is a simple smoke test of the HttpURLPermission mechanism, which
- * checks for either IOException (due to unknown host) or SecurityException
- * due to lack of permission to connect
+ * @test
+ * @summary A simple smoke test of the HttpURLPermission mechanism, which checks
+ * for either IOException (due to unknown host) or SecurityException
+ * due to lack of permission to connect
+ * @run main/othervm LookupTest
*/
-import java.net.*;
-import java.io.*;
-import jdk.testlibrary.Utils;
+import java.io.BufferedWriter;
+import java.io.FilePermission;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+import java.net.NetPermission;
+import java.net.ProxySelector;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.net.SocketPermission;
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.URLPermission;
+import java.security.CodeSource;
+import java.security.Permission;
+import java.security.PermissionCollection;
+import java.security.Permissions;
+import java.security.Policy;
+import java.security.ProtectionDomain;
+import static java.nio.charset.StandardCharsets.US_ASCII;
public class LookupTest {
- static void test(
- String url, boolean throwsSecException, boolean throwsIOException)
- {
+ static int port;
+ static volatile ServerSocket serverSocket;
+
+ static void test(String url,
+ boolean throwsSecException,
+ boolean throwsIOException) {
+ ProxySelector.setDefault(null);
+ URL u;
+ InputStream is = null;
try {
- ProxySelector.setDefault(null);
- URL u = new URL(url);
- System.err.println ("Connecting to " + u);
+ u = new URL(url);
+ System.err.println("Connecting to " + u);
URLConnection urlc = u.openConnection();
- InputStream is = urlc.getInputStream();
+ is = urlc.getInputStream();
} catch (SecurityException e) {
if (!throwsSecException) {
- throw new RuntimeException ("(1) was not expecting ", e);
+ throw new RuntimeException("Unexpected SecurityException:", e);
+ }
+ return;
+ } catch (IOException e) {
+ if (!throwsIOException) {
+ System.err.println("Unexpected IOException:" + e.getMessage());
+ throw new RuntimeException(e);
}
return;
- } catch (IOException ioe) {
- if (!throwsIOException) {
- throw new RuntimeException ("(2) was not expecting ", ioe);
+ } finally {
+ if (is != null) {
+ try {
+ is.close();
+ } catch (IOException e) {
+ System.err.println("Unexpected IOException:" + e.getMessage());
+ throw new RuntimeException(e);
+ }
}
- return;
}
+
if (throwsSecException || throwsIOException) {
- System.err.printf ("was expecting a %s\n", throwsSecException ?
- "security exception" : "IOException");
+ System.err.printf("was expecting a %s\n", throwsSecException
+ ? "security exception" : "IOException");
throw new RuntimeException("was expecting an exception");
}
}
- static int port;
- static ServerSocket serverSocket;
+ static final String CWD = System.getProperty("user.dir", ".");
public static void main(String args[]) throws Exception {
-
-
- String cmd = args[0];
- if (cmd.equals("-getport")) {
- port = Utils.getFreePort();
- System.out.print(port);
- } else if (cmd.equals("-runtest")) {
- port = Integer.parseInt(args[1]);
- String hostsFileName = System.getProperty("user.dir", ".") + "/LookupTestHosts";
- System.setProperty("jdk.net.hosts.file", hostsFileName);
- addMappingToHostsFile("allowedAndFound.com", "127.0.0.1", hostsFileName, false);
- addMappingToHostsFile("notAllowedButFound.com", "99.99.99.99", hostsFileName, true);
- // name "notAllowedAndNotFound.com" is not in map
- // name "allowedButNotfound.com" is not in map
- try {
- startServer();
-
- System.setSecurityManager(new SecurityManager());
-
- test("http://allowedAndFound.com:" + port + "/foo", false, false);
-
- test("http://notAllowedButFound.com:" + port + "/foo", true, false);
-
- test("http://allowedButNotfound.com:" + port + "/foo", false, true);
-
- test("http://notAllowedAndNotFound.com:" + port + "/foo", true, false);
- } finally {
- serverSocket.close();
- }
- } else {
- throw new RuntimeException("Bad invocation: " + cmd);
+ String hostsFileName = CWD + "/LookupTestHosts";
+ System.setProperty("jdk.net.hosts.file", hostsFileName);
+ addMappingToHostsFile("allowedAndFound.com",
+ "127.0.0.1",
+ hostsFileName,
+ false);
+ addMappingToHostsFile("notAllowedButFound.com",
+ "99.99.99.99",
+ hostsFileName,
+ true);
+ // name "notAllowedAndNotFound.com" is not in map
+ // name "allowedButNotfound.com" is not in map
+ Server server = new Server();
+ try {
+ Policy.setPolicy(new LookupTestPolicy());
+ System.setSecurityManager(new SecurityManager());
+ server.start();
+ test("http://allowedAndFound.com:" + port + "/foo", false, false);
+ test("http://notAllowedButFound.com:" + port + "/foo", true, false);
+ test("http://allowedButNotfound.com:" + port + "/foo", false, true);
+ test("http://notAllowedAndNotFound.com:" + port + "/foo", true, false);
+ } finally {
+ server.terminate();
}
}
- static Thread server;
+ static class Server extends Thread {
+ private volatile boolean done;
- static class Server extends Thread {
+ public Server() throws IOException {
+ serverSocket = new ServerSocket(0);
+ port = serverSocket.getLocalPort();
+ }
+
public void run() {
- byte[] buf = new byte[1000];
try {
- while (true) {
- Socket s = serverSocket.accept();
- InputStream i = s.getInputStream();
- i.read(buf);
- OutputStream o = s.getOutputStream();
- String rsp = "HTTP/1.1 200 Ok\r\n" +
- "Connection: close\r\nContent-length: 0\r\n\r\n";
- o.write(rsp.getBytes());
- o.close();
+ while (!done) {
+ try (Socket s = serverSocket.accept()) {
+ readOneRequest(s.getInputStream());
+ OutputStream o = s.getOutputStream();
+ String rsp = "HTTP/1.1 200 Ok\r\n" +
+ "Connection: close\r\n" +
+ "Content-length: 0\r\n\r\n";
+ o.write(rsp.getBytes(US_ASCII));
+ }
}
} catch (IOException e) {
- return;
+ if (!done)
+ e.printStackTrace();
}
- }
- }
+ }
+
+ void terminate() {
+ done = true;
+ try { serverSocket.close(); }
+ catch (IOException unexpected) { unexpected.printStackTrace(); }
+ }
+
+ static final byte[] requestEnd = new byte[] {'\r', '\n', '\r', '\n' };
- static void startServer() {
- try {
- serverSocket = new ServerSocket(port);
- server = new Server();
- server.start();
- } catch (Exception e) {
- throw new RuntimeException ("Test failed to initialize", e);
+ // Read until the end of a HTTP request
+ void readOneRequest(InputStream is) throws IOException {
+ int requestEndCount = 0, r;
+ while ((r = is.read()) != -1) {
+ if (r == requestEnd[requestEndCount]) {
+ requestEndCount++;
+ if (requestEndCount == 4) {
+ break;
+ }
+ } else {
+ requestEndCount = 0;
+ }
+ }
}
}
- private static void addMappingToHostsFile (String host,
- String addr,
- String hostsFileName,
- boolean append)
- throws Exception {
+ private static void addMappingToHostsFile(String host,
+ String addr,
+ String hostsFileName,
+ boolean append)
+ throws IOException
+ {
String mapping = addr + " " + host;
- try (PrintWriter hfPWriter = new PrintWriter(new BufferedWriter(
- new FileWriter(hostsFileName, append)))) {
+ try (FileWriter fr = new FileWriter(hostsFileName, append);
+ PrintWriter hfPWriter = new PrintWriter(new BufferedWriter(fr))) {
hfPWriter.println(mapping);
-}
+ }
}
+ static class LookupTestPolicy extends Policy {
+ final PermissionCollection perms = new Permissions();
+
+ LookupTestPolicy() throws Exception {
+ perms.add(new NetPermission("setProxySelector"));
+ perms.add(new SocketPermission("localhost:1024-", "resolve,accept"));
+ perms.add(new URLPermission("http://allowedAndFound.com:" + port + "/-", "*:*"));
+ perms.add(new URLPermission("http://allowedButNotfound.com:" + port + "/-", "*:*"));
+ perms.add(new FilePermission("<<ALL FILES>>", "read,write,delete"));
+ //perms.add(new PropertyPermission("java.io.tmpdir", "read"));
+ }
+
+ public PermissionCollection getPermissions(ProtectionDomain domain) {
+ return perms;
+ }
+
+ public PermissionCollection getPermissions(CodeSource codesource) {
+ return perms;
+ }
+
+ public boolean implies(ProtectionDomain domain, Permission perm) {
+ return perms.implies(perm);
+ }
+ }
}
--- a/jdk/test/java/net/URLPermission/nstest/lookup.sh Wed Nov 09 15:20:30 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,63 +0,0 @@
-#!/bin/sh
-#
-# Copyright (c) 2013, 2016 Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-# @test
-# @library /lib/testlibrary
-# @build jdk.testlibrary.*
-# @compile -XDignore.symbol.file=true LookupTest.java
-# @run shell/timeout=50 lookup.sh
-# @key intermittent
-#
-
-OS=`uname -s`
-case ${OS} in
-Windows_* | CYGWIN*)
- PS=";"
- FS="\\"
- ;;
-*)
- PS=":"
- FS="/"
- ;;
-esac
-
-port=`${TESTJAVA}/bin/java -cp ${TESTCLASSPATH} LookupTest -getport`
-
-cat << POLICY > policy
-grant {
- permission java.net.URLPermission "http://allowedAndFound.com:${port}/-", "*:*";
- permission java.net.URLPermission "http://allowedButNotfound.com:${port}/-", "*:*";
- permission java.net.NetPermission "setProxySelector";
- permission java.io.FilePermission "<<ALL FILES>>", "read,write,delete";
- permission java.util.PropertyPermission "java.io.tmpdir", "read";
-
- // needed for HttpServer
- permission "java.net.SocketPermission" "localhost:1024-", "resolve,accept";
-};
-POLICY
-
-${TESTJAVA}/bin/java ${TESTVMOPTS} \
- -Djava.security.policy=file:./policy \
- -Dtest.src=${TESTSRC} \
- -cp ${TESTCLASSPATH}${PS}${TESTSRC} LookupTest -runtest ${port}
--- a/jdk/test/java/net/httpclient/APIErrors.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/test/java/net/httpclient/APIErrors.java Wed Nov 09 10:04:43 2016 -0800
@@ -21,10 +21,11 @@
* questions.
*/
-/**
+/*
* @test
* @bug 8087112
* @modules java.httpclient
+ * java.logging
* jdk.httpserver
* @library /lib/testlibrary/
* @build jdk.testlibrary.SimpleSSLContext ProxyServer
@@ -35,13 +36,23 @@
*/
//package javaapplication16;
-import com.sun.net.httpserver.*;
+import com.sun.net.httpserver.HttpContext;
+import com.sun.net.httpserver.HttpHandler;
+import com.sun.net.httpserver.HttpServer;
+import com.sun.net.httpserver.HttpsServer;
import java.io.IOException;
-import java.net.*;
-import java.net.http.*;
+import java.net.InetSocketAddress;
+import java.net.PasswordAuthentication;
+import java.net.ProxySelector;
+import java.net.URI;
+import java.net.http.HttpClient;
+import java.net.http.HttpRequest;
+import java.net.http.HttpResponse;
import java.util.LinkedList;
import java.util.List;
-import java.util.concurrent.*;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ExecutorService;
import java.util.function.Supplier;
/**
--- a/jdk/test/java/net/httpclient/ManyRequests.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/test/java/net/httpclient/ManyRequests.java Wed Nov 09 10:04:43 2016 -0800
@@ -21,10 +21,11 @@
* questions.
*/
-/**
+/*
* @test
* @bug 8087112
* @modules java.httpclient
+ * java.logging
* jdk.httpserver
* @library /lib/testlibrary/ /
* @build jdk.testlibrary.SimpleSSLContext EchoHandler
@@ -36,7 +37,9 @@
//package javaapplication16;
-import com.sun.net.httpserver.*;
+import com.sun.net.httpserver.HttpsConfigurator;
+import com.sun.net.httpserver.HttpsParameters;
+import com.sun.net.httpserver.HttpsServer;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.net.http.HttpClient;
@@ -48,9 +51,10 @@
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Random;
-import java.util.logging.*;
+import java.util.logging.Logger;
+import java.util.logging.Level;
import java.util.concurrent.CompletableFuture;
-import javax.net.ssl.*;
+import javax.net.ssl.SSLContext;
import jdk.testlibrary.SimpleSSLContext;
public class ManyRequests {
--- a/jdk/test/java/net/httpclient/RequestBodyTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/test/java/net/httpclient/RequestBodyTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -21,9 +21,10 @@
* questions.
*/
-/**
+/*
* @test @bug 8087112
* @modules java.httpclient
+ * java.logging
* jdk.httpserver
* @library /lib/testlibrary/ /
* @compile ../../../com/sun/net/httpserver/LogFilter.java
--- a/jdk/test/java/net/httpclient/SmokeTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/test/java/net/httpclient/SmokeTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -21,10 +21,11 @@
* questions.
*/
-/**
+/*
* @test
* @bug 8087112
* @modules java.httpclient
+ * java.logging
* jdk.httpserver
* @library /lib/testlibrary/ /
* @build jdk.testlibrary.SimpleSSLContext ProxyServer EchoHandler
@@ -33,13 +34,40 @@
* @run main/othervm SmokeTest
*/
-import com.sun.net.httpserver.*;
-import java.net.*;
-import java.net.http.*;
-import java.io.*;
-import java.util.concurrent.*;
-import javax.net.ssl.*;
-import java.nio.file.*;
+import com.sun.net.httpserver.Headers;
+import com.sun.net.httpserver.HttpContext;
+import com.sun.net.httpserver.HttpExchange;
+import com.sun.net.httpserver.HttpHandler;
+import com.sun.net.httpserver.HttpServer;
+import com.sun.net.httpserver.HttpsConfigurator;
+import com.sun.net.httpserver.HttpsParameters;
+import com.sun.net.httpserver.HttpsServer;
+import java.net.InetSocketAddress;
+import java.net.PasswordAuthentication;
+import java.net.ProxySelector;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.net.URI;
+import java.net.http.HttpClient;
+import java.net.http.HttpRequest;
+import java.net.http.HttpResponse;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.CompletionException;
+import java.util.concurrent.CyclicBarrier;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLParameters;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
--- a/jdk/test/java/net/httpclient/security/Driver.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/test/java/net/httpclient/security/Driver.java Wed Nov 09 10:04:43 2016 -0800
@@ -28,6 +28,7 @@
* @bug 8087112
* @library /lib/testlibrary/
* @modules java.httpclient
+ * java.logging
* jdk.httpserver
* @build jdk.testlibrary.SimpleSSLContext jdk.testlibrary.Utils
* @compile ../../../../com/sun/net/httpserver/LogFilter.java
--- a/jdk/test/java/net/httpclient/security/Security.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/test/java/net/httpclient/security/Security.java Wed Nov 09 10:04:43 2016 -0800
@@ -23,10 +23,11 @@
* questions.
*/
-/**
+/*
* @test
* @bug 8087112
* @modules java.httpclient
+ * java.logging
* jdk.httpserver
* @library /lib/testlibrary/
* @build jdk.testlibrary.SimpleSSLContext
@@ -50,14 +51,27 @@
// Tests 1, 10, 11 and 12 executed from Driver
-import com.sun.net.httpserver.*;
+import com.sun.net.httpserver.Headers;
+import com.sun.net.httpserver.HttpContext;
+import com.sun.net.httpserver.HttpExchange;
+import com.sun.net.httpserver.HttpHandler;
+import com.sun.net.httpserver.HttpServer;
+import com.sun.net.httpserver.HttpsServer;
import java.io.IOException;
import java.io.InputStream;
import java.io.File;
import java.io.OutputStream;
import java.lang.reflect.Constructor;
-import java.net.*;
-import java.net.http.*;
+import java.net.BindException;
+import java.net.InetSocketAddress;
+import java.net.ProxySelector;
+import java.net.URI;
+import java.net.URLClassLoader;
+import java.net.URL;
+import java.net.http.HttpHeaders;
+import java.net.http.HttpClient;
+import java.net.http.HttpRequest;
+import java.net.http.HttpResponse;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -66,13 +80,15 @@
import java.nio.file.StandardCopyOption;
import java.util.LinkedList;
import java.util.List;
-import java.util.concurrent.*;
-import java.util.function.*;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ExecutorService;
+import java.util.function.LongConsumer;
import java.util.logging.ConsoleHandler;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.lang.reflect.InvocationTargetException;
-import java.net.BindException;
/**
* Security checks test
--- a/jdk/test/java/net/ipv6tests/Tests.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/test/java/net/ipv6tests/Tests.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -139,11 +139,17 @@
/* check the time got is within 50% of the time expected */
public static void checkTime (long got, long expected) {
- dprintln ("checkTime: got " + got + " expected " + expected);
- long upper = expected + (expected / 2);
- long lower = expected - (expected / 2);
+ checkTime(got, expected, expected);
+ }
+
+ /* check the time got is between start and end, given 50% tolerance */
+ public static void checkTime(long got, long start, long end) {
+ dprintln("checkTime: got = " + got + " start = " + start + " end = " + end);
+ long upper = end + (end / 2);
+ long lower = start - (start / 2);
if (got > upper || got < lower) {
- throw new RuntimeException ("checkTime failed: got " + got + " expected " + expected);
+ throw new RuntimeException("checkTime failed: got " + got
+ + ", expected between " + start + " and " + end);
}
}
--- a/jdk/test/java/net/ipv6tests/UdpTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/test/java/net/ipv6tests/UdpTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -24,7 +24,6 @@
/*
* @test
* @bug 4868820
- * @key intermittent
* @summary IPv6 support for Windows XP and 2003 server
*/
@@ -159,7 +158,7 @@
});
t1 = System.currentTimeMillis();
s1.receive (new DatagramPacket (new byte [128], 128));
- checkTime (System.currentTimeMillis() - t1, 4000);
+ checkTime (System.currentTimeMillis() - t1, 2000, 10000);
s1.close ();
s2.close ();
System.out.println ("Test2: OK");
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/security/misc/GetInstanceNullsEmpties.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,696 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.security.*;
+import java.security.cert.*;
+import javax.crypto.*;
+import javax.net.ssl.*;
+import javax.security.auth.login.*;
+import java.lang.reflect.*;
+import java.util.Arrays;
+
+/*
+ * @test
+ * @bug 4985694
+ * @summary Incomplete spec for most of the getInstances
+ */
+/**
+ * A simple test to see what is being thrown when null Strings are passed
+ * to the various getInstance() methods.
+ *
+ * These tests use various algorithm names that don't exist (e.g. "FOO"
+ * Ciphers). Just need something non-null for testing, as the tests will throw
+ * exceptions before trying to instantiate a real object.
+ */
+public class GetInstanceNullsEmpties {
+
+ private static final Provider SUN = Security.getProvider("SUN");
+
+ /*
+ * See if there are more than "expected" number of getInstance() methods,
+ * which will indicate to developers that this test needs an update.
+ */
+ private static void checkNewMethods(Class<?> clazz, int expected)
+ throws Exception {
+
+ long found = Arrays.stream(clazz.getMethods())
+ .filter(name -> name.getName().equals("getInstance"))
+ .count();
+
+ if (found != expected) {
+ throw new Exception("Number of getInstance() mismatch: "
+ + expected + " expected, " + found + " found");
+ }
+ }
+
+ /**
+ * Main loop.
+ */
+ public static void main(String[] args) throws Exception {
+
+ /*
+ * JCA
+ */
+ testAlgorithmParameterGenerator();
+ testAlgorithmParameters();
+ testCertificateFactory();
+ testCertPathBuilder();
+ testCertPathValidator();
+ testCertStore();
+ testKeyFactory();
+ testKeyPairGenerator();
+ testKeyStore();
+ testMessageDigest();
+ testPolicy();
+ testSecureRandom();
+ testSignature();
+
+ /*
+ * JCE
+ */
+ testCipher();
+ testExemptionMechanism();
+ testKeyAgreement();
+ testKeyGenerator();
+ testMac();
+ testSecretKeyFactory();
+
+ /*
+ * JSSE
+ */
+ testKeyManagerFactory();
+ testSSLContext();
+ testTrustManagerFactory();
+
+ /*
+ * JGSS
+ *
+ * KeyTab.getInstance doesn't take algorithm names, so we'll
+ * ignore this one.
+ */
+ testConfiguration();
+
+ System.out.println("\nTEST PASSED!");
+ }
+
+ private static Method getInstance(Class clazz, Class... args)
+ throws Exception {
+ boolean firstPrinted = false;
+
+ System.out.print("\n" + clazz.getName() + "(");
+ for (Class c : args) {
+ System.out.print(firstPrinted
+ ? ", " + c.getName() : c.getName());
+ firstPrinted = true;
+ }
+ System.out.println("):");
+
+ return clazz.getMethod("getInstance", args);
+ }
+
+ private static void run(Method m, Class expectedException,
+ Object... args) throws Exception {
+
+ try {
+ m.invoke(null, args);
+ throw new Exception("Didn't throw exception");
+ } catch (InvocationTargetException ite) {
+ Throwable root = ite.getCause();
+ if (root instanceof Exception) {
+ Exception e = (Exception) root;
+ if (expectedException.isInstance(e)) {
+ System.out.print("OK ");
+ return;
+ } else {
+ System.out.println(
+ "Unexpected InvocationTargetException!");
+ throw e;
+ }
+ }
+ throw ite;
+ }
+ }
+
+ /*
+ * Constants so lines aren't so long.
+ */
+ private static final Class STRING = String.class;
+ private static final Class PROVIDER = Provider.class;
+
+ private static void testAlgorithmParameterGenerator() throws Exception {
+ Class clazz = AlgorithmParameterGenerator.class;
+ Method m;
+
+ checkNewMethods(clazz, 3);
+
+ m = getInstance(clazz, STRING);
+ run(m, NullPointerException.class, (Object) null);
+ run(m, NoSuchAlgorithmException.class, "");
+
+ m = getInstance(clazz, STRING, STRING);
+ run(m, NullPointerException.class, null, "SUN");
+ run(m, NoSuchAlgorithmException.class, "", "SUN");
+ run(m, IllegalArgumentException.class, "FOO", null);
+ run(m, IllegalArgumentException.class, "FOO", "");
+
+ m = getInstance(clazz, STRING, PROVIDER);
+ run(m, NullPointerException.class, null, SUN);
+ run(m, NoSuchAlgorithmException.class, "", SUN);
+ run(m, IllegalArgumentException.class, "FOO", null);
+ }
+
+ private static void testAlgorithmParameters() throws Exception {
+ Class clazz = AlgorithmParameters.class;
+ Method m;
+
+ checkNewMethods(clazz, 3);
+
+ m = getInstance(clazz, STRING);
+ run(m, NullPointerException.class, (Object) null);
+ run(m, NoSuchAlgorithmException.class, "");
+
+ m = getInstance(clazz, STRING, STRING);
+ run(m, NullPointerException.class, null, "SUN");
+ run(m, NoSuchAlgorithmException.class, "", "SUN");
+ run(m, IllegalArgumentException.class, "FOO", null);
+ run(m, IllegalArgumentException.class, "FOO", "");
+
+ m = getInstance(clazz, STRING, PROVIDER);
+ run(m, NullPointerException.class, null, SUN);
+ run(m, NoSuchAlgorithmException.class, "", SUN);
+ run(m, IllegalArgumentException.class, "FOO", null);
+ }
+
+ private static void testCertPathBuilder() throws Exception {
+ Class clazz = CertPathBuilder.class;
+ Method m;
+
+ checkNewMethods(clazz, 3);
+
+ m = getInstance(clazz, STRING);
+ run(m, NullPointerException.class, (Object) null);
+ run(m, NoSuchAlgorithmException.class, "");
+
+ m = getInstance(clazz, STRING, STRING);
+ run(m, NullPointerException.class, null, "SUN");
+ run(m, NoSuchAlgorithmException.class, "", "SUN");
+ run(m, IllegalArgumentException.class, "FOO", null);
+ run(m, IllegalArgumentException.class, "FOO", "");
+
+ m = getInstance(clazz, STRING, PROVIDER);
+ run(m, NullPointerException.class, null, SUN);
+ run(m, NoSuchAlgorithmException.class, "", SUN);
+ run(m, IllegalArgumentException.class, "FOO", null);
+ }
+
+ private static void testCertPathValidator() throws Exception {
+ Class clazz = CertPathValidator.class;
+ Method m;
+
+ checkNewMethods(clazz, 3);
+
+ m = getInstance(clazz, STRING);
+ run(m, NullPointerException.class, (Object) null);
+ run(m, NoSuchAlgorithmException.class, "");
+
+ m = getInstance(clazz, STRING, STRING);
+ run(m, NullPointerException.class, null, "SUN");
+ run(m, NoSuchAlgorithmException.class, "", "SUN");
+ run(m, IllegalArgumentException.class, "FOO", null);
+ run(m, IllegalArgumentException.class, "FOO", "");
+
+ m = getInstance(clazz, STRING, PROVIDER);
+ run(m, NullPointerException.class, null, SUN);
+ run(m, NoSuchAlgorithmException.class, "", SUN);
+ run(m, IllegalArgumentException.class, "FOO", null);
+ }
+
+ private static void testCertStore() throws Exception {
+ Class clazz = CertStore.class;
+ Method m;
+ CertStoreParameters csp = () -> null;
+
+ checkNewMethods(clazz, 3);
+
+ m = getInstance(clazz, STRING, CertStoreParameters.class);
+ run(m, NullPointerException.class, (Object) null, csp);
+ run(m, NoSuchAlgorithmException.class, "", csp);
+
+ m = getInstance(clazz, STRING, CertStoreParameters.class, STRING);
+ run(m, NullPointerException.class, null, csp, "SUN");
+ run(m, NoSuchAlgorithmException.class, "", csp, "SUN");
+ run(m, IllegalArgumentException.class, "FOO", csp, null);
+ run(m, IllegalArgumentException.class, "FOO", csp, "");
+
+ m = getInstance(clazz, STRING, CertStoreParameters.class, PROVIDER);
+ run(m, NullPointerException.class, null, csp, SUN);
+ run(m, NoSuchAlgorithmException.class, "", csp, SUN);
+ run(m, IllegalArgumentException.class, "FOO", csp, null);
+ }
+
+ private static void testCertificateFactory() throws Exception {
+ Class clazz = CertificateFactory.class;
+ Method m;
+
+ checkNewMethods(clazz, 3);
+
+ m = getInstance(clazz, STRING);
+ run(m, NullPointerException.class, (Object) null);
+ run(m, CertificateException.class, "");
+
+ m = getInstance(clazz, STRING, STRING);
+ run(m, NullPointerException.class, null, "SUN");
+ run(m, CertificateException.class, "", "SUN");
+ run(m, IllegalArgumentException.class, "FOO", null);
+ run(m, IllegalArgumentException.class, "FOO", "");
+
+ m = getInstance(clazz, STRING, PROVIDER);
+ run(m, NullPointerException.class, null, SUN);
+ run(m, CertificateException.class, "", SUN);
+ run(m, IllegalArgumentException.class, "FOO", null);
+ }
+
+ private static void testCipher() throws Exception {
+ Class clazz = Cipher.class;
+ Method m;
+
+ checkNewMethods(clazz, 3);
+
+ /*
+ * Note the Cipher API is spec'd to throw a NoSuchAlgorithmException
+ * for a null transformation.
+ */
+ m = getInstance(clazz, STRING);
+ run(m, NoSuchAlgorithmException.class, (Object) null);
+ run(m, NoSuchAlgorithmException.class, "");
+
+ m = getInstance(clazz, STRING, STRING);
+ run(m, NoSuchAlgorithmException.class, null, "SUN");
+ run(m, NoSuchAlgorithmException.class, "", "SUN");
+ run(m, IllegalArgumentException.class, "FOO", null);
+ run(m, IllegalArgumentException.class, "FOO", "");
+
+ m = getInstance(clazz, STRING, PROVIDER);
+ run(m, NoSuchAlgorithmException.class, null, SUN);
+ run(m, NoSuchAlgorithmException.class, "", SUN);
+ run(m, IllegalArgumentException.class, "FOO", null);
+ }
+
+ private static void testConfiguration() throws Exception {
+ Class clazz = Configuration.class;
+ Method m;
+ Configuration.Parameters cp = new Configuration.Parameters() {
+ };
+
+ checkNewMethods(clazz, 3);
+
+ m = getInstance(clazz, STRING, Configuration.Parameters.class);
+ run(m, NullPointerException.class, (Object) null, cp);
+ run(m, NoSuchAlgorithmException.class, "", cp);
+
+ m = getInstance(clazz, STRING, Configuration.Parameters.class, STRING);
+ run(m, NullPointerException.class, null, cp, "SUN");
+ run(m, NoSuchAlgorithmException.class, "", cp, "SUN");
+ run(m, IllegalArgumentException.class, "FOO", cp, null);
+ run(m, IllegalArgumentException.class, "FOO", cp, "");
+
+ m = getInstance(clazz, STRING, Configuration.Parameters.class,
+ PROVIDER);
+ run(m, NullPointerException.class, null, cp, SUN);
+ run(m, NoSuchAlgorithmException.class, "", cp, SUN);
+ run(m, IllegalArgumentException.class, "FOO", cp, null);
+ }
+
+ private static void testExemptionMechanism() throws Exception {
+ Class clazz = ExemptionMechanism.class;
+ Method m;
+
+ checkNewMethods(clazz, 3);
+
+ m = getInstance(clazz, STRING);
+ run(m, NullPointerException.class, (Object) null);
+ run(m, NoSuchAlgorithmException.class, "");
+
+ m = getInstance(clazz, STRING, STRING);
+ run(m, NullPointerException.class, null, "SUN");
+ run(m, NoSuchAlgorithmException.class, "", "SUN");
+ run(m, IllegalArgumentException.class, "FOO", null);
+ run(m, IllegalArgumentException.class, "FOO", "");
+
+ m = getInstance(clazz, STRING, PROVIDER);
+ run(m, NullPointerException.class, null, SUN);
+ run(m, NoSuchAlgorithmException.class, "", SUN);
+ run(m, IllegalArgumentException.class, "FOO", null);
+ }
+
+ private static void testKeyAgreement() throws Exception {
+ Class clazz = KeyAgreement.class;
+ Method m;
+
+ checkNewMethods(clazz, 3);
+
+ m = getInstance(clazz, STRING);
+ run(m, NullPointerException.class, (Object) null);
+ run(m, NoSuchAlgorithmException.class, "");
+
+ m = getInstance(clazz, STRING, STRING);
+ run(m, NullPointerException.class, null, "SUN");
+ run(m, NoSuchAlgorithmException.class, "", "SUN");
+ run(m, IllegalArgumentException.class, "FOO", null);
+ run(m, IllegalArgumentException.class, "FOO", "");
+
+ m = getInstance(clazz, STRING, PROVIDER);
+ run(m, NullPointerException.class, null, SUN);
+ run(m, NoSuchAlgorithmException.class, "", SUN);
+ run(m, IllegalArgumentException.class, "FOO", null);
+ }
+
+ private static void testKeyFactory() throws Exception {
+ Class clazz = KeyFactory.class;
+ Method m;
+
+ checkNewMethods(clazz, 3);
+
+ m = getInstance(clazz, STRING);
+ run(m, NullPointerException.class, (Object) null);
+ run(m, NoSuchAlgorithmException.class, "");
+
+ m = getInstance(clazz, STRING, STRING);
+ run(m, NullPointerException.class, null, "SUN");
+ run(m, NoSuchAlgorithmException.class, "", "SUN");
+ run(m, IllegalArgumentException.class, "FOO", null);
+ run(m, IllegalArgumentException.class, "FOO", "");
+
+ m = getInstance(clazz, STRING, PROVIDER);
+ run(m, NullPointerException.class, null, SUN);
+ run(m, NoSuchAlgorithmException.class, "", SUN);
+ run(m, IllegalArgumentException.class, "FOO", null);
+ }
+
+ private static void testKeyGenerator() throws Exception {
+ Class clazz = KeyGenerator.class;
+ Method m;
+
+ checkNewMethods(clazz, 3);
+
+ m = getInstance(clazz, STRING);
+ run(m, NullPointerException.class, (Object) null);
+ run(m, NoSuchAlgorithmException.class, "");
+
+ m = getInstance(clazz, STRING, STRING);
+ run(m, NullPointerException.class, null, "SUN");
+ run(m, NoSuchAlgorithmException.class, "", "SUN");
+ run(m, IllegalArgumentException.class, "FOO", null);
+ run(m, IllegalArgumentException.class, "FOO", "");
+
+ m = getInstance(clazz, STRING, PROVIDER);
+ run(m, NullPointerException.class, null, SUN);
+ run(m, NoSuchAlgorithmException.class, "", SUN);
+ run(m, IllegalArgumentException.class, "FOO", null);
+ }
+
+ private static void testKeyManagerFactory() throws Exception {
+ Class clazz = KeyManagerFactory.class;
+ Method m;
+
+ checkNewMethods(clazz, 3);
+
+ m = getInstance(clazz, STRING);
+ run(m, NullPointerException.class, (Object) null);
+ run(m, NoSuchAlgorithmException.class, "");
+
+ m = getInstance(clazz, STRING, STRING);
+ run(m, NullPointerException.class, null, "SUN");
+ run(m, NoSuchAlgorithmException.class, "", "SUN");
+ run(m, IllegalArgumentException.class, "FOO", null);
+ run(m, IllegalArgumentException.class, "FOO", "");
+
+ m = getInstance(clazz, STRING, PROVIDER);
+ run(m, NullPointerException.class, null, SUN);
+ run(m, NoSuchAlgorithmException.class, "", SUN);
+ run(m, IllegalArgumentException.class, "FOO", null);
+ }
+
+ private static void testKeyPairGenerator() throws Exception {
+ Class clazz = KeyPairGenerator.class;
+ Method m;
+
+ checkNewMethods(clazz, 3);
+
+ m = getInstance(clazz, STRING);
+ run(m, NullPointerException.class, (Object) null);
+ run(m, NoSuchAlgorithmException.class, "");
+
+ m = getInstance(clazz, STRING, STRING);
+ run(m, NullPointerException.class, null, "SUN");
+ run(m, NoSuchAlgorithmException.class, "", "SUN");
+ run(m, IllegalArgumentException.class, "FOO", null);
+ run(m, IllegalArgumentException.class, "FOO", "");
+
+ m = getInstance(clazz, STRING, PROVIDER);
+ run(m, NullPointerException.class, null, SUN);
+ run(m, NoSuchAlgorithmException.class, "", SUN);
+ run(m, IllegalArgumentException.class, "FOO", null);
+ }
+
+ private static void testKeyStore() throws Exception {
+ Class clazz = KeyStore.class;
+ Method m;
+
+ /*
+ * There are actually two additional getInstance() methods with File
+ * as the first parameter.
+ */
+ checkNewMethods(clazz, 5);
+
+ m = getInstance(clazz, STRING);
+ run(m, NullPointerException.class, (Object) null);
+ run(m, KeyStoreException.class, "");
+
+ m = getInstance(clazz, STRING, STRING);
+ run(m, NullPointerException.class, null, "SUN");
+ run(m, KeyStoreException.class, "", "SUN");
+ run(m, IllegalArgumentException.class, "FOO", null);
+ run(m, IllegalArgumentException.class, "FOO", "");
+
+ m = getInstance(clazz, STRING, PROVIDER);
+ run(m, NullPointerException.class, null, SUN);
+ run(m, KeyStoreException.class, "", SUN);
+ run(m, IllegalArgumentException.class, "FOO", null);
+ }
+
+ private static void testMac() throws Exception {
+ Class clazz = Mac.class;
+ Method m;
+
+ checkNewMethods(clazz, 3);
+
+ m = getInstance(clazz, STRING);
+ run(m, NullPointerException.class, (Object) null);
+ run(m, NoSuchAlgorithmException.class, "");
+
+ m = getInstance(clazz, STRING, STRING);
+ run(m, NullPointerException.class, null, "SUN");
+ run(m, NoSuchAlgorithmException.class, "", "SUN");
+ run(m, IllegalArgumentException.class, "FOO", null);
+ run(m, IllegalArgumentException.class, "FOO", "");
+
+ m = getInstance(clazz, STRING, PROVIDER);
+ run(m, NullPointerException.class, null, SUN);
+ run(m, NoSuchAlgorithmException.class, "", SUN);
+ run(m, IllegalArgumentException.class, "FOO", null);
+ }
+
+ private static void testMessageDigest() throws Exception {
+ Class clazz = MessageDigest.class;
+ Method m;
+
+ checkNewMethods(clazz, 3);
+
+ m = getInstance(clazz, STRING);
+ run(m, NullPointerException.class, (Object) null);
+ run(m, NoSuchAlgorithmException.class, "");
+
+ m = getInstance(clazz, STRING, STRING);
+ run(m, NullPointerException.class, null, "SUN");
+ run(m, NoSuchAlgorithmException.class, "", "SUN");
+ run(m, IllegalArgumentException.class, "FOO", null);
+ run(m, IllegalArgumentException.class, "FOO", "");
+
+ m = getInstance(clazz, STRING, PROVIDER);
+ run(m, NullPointerException.class, null, SUN);
+ run(m, NoSuchAlgorithmException.class, "", SUN);
+ run(m, IllegalArgumentException.class, "FOO", null);
+ }
+
+ private static void testPolicy() throws Exception {
+ Class clazz = Policy.class;
+ Method m;
+ Policy.Parameters pp = new Policy.Parameters() {
+ };
+
+ checkNewMethods(clazz, 3);
+
+ m = getInstance(clazz, STRING, Policy.Parameters.class);
+ run(m, NullPointerException.class, (Object) null, pp);
+ run(m, NoSuchAlgorithmException.class, "", pp);
+
+ m = getInstance(clazz, STRING, Policy.Parameters.class, STRING);
+ run(m, NullPointerException.class, null, pp, "SUN");
+ run(m, NoSuchAlgorithmException.class, "", pp, "SUN");
+ run(m, IllegalArgumentException.class, "FOO", pp, null);
+ run(m, IllegalArgumentException.class, "FOO", pp, "");
+
+ m = getInstance(clazz, STRING, Policy.Parameters.class, PROVIDER);
+ run(m, NullPointerException.class, null, pp, SUN);
+ run(m, NoSuchAlgorithmException.class, "", pp, SUN);
+ run(m, IllegalArgumentException.class, "FOO", pp, null);
+ }
+
+ private static void testSSLContext() throws Exception {
+ Class clazz = SSLContext.class;
+ Method m;
+
+ checkNewMethods(clazz, 3);
+
+ m = getInstance(clazz, STRING);
+ run(m, NullPointerException.class, (Object) null);
+ run(m, NoSuchAlgorithmException.class, "");
+
+ m = getInstance(clazz, STRING, STRING);
+ run(m, NullPointerException.class, null, "SUN");
+ run(m, NoSuchAlgorithmException.class, "", "SUN");
+ run(m, IllegalArgumentException.class, "FOO", null);
+ run(m, IllegalArgumentException.class, "FOO", "");
+
+ m = getInstance(clazz, STRING, PROVIDER);
+ run(m, NullPointerException.class, null, SUN);
+ run(m, NoSuchAlgorithmException.class, "", SUN);
+ run(m, IllegalArgumentException.class, "FOO", null);
+ }
+
+ private static void testSecretKeyFactory() throws Exception {
+ Class clazz = SecretKeyFactory.class;
+ Method m;
+
+ checkNewMethods(clazz, 3);
+
+ m = getInstance(clazz, STRING);
+ run(m, NullPointerException.class, (Object) null);
+ run(m, NoSuchAlgorithmException.class, "");
+
+ m = getInstance(clazz, STRING, STRING);
+ run(m, NullPointerException.class, null, "SUN");
+ run(m, NoSuchAlgorithmException.class, "", "SUN");
+ run(m, IllegalArgumentException.class, "FOO", null);
+ run(m, IllegalArgumentException.class, "FOO", "");
+
+ m = getInstance(clazz, STRING, PROVIDER);
+ run(m, NullPointerException.class, null, SUN);
+ run(m, NoSuchAlgorithmException.class, "", SUN);
+ run(m, IllegalArgumentException.class, "FOO", null);
+ }
+
+ private static void testSecureRandom() throws Exception {
+ Class clazz = SecureRandom.class;
+ Method m;
+ SecureRandomParameters srp = new SecureRandomParameters() {
+ };
+
+ checkNewMethods(clazz, 6);
+
+ m = getInstance(clazz, STRING);
+ run(m, NullPointerException.class, (Object) null);
+ run(m, NoSuchAlgorithmException.class, "");
+
+ m = getInstance(clazz, STRING, STRING);
+ run(m, NullPointerException.class, null, "SUN");
+ run(m, NoSuchAlgorithmException.class, "", "SUN");
+ run(m, IllegalArgumentException.class, "FOO", null);
+ run(m, IllegalArgumentException.class, "FOO", "");
+
+ m = getInstance(clazz, STRING, PROVIDER);
+ run(m, NullPointerException.class, null, SUN);
+ run(m, NoSuchAlgorithmException.class, "", SUN);
+ run(m, IllegalArgumentException.class, "FOO", null);
+
+ m = getInstance(clazz, STRING, SecureRandomParameters.class);
+ run(m, NullPointerException.class, (Object) null, srp);
+ run(m, NoSuchAlgorithmException.class, "", srp);
+
+ m = getInstance(clazz, STRING, SecureRandomParameters.class, STRING);
+ run(m, NullPointerException.class, null, srp, "SUN");
+ run(m, NoSuchAlgorithmException.class, "", srp, "SUN");
+ run(m, IllegalArgumentException.class, "FOO", srp, null);
+ run(m, IllegalArgumentException.class, "FOO", srp, "");
+
+ m = getInstance(clazz, STRING, SecureRandomParameters.class, PROVIDER);
+ run(m, NullPointerException.class, null, srp, SUN);
+ run(m, NoSuchAlgorithmException.class, "", srp, SUN);
+ run(m, IllegalArgumentException.class, "FOO", srp, null);
+ }
+
+ private static void testSignature() throws Exception {
+ Class clazz = Signature.class;
+ Method m;
+
+ checkNewMethods(clazz, 3);
+
+ m = getInstance(clazz, STRING);
+ run(m, NullPointerException.class, (Object) null);
+ run(m, NoSuchAlgorithmException.class, "");
+
+ m = getInstance(clazz, STRING, STRING);
+ run(m, NullPointerException.class, null, "SUN");
+ run(m, NoSuchAlgorithmException.class, "", "SUN");
+ run(m, IllegalArgumentException.class, "FOO", null);
+ run(m, IllegalArgumentException.class, "FOO", "");
+
+ m = getInstance(clazz, STRING, PROVIDER);
+ run(m, NullPointerException.class, null, SUN);
+ run(m, NoSuchAlgorithmException.class, "", SUN);
+ run(m, IllegalArgumentException.class, "FOO", null);
+ }
+
+ private static void testTrustManagerFactory() throws Exception {
+ Class clazz = TrustManagerFactory.class;
+ Method m;
+
+ checkNewMethods(clazz, 3);
+
+ m = getInstance(clazz, STRING);
+ run(m, NullPointerException.class, (Object) null);
+ run(m, NoSuchAlgorithmException.class, "");
+
+ m = getInstance(clazz, STRING, STRING);
+ run(m, NullPointerException.class, null, "SUN");
+ run(m, NoSuchAlgorithmException.class, "", "SUN");
+ run(m, IllegalArgumentException.class, "FOO", null);
+ run(m, IllegalArgumentException.class, "FOO", "");
+
+ m = getInstance(clazz, STRING, PROVIDER);
+ run(m, NullPointerException.class, null, SUN);
+ run(m, NoSuchAlgorithmException.class, "", SUN);
+ run(m, IllegalArgumentException.class, "FOO", null);
+ }
+}
--- a/jdk/test/java/security/testlibrary/Proc.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/test/java/security/testlibrary/Proc.java Wed Nov 09 10:04:43 2016 -0800
@@ -243,16 +243,23 @@
// Starts the proc
public Proc start() throws IOException {
List<String> cmd = new ArrayList<>();
+ boolean hasModules;
if (launcher != null) {
cmd.add(launcher);
+ File base = new File(launcher).getParentFile().getParentFile();
+ hasModules = new File(base, "modules").exists() ||
+ new File(base, "jmods").exists();
} else {
cmd.add(new File(new File(System.getProperty("java.home"), "bin"),
"java").getPath());
+ hasModules = true;
}
- Stream.of(jdk.internal.misc.VM.getRuntimeArguments())
- .filter(arg -> arg.startsWith("--add-exports="))
- .forEach(cmd::add);
+ if (hasModules) {
+ Stream.of(jdk.internal.misc.VM.getRuntimeArguments())
+ .filter(arg -> arg.startsWith("--add-exports="))
+ .forEach(cmd::add);
+ }
Collections.addAll(cmd, splitProperty("test.vm.opts"));
Collections.addAll(cmd, splitProperty("test.java.opts"));
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/Locale/Bug8166994.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+/*
+ * @test
+ * @bug 8166884
+ * @summary Checks the subsequent call to parse the same language ranges
+ * which must generate the same list of language ranges
+ * i.e. the priority list containing equivalents, as in the
+ * first call
+ */
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Locale;
+import java.util.stream.Collectors;
+
+public class Bug8166994 {
+
+ public static void main(String[] args) {
+ List<String> list = Arrays.asList("ccq-aa", "ybd-aa", "rki-aa");
+ String ranges = "ccq-aa";
+ testParseConsistency(list, ranges);
+
+ // consecutive call to check the language range parse consistency
+ testParseConsistency(list, ranges);
+
+ // another case with ranges consisting of multiple equivalents and
+ // single equivalents
+ list = Arrays.asList("gfx-xz", "oun-xz", "mwj-xz", "vaj-xz",
+ "taj-xy", "tsf-xy");
+ ranges = "gfx-xz, taj-xy";
+ testParseConsistency(list, ranges);
+ // consecutive call to check the language range parse consistency
+ testParseConsistency(list, ranges);
+
+ }
+
+ private static void testParseConsistency(List<String> list, String ranges) {
+ List<String> priorityList = parseRanges(ranges);
+ if (!list.equals(priorityList)) {
+ throw new RuntimeException("Failed to parse the language range ["
+ + ranges + "], Expected: " + list + " Found: "
+ + priorityList);
+ }
+ }
+
+ private static List<String> parseRanges(String s) {
+ return Locale.LanguageRange.parse(s).stream()
+ .map(Locale.LanguageRange::getRange)
+ .collect(Collectors.toList());
+ }
+
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/logging/LogManager/LinkageErrorTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.logging.Handler;
+import java.util.logging.LogRecord;
+import java.util.logging.Logger;
+
+/**
+ * @test 8152515
+ * @summary Checks that LinkageError are ignored when closing handlers
+ * during Shutdown.
+ * @build LinkageErrorTest
+ * @run main/othervm LinkageErrorTest
+ */
+
+public class LinkageErrorTest {
+
+ public static class TestHandler extends Handler {
+
+ private volatile boolean closed;
+ public TestHandler() {
+ INSTANCES.add(this);
+ }
+
+ @Override
+ public void publish(LogRecord record) {
+ }
+
+ @Override
+ public void flush() {
+ }
+
+ @Override
+ public void close() throws SecurityException {
+ closed = true;
+ try {
+ System.out.println(INSTANCES);
+ } catch (Throwable t) {
+ // ignore
+ }
+ throw new LinkageError();
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + "{closed=" + closed + '}';
+ }
+
+ private static final CopyOnWriteArrayList<Handler> INSTANCES
+ = new CopyOnWriteArrayList<>();
+ }
+
+ private static final Logger LOGGER = Logger.getLogger("test");
+ private static final Logger GLOBAL = Logger.getGlobal();
+
+ public static void main(String[] args) {
+ LOGGER.addHandler(new TestHandler());
+ LOGGER.addHandler(new TestHandler());
+ GLOBAL.addHandler(new TestHandler());
+ }
+}
--- a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/ThowableHelper.java Wed Nov 09 15:20:30 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package java.util.stream;
-
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertTrue;
-
-public final class ThowableHelper {
-
- public static void checkException(Class<? extends Exception> ce, Runnable r) {
- Exception caught = null;
- try {
- r.run();
- } catch (Exception e) {
- caught = e;
- }
-
- assertNotNull(caught);
- assertTrue(ce.isInstance(caught));
- }
-
- public static void checkNPE(Runnable r) {
- checkException(NullPointerException.class, r);
- }
-
- public static void checkISE(Runnable r) {
- checkException(IllegalStateException.class, r);
- }
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/ThrowableHelper.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.util.stream;
+
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
+public final class ThrowableHelper {
+
+ public static void checkException(Class<? extends Exception> ce, Runnable r) {
+ Exception caught = null;
+ try {
+ r.run();
+ } catch (Exception e) {
+ caught = e;
+ }
+
+ assertNotNull(caught);
+ assertTrue(ce.isInstance(caught));
+ }
+
+ public static void checkNPE(Runnable r) {
+ checkException(NullPointerException.class, r);
+ }
+
+ public static void checkISE(Runnable r) {
+ checkException(IllegalStateException.class, r);
+ }
+}
--- a/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/CollectAndSummaryStatisticsTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/CollectAndSummaryStatisticsTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -43,7 +43,7 @@
import java.util.stream.OpTestCase;
import static java.util.stream.LambdaTestHelpers.countTo;
-import static java.util.stream.ThowableHelper.checkNPE;
+import static java.util.stream.ThrowableHelper.checkNPE;
@Test
public class CollectAndSummaryStatisticsTest extends OpTestCase {
--- a/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/CollectionAndMapModifyStreamTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/CollectionAndMapModifyStreamTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -113,7 +113,7 @@
Map<String, Supplier<Map<Integer, Integer>>> maps = new HashMap<>();
maps.put(HashMap.class.getName(), () -> new HashMap<>(content));
- maps.put(HashMap.class.getName(), () -> new LinkedHashMap<>(content));
+ maps.put(LinkedHashMap.class.getName(), () -> new LinkedHashMap<>(content));
maps.put(IdentityHashMap.class.getName(), () -> new IdentityHashMap<>(content));
maps.put(WeakHashMap.class.getName(), () -> new WeakHashMap<>(content));
--- a/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/FlatMapOpTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/FlatMapOpTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -49,7 +49,7 @@
import java.util.stream.TestData;
import static java.util.stream.LambdaTestHelpers.*;
-import static java.util.stream.ThowableHelper.checkNPE;
+import static java.util.stream.ThrowableHelper.checkNPE;
@Test
public class FlatMapOpTest extends OpTestCase {
--- a/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/IterateTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/IterateTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -38,7 +38,7 @@
import java.util.stream.TestData;
import java.util.stream.TestData.Factory;
-import static java.util.stream.ThowableHelper.checkNPE;
+import static java.util.stream.ThrowableHelper.checkNPE;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
--- a/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/StreamBuilderTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/StreamBuilderTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -38,7 +38,7 @@
import java.util.stream.TestData;
import static java.util.stream.Collectors.toList;
-import static java.util.stream.ThowableHelper.checkISE;
+import static java.util.stream.ThrowableHelper.checkISE;
@Test
public class StreamBuilderTest extends OpTestCase {
--- a/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/StreamCloseTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/StreamCloseTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -36,8 +36,8 @@
import org.testng.annotations.Test;
import static java.util.stream.LambdaTestHelpers.countTo;
-import static java.util.stream.ThowableHelper.checkNPE;
-import static java.util.stream.ThowableHelper.checkISE;
+import static java.util.stream.ThrowableHelper.checkNPE;
+import static java.util.stream.ThrowableHelper.checkISE;
@Test(groups = { "serialization-hostile" })
public class StreamCloseTest extends OpTestCase {
--- a/jdk/test/javax/net/ssl/DTLS/DTLSOverDatagram.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/test/javax/net/ssl/DTLS/DTLSOverDatagram.java Wed Nov 09 10:04:43 2016 -0800
@@ -176,7 +176,10 @@
boolean finished = onReceiveTimeout(
engine, peerAddr, side, packets);
+ log(side, "Reproduced " + packets.size() + " packets");
for (DatagramPacket p : packets) {
+ printHex("Reproduced packet",
+ p.getData(), p.getOffset(), p.getLength());
socket.send(p);
}
@@ -334,7 +337,7 @@
String side, List<DatagramPacket> packets) throws Exception {
boolean endLoops = false;
- int loops = MAX_HANDSHAKE_LOOPS;
+ int loops = MAX_HANDSHAKE_LOOPS / 2;
while (!endLoops &&
(serverException == null) && (clientException == null)) {
@@ -350,7 +353,8 @@
SSLEngineResult.Status rs = r.getStatus();
SSLEngineResult.HandshakeStatus hs = r.getHandshakeStatus();
- log(side, "====packet(" + loops + ", " + rs + ", " + hs + ")====");
+ log(side, "----produce handshake packet(" +
+ loops + ", " + rs + ", " + hs + ")----");
if (rs == SSLEngineResult.Status.BUFFER_OVERFLOW) {
// the client maximum fragment size config does not work?
throw new Exception("Buffer overflow: " +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/net/ssl/SSLEngine/EngineCloseOnAlert.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,373 @@
+/*
+ * Copyright (c) 2004, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8133632
+ * @summary javax.net.ssl.SSLEngine does not properly handle received
+ * SSL fatal alerts
+ * @run main/othervm EngineCloseOnAlert
+ */
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import javax.net.ssl.*;
+import java.nio.ByteBuffer;
+import java.util.*;
+import java.security.*;
+import static javax.net.ssl.SSLEngineResult.HandshakeStatus.*;
+
+public class EngineCloseOnAlert {
+
+ private static final String pathToStores = "../etc";
+ private static final String keyStoreFile = "keystore";
+ private static final String trustStoreFile = "truststore";
+ private static final String passwd = "passphrase";
+ private static final String keyFilename =
+ System.getProperty("test.src", ".") + "/" + pathToStores +
+ "/" + keyStoreFile;
+ private static final String trustFilename =
+ System.getProperty("test.src", ".") + "/" + pathToStores +
+ "/" + trustStoreFile;
+
+ private static KeyManagerFactory KMF;
+ private static TrustManagerFactory TMF;
+ private static TrustManagerFactory EMPTY_TMF;
+
+ private static final String[] TLS10ONLY = { "TLSv1" };
+ private static final String[] TLS12ONLY = { "TLSv1.2" };
+ private static final String[] ONECIPHER =
+ { "TLS_RSA_WITH_AES_128_CBC_SHA" };
+
+ public interface TestCase {
+ public void runTest() throws Exception;
+ }
+
+ public static void main(String[] args) throws Exception {
+ int failed = 0;
+ List<TestCase> testMatrix = new LinkedList<TestCase>() {{
+ add(clientReceivesAlert);
+ add(serverReceivesAlert);
+ }};
+
+ // Create the various key/trust manager factories we'll need
+ createManagerFactories();
+
+ for (TestCase test : testMatrix) {
+ try {
+ test.runTest();
+ } catch (Exception e) {
+ System.out.println("Exception in test:\n" + e);
+ e.printStackTrace(System.out);
+ failed++;
+ }
+ }
+
+ System.out.println("Total tests: " + testMatrix.size() + ", passed: " +
+ (testMatrix.size() - failed) + ", failed: " + failed);
+ if (failed > 0) {
+ throw new RuntimeException("One or more tests failed.");
+ }
+ }
+
+ private static final TestCase clientReceivesAlert = new TestCase() {
+ @Override
+ public void runTest() throws Exception {
+ System.out.println("");
+ System.out.println("=======================================");
+ System.out.println("Test: Client receives alert from server");
+ System.out.println("=======================================");
+
+ // For this test, we won't initialize any keystore so the
+ // server will throw an exception because it has no key/cert to
+ // match the requested ciphers offered by the client. This
+ // will generate an alert from the server to the client.
+
+ SSLContext context = SSLContext.getDefault();
+ SSLEngine client = context.createSSLEngine();
+ SSLEngine server = context.createSSLEngine();
+ client.setUseClientMode(true);
+ server.setUseClientMode(false);
+ SSLEngineResult clientResult;
+ SSLEngineResult serverResult;
+
+ ByteBuffer raw = ByteBuffer.allocate(32768);
+ ByteBuffer plain = ByteBuffer.allocate(32768);
+
+ // Generate the client hello and have the server unwrap it
+ client.wrap(plain, raw);
+ checkEngineState(client, NEED_UNWRAP, false, false);
+ raw.flip();
+ System.out.println("Client-to-Server:\n-----------------\n" +
+ dumpHexBytes(raw, 16, "\n", ":"));
+
+
+ // The server should need to run a delegated task while processing
+ // the client hello data.
+ serverResult = server.unwrap(raw, plain);
+ checkEngineState(server, NEED_TASK, false, false);
+ System.out.println("Server result: " + serverResult);
+ runDelegatedTasks(serverResult, server);
+ checkEngineState(server, NEED_WRAP, true, false);
+
+ try {
+ raw.clear();
+ serverResult = server.wrap(plain, raw);
+ System.out.println("Server result: " + serverResult);
+ runDelegatedTasks(serverResult, server);
+ } catch (SSLException e) {
+ // This is the expected code path
+ System.out.println("Server throws exception: " + e);
+ System.out.println("Server engine state: " +
+ "isInboundDone = "+ server.isInboundDone() +
+ ", isOutboundDone = " + server.isOutboundDone() +
+ ", handshake status = " + server.getHandshakeStatus());
+ checkEngineState(server, NEED_WRAP, true, false);
+ }
+ raw.clear();
+
+ // The above should show that isInboundDone returns true, and
+ // handshake status is NEED_WRAP. That is the correct behavior,
+ // wrap will put a fatal alert message in the buffer.
+ serverResult = server.wrap(plain, raw);
+ System.out.println("Server result (wrap after exception): " +
+ serverResult);
+ System.out.println("Server engine closure state: isInboundDone="
+ + server.isInboundDone() + ", isOutboundDone="
+ + server.isOutboundDone());
+ checkEngineState(server, NEED_UNWRAP, true, true);
+ raw.flip();
+
+ System.out.println("Server-to-Client:\n-----------------\n" +
+ dumpHexBytes(raw, 16, "\n", ":"));
+
+ // Client side will read the fatal alert and throw exception.
+ try {
+ clientResult = client.unwrap(raw, plain);
+ System.out.println("Client result (unwrap alert): " +
+ clientResult);
+ } catch (SSLException e) {
+ System.out.println("Client throws exception: " + e);
+ System.out.println("Engine closure status: isInboundDone="
+ + client.isInboundDone() + ", isOutboundDone="
+ + client.isOutboundDone() + ", handshake status="
+ + client.getHandshakeStatus());
+ checkEngineState(client, NOT_HANDSHAKING, true, true);
+ }
+ raw.clear();
+
+ // Last test, we try to unwrap
+ clientResult = client.unwrap(raw, plain);
+ checkEngineState(client, NOT_HANDSHAKING, true, true);
+ System.out.println("Client result (wrap after exception): " +
+ clientResult);
+ }
+ };
+
+ private static final TestCase serverReceivesAlert = new TestCase() {
+ @Override
+ public void runTest() throws Exception {
+ SSLContext cliContext = SSLContext.getDefault();
+ SSLContext servContext = SSLContext.getInstance("TLS");
+ servContext.init(KMF.getKeyManagers(), TMF.getTrustManagers(),
+ null);
+ SSLEngine client = cliContext.createSSLEngine();
+ SSLEngine server = servContext.createSSLEngine();
+ client.setUseClientMode(true);
+ client.setEnabledProtocols(TLS12ONLY);
+ client.setEnabledCipherSuites(ONECIPHER);
+ server.setUseClientMode(false);
+ server.setEnabledProtocols(TLS10ONLY);
+ SSLEngineResult clientResult;
+ SSLEngineResult serverResult;
+ ByteBuffer raw = ByteBuffer.allocate(32768);
+ ByteBuffer plain = ByteBuffer.allocate(32768);
+
+ System.out.println("");
+ System.out.println("=======================================");
+ System.out.println("Test: Server receives alert from client");
+ System.out.println("=======================================");
+
+ // Generate the client hello and have the server unwrap it
+ checkEngineState(client, NOT_HANDSHAKING, false, false);
+ client.wrap(plain, raw);
+ checkEngineState(client, NEED_UNWRAP, false, false);
+ raw.flip();
+ System.out.println("Client-to-Server:\n-----------------\n" +
+ dumpHexBytes(raw, 16, "\n", ":"));
+
+ // The server should need to run a delegated task while processing
+ // the client hello data.
+ serverResult = server.unwrap(raw, plain);
+ checkEngineState(server, NEED_TASK, false, false);
+ runDelegatedTasks(serverResult, server);
+ checkEngineState(server, NEED_WRAP, false, false);
+ raw.compact();
+
+ // The server should now wrap the response back to the client
+ server.wrap(plain, raw);
+ checkEngineState(server, NEED_UNWRAP, false, false);
+ raw.flip();
+ System.out.println("Server-to-Client:\n-----------------\n" +
+ dumpHexBytes(raw, 16, "\n", ":"));
+
+ // The client should parse this and throw an exception because
+ // It is unwiling to do TLS 1.0
+ clientResult = client.unwrap(raw, plain);
+ checkEngineState(client, NEED_TASK, false, false);
+ runDelegatedTasks(clientResult, client);
+ checkEngineState(client, NEED_UNWRAP, false, false);
+
+ try {
+ client.unwrap(raw, plain);
+ } catch (SSLException e) {
+ System.out.println("Client throws exception: " + e);
+ System.out.println("Engine closure status: isInboundDone="
+ + client.isInboundDone() + ", isOutboundDone="
+ + client.isOutboundDone() + ", handshake status="
+ + client.getHandshakeStatus());
+ checkEngineState(client, NEED_WRAP, true, false);
+ }
+ raw.clear();
+
+ // Now the client should wrap the exception
+ client.wrap(plain, raw);
+ checkEngineState(client, NEED_UNWRAP, true, true);
+ raw.flip();
+ System.out.println("Client-to-Server:\n-----------------\n" +
+ dumpHexBytes(raw, 16, "\n", ":"));
+
+ try {
+ server.unwrap(raw, plain);
+ checkEngineState(server, NEED_UNWRAP, false, false);
+ } catch (SSLException e) {
+ System.out.println("Server throws exception: " + e);
+ System.out.println("Engine closure status: isInboundDone="
+ + server.isInboundDone() + ", isOutboundDone="
+ + server.isOutboundDone() + ", handshake status="
+ + server.getHandshakeStatus());
+ checkEngineState(server, NOT_HANDSHAKING, true, true);
+ }
+ raw.clear();
+ }
+ };
+
+
+ /*
+ * If the result indicates that we have outstanding tasks to do,
+ * go ahead and run them in this thread.
+ */
+ private static void runDelegatedTasks(SSLEngineResult result,
+ SSLEngine engine) throws Exception {
+
+ if (result.getHandshakeStatus() ==
+ SSLEngineResult.HandshakeStatus.NEED_TASK) {
+ Runnable runnable;
+ while ((runnable = engine.getDelegatedTask()) != null) {
+ System.out.println("\trunning delegated task...");
+ runnable.run();
+ }
+ SSLEngineResult.HandshakeStatus hsStatus =
+ engine.getHandshakeStatus();
+ if (hsStatus == SSLEngineResult.HandshakeStatus.NEED_TASK) {
+ throw new Exception(
+ "handshake shouldn't need additional tasks");
+ }
+ System.out.println("\tnew HandshakeStatus: " + hsStatus);
+ }
+ }
+
+ /**
+ *
+ * @param data The array of bytes to dump to stdout.
+ * @param itemsPerLine The number of bytes to display per line
+ * if the {@code lineDelim} character is blank then all bytes will be
+ * printed on a single line.
+ * @param lineDelim The delimiter between lines
+ * @param itemDelim The delimiter between bytes
+ *
+ * @return The hexdump of the byte array
+ */
+ private static String dumpHexBytes(ByteBuffer data, int itemsPerLine,
+ String lineDelim, String itemDelim) {
+ StringBuilder sb = new StringBuilder();
+
+ if (data != null) {
+ data.mark();
+ for (int i = 0; i < data.limit(); i++) {
+ if (i % itemsPerLine == 0 && i != 0) {
+ sb.append(lineDelim);
+ }
+ sb.append(String.format("%02X", data.get(i)));
+ if (i % itemsPerLine != (itemsPerLine - 1) &&
+ i != (data.limit() -1)) {
+ sb.append(itemDelim);
+ }
+ }
+ data.reset();
+ }
+
+ return sb.toString();
+ }
+
+ private static void createManagerFactories()
+ throws GeneralSecurityException, IOException {
+ KeyStore keystore = KeyStore.getInstance("PKCS12");
+ KeyStore truststore = KeyStore.getInstance("PKCS12");
+ KeyStore empty_ts = KeyStore.getInstance("PKCS12");
+ char[] passphrase = passwd.toCharArray();
+
+ keystore.load(new FileInputStream(keyFilename), passphrase);
+ truststore.load(new FileInputStream(trustFilename), passphrase);
+ empty_ts.load(null, "".toCharArray());
+
+ KMF = KeyManagerFactory.getInstance("PKIX");
+ KMF.init(keystore, passphrase);
+ TMF = TrustManagerFactory.getInstance("PKIX");
+ TMF.init(truststore);
+ EMPTY_TMF = TrustManagerFactory.getInstance("PKIX");
+ EMPTY_TMF.init(truststore);
+ }
+
+ private static void checkEngineState(SSLEngine engine,
+ SSLEngineResult.HandshakeStatus expectedHSStat,
+ boolean expectedInboundDone, boolean expectedOutboundDone) {
+ if (engine.getHandshakeStatus() != expectedHSStat ||
+ engine.isInboundDone() != expectedInboundDone ||
+ engine.isOutboundDone() != expectedOutboundDone) {
+ throw new RuntimeException("Error: engine not in expected state\n" +
+ "Expected: state = " + expectedHSStat +
+ ", inDone = " + expectedInboundDone +
+ ", outDone = " + expectedOutboundDone + "\n" +
+ "Actual: state = " + engine.getHandshakeStatus() +
+ ", inDone = " + engine.isInboundDone() +
+ ", outDone = " + engine.isOutboundDone());
+ } else {
+ System.out.println((engine.getUseClientMode() ?
+ "Client" : "Server") + " handshake status: " +
+ engine.getHandshakeStatus() + ", inDone = " +
+ engine.isInboundDone() + ", outDone = " +
+ engine.isOutboundDone());
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/jdk/editpad/EditPadTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,342 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8167636 8167639 8168972
+ * @summary Testing built-in editor.
+ * @modules java.desktop/java.awt
+ * jdk.internal.ed/jdk.internal.editor.spi
+ * jdk.editpad/jdk.editpad
+ * @run testng EditPadTest
+ */
+
+import java.awt.AWTException;
+import java.awt.Component;
+import java.awt.Container;
+import java.awt.Dimension;
+import java.awt.Frame;
+import java.awt.GraphicsEnvironment;
+import java.awt.Point;
+import java.awt.Robot;
+import java.awt.event.InputEvent;
+import java.awt.event.WindowEvent;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ServiceLoader;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.function.Consumer;
+
+import javax.swing.JButton;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextArea;
+import javax.swing.JViewport;
+import javax.swing.SwingUtilities;
+
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+import jdk.internal.editor.spi.BuildInEditorProvider;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
+@Test
+public class EditPadTest {
+
+ private static final int DELAY = 500;
+ private static final String WINDOW_LABEL = "Test Edit Pad";
+
+ private static ExecutorService executor;
+ private static Robot robot;
+ private static JFrame frame = null;
+ private static JTextArea area = null;
+ private static JButton cancel = null;
+ private static JButton accept = null;
+ private static JButton exit = null;
+
+ @BeforeClass
+ public static void setUpEditorPadTest() {
+ if (!GraphicsEnvironment.isHeadless()) {
+ try {
+ robot = new Robot();
+ robot.setAutoWaitForIdle(true);
+ robot.setAutoDelay(DELAY);
+ } catch (AWTException e) {
+ throw new ExceptionInInitializerError(e);
+ }
+ }
+ }
+
+ @AfterClass
+ public static void shutdown() {
+ executorShutdown();
+ }
+
+ public void testSimple() {
+ testEdit("abcdef", 1, "xyz",
+ () -> assertSource("abcdef"),
+ () -> writeSource("xyz"),
+ () -> accept(),
+ () -> assertSource("xyz"),
+ () -> shutdownEditor());
+ }
+
+ public void testCancel() {
+ testEdit("abcdef", 0, "abcdef",
+ () -> assertSource("abcdef"),
+ () -> writeSource("xyz"),
+ () -> cancel());
+ }
+
+ public void testAbort() {
+ testEdit("abcdef", 0, "abcdef",
+ () -> assertSource("abcdef"),
+ () -> writeSource("xyz"),
+ () -> shutdownEditor());
+ }
+
+ public void testAcceptCancel() {
+ testEdit("abcdef", 1, "xyz",
+ () -> assertSource("abcdef"),
+ () -> writeSource("xyz"),
+ () -> accept(),
+ () -> assertSource("xyz"),
+ () -> writeSource("!!!!!!!!!"),
+ () -> cancel());
+ }
+
+ public void testAcceptEdit() {
+ testEdit("abcdef", 2, "xyz",
+ () -> assertSource("abcdef"),
+ () -> writeSource("NoNo"),
+ () -> accept(),
+ () -> assertSource("NoNo"),
+ () -> writeSource("xyz"),
+ () -> exit());
+ }
+
+ private void testEdit(String initialText,
+ int savedCount, String savedText, Runnable... actions) {
+ class Handler {
+
+ String text = null;
+ int count = 0;
+
+ void handle(String s) {
+ ++count;
+ text = s;
+ }
+ }
+ Handler save = new Handler();
+ Handler error = new Handler();
+
+ if (GraphicsEnvironment.isHeadless()) {
+ // Do not actually run if we are headless
+ return;
+ }
+ Future<?> task = doActions(actions);
+ builtInEdit(initialText, save::handle, error::handle);
+ complete(task);
+ assertEquals(error.count, 0, "Error: " + error.text);
+ assertTrue(save.count != savedCount
+ || save.text == null
+ ? savedText != null
+ : savedText.equals(save.text),
+ "Expected " + savedCount + " saves, got " + save.count
+ + ", expected \"" + savedText + "\" got \"" + save.text + "\"");
+ }
+
+ private static ExecutorService getExecutor() {
+ if (executor == null) {
+ executor = Executors.newSingleThreadExecutor();
+ }
+ return executor;
+ }
+
+ private static void executorShutdown() {
+ if (executor != null) {
+ executor.shutdown();
+ executor = null;
+ }
+ }
+
+ private void builtInEdit(String initialText,
+ Consumer<String> saveHandler, Consumer<String> errorHandler) {
+ ServiceLoader<BuildInEditorProvider> sl
+ = ServiceLoader.load(BuildInEditorProvider.class);
+ // Find the highest ranking provider
+ BuildInEditorProvider provider = null;
+ for (BuildInEditorProvider p : sl) {
+ if (provider == null || p.rank() > provider.rank()) {
+ provider = p;
+ }
+ }
+ if (provider != null) {
+ provider.edit(WINDOW_LABEL,
+ initialText, saveHandler, errorHandler);
+ } else {
+ throw new InternalError("Cannot find provider");
+ }
+ }
+
+ private Future<?> doActions(Runnable... actions) {
+ return getExecutor().submit(() -> {
+ try {
+ waitForIdle();
+ SwingUtilities.invokeLater(this::seekElements);
+ waitForIdle();
+ for (Runnable act : actions) {
+ act.run();
+ }
+ } catch (Throwable e) {
+ shutdownEditor();
+ if (e instanceof AssertionError) {
+ throw (AssertionError) e;
+ }
+ throw new RuntimeException(e);
+ }
+ });
+ }
+
+ private void complete(Future<?> task) {
+ try {
+ task.get();
+ waitForIdle();
+ } catch (ExecutionException e) {
+ if (e.getCause() instanceof AssertionError) {
+ throw (AssertionError) e.getCause();
+ }
+ throw new RuntimeException(e);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ } finally {
+ shutdownEditor();
+ }
+ }
+
+ private void writeSource(String s) {
+ SwingUtilities.invokeLater(() -> area.setText(s));
+ }
+
+ private void assertSource(String expected) {
+ String[] s = new String[1];
+ try {
+ SwingUtilities.invokeAndWait(() -> s[0] = area.getText());
+ } catch (InvocationTargetException | InterruptedException e) {
+ throw new RuntimeException(e);
+ }
+ assertEquals(s[0], expected);
+ }
+
+ private void accept() {
+ clickOn(accept);
+ }
+
+ private void exit() {
+ clickOn(exit);
+ }
+
+ private void cancel() {
+ clickOn(cancel);
+ }
+
+ private void shutdownEditor() {
+ SwingUtilities.invokeLater(this::clearElements);
+ waitForIdle();
+ }
+
+ private void waitForIdle() {
+ robot.waitForIdle();
+ robot.delay(DELAY);
+ }
+
+ private void seekElements() {
+ for (Frame f : Frame.getFrames()) {
+ if (f.getTitle().equals(WINDOW_LABEL)) {
+ frame = (JFrame) f;
+ // workaround
+ frame.setLocation(0, 0);
+ Container root = frame.getContentPane();
+ for (Component c : root.getComponents()) {
+ if (c instanceof JScrollPane) {
+ JScrollPane scrollPane = (JScrollPane) c;
+ for (Component comp : scrollPane.getComponents()) {
+ if (comp instanceof JViewport) {
+ JViewport view = (JViewport) comp;
+ area = (JTextArea) view.getComponent(0);
+ }
+ }
+ }
+ if (c instanceof JPanel) {
+ JPanel p = (JPanel) c;
+ for (Component comp : p.getComponents()) {
+ if (comp instanceof JButton) {
+ JButton b = (JButton) comp;
+ switch (b.getText()) {
+ case "Cancel":
+ cancel = b;
+ break;
+ case "Exit":
+ exit = b;
+ break;
+ case "Accept":
+ accept = b;
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ private void clearElements() {
+ if (frame != null) {
+ frame.dispatchEvent(new WindowEvent(frame, WindowEvent.WINDOW_CLOSING));
+ frame = null;
+ }
+ area = null;
+ accept = null;
+ cancel = null;
+ exit = null;
+ }
+
+ private void clickOn(JButton button) {
+ waitForIdle();
+ waitForIdle();
+ waitForIdle();
+ waitForIdle();
+ waitForIdle();
+ waitForIdle();
+ Point p = button.getLocationOnScreen();
+ Dimension d = button.getSize();
+ robot.mouseMove(p.x + d.width / 2, p.y + d.height / 2);
+ robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
+ robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/lib/security/SecurityTools.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,122 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import jdk.testlibrary.JDKToolLauncher;
+import jdk.testlibrary.OutputAnalyzer;
+import jdk.testlibrary.ProcessTools;
+
+public class SecurityTools {
+
+ public static final String NO_ALIAS = null;
+
+ // keytool
+
+ public static OutputAnalyzer keytool(List<String> options)
+ throws Throwable {
+
+ JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("keytool")
+ .addVMArg("-Duser.language=en")
+ .addVMArg("-Duser.country=US");
+ for (String option : options) {
+ if (option.startsWith("-J")) {
+ launcher.addVMArg(option.substring(2));
+ } else {
+ launcher.addToolArg(option);
+ }
+ }
+ return ProcessTools.executeCommand(launcher.getCommand());
+ }
+
+ public static OutputAnalyzer keytool(String options) throws Throwable {
+ return keytool(options.split("\\s+"));
+ }
+
+ public static OutputAnalyzer keytool(String... options) throws Throwable {
+ return keytool(List.of(options));
+ }
+
+ // jarsigner
+
+ public static OutputAnalyzer jarsigner(String jar, String alias,
+ List<String> options) throws Throwable {
+ JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jarsigner")
+ .addVMArg("-Duser.language=en")
+ .addVMArg("-Duser.country=US");
+ for (String option : options) {
+ if (option.startsWith("-J")) {
+ launcher.addVMArg(option.substring(2));
+ } else {
+ launcher.addToolArg(option);
+ }
+ }
+ launcher.addToolArg(jar);
+ if (alias != null) {
+ launcher.addToolArg(alias);
+ }
+ return ProcessTools.executeCommand(launcher.getCommand());
+ }
+
+ public static OutputAnalyzer jarsigner(String jar, String alias,
+ String options) throws Throwable {
+
+ return jarsigner(jar, alias, options.split("\\s+"));
+ }
+
+ public static OutputAnalyzer jarsigner(String jar, String alias,
+ String... options) throws Throwable {
+
+ return jarsigner(jar, alias, List.of(options));
+ }
+
+ public static OutputAnalyzer sign(String jar, String alias, String... options)
+ throws Throwable {
+
+ return jarsigner(jar, alias,
+ mergeOptions("-J-Djava.security.egd=file:/dev/./urandom", options));
+ }
+
+ public static OutputAnalyzer verify(String jar, String... options)
+ throws Throwable {
+
+ return jarsigner(jar, NO_ALIAS, mergeOptions("-verify", options));
+ }
+
+ // helper methods
+
+ private static List<String> mergeOptions(
+ String firstOption, String... secondPart) {
+
+ return mergeOptions(List.of(firstOption), secondPart);
+ }
+
+ private static List<String> mergeOptions(
+ List<String> firstPart, String... secondPart) {
+
+ List<String> options = new ArrayList<>(firstPart);
+ Collections.addAll(options, secondPart);
+ return options;
+ }
+}
--- a/jdk/test/sun/reflect/ReflectionFactory/ReflectionFactoryTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/test/sun/reflect/ReflectionFactory/ReflectionFactoryTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -45,7 +45,7 @@
/*
* @test
- * @bug 8137058 8164908
+ * @bug 8137058 8164908 8168980
* @run testng ReflectionFactoryTest
* @run testng/othervm/policy=security.policy ReflectionFactoryTest
* @summary Basic test for the unsupported ReflectionFactory
@@ -95,6 +95,47 @@
}
}
+ @DataProvider(name = "NonSerialConstructors")
+ static Object[][] constructors() throws NoSuchMethodException {
+ return new Object[][] {
+ {Foo.class, Object.class.getDeclaredConstructor()},
+ {Foo.class, Foo.class.getDeclaredConstructor()},
+ {Baz.class, Object.class.getDeclaredConstructor()},
+ {Baz.class, Foo.class.getDeclaredConstructor()},
+ {Baz.class, Baz.class.getDeclaredConstructor()}
+ };
+ }
+
+ /**
+ * Tests that the given Constructor, in the hierarchy, is run.
+ */
+ @Test(dataProvider="NonSerialConstructors")
+ static void testNonSerializableConstructor(Class<?> cl,
+ Constructor<?> constructorToCall)
+ throws ReflectiveOperationException
+ {
+ @SuppressWarnings("unchecked")
+ Constructor<?> c = factory.newConstructorForSerialization(cl,
+ constructorToCall);
+
+ Object o = c.newInstance();
+ Assert.assertEquals(o.getClass(), cl, "Instance is wrong type");
+
+ int expectedFoo = 0;
+ int expectedBaz = 0;
+ if (constructorToCall.getName().equals("ReflectionFactoryTest$Foo")) {
+ expectedFoo = 1;
+ } else if (constructorToCall.getName().equals("ReflectionFactoryTest$Baz")) {
+ expectedFoo = 1;
+ expectedBaz = 4;
+ }
+
+ Assert.assertEquals(((Foo)o).foo(), expectedFoo);
+ if (o instanceof Baz) {
+ Assert.assertEquals(((Baz)o).baz(), expectedBaz);
+ }
+ }
+
static class Foo {
private int foo;
public Foo() {
@@ -109,6 +150,8 @@
int expectedFoo = 1;
Assert.assertEquals(foo, expectedFoo, "foo() constructor not run");
}
+
+ public int foo() { return foo; }
}
static class Bar extends Foo implements Serializable {
@@ -128,6 +171,12 @@
}
}
+ static class Baz extends Foo {
+ private final int baz;
+ public Baz() { this.baz = 4; }
+ public int baz() { return baz; }
+ }
+
/**
* Test newConstructorForExternalization returns the constructor and it can be called.
* @throws NoSuchMethodException - error
--- a/jdk/test/sun/rmi/runtime/Log/6409194/NoConsoleOutput.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/test/sun/rmi/runtime/Log/6409194/NoConsoleOutput.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -35,7 +35,7 @@
* java.rmi/sun.rmi.server
* java.rmi/sun.rmi.transport
* java.rmi/sun.rmi.transport.tcp
- * @build TestLibrary JavaVM
+ * @build JavaVM
* @run main/othervm NoConsoleOutput
*/
@@ -43,8 +43,6 @@
import java.io.File;
import java.rmi.Remote;
import java.rmi.RemoteException;
-import java.rmi.registry.LocateRegistry;
-import java.rmi.registry.Registry;
import java.rmi.server.UnicastRemoteObject;
public class NoConsoleOutput {
@@ -53,7 +51,7 @@
System.err.println("\nRegression test for bug 6409194\n");
/*
- * Exdecute a subprocess VM that does a bunch of RMI activity
+ * Execute a subprocess VM that does a bunch of RMI activity
* with a logging configuration file that does not specify a
* ConsoleHandler and with no legacy sun.rmi.*.logLevel system
* properties set.
@@ -65,7 +63,7 @@
ByteArrayOutputStream err = new ByteArrayOutputStream();
// We instantiate a JavaVM that should not produce any console output
- // (neither on standard output, nor on standard err streams).
+ // on standard err streams, where RMI logging messages are sent to.
JavaVM vm = new JavaVM(
DoRMIStuff.class.getName(),
"--add-exports=java.rmi/sun.rmi.registry=ALL-UNNAMED"
@@ -77,8 +75,7 @@
vm.execute();
/*
- * Verify that the subprocess had no System.out or System.err
- * output.
+ * Verify that the subprocess had no System.err output.
*/
String outString = out.toString();
String errString = err.toString();
@@ -89,7 +86,7 @@
System.err.print(err);
System.err.println("---------------------------------------------");
- if (outString.length() > 0 || errString.length() > 0) {
+ if (errString.length() > 0) {
throw new Error("TEST FAILED: unexpected subprocess output");
}
@@ -105,13 +102,8 @@
public Object echo(Object obj) { return obj; }
}
public static void main(String[] args) throws Exception {
- Registry registry = TestLibrary.createRegistryOnUnusedPort();
- int registryPort = TestLibrary.getRegistryPort(registry);
- Registry reg = LocateRegistry.getRegistry("", registryPort);
FooImpl fooimpl = new FooImpl();
- UnicastRemoteObject.exportObject(fooimpl, 0);
- reg.rebind("foo", fooimpl);
- Foo foostub = (Foo) reg.lookup("foo");
+ Foo foostub = (Foo) UnicastRemoteObject.exportObject(fooimpl, 0);
FooImpl fooimpl2 = new FooImpl();
UnicastRemoteObject.exportObject(fooimpl2, 0);
foostub.echo(fooimpl2);
--- a/jdk/test/sun/security/ec/TestEC.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/test/sun/security/ec/TestEC.java Wed Nov 09 10:04:43 2016 -0800
@@ -35,7 +35,7 @@
* @library ../pkcs11/sslecc
* @library ../../../java/security/testlibrary
* @modules jdk.crypto.pkcs11/sun.security.pkcs11.wrapper
- * @compile -XDignore.symbol.file TestEC.java
+ * @compile --add-modules jdk.crypto.pkcs11 TestEC.java
* @run main/othervm -Djdk.tls.namedGroups="secp256r1,sect193r1" TestEC
* @run main/othervm/java.security.policy=TestEC.policy -Djdk.tls.namedGroups="secp256r1,sect193r1" TestEC
*/
--- a/jdk/test/sun/security/krb5/auto/ReplayCacheExpunge.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/test/sun/security/krb5/auto/ReplayCacheExpunge.java Wed Nov 09 10:04:43 2016 -0800
@@ -47,15 +47,15 @@
int count = Integer.parseInt(args[0]);
ReplayCache cache = ReplayCache.getInstance("dfl:./");
AuthTimeWithHash a1 =
- new AuthTimeWithHash(client, server, time(-400), 0, hash("1"));
+ new AuthTimeWithHash(client, server, time(-400), 0, "HASH", hash("1"));
AuthTimeWithHash a2 =
- new AuthTimeWithHash(client, server, time(0), 0, hash("4"));
+ new AuthTimeWithHash(client, server, time(0), 0, "HASH", hash("4"));
KerberosTime now = new KerberosTime(time(0)*1000L);
KerberosTime then = new KerberosTime(time(-300)*1000L);
// Once upon a time, we added a lot of events
for (int i=0; i<count; i++) {
- a1 = new AuthTimeWithHash(client, server, time(-400), 0, hash(""));
+ a1 = new AuthTimeWithHash(client, server, time(-400), 0, "HASH", hash(""));
cache.checkAndStore(then, a1);
}
--- a/jdk/test/sun/security/krb5/auto/ReplayCachePrecise.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/test/sun/security/krb5/auto/ReplayCachePrecise.java Wed Nov 09 10:04:43 2016 -0800
@@ -48,9 +48,9 @@
public static void main(String[] args) throws Exception {
AuthTimeWithHash a1 = new AuthTimeWithHash(client, server, time(0), 0,
- "1111111111111111");
+ "HASH", "1111111111111111");
AuthTimeWithHash a2 = new AuthTimeWithHash(client, server, time(0), 0,
- "2222222222222222");
+ "HASH", "2222222222222222");
KerberosTime now = new KerberosTime(time(0)*1000L);
// When all new styles, must exact match
--- a/jdk/test/sun/security/krb5/auto/ReplayCacheTestProc.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/test/sun/security/krb5/auto/ReplayCacheTestProc.java Wed Nov 09 10:04:43 2016 -0800
@@ -23,11 +23,10 @@
/*
* @test
- * @bug 7152176
+ * @bug 7152176 8168518
* @summary More krb5 tests
- * @library ../../../../java/security/testlibrary/
- * @compile -XDignore.symbol.file ReplayCacheTestProc.java
- * @run main/othervm/timeout=100 ReplayCacheTestProc
+ * @library ../../../../java/security/testlibrary/ /test/lib
+ * @run main/othervm/timeout=300 ReplayCacheTestProc
*/
import java.io.*;
@@ -38,17 +37,40 @@
import java.nio.file.StandardCopyOption;
import java.nio.file.StandardOpenOption;
import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
import java.util.*;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import jdk.test.lib.Platform;
import sun.security.jgss.GSSUtil;
-import sun.security.krb5.internal.APReq;
import sun.security.krb5.internal.rcache.AuthTime;
-// This test runs multiple acceptor Procs to mimin AP-REQ replays.
+/**
+ * This test runs multiple acceptor Procs to mimic AP-REQ replays.
+ * These system properties are supported:
+ *
+ * - test.libs on what types of acceptors to use
+ * Format: CSV of (J|N|N<suffix>=<libname>|J<suffix>=<launcher>)
+ * Default: J,N on Solaris and Linux where N is available, or J
+ * Example: J,N,N14=/krb5-1.14/lib/libgssapi_krb5.so,J8=/java8/bin/java
+ *
+ * - test.runs on manual runs. If empty, a iterate through all pattern
+ * Format: (req# | client# service#) acceptor# expected, ...
+ * Default: null
+ * Example: c0s0Jav,c1s1N14av,r0Jbx means 0th req is new c0->s0 sent to Ja,
+ * 1st req is new c1 to s1 sent to N14a,
+ * 2nd req is old (0th replayed) sent to Jb.
+ * a/b at the end of acceptor is different acceptors of the same lib
+ *
+ * - test.autoruns on number of automatic runs
+ * Format: number
+ * Default: 100
+ */
public class ReplayCacheTestProc {
- private static Proc[] ps;
- private static Proc pc;
+ private static Proc[] pa; // all acceptors
+ private static Proc pi; // the single initiator
private static List<Req> reqs = new ArrayList<>();
private static String HOST = "localhost";
@@ -59,119 +81,193 @@
"/var/krb5/rcache/" :
System.getProperty("user.dir");
+ private static MessageDigest md5, sha256;
+
+ static {
+ try {
+ md5 = MessageDigest.getInstance("MD5");
+ sha256 = MessageDigest.getInstance("SHA-256");
+ } catch (NoSuchAlgorithmException nsae) {
+ throw new AssertionError("Impossible", nsae);
+ }
+ }
private static long uid;
public static void main0(String[] args) throws Exception {
System.setProperty("java.security.krb5.conf", OneKDC.KRB5_CONF);
if (args.length == 0) { // The controller
- int ns = 5; // number of servers
- int nu = 5; // number of users
- int nx = 50; // number of experiments
- int np = 5; // number of peers (services)
- int mode = 0; // native(1), random(0), java(-1)
- boolean random = true; // random experiments choreograph
-
- // Do not test interop with native GSS on some platforms
- String os = System.getProperty("os.name", "???");
- if (!os.startsWith("SunOS") && !os.startsWith("Linux")) {
- mode = -1;
- }
+ int nc = 5; // number of clients
+ int ns = 5; // number of services
+ String[] libs; // available acceptor types:
+ // J: java
+ // J<suffix>=<java launcher>: another java
+ // N: default native lib
+ // N<suffix>=<libname>: another native lib
+ Ex[] result;
+ int numPerType = 2; // number of acceptors per type
uid = jdk.internal.misc.VM.geteuid();
KDC kdc = KDC.create(OneKDC.REALM, HOST, 0, true);
- for (int i=0; i<nu; i++) {
- kdc.addPrincipal(user(i), OneKDC.PASS);
+ for (int i=0; i<nc; i++) {
+ kdc.addPrincipal(client(i), OneKDC.PASS);
}
kdc.addPrincipalRandKey("krbtgt/" + OneKDC.REALM);
- for (int i=0; i<np; i++) {
- kdc.addPrincipalRandKey(peer(i));
+ for (int i=0; i<ns; i++) {
+ kdc.addPrincipalRandKey(service(i));
}
kdc.writeKtab(OneKDC.KTAB);
KDC.saveConfig(OneKDC.KRB5_CONF, kdc);
- if (mode != -1) {
- // A special native server to check basic sanity
- if (ns(-1).waitFor() != 0) {
- Proc.d("Native mode sanity check failed, revert to java");
- mode = -1;
+ // User-provided libs
+ String userLibs = System.getProperty("test.libs");
+
+ if (userLibs != null) {
+ libs = userLibs.split(",");
+ } else {
+ if (Platform.isOSX() || Platform.isWindows()) {
+ // macOS uses Heimdal and Windows has no native lib
+ libs = new String[]{"J"};
+ } else {
+ if (acceptor("N", "sanity").waitFor() != 0) {
+ Proc.d("Native mode sanity check failed, only java");
+ libs = new String[]{"J"};
+ } else {
+ libs = new String[]{"J", "N"};
+ }
}
}
- pc = Proc.create("ReplayCacheTestProc").debug("C")
- .args("client")
+ pi = Proc.create("ReplayCacheTestProc").debug("C")
+ .args("initiator")
.start();
- ps = new Proc[ns];
- Ex[] result = new Ex[nx];
- if (!random) {
- // 2 experiments, 2 server, 1 peer, 1 user
- nx = 2; ns = 2; np = 1; nu = 1;
+ int na = libs.length * numPerType; // total number of acceptors
+ pa = new Proc[na];
- // Creates reqs from user# to peer#
- req(0, 0);
+ // Acceptors, numPerType for 1st, numForType for 2nd, ...
+ for (int i=0; i<na; i++) {
+ pa[i] = acceptor(libs[i/numPerType],
+ "" + (char)('a' + i%numPerType));
+ }
- // Creates server#
- ps[0] = ns(0);
- ps[1] = js(1);
+ // Manual runs
+ String userRuns = System.getProperty("test.runs");
- // Runs ex# using req# to server# with expected result
- result[0] = round(0, 0, 0, true);
- result[1] = round(1, 0, 1, false);
- } else {
+ if (userRuns == null) {
+ result = new Ex[Integer.parseInt(
+ System.getProperty("test.autoruns", "100"))];
Random r = new Random();
- for (int i=0; i<ns; i++) {
- boolean useNative = (mode == 1) ? true
- : (mode == -1 ? false : r.nextBoolean());
- ps[i] = useNative?ns(i):js(i);
+ for (int i = 0; i < result.length; i++) {
+ boolean expected = reqs.isEmpty() || r.nextBoolean();
+ result[i] = new Ex(
+ i,
+ expected ?
+ req(r.nextInt(nc), r.nextInt(ns)) :
+ r.nextInt(reqs.size()),
+ pa[r.nextInt(na)],
+ expected);
}
- for (int i=0; i<nx; i++) {
- result[i] = new Ex();
- int old; // which req to send
- boolean expected;
- if (reqs.isEmpty() || r.nextBoolean()) {
- Proc.d("Console get new AP-REQ");
- old = req(r.nextInt(nu), r.nextInt(np));
- expected = true;
- } else {
- Proc.d("Console resue old");
- old = r.nextInt(reqs.size());
- expected = false;
+ } else if (userRuns.isEmpty()) {
+ int count = 0;
+ result = new Ex[libs.length * libs.length];
+ for (int i = 0; i < libs.length; i++) {
+ result[count] = new Ex(
+ count,
+ req(0, 0),
+ pa[i * numPerType],
+ true);
+ count++;
+ for (int j = 0; j < libs.length; j++) {
+ if (i == j) {
+ continue;
+ }
+ result[count] = new Ex(
+ count,
+ i,
+ pa[j * numPerType],
+ false);
+ count++;
}
- int s = r.nextInt(ns);
- Proc.d("Console send to " + s);
- result[i] = round(i, old, s, expected);
- Proc.d("Console sees " + result[i].actual);
+ }
+ } else {
+ String[] runs = userRuns.split(",");
+ result = new Ex[runs.length];
+ for (int i = 0; i < runs.length; i++) {
+ UserRun run = new UserRun(runs[i]);
+ result[i] = new Ex(
+ i,
+ run.req() == -1 ?
+ req(run.client(), run.service()) :
+ result[run.req()].req,
+ Arrays.stream(pa)
+ .filter(p -> p.debug().equals(run.acceptor()))
+ .findFirst()
+ .orElseThrow(() -> new Exception(
+ "no acceptor named " + run.acceptor())),
+ run.success());
}
}
- pc.println("END");
- for (int i=0; i<ns; i++) {
- ps[i].println("END");
+ for (Ex x : result) {
+ x.run();
}
- System.out.println("Result\n======");
+
+ pi.println("END");
+ for (int i=0; i<na; i++) {
+ pa[i].println("END");
+ }
+ System.out.println("\nAll Test Results\n================");
boolean finalOut = true;
- for (int i=0; i<nx; i++) {
+ System.out.println(" req** client service acceptor Result");
+ System.out.println("---- ------- ------ --------- -------- -------");
+ for (int i=0; i<result.length; i++) {
boolean out = result[i].expected==result[i].actual;
finalOut &= out;
- System.out.printf("%3d: %s (%2d): u%d h%d %s %s %s %2d\n",
+ System.out.printf("%3d: %3d%s c%d s%d %4s %8s %s %s\n",
i,
- result[i].expected?"----":" ",
- result[i].old,
- result[i].user, result[i].peer, result[i].server,
- result[i].actual?"Good":"Bad ",
- out?" ":"xxx",
- result[i].csize);
+ result[i].req,
+ result[i].expected ? "**" : " ",
+ reqs.get(result[i].req).client,
+ reqs.get(result[i].req).service,
+ "(" + result[i].csize + ")",
+ result[i].acceptor.debug(),
+ result[i].actual ? "++" : "--",
+ out ? " " : "xxx");
+ }
+
+ System.out.println("\nPath of Reqs\n============");
+ for (int j=0; ; j++) {
+ boolean found = false;
+ for (int i=0; i<result.length; i++) {
+ if (result[i].req == j) {
+ if (!found) {
+ System.out.printf("%3d (c%s -> s%s): ", j,
+ reqs.get(j).client, reqs.get(j).service);
+ }
+ System.out.printf("%s%s(%d)%s",
+ found ? " -> " : "",
+ result[i].acceptor.debug(),
+ i,
+ result[i].actual != result[i].expected ?
+ "xxx" : "");
+ found = true;
+ }
+ }
+ System.out.println();
+ if (!found) {
+ break;
+ }
}
if (!finalOut) throw new Exception();
- } else if (args[0].equals("N-1")) {
+ } else if (args[0].equals("Nsanity")) {
// Native mode sanity check
Proc.d("Detect start");
Context s = Context.fromUserKtab("*", OneKDC.KTAB, true);
s.startAsServer(GSSUtil.GSS_KRB5_MECH_OID);
- } else if (args[0].equals("client")) {
+ } else if (args[0].equals("initiator")) {
while (true) {
String title = Proc.textIn();
Proc.d("Client see " + title);
@@ -185,22 +281,26 @@
Proc.binOut(token);
}
} else {
+ Proc.d(System.getProperty("java.vm.version"));
+ Proc.d(System.getProperty("sun.security.jgss.native"));
+ Proc.d(System.getProperty("sun.security.jgss.lib"));
+ Proc.d("---------------------------------\n");
Proc.d("Server start");
Context s = Context.fromUserKtab("*", OneKDC.KTAB, true);
Proc.d("Server login");
while (true) {
String title = Proc.textIn();
- Proc.d("Server " + args[0] + " sees " + title);
+ Proc.d("Server sees " + title);
if (title.equals("END")) break;
s.startAsServer(GSSUtil.GSS_KRB5_MECH_OID);
byte[] token = Proc.binIn();
try {
s.take(token);
Proc.textOut("true");
- Proc.d(args[0] + " Good");
+ Proc.d("Good");
} catch (Exception e) {
Proc.textOut("false");
- Proc.d(args[0] + " Bad");
+ Proc.d("Bad");
}
}
}
@@ -215,79 +315,90 @@
}
}
- // returns the user name
- private static String user(int p) {
- return "USER" + p;
+ // returns the client name
+ private static String client(int p) {
+ return "client" + p;
}
- // returns the peer name
- private static String peer(int p) {
- return "host" + p + "/" + HOST;
+
+ // returns the service name
+ private static String service(int p) {
+ return "service" + p + "/" + HOST;
}
- // returns the dfl name for a host
+
+ // returns the dfl name for a service
private static String dfl(int p) {
- return cwd + "host" + p + (uid == -1 ? "" : ("_"+uid));
+ return "service" + p + (uid == -1 ? "" : ("_"+uid));
}
+
// generates an ap-req and save into reqs, returns the index
- private static int req(int user, int peer) throws Exception {
- pc.println(user(user) + " " + peer(peer));
- Req req = new Req(user, peer, pc.readData());
+ private static int req(int client, int service) throws Exception {
+ pi.println(client(client) + " " + service(service));
+ Req req = new Req(client, service, pi.readData());
reqs.add(req);
return reqs.size() - 1;
}
- // carries out a round of experiment
- // i: ex#, old: which req, server: which server, expected: result?
- private static Ex round(int i, int old, int server, boolean expected)
- throws Exception {
- ps[server].println("TEST");
- ps[server].println(reqs.get(old).msg);
- String reply = ps[server].readData();
- Ex result = new Ex();
- result.i = i;
- result.expected = expected;
- result.server = ps[server].debug();
- result.actual = Boolean.valueOf(reply);
- result.user = reqs.get(old).user;
- result.peer = reqs.get(old).peer;
- result.old = old;
- result.csize = csize(result.peer);
- result.hash = hash(reqs.get(old).msg);
- if (new File(dfl(result.peer)).exists()) {
- Files.copy(Paths.get(dfl(result.peer)), Paths.get(
- String.format("%03d-USER%d-host%d-%s-%s",
- i, result.user, result.peer, result.server,
- result.actual)
- + "-" + result.hash),
- StandardCopyOption.COPY_ATTRIBUTES);
+
+ // create a acceptor
+ private static Proc acceptor(String type, String suffix) throws Exception {
+ Proc p;
+ String label;
+ String lib;
+ int pos = type.indexOf('=');
+ if (pos < 0) {
+ label = type;
+ lib = null;
+ } else {
+ label = type.substring(0, pos);
+ lib = type.substring(pos + 1);
}
- return result;
+ if (type.startsWith("J")) {
+ if (lib == null) {
+ p = Proc.create("ReplayCacheTestProc");
+ } else {
+ p = Proc.create("ReplayCacheTestProc", lib);
+ }
+ p.prop("sun.security.krb5.rcache", "dfl")
+ .prop("java.io.tmpdir", cwd);
+ String useMD5 = System.getProperty("jdk.krb5.rcache.useMD5");
+ if (useMD5 != null) {
+ p.prop("jdk.krb5.rcache.useMD5", useMD5);
+ }
+ } else {
+ p = Proc.create("ReplayCacheTestProc")
+ .env("KRB5_CONFIG", OneKDC.KRB5_CONF)
+ .env("KRB5_KTNAME", OneKDC.KTAB)
+ .env("KRB5RCACHEDIR", cwd)
+ .prop("sun.security.jgss.native", "true")
+ .prop("javax.security.auth.useSubjectCredsOnly", "false")
+ .prop("sun.security.nativegss.debug", "true");
+ if (lib != null) {
+ String libDir = lib.substring(0, lib.lastIndexOf('/'));
+ p.prop("sun.security.jgss.lib", lib)
+ .env("DYLD_LIBRARY_PATH", libDir)
+ .env("LD_LIBRARY_PATH", libDir);
+ }
+ }
+ Proc.d(label+suffix+" started");
+ return p.args(label+suffix).debug(label+suffix).start();
}
- // create a native server
- private static Proc ns(int i) throws Exception {
- return Proc.create("ReplayCacheTestProc")
- .args("N"+i)
- .env("KRB5_CONFIG", OneKDC.KRB5_CONF)
- .env("KRB5_KTNAME", OneKDC.KTAB)
- .env("KRB5RCACHEDIR", cwd)
- .prop("sun.security.jgss.native", "true")
- .prop("javax.security.auth.useSubjectCredsOnly", "false")
- .prop("sun.security.nativegss.debug", "true")
- .debug("N"+i)
- .start();
+
+ // generates hash of authenticator inside ap-req inside initsectoken
+ private static void record(String label, Req req) throws Exception {
+ byte[] data = Base64.getDecoder().decode(req.msg);
+ data = Arrays.copyOfRange(data, 17, data.length);
+
+ try (PrintStream ps = new PrintStream(
+ new FileOutputStream("log.txt", true))) {
+ ps.printf("%s:\nmsg: %s\nMD5: %s\nSHA-256: %s\n\n",
+ label,
+ req.msg,
+ hex(md5.digest(data)),
+ hex(sha256.digest(data)));
+ }
}
- // creates a java server
- private static Proc js(int i) throws Exception {
- return Proc.create("ReplayCacheTestProc")
- .debug("S"+i)
- .args("S"+i)
- .prop("sun.security.krb5.rcache", "dfl")
- .prop("java.io.tmpdir", cwd)
- .start();
- }
- // generates hash of authenticator inside ap-req inside initsectoken
- private static String hash(String req) throws Exception {
- byte[] data = Base64.getDecoder().decode(req);
- data = Arrays.copyOfRange(data, 17, data.length);
- byte[] hash = MessageDigest.getInstance("MD5").digest(new APReq(data).authenticator.getBytes());
+
+ // Returns a compact hexdump for a byte array
+ private static String hex(byte[] hash) {
char[] h = new char[hash.length * 2];
char[] hexConst = "0123456789ABCDEF".toCharArray();
for (int i=0; i<hash.length; i++) {
@@ -296,10 +407,11 @@
}
return new String(h);
}
+
// return size of dfl file, excluding the null hash ones
private static int csize(int p) throws Exception {
try (SeekableByteChannel chan = Files.newByteChannel(
- Paths.get(dfl(p)), StandardOpenOption.READ)) {
+ Paths.get(cwd, dfl(p)), StandardOpenOption.READ)) {
chan.position(6);
int cc = 0;
while (true) {
@@ -314,27 +426,73 @@
return 0;
}
}
+
// models an experiement
private static class Ex {
int i; // #
+ int req; // which ap-req to send
+ Proc acceptor; // which acceptor to send to
boolean expected; // expected result
+
boolean actual; // actual output
- int old; // which ap-req to send
- String server; // which server to send to
+ int csize; // size of rcache after test
String hash; // the hash of req
- int user; // which initiator
- int peer; // which acceptor
- int csize; // size of rcache after test
+
+ Ex(int i, int req, Proc acceptor, boolean expected) {
+ this.i = i;
+ this.req = req;
+ this.acceptor = acceptor;
+ this.expected = expected;
+ }
+
+ void run() throws Exception {
+ Req r = reqs.get(req);
+ acceptor.println("TEST");
+ acceptor.println(r.msg);
+ String reply = acceptor.readData();
+
+ actual = Boolean.valueOf(reply);
+ csize = csize(r.service);
+
+ String label = String.format("%03d-CLIENT%d-SERVICE%d-%s-%s",
+ i, r.client, r.service, acceptor.debug(), actual);
+
+ record(label, r);
+ if (new File(cwd, dfl(r.service)).exists()) {
+ Files.copy(Paths.get(cwd, dfl(r.service)), Paths.get(label),
+ StandardCopyOption.COPY_ATTRIBUTES);
+ }
+ }
}
+
// models a saved ap-req msg
private static class Req {
String msg; // based64-ed req
- int user; // which initiator
- int peer; // which accceptor
- Req(int user, int peer, String msg) {
+ int client; // which client
+ int service; // which service
+ Req(int client, int service, String msg) {
this.msg = msg;
- this.user= user;
- this.peer = peer;
+ this.client= client;
+ this.service = service;
+ }
+ }
+
+ private static class UserRun {
+ static final Pattern p
+ = Pattern.compile("(c(\\d)+s(\\d+)|r(\\d+))(.*)(.)");
+ final Matcher m;
+
+ UserRun(String run) { m = p.matcher(run); m.find(); }
+
+ int req() { return group(4); }
+ int client() { return group(2); }
+ int service() { return group(3); }
+ String acceptor() { return m.group(5); }
+ boolean success() { return m.group(6).equals("v"); }
+
+ int group(int i) {
+ String g = m.group(i);
+ return g == null ? -1 : Integer.parseInt(g);
}
}
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/krb5/auto/rcache_usemd5.sh Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,30 @@
+#
+# Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+# @test
+# @bug 8168518
+# @library ../../../../java/security/testlibrary/ /test/lib
+# @run main/othervm/timeout=300 -Djdk.krb5.rcache.useMD5=true ReplayCacheTestProc
+# @summary testing jdk.krb5.rcache.useMD5. This action is put in a separate
+# test so that ReplayCacheTestProc.java can be launched with special
+# test.* system properties easily.
--- a/jdk/test/sun/security/mscapi/IsSunMSCAPIAvailable.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/test/sun/security/mscapi/IsSunMSCAPIAvailable.java Wed Nov 09 10:04:43 2016 -0800
@@ -26,6 +26,7 @@
* @bug 6318171 6931562
* @requires os.family == "windows"
* @modules jdk.crypto.mscapi/sun.security.mscapi
+ * @compile --add-modules jdk.crypto.mscapi IsSunMSCAPIAvailable.java
* @run main/othervm IsSunMSCAPIAvailable
*/
--- a/jdk/test/sun/security/pkcs11/ec/TestCurves.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/test/sun/security/pkcs11/ec/TestCurves.java Wed Nov 09 10:04:43 2016 -0800
@@ -28,7 +28,7 @@
* @author Andreas Sterbenz
* @library ..
* @modules jdk.crypto.pkcs11/sun.security.pkcs11.wrapper
- * @compile -XDignore.symbol.file TestCurves.java
+ * @compile --add-modules jdk.crypto.pkcs11 TestCurves.java
* @run main/othervm TestCurves
* @run main/othervm TestCurves sm
* @key randomness
--- a/jdk/test/sun/security/tools/keytool/KeyToolTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/test/sun/security/tools/keytool/KeyToolTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -1211,18 +1211,26 @@
void sqePrintcertTest() throws Exception {
remove("x.jks");
remove("mykey.cert");
+ remove("myweakkey.cert");
testOK("", "-keystore x.jks -storetype JKS -storepass changeit " +
"-keypass changeit -genkeypair -dname CN=olala");
testOK("", "-keystore x.jks -storetype JKS -storepass changeit " +
"-export -file mykey.cert -alias mykey");
+ testOK("", "-keystore x.jks -storetype JKS -storepass changeit " +
+ "-keypass changeit -genkeypair -dname CN=weak -keyalg rsa " +
+ "-keysize 512 -sigalg MD5withRSA -alias myweakkey");
+ testOK("", "-keystore x.jks -storetype JKS -storepass changeit " +
+ "-export -file myweakkey.cert -alias myweakkey");
testFail("", "-printcert -file badkeystore");
testFail("", "-printcert -file a/b/c/d");
testOK("", "-printcert -file mykey.cert");
+ testOK("", "-printcert -file myweakkey.cert");
FileInputStream fin = new FileInputStream("mykey.cert");
testOK(fin, "-printcert");
fin.close();
remove("x.jks");
remove("mykey.cert");
+ remove("myweakkey.cert");
}
// 8074935: jdk8 keytool doesn't validate pem files for RFC 1421 correctness
--- a/jdk/test/sun/security/tools/keytool/PrintSSL.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/test/sun/security/tools/keytool/PrintSSL.java Wed Nov 09 10:04:43 2016 -0800
@@ -24,20 +24,32 @@
/*
* @test
* @bug 6480981 8160624
- * @modules java.base/sun.security.tools.keytool
* @summary keytool should be able to import certificates from remote SSL server
+ * @library /lib/security
+ * @library /lib/testlibrary
* @run main/othervm PrintSSL
*/
-import java.io.IOException;
import java.net.ServerSocket;
+import java.nio.file.Files;
+import java.nio.file.Paths;
import java.util.concurrent.CountDownLatch;
import javax.net.ssl.SSLServerSocketFactory;
import javax.net.ssl.SSLSocket;
+import jdk.testlibrary.OutputAnalyzer;
public class PrintSSL {
- public static void main(String[] args) throws Exception {
+ public static void main(String[] args) throws Throwable {
+ Files.deleteIfExists(Paths.get("keystore"));
+
+ // make sure that "-printcert" works with weak algorithms
+ OutputAnalyzer out = SecurityTools.keytool("-genkeypair "
+ + "-keystore keystore -storepass passphrase "
+ + "-keypass passphrase -keyalg rsa -keysize 512 "
+ + "-sigalg MD5withRSA -alias rsa_alias -dname CN=Server");
+ System.out.println(out.getOutput());
+ out.shouldHaveExitValue(0);
int port = new Server().start();
if(port == -1) {
@@ -47,7 +59,10 @@
String cmd = String.format(
"-debug %s -printcert -sslserver localhost:%s",
((vmOpt == null) ? "" : vmOpt ), port);
- sun.security.tools.keytool.Main.main(cmd.split("\\s+"));
+
+ out = SecurityTools.keytool(cmd);
+ System.out.println(out.getOutput());
+ out.shouldHaveExitValue(0);
}
private static class Server implements Runnable {
@@ -68,9 +83,7 @@
public void run() {
System.setProperty("javax.net.ssl.keyStorePassword", "passphrase");
- System.setProperty("javax.net.ssl.keyStore",
- System.getProperty("test.src", "./")
- + "/../../../../javax/net/ssl/etc/keystore");
+ System.setProperty("javax.net.ssl.keyStore", "keystore");
SSLServerSocketFactory sslssf =
(SSLServerSocketFactory) SSLServerSocketFactory.getDefault();
try (ServerSocket server = sslssf.createServerSocket(0)) {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/tools/keytool/ReadJar.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 6890872 8168882
+ * @summary keytool -printcert to recognize signed jar files
+ * @library /lib/security
+ * @library /lib/testlibrary
+ */
+
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import jdk.testlibrary.JarUtils;
+import jdk.testlibrary.OutputAnalyzer;
+
+public class ReadJar {
+
+ public static void main(String[] args) throws Throwable {
+ testWithMD5();
+ }
+
+ // make sure that -printcert option works
+ // if a weak algorithm was used for signing a jar
+ private static void testWithMD5() throws Throwable {
+ // create jar files
+ JarUtils.createJar("test_md5.jar", "test");
+ JarUtils.createJar("test_rsa.jar", "test");
+
+ // create a keystore and generate keys for jar signing
+ Files.deleteIfExists(Paths.get("keystore"));
+
+ OutputAnalyzer out = SecurityTools.keytool("-genkeypair "
+ + "-keystore keystore -storepass password "
+ + "-keypass password -keyalg rsa -alias rsa_alias -dname CN=A");
+ System.out.println(out.getOutput());
+ out.shouldHaveExitValue(0);
+
+ out = SecurityTools.jarsigner("test_rsa.jar", "rsa_alias",
+ "-keystore keystore -storepass password ");
+ System.out.println(out.getOutput());
+ out.shouldHaveExitValue(0);
+
+ printCert("test_rsa.jar");
+
+ out = SecurityTools.jarsigner("test_md5.jar", "rsa_alias",
+ "-keystore keystore -storepass password "
+ + "-sigalg MD5withRSA -digestalg MD5");
+ System.out.println(out.getOutput());
+ out.shouldHaveExitValue(0);
+
+ printCert("test_md5.jar");
+ }
+
+ private static void printCert(String jar) throws Throwable {
+ OutputAnalyzer out = SecurityTools.keytool("-printcert -jarfile " + jar);
+ System.out.println(out.getOutput());
+ out.shouldHaveExitValue(0);
+ out.shouldNotContain("Not a signed jar file");
+
+ out = SecurityTools.keytool("-printcert -rfc -jarfile " + jar);
+ System.out.println(out.getOutput());
+ out.shouldHaveExitValue(0);
+ out.shouldNotContain("Not a signed jar file");
+ }
+}
--- a/jdk/test/sun/security/tools/keytool/readjar.sh Wed Nov 09 15:20:30 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,57 +0,0 @@
-#
-# Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-# @test
-# @bug 6890872
-# @summary keytool -printcert to recognize signed jar files
-#
-
-if [ "${TESTJAVA}" = "" ] ; then
- JAVAC_CMD=`which javac`
- TESTJAVA=`dirname $JAVAC_CMD`/..
- COMPILEJAVA=${TESTJAVA}
-fi
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
- Windows_* )
- FS="\\"
- ;;
- * )
- FS="/"
- ;;
-esac
-
-KS=readjar.jks
-rm $KS
-$TESTJAVA${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -storepass changeit -keypass changeit -keystore $KS \
- -keyalg rsa -alias x -dname CN=X -genkeypair
-$COMPILEJAVA${FS}bin${FS}jar ${TESTTOOLVMOPTS} cvf readjar.jar $KS
-$COMPILEJAVA${FS}bin${FS}jarsigner ${TESTTOOLVMOPTS} -storepass changeit -keystore $KS readjar.jar x
-
-$TESTJAVA${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -printcert -jarfile readjar.jar || exit 1
-$TESTJAVA${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -printcert -jarfile readjar.jar -rfc || exit 1
-
-exit 0
-
--- a/jdk/test/sun/util/calendar/zi/tzdata/VERSION Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/test/sun/util/calendar/zi/tzdata/VERSION Wed Nov 09 10:04:43 2016 -0800
@@ -21,4 +21,4 @@
# or visit www.oracle.com if you need additional information or have any
# questions.
#
-tzdata2016h
+tzdata2016i
--- a/jdk/test/sun/util/calendar/zi/tzdata/antarctica Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/test/sun/util/calendar/zi/tzdata/antarctica Wed Nov 09 10:04:43 2016 -0800
@@ -87,13 +87,18 @@
# Background:
# http://www.timeanddate.com/news/time/antartica-time-changes-2010.html
+# From Steffen Thorsen (2016-10-28):
+# Australian Antarctica Division informed us that Casey changed time
+# zone to UTC+11 in "the morning of 22nd October 2016".
+
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone Antarctica/Casey 0 - -00 1969
8:00 - +08 2009 Oct 18 2:00
11:00 - +11 2010 Mar 5 2:00
8:00 - +08 2011 Oct 28 2:00
11:00 - +11 2012 Feb 21 17:00u
- 8:00 - +08
+ 8:00 - +08 2016 Oct 22
+ 11:00 - +11
Zone Antarctica/Davis 0 - -00 1957 Jan 13
7:00 - +07 1964 Nov
0 - -00 1969 Feb
--- a/jdk/test/sun/util/calendar/zi/tzdata/asia Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/test/sun/util/calendar/zi/tzdata/asia Wed Nov 09 10:04:43 2016 -0800
@@ -794,9 +794,19 @@
###############################################################################
# Cyprus
-#
+
# Milne says the Eastern Telegraph Company used 2:14:00. Stick with LMT.
+# IATA SSIM (1998-09) has Cyprus using EU rules for the first time.
+
+# From Paul Eggert (2016-09-09):
+# Yesterday's Cyprus Mail reports that Northern Cyprus followed Turkey's
+# lead and switched from +02/+03 to +03 year-round.
+# http://cyprus-mail.com/2016/09/08/two-time-zones-cyprus-turkey-will-not-turn-clocks-back-next-month/
#
+# From Even Scharning (2016-10-31):
+# Looks like the time zone split in Cyprus went through last night.
+# http://cyprus-mail.com/2016/10/30/cyprus-new-division-two-time-zones-now-reality/
+
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
Rule Cyprus 1975 only - Apr 13 0:00 1:00 S
Rule Cyprus 1975 only - Oct 12 0:00 0 -
@@ -811,7 +821,10 @@
Zone Asia/Nicosia 2:13:28 - LMT 1921 Nov 14
2:00 Cyprus EE%sT 1998 Sep
2:00 EUAsia EE%sT
-# IATA SSIM (1998-09) has Cyprus using EU rules for the first time.
+Zone Asia/Famagusta 2:15:48 - LMT 1921 Nov 14
+ 2:00 Cyprus EE%sT 1998 Sep
+ 2:00 EUAsia EE%sT 2016 Sep 8
+ 3:00 - +03
# Classically, Cyprus belongs to Asia; e.g. see Herodotus, Histories, I.72.
# However, for various reasons many users expect to find it under Europe.
--- a/jdk/test/sun/util/calendar/zi/tzdata/australasia Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/test/sun/util/calendar/zi/tzdata/australasia Wed Nov 09 10:04:43 2016 -0800
@@ -725,11 +725,13 @@
Rule Tonga 2000 only - Mar 19 2:00s 0 -
Rule Tonga 2000 2001 - Nov Sun>=1 2:00 1:00 S
Rule Tonga 2001 2002 - Jan lastSun 2:00 0 -
+Rule Tonga 2016 max - Nov Sun>=1 2:00 1:00 S
+Rule Tonga 2017 max - Jan Sun>=15 3:00 0 -
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone Pacific/Tongatapu 12:19:20 - LMT 1901
- 12:20 - TOT 1941 # Tonga Time
- 13:00 - TOT 1999
- 13:00 Tonga TO%sT
+ 12:20 - +1220 1941
+ 13:00 - +13 1999
+ 13:00 Tonga +13/+14
# Tuvalu
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
@@ -1735,9 +1737,17 @@
# of January the standard time in the Kingdom shall be moved backward by one
# hour to 1:00am.
-# From Pulu 'Anau (2002-11-05):
+# From Pulu ʻAnau (2002-11-05):
# The law was for 3 years, supposedly to get renewed. It wasn't.
+# From Pulu ʻAnau (2016-10-27):
+# http://mic.gov.to/news-today/press-releases/6375-daylight-saving-set-to-run-from-6-november-2016-to-15-january-2017
+# Cannot find anyone who knows the rules, has seen the duration or has seen
+# the cabinet decision, but it appears we are following Fiji's rule set.
+#
+# From Tim Parenti (2016-10-26):
+# Assume Tonga will observe DST from the first Sunday in November at 02:00
+# through the third Sunday in January at 03:00, like Fiji, for now.
# Wake
--- a/jdk/test/sun/util/calendar/zi/tzdata/europe Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/test/sun/util/calendar/zi/tzdata/europe Wed Nov 09 10:04:43 2016 -0800
@@ -1523,73 +1523,84 @@
# But these events all occurred before the 1970 cutoff,
# so record only the time in Rome.
#
-# From Paul Eggert (2006-03-22):
-# For Italian DST we have three sources: Shanks & Pottenger, Whitman, and
-# F. Pollastri
-# Day-light Saving Time in Italy (2006-02-03)
-# http://toi.iriti.cnr.it/uk/ienitlt.html
-# ('FP' below), taken from an Italian National Electrotechnical Institute
-# publication. When the three sources disagree, guess who's right, as follows:
+# From Michael Deckers (2016-10-24):
+# http://www.ac-ilsestante.it/MERIDIANE/ora_legale quotes a law of 1893-08-10
+# ... [translated as] "The preceding dispositions will enter into
+# force at the instant at which, according to the time specified in
+# the 1st article, the 1st of November 1893 will begin...."
#
-# year FP Shanks&P. (S) Whitman (W) Go with:
-# 1916 06-03 06-03 24:00 06-03 00:00 FP & W
-# 09-30 09-30 24:00 09-30 01:00 FP; guess 24:00s
-# 1917 04-01 03-31 24:00 03-31 00:00 FP & S
-# 09-30 09-29 24:00 09-30 01:00 FP & W
-# 1918 03-09 03-09 24:00 03-09 00:00 FP & S
-# 10-06 10-05 24:00 10-06 01:00 FP & W
-# 1919 03-01 03-01 24:00 03-01 00:00 FP & S
-# 10-04 10-04 24:00 10-04 01:00 FP; guess 24:00s
-# 1920 03-20 03-20 24:00 03-20 00:00 FP & S
-# 09-18 09-18 24:00 10-01 01:00 FP; guess 24:00s
-# 1944 04-02 04-03 02:00 S (see C-Eur)
-# 09-16 10-02 03:00 FP; guess 24:00s
-# 1945 09-14 09-16 24:00 FP; guess 24:00s
-# 1970 05-21 05-31 00:00 S
-# 09-20 09-27 00:00 S
+# From Pierpaolo Bernardi (2016-10-20):
+# The authoritative source for time in Italy is the national metrological
+# institute, which has a summary page of historical DST data at
+# http://www.inrim.it/res/tf/ora_legale_i.shtml
+# (2016-10-24):
+# http://www.renzobaldini.it/le-ore-legali-in-italia/
+# has still different data for 1944. It divides Italy in two, as
+# there were effectively two governments at the time, north of Gothic
+# Line German controlled territory, official government RSI, and south
+# of the Gothic Line, controlled by allied armies.
+#
+# From Brian Inglis (2016-10-23):
+# Viceregal LEGISLATIVE DECREE. 14 September 1944, no. 219.
+# Restoration of Standard Time. (044U0219) (OJ 62 of 30.9.1944) ...
+# Given the R. law decreed on 1944-03-29, no. 92, by which standard time is
+# advanced to sixty minutes later starting at hour two on 1944-04-02; ...
+# Starting at hour three on the date 1944-09-17 standard time will be resumed.
+#
+# From Paul Eggert (2016-10-27):
+# Go with INRiM for DST rules, except as corrected by Inglis for 1944
+# for the Kingdom of Italy. This is consistent with Renzo Baldini.
+# Model Rome's occupation by using using C-Eur rules from 1943-09-10
+# to 1944-06-04; although Rome was an open city during this period, it
+# was effectively controlled by Germany.
#
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
-Rule Italy 1916 only - Jun 3 0:00s 1:00 S
-Rule Italy 1916 only - Oct 1 0:00s 0 -
-Rule Italy 1917 only - Apr 1 0:00s 1:00 S
-Rule Italy 1917 only - Sep 30 0:00s 0 -
-Rule Italy 1918 only - Mar 10 0:00s 1:00 S
-Rule Italy 1918 1919 - Oct Sun>=1 0:00s 0 -
-Rule Italy 1919 only - Mar 2 0:00s 1:00 S
-Rule Italy 1920 only - Mar 21 0:00s 1:00 S
-Rule Italy 1920 only - Sep 19 0:00s 0 -
-Rule Italy 1940 only - Jun 15 0:00s 1:00 S
-Rule Italy 1944 only - Sep 17 0:00s 0 -
-Rule Italy 1945 only - Apr 2 2:00 1:00 S
-Rule Italy 1945 only - Sep 15 0:00s 0 -
-Rule Italy 1946 only - Mar 17 2:00s 1:00 S
-Rule Italy 1946 only - Oct 6 2:00s 0 -
-Rule Italy 1947 only - Mar 16 0:00s 1:00 S
-Rule Italy 1947 only - Oct 5 0:00s 0 -
-Rule Italy 1948 only - Feb 29 2:00s 1:00 S
-Rule Italy 1948 only - Oct 3 2:00s 0 -
-Rule Italy 1966 1968 - May Sun>=22 0:00 1:00 S
-Rule Italy 1966 1969 - Sep Sun>=22 0:00 0 -
-Rule Italy 1969 only - Jun 1 0:00 1:00 S
-Rule Italy 1970 only - May 31 0:00 1:00 S
-Rule Italy 1970 only - Sep lastSun 0:00 0 -
-Rule Italy 1971 1972 - May Sun>=22 0:00 1:00 S
-Rule Italy 1971 only - Sep lastSun 1:00 0 -
-Rule Italy 1972 only - Oct 1 0:00 0 -
-Rule Italy 1973 only - Jun 3 0:00 1:00 S
-Rule Italy 1973 1974 - Sep lastSun 0:00 0 -
-Rule Italy 1974 only - May 26 0:00 1:00 S
-Rule Italy 1975 only - Jun 1 0:00s 1:00 S
-Rule Italy 1975 1977 - Sep lastSun 0:00s 0 -
-Rule Italy 1976 only - May 30 0:00s 1:00 S
-Rule Italy 1977 1979 - May Sun>=22 0:00s 1:00 S
-Rule Italy 1978 only - Oct 1 0:00s 0 -
-Rule Italy 1979 only - Sep 30 0:00s 0 -
+Rule Italy 1916 only - Jun 3 24:00 1:00 S
+Rule Italy 1916 1917 - Sep 30 24:00 0 -
+Rule Italy 1917 only - Mar 31 24:00 1:00 S
+Rule Italy 1918 only - Mar 9 24:00 1:00 S
+Rule Italy 1918 only - Oct 6 24:00 0 -
+Rule Italy 1919 only - Mar 1 24:00 1:00 S
+Rule Italy 1919 only - Oct 4 24:00 0 -
+Rule Italy 1920 only - Mar 20 24:00 1:00 S
+Rule Italy 1920 only - Sep 18 24:00 0 -
+Rule Italy 1940 only - Jun 14 24:00 1:00 S
+Rule Italy 1942 only - Nov 2 2:00s 0 -
+Rule Italy 1943 only - Mar 29 2:00s 1:00 S
+Rule Italy 1943 only - Oct 4 2:00s 0 -
+Rule Italy 1944 only - Apr 2 2:00s 1:00 S
+Rule Italy 1944 only - Sep 17 2:00s 0 -
+Rule Italy 1945 only - Apr 2 2:00 1:00 S
+Rule Italy 1945 only - Sep 15 1:00 0 -
+Rule Italy 1946 only - Mar 17 2:00s 1:00 S
+Rule Italy 1946 only - Oct 6 2:00s 0 -
+Rule Italy 1947 only - Mar 16 0:00s 1:00 S
+Rule Italy 1947 only - Oct 5 0:00s 0 -
+Rule Italy 1948 only - Feb 29 2:00s 1:00 S
+Rule Italy 1948 only - Oct 3 2:00s 0 -
+Rule Italy 1966 1968 - May Sun>=22 0:00s 1:00 S
+Rule Italy 1966 only - Sep 24 24:00 0 -
+Rule Italy 1967 1969 - Sep Sun>=22 0:00s 0 -
+Rule Italy 1969 only - Jun 1 0:00s 1:00 S
+Rule Italy 1970 only - May 31 0:00s 1:00 S
+Rule Italy 1970 only - Sep lastSun 0:00s 0 -
+Rule Italy 1971 1972 - May Sun>=22 0:00s 1:00 S
+Rule Italy 1971 only - Sep lastSun 0:00s 0 -
+Rule Italy 1972 only - Oct 1 0:00s 0 -
+Rule Italy 1973 only - Jun 3 0:00s 1:00 S
+Rule Italy 1973 1974 - Sep lastSun 0:00s 0 -
+Rule Italy 1974 only - May 26 0:00s 1:00 S
+Rule Italy 1975 only - Jun 1 0:00s 1:00 S
+Rule Italy 1975 1977 - Sep lastSun 0:00s 0 -
+Rule Italy 1976 only - May 30 0:00s 1:00 S
+Rule Italy 1977 1979 - May Sun>=22 0:00s 1:00 S
+Rule Italy 1978 only - Oct 1 0:00s 0 -
+Rule Italy 1979 only - Sep 30 0:00s 0 -
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone Europe/Rome 0:49:56 - LMT 1866 Sep 22
- 0:49:56 - RMT 1893 Nov 1 0:00s # Rome Mean
- 1:00 Italy CE%sT 1942 Nov 2 2:00s
- 1:00 C-Eur CE%sT 1944 Jul
+ 0:49:56 - RMT 1893 Oct 31 23:49:56 # Rome Mean
+ 1:00 Italy CE%sT 1943 Sep 10
+ 1:00 C-Eur CE%sT 1944 Jun 4
1:00 Italy CE%sT 1980
1:00 EU CE%sT
@@ -1788,6 +1799,10 @@
# See Europe/Belgrade.
# Malta
+#
+# From Paul Eggert (2016-10-21):
+# Assume 1900-1972 was like Rome, overriding Shanks.
+#
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
Rule Malta 1973 only - Mar 31 0:00s 1:00 S
Rule Malta 1973 only - Sep 29 0:00s 0 -
@@ -1798,8 +1813,6 @@
Rule Malta 1980 only - Mar 31 2:00 1:00 S
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone Europe/Malta 0:58:04 - LMT 1893 Nov 2 0:00s # Valletta
- 1:00 Italy CE%sT 1942 Nov 2 2:00s
- 1:00 C-Eur CE%sT 1945 Apr 2 2:00s
1:00 Italy CE%sT 1973 Mar 31
1:00 Malta CE%sT 1981
1:00 EU CE%sT
@@ -1931,7 +1944,7 @@
# Amsterdam mean time.
# The data entries before 1945 are taken from
-# http://www.staff.science.uu.nl/~gent0113/idl/idl.htm
+# http://www.staff.science.uu.nl/~gent0113/wettijd/wettijd.htm
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
Rule Neth 1916 only - May 1 0:00 1:00 NST # Netherlands Summer Time
--- a/jdk/test/sun/util/calendar/zi/tzdata/zone.tab Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/test/sun/util/calendar/zi/tzdata/zone.tab Wed Nov 09 10:04:43 2016 -0800
@@ -175,7 +175,8 @@
CV +1455-02331 Atlantic/Cape_Verde
CW +1211-06900 America/Curacao
CX -1025+10543 Indian/Christmas
-CY +3510+03322 Asia/Nicosia
+CY +3510+03322 Asia/Nicosia Cyprus (most areas)
+CY +3507+03357 Asia/Famagusta Northern Cyprus
CZ +5005+01426 Europe/Prague
DE +5230+01322 Europe/Berlin Germany (most areas)
DE +4742+00841 Europe/Busingen Busingen
--- a/jdk/test/tools/jlink/JLinkPluginsTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/test/tools/jlink/JLinkPluginsTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -83,5 +83,21 @@
Path imageDir = helper.generateDefaultImage(userOptions, moduleName).assertSuccess();
helper.checkImage(imageDir, moduleName, null, null);
}
+ {
+ // disable generate jli classes - JDK-8160063
+ String[] userOptions = {"--disable-plugin", "generate-jli-classes"};
+ String moduleName = "jlidisabled";
+ helper.generateDefaultJModule(moduleName, "composite2");
+ Path imageDir = helper.generateDefaultImage(userOptions, moduleName).assertSuccess();
+ helper.checkImage(imageDir, moduleName, null, null);
+ }
+ {
+ // disable invalid plugin - JDK-8160063
+ String[] userOptions = {"--disable-plugin", "non-existent-plugin"};
+ String moduleName = "invaliddisabled";
+ helper.generateDefaultJModule(moduleName, "composite2");
+ helper.generateDefaultImage(userOptions, moduleName).
+ assertFailure("Error: No such plugin: non-existent-plugin");
+ }
}
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/jlink/JLinkSigningTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,195 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8159393
+ * @summary Test signed jars involved in image creation
+ * @modules java.base/jdk.internal.jimage
+ * jdk.jlink/jdk.tools.jlink.internal
+ * jdk.compiler/com.sun.tools.javac
+ * java.base/sun.security.tools.keytool
+ * jdk.jartool/sun.security.tools.jarsigner
+ * jdk.jartool/sun.tools.jar
+ * @run main/othervm JLinkSigningTest
+ */
+
+
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Arrays;
+
+public class JLinkSigningTest {
+ static final String[] MODULE_INFO = {
+ "module test {",
+ "}",
+ };
+
+ static final String[] TEST_CLASS = {
+ "package test;",
+ "public class test {",
+ " public static void main(String[] args) {",
+ " }",
+ "}",
+ };
+
+ static void report(String command, String[] args) {
+ System.out.println(command + " " + String.join(" ", Arrays.asList(args)));
+ }
+
+ static void javac(String[] args) {
+ report("javac", args);
+ com.sun.tools.javac.Main javac = new com.sun.tools.javac.Main();
+
+ if (javac.compile(args) != 0) {
+ throw new RuntimeException("javac failed");
+ }
+ }
+
+ static void jar(String[] args) {
+ report("jar", args);
+ sun.tools.jar.Main jar = new sun.tools.jar.Main(System.out, System.err, "jar");
+
+ if (!jar.run(args)) {
+ throw new RuntimeException("jar failed");
+ }
+ }
+
+ static void keytool(String[] args) {
+ report("keytool", args);
+
+ try {
+ sun.security.tools.keytool.Main.main(args);
+ } catch (Exception ex) {
+ throw new RuntimeException("keytool failed");
+ }
+ }
+
+ static void jarsigner(String[] args) {
+ report("jarsigner", args);
+
+ try {
+ sun.security.tools.jarsigner.Main.main(args);
+ } catch (Exception ex) {
+ throw new RuntimeException("jarsigner failed");
+ }
+ }
+
+ static void jlink(String[] args) {
+ report("jlink", args);
+
+ try {
+ jdk.tools.jlink.internal.Main.run(new PrintWriter(System.out, true),
+ new PrintWriter(System.err, true),
+ args);
+ } catch (Exception ex) {
+ throw new RuntimeException("jlink failed");
+ }
+ }
+
+ public static void main(String[] args) {
+ final String JAVA_HOME = System.getProperty("java.home");
+ Path moduleInfoJavaPath = Paths.get("module-info.java");
+ Path moduleInfoClassPath = Paths.get("module-info.class");
+ Path testDirectoryPath = Paths.get("test");
+ Path testJavaPath = testDirectoryPath.resolve("test.java");
+ Path testClassPath = testDirectoryPath.resolve("test.class");
+ Path testModsDirectoryPath = Paths.get("testmods");
+ Path jmodsPath = Paths.get(JAVA_HOME, "jmods");
+ Path testjarPath = testModsDirectoryPath.resolve("test.jar");
+ String modulesPath = testjarPath.toString() +
+ File.pathSeparator +
+ jmodsPath.toString();
+
+ try {
+ Files.write(moduleInfoJavaPath, Arrays.asList(MODULE_INFO));
+ Files.createDirectories(testDirectoryPath);
+ Files.write(testJavaPath, Arrays.asList(TEST_CLASS));
+ Files.createDirectories(testModsDirectoryPath);
+ } catch (IOException ex) {
+ throw new RuntimeException("file construction failed");
+ }
+
+ javac(new String[] {
+ testJavaPath.toString(),
+ moduleInfoJavaPath.toString(),
+ });
+
+ jar(new String[] {
+ "-c",
+ "-f", testjarPath.toString(),
+ "--module-path", jmodsPath.toString(),
+ testClassPath.toString(),
+ moduleInfoClassPath.toString(),
+ });
+
+ keytool(new String[] {
+ "-genkey",
+ "-keyalg", "RSA",
+ "-dname", "CN=John Doe, OU=JPG, O=Oracle, L=Santa Clara, ST=California, C=US",
+ "-alias", "examplekey",
+ "-storepass", "password",
+ "-keypass", "password",
+ "-keystore", "examplekeystore",
+ "-validity", "365",
+ });
+
+ jarsigner(new String[] {
+ "-keystore", "examplekeystore",
+ "-verbose", testjarPath.toString(),
+ "-storepass", "password",
+ "-keypass", "password",
+ "examplekey",
+ });
+
+ try {
+ jlink(new String[] {
+ "--module-path", modulesPath,
+ "--add-modules", "test",
+ "--output", "foo",
+ });
+ } catch (Throwable ex) {
+ System.out.println("Failed as should");
+ }
+
+ try {
+ jlink(new String[] {
+ "--module-path", modulesPath,
+ "--add-modules", "test",
+ "--ignore-signing-information",
+ "--output", "foo",
+ });
+ System.out.println("Suceeded as should");
+ } catch (Throwable ex) {
+ System.err.println("Should not have failed");
+ throw new RuntimeException(ex);
+ }
+
+ System.out.println("Done");
+ }
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/jlink/multireleasejar/JLinkMultiReleaseJarTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,256 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8156499
+ * @summary Test image creation from Multi-Release JAR
+ * @author Steve Drach
+ * @library /lib/testlibrary /test/lib
+ * @modules java.base/jdk.internal.jimage
+ * java.base/jdk.internal.module
+ * @build jdk.testlibrary.FileUtils jdk.test.lib.process.*
+ * @run testng JLinkMultiReleaseJarTest
+*/
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.UncheckedIOException;
+import java.lang.invoke.MethodHandle;
+import java.lang.invoke.MethodHandles;
+import java.lang.invoke.MethodType;
+import java.lang.module.ModuleDescriptor;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.StandardCopyOption;
+import java.util.Arrays;
+import java.util.Set;
+import java.util.jar.JarFile;
+import java.util.spi.ToolProvider;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import jdk.internal.jimage.BasicImageReader;
+import jdk.test.lib.process.ProcessTools;
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.testlibrary.FileUtils;
+
+import org.testng.Assert;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+public class JLinkMultiReleaseJarTest {
+ private static final ToolProvider JAR_TOOL = ToolProvider.findFirst("jar")
+ .orElseThrow(() -> new RuntimeException("jar tool not found"));
+ private static final ToolProvider JAVAC_TOOL = ToolProvider.findFirst("javac")
+ .orElseThrow(() -> new RuntimeException("javac tool not found"));
+ private static final ToolProvider JLINK_TOOL = ToolProvider.findFirst("jlink")
+ .orElseThrow(() -> new RuntimeException("jlink tool not found"));
+
+ private final Path userdir = Paths.get(System.getProperty("user.dir", "."));
+ private final Path javahome = Paths.get(System.getProperty("java.home"));
+ private final Path jmodsdir = javahome.resolve("jmods");
+
+ private final String pathsep = System.getProperty("path.separator");
+
+ private byte[] resource = (Runtime.version().major() + " resource file").getBytes();
+
+ @BeforeClass
+ public void initialize() throws IOException {
+ Path srcdir = Paths.get(System.getProperty("test.src"));
+
+ // create class files from source
+ Path base = srcdir.resolve("base");
+ Path basemods = userdir.resolve("basemods");
+ javac(base, basemods, base.toString());
+
+ Path rt = srcdir.resolve("rt");
+ Path rtmods = userdir.resolve("rtmods");
+ javac(rt, rtmods, rt.toString());
+
+ // create resources in basemods and rtmods
+ Path dest = basemods.resolve("m1").resolve("resource.txt");
+ byte[] text = "base resource file".getBytes();
+ ByteArrayInputStream is = new ByteArrayInputStream(text);
+ Files.copy(is, dest);
+
+ dest = rtmods.resolve("m1").resolve("resource.txt");
+ is = new ByteArrayInputStream(resource);
+ Files.copy(is, dest);
+
+ // build multi-release jar file with different module-infos
+ String[] args = {
+ "-cf", "m1.jar",
+ "-C", basemods.resolve("m1").toString(), ".",
+ "--release ", String.valueOf(JarFile.runtimeVersion().major()),
+ "-C", rtmods.resolve("m1").toString(), "."
+ };
+ JAR_TOOL.run(System.out, System.err, args);
+
+ // now move the module-info that requires logging to temporary place
+ Files.move(rtmods.resolve("m1").resolve("module-info.class"),
+ userdir.resolve("module-info.class"));
+
+ // and build another jar
+ args[1] = "m1-no-logging.jar";
+ JAR_TOOL.run(System.out, System.err, args);
+
+ // replace the no logging module-info with the logging module-info
+ Files.move(userdir.resolve("module-info.class"),
+ basemods.resolve("m1").resolve("module-info.class"),
+ StandardCopyOption.REPLACE_EXISTING);
+
+ // and build another jar
+ args[1] = "m1-logging.jar";
+ JAR_TOOL.run(System.out, System.err, args);
+ }
+
+ private void javac(Path source, Path destination, String srcpath) throws IOException {
+ String[] args = Stream.concat(
+ Stream.of("-d", destination.toString(), "--module-source-path", srcpath),
+ Files.walk(source)
+ .map(Path::toString)
+ .filter(s -> s.endsWith(".java"))
+ ).toArray(String[]::new);
+ int rc = JAVAC_TOOL.run(System.out, System.err, args);
+ Assert.assertEquals(rc, 0);
+ }
+
+ @AfterClass
+ public void close() throws IOException {
+ Files.walk(userdir, 1)
+ .filter(p -> !p.equals(userdir))
+ .forEach(p -> {
+ try {
+ if (Files.isDirectory(p)) {
+ FileUtils.deleteFileTreeWithRetry(p);
+ } else {
+ FileUtils.deleteFileIfExistsWithRetry(p);
+ }
+ } catch (IOException x) {
+ throw new UncheckedIOException(x);
+ }
+ });
+ }
+
+ @Test
+ public void basicTest() throws Throwable {
+ if (ignoreTest()) return;
+
+ // use jlink to build image from multi-release jar
+ jlink("m1.jar", "myimage");
+
+ // validate image
+ Path jimage = userdir.resolve("myimage").resolve("lib").resolve("modules");
+ try (BasicImageReader reader = BasicImageReader.open(jimage)) {
+
+ // do we have the right entry names?
+ Set<String> names = Arrays.stream(reader.getEntryNames())
+ .filter(n -> n.startsWith("/m1"))
+ .collect(Collectors.toSet());
+ Assert.assertEquals(names, Set.of(
+ "/m1/module-info.class",
+ "/m1/p/Main.class",
+ "/m1/p/Type.class",
+ "/m1/q/PublicClass.class",
+ "/m1/META-INF/MANIFEST.MF",
+ "/m1/resource.txt"));
+
+ // do we have the right module-info.class?
+ byte[] b = reader.getResource("/m1/module-info.class");
+ Set<String> requires = ModuleDescriptor
+ .read(new ByteArrayInputStream(b))
+ .requires()
+ .stream()
+ .map(mdr -> mdr.name())
+ .filter(nm -> !nm.equals("java.base"))
+ .collect(Collectors.toSet());
+ Assert.assertEquals(requires, Set.of("java.logging"));
+
+ // do we have the right resource?
+ b = reader.getResource("/m1/resource.txt");
+ Assert.assertEquals(b, resource);
+
+ // do we have the right class?
+ b = reader.getResource("/m1/p/Main.class");
+ Class<?> clazz = (new ByteArrayClassLoader()).loadClass("p.Main", b);
+ MethodHandle getVersion = MethodHandles.lookup()
+ .findVirtual(clazz, "getVersion", MethodType.methodType(int.class));
+ int version = (int) getVersion.invoke(clazz.getConstructor().newInstance());
+ Assert.assertEquals(version, JarFile.runtimeVersion().major());
+ }
+ }
+
+ @Test
+ public void noLoggingTest() throws Throwable {
+ if (ignoreTest()) return;
+
+ jlink("m1-no-logging.jar", "no-logging-image");
+ runImage("no-logging-image", false);
+ }
+
+ @Test
+ public void loggingTest() throws Throwable {
+ if (ignoreTest()) return;
+
+ jlink("m1-logging.jar", "logging-image");
+ runImage("logging-image", true);
+
+ }
+
+ // java.base.jmod must exist for this test to make sense
+ private boolean ignoreTest() {
+ if (Files.isRegularFile(jmodsdir.resolve("java.base.jmod"))) {
+ return false;
+ }
+ System.err.println("Test skipped. NO jmods/java.base.jmod");
+ return true;
+ }
+
+
+ private void jlink(String jar, String image) {
+ String args = "--output " + image + " --add-modules m1 --module-path " +
+ jar + pathsep + jmodsdir.toString();
+ int exitCode = JLINK_TOOL.run(System.out, System.err, args.split(" +"));
+ Assert.assertEquals(exitCode, 0);
+ }
+
+ public void runImage(String image, boolean expected) throws Throwable {
+ Path java = Paths.get(image, "bin", "java");
+ OutputAnalyzer oa = ProcessTools.executeProcess(java.toString(), "-m", "m1/p.Main");
+ String sout = oa.getStdout();
+ boolean actual = sout.contains("logging found");
+ Assert.assertEquals(actual, expected);
+ System.out.println(sout);
+ System.err.println(oa.getStderr());
+ Assert.assertEquals(oa.getExitValue(), 0);
+ }
+
+ private static class ByteArrayClassLoader extends ClassLoader {
+ public Class<?> loadClass(String name, byte[] bytes) {
+ return defineClass(name, bytes, 0, bytes.length);
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/jlink/multireleasejar/base/m1/module-info.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+module m1 {
+ exports p;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/jlink/multireleasejar/base/m1/p/Main.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package p;
+
+import java.lang.module.ModuleFinder;
+
+public class Main {
+ private String msg = "something to give this a different size";
+
+ public int getVersion() {
+ return 8;
+ }
+
+ private void testForLogging() {
+ ModuleFinder.ofSystem().find("java.logging").ifPresentOrElse(
+ mr -> System.out.println("java.logging found in image"),
+ () -> System.out.println("java.logging not found in image")
+ );
+ }
+
+ public static void main(String[] args) {
+ Main main = new Main();
+ main.testForLogging();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/jlink/multireleasejar/rt/m1/module-info.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+module m1 {
+ requires java.logging;
+ exports p;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/jlink/multireleasejar/rt/m1/p/Main.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package p;
+
+import java.lang.module.ModuleFinder;
+import java.util.jar.JarFile;
+
+public class Main {
+ public int getVersion() {
+ return JarFile.runtimeVersion().major();
+ }
+
+ private void testForLogging() {
+ ModuleFinder.ofSystem().find("java.logging").ifPresentOrElse(
+ mr -> System.out.println("java.logging found in image"),
+ () -> System.out.println("java.logging not found in image")
+ );
+ }
+
+ public static void main(String[] args) {
+ Main main = new Main();
+ main.testForLogging();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/jlink/multireleasejar/rt/m1/p/Type.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package p;
+
+class Type{}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/jlink/multireleasejar/rt/m1/q/PublicClass.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package q;
+
+public class PublicClass {
+ public void doNothing() {
+ int i = 3 + 2;
+ }
+}
--- a/jdk/test/tools/jmod/JmodTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/test/tools/jmod/JmodTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -28,6 +28,7 @@
* jdk.jlink
* @build jdk.testlibrary.FileUtils CompilerUtils
* @run testng JmodTest
+ * @bug 8142968
* @summary Basic test for jmod
*/
@@ -85,6 +86,31 @@
Files.createDirectories(MODS_DIR);
}
+ // JDK-8166286 - jmod fails on symlink to directory
+ @Test
+ public void testSymlinks() throws IOException {
+ Path apaDir = EXPLODED_DIR.resolve("apa");
+ Path classesDir = EXPLODED_DIR.resolve("apa").resolve("classes");
+ assertTrue(compileModule("apa", classesDir));
+ Path libDir = apaDir.resolve("lib");
+ createFiles(libDir, List.of("foo/bar/libfoo.so"));
+ try {
+ Path link = Files.createSymbolicLink(
+ libDir.resolve("baz"), libDir.resolve("foo").toAbsolutePath());
+ assertTrue(Files.exists(link));
+ } catch (UnsupportedOperationException uoe) {
+ // OS does not support symlinks. Nothing to test!
+ return;
+ }
+
+ Path jmod = MODS_DIR.resolve("apa.jmod");
+ jmod("create",
+ "--libs=", libDir.toString(),
+ "--class-path", classesDir.toString(),
+ jmod.toString())
+ .assertSuccess();
+ }
+
@Test
public void testList() throws IOException {
String cp = EXPLODED_DIR.resolve("foo").resolve("classes").toString();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/jmod/src/apa/jdk/test/apa/Apa.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.test.apa;
+
+public class Apa { }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/jmod/src/apa/module-info.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+module apa {
+ exports jdk.test.apa;
+}
--- a/jdk/test/tools/launcher/MiscTests.java Wed Nov 09 15:20:30 2016 +0300
+++ b/jdk/test/tools/launcher/MiscTests.java Wed Nov 09 10:04:43 2016 -0800
@@ -69,8 +69,6 @@
static void test6856415() throws IOException {
final String mainClass = "Foo6856415";
- final String exportOpts
- = "--add-exports=jdk.crypto.pkcs11/sun.security.pkcs11=ALL-UNNAMED";
List<String> scratch = new ArrayList<>();
scratch.add("public class Foo6856415 {");
@@ -81,7 +79,9 @@
scratch.add("}");
createFile(new File(mainClass + ".java"), scratch);
- compile(mainClass + ".java", exportOpts);
+ compile(mainClass + ".java",
+ "--add-modules=jdk.crypto.pkcs11",
+ "--add-exports=jdk.crypto.pkcs11/sun.security.pkcs11=ALL-UNNAMED");
File testJar = new File("Foo.jar");
testJar.delete();
--- a/langtools/.hgtags Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/.hgtags Wed Nov 09 10:04:43 2016 -0800
@@ -384,3 +384,5 @@
17a82cb0e4b480e97021691d39917f15e3f7b653 jdk-9+139
6842e63d6c3971172214b411f29965852ca175d1 jdk-9+140
296c875051187918f8f3f87e9432036d13013d39 jdk-9+141
+d245e56f4a79a8a8d18bd143c08f079ee98ab638 jdk-9+142
+6ef8a1453577832626b0efb7f70a3102b721ebbf jdk-9+143
--- a/langtools/make/build.xml Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/make/build.xml Wed Nov 09 10:04:43 2016 -0800
@@ -84,17 +84,21 @@
<property name="build.prevsrc" location="${build.dir}/prevsrc"/>
<pathconvert property="modules.names" pathsep=",">
- <globmapper from="${src.dir}/*" to="*" />
+ <globmapper from="${src.dir}/*" to="*" handledirsep="yes"/>
<dirset dir="${src.dir}" includes="*.*"/>
</pathconvert>
<pathconvert property="xpatch.rest" pathsep=" --patch-module=">
- <regexpmapper from="${file.separator}([^${file.separator}]+)$" to='\1="${build.modules}${file.separator}\1"' />
+ <regexpmapper from="/([^$/]+)$"
+ to='\1="${build.modules}/\1"'
+ handledirsep="yes"/>
<dirset dir="${src.dir}" includes="*.*"/>
</pathconvert>
<pathconvert property="xpatch.noquotes.rest" pathsep=" --patch-module=">
- <regexpmapper from="${file.separator}([^${file.separator}]+)$" to="\1=${build.modules}${file.separator}\1" />
+ <regexpmapper from="/([^$/]+)$"
+ to="\1=${build.modules}/\1"
+ handledirsep="yes"/>
<dirset dir="${src.dir}" includes="*.*"/>
</pathconvert>
@@ -207,7 +211,9 @@
<arg line="-source ${javac.source} -target ${javac.target}" />
<arg value="-d" />
<arg value="${build.modules}" />
- <arg line="${javac.opts} --module-source-path ${src.dir}${file.separator}*${file.separator}share${file.separator}classes:${build.gensrc} -m ${modules.names}" />
+ <arg line="${javac.opts}" />
+ <arg line="--module-source-path ${src.dir}${file.separator}*${file.separator}share${file.separator}classes${path.separator}${build.gensrc}" />
+ <arg line="-m ${modules.names}" />
</exec>
<delete>
<fileset dir="${build.modules}" includes="**/module-info.class"/>
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/doclint/Entity.java Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/doclint/Entity.java Wed Nov 09 10:04:43 2016 -0800
@@ -297,17 +297,21 @@
rsaquo(8250),
euro(8364);
- int code;
+ public final int code;
private Entity(int code) {
this.code = code;
}
- static boolean isValid(String name) {
+ public static boolean isValid(String name) {
return names.containsKey(name);
}
- static boolean isValid(int code) {
+ public static Entity get(String name) {
+ return names.get(name);
+ }
+
+ public static boolean isValid(int code) {
// allow numeric codes for standard ANSI characters
return codes.containsKey(code) || ( 32 <= code && code < 2127);
}
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -101,6 +101,8 @@
@Override
public Main.Result call() throws Exception {
prepareCompiler(false);
+ if (compiler.errorCount() > 0)
+ return Main.Result.ERROR;
compiler.compile(args.getFileObjects(), args.getClassNames(), processors);
return (compiler.errorCount() > 0) ? Main.Result.ERROR : Main.Result.OK; // FIXME?
}
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java Wed Nov 09 10:04:43 2016 -0800
@@ -1004,7 +1004,7 @@
List<Type> argtypes = msym.type.getParameterTypes();
return (msym.flags_field & NATIVE) != 0 &&
(msym.owner == syms.methodHandleType.tsym || msym.owner == syms.varHandleType.tsym) &&
- argtypes.tail.tail == null &&
+ argtypes.length() == 1 &&
argtypes.head.hasTag(TypeTag.ARRAY) &&
((ArrayType)argtypes.head).elemtype.tsym == syms.objectType.tsym;
}
@@ -2850,20 +2850,64 @@
return undef;
}
+ public class CandidatesCache {
+ public Map<Entry, List<MethodSymbol>> cache = new WeakHashMap<>();
+
+ class Entry {
+ Type site;
+ MethodSymbol msym;
+
+ Entry(Type site, MethodSymbol msym) {
+ this.site = site;
+ this.msym = msym;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof Entry) {
+ Entry e = (Entry)obj;
+ return e.msym == msym && isSameType(site, e.site);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return Types.this.hashCode(site) & ~msym.hashCode();
+ }
+ }
+
+ public List<MethodSymbol> get(Entry e) {
+ return cache.get(e);
+ }
+
+ public void put(Entry e, List<MethodSymbol> msymbols) {
+ cache.put(e, msymbols);
+ }
+ }
+
+ public CandidatesCache candidatesCache = new CandidatesCache();
//where
public List<MethodSymbol> interfaceCandidates(Type site, MethodSymbol ms) {
- Filter<Symbol> filter = new MethodFilter(ms, site);
- List<MethodSymbol> candidates = List.nil();
+ CandidatesCache.Entry e = candidatesCache.new Entry(site, ms);
+ List<MethodSymbol> candidates = candidatesCache.get(e);
+ if (candidates == null) {
+ Filter<Symbol> filter = new MethodFilter(ms, site);
+ List<MethodSymbol> candidates2 = List.nil();
for (Symbol s : membersClosure(site, false).getSymbols(filter)) {
if (!site.tsym.isInterface() && !s.owner.isInterface()) {
return List.of((MethodSymbol)s);
- } else if (!candidates.contains(s)) {
- candidates = candidates.prepend((MethodSymbol)s);
+ } else if (!candidates2.contains(s)) {
+ candidates2 = candidates2.prepend((MethodSymbol)s);
}
}
- return prune(candidates);
+ candidates = prune(candidates2);
+ candidatesCache.put(e, candidates);
}
+ return candidates;
+ }
public List<MethodSymbol> prune(List<MethodSymbol> methods) {
ListBuffer<MethodSymbol> methodsMin = new ListBuffer<>();
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java Wed Nov 09 10:04:43 2016 -0800
@@ -853,9 +853,9 @@
List<Type> caughtPrev = caught;
ListBuffer<FlowPendingExit> pendingExitsPrev = pendingExits;
Lint lintPrev = lint;
-
+ boolean anonymousClass = tree.name == names.empty;
pendingExits = new ListBuffer<>();
- if (tree.name != names.empty) {
+ if (!anonymousClass) {
caught = List.nil();
}
classDef = tree;
@@ -874,7 +874,7 @@
// add intersection of all thrown clauses of initial constructors
// to set of caught exceptions, unless class is anonymous.
- if (tree.name != names.empty) {
+ if (!anonymousClass) {
boolean firstConstructor = true;
for (List<JCTree> l = tree.defs; l.nonEmpty(); l = l.tail) {
if (TreeInfo.isInitialConstructor(l.head)) {
@@ -905,10 +905,11 @@
// Changing the throws clause on the fly is okay here because
// the anonymous constructor can't be invoked anywhere else,
// and its type hasn't been cached.
- if (tree.name == names.empty) {
+ if (anonymousClass) {
for (List<JCTree> l = tree.defs; l.nonEmpty(); l = l.tail) {
- if (TreeInfo.isInitialConstructor(l.head)) {
+ if (TreeInfo.isConstructor(l.head)) {
JCMethodDecl mdef = (JCMethodDecl)l.head;
+ scan(mdef);
mdef.thrown = make.Types(thrown);
mdef.sym.type = types.createMethodTypeWithThrown(mdef.sym.type, thrown);
}
@@ -918,6 +919,8 @@
// process all the methods
for (List<JCTree> l = tree.defs; l.nonEmpty(); l = l.tail) {
+ if (anonymousClass && TreeInfo.isConstructor(l.head))
+ continue; // there can never be an uncaught exception.
if (l.head.hasTag(METHODDEF)) {
scan(l.head);
errorUncaught();
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Infer.java Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Infer.java Wed Nov 09 10:04:43 2016 -0800
@@ -404,15 +404,11 @@
} else if (to.hasTag(NONE)) {
to = from.isPrimitive() ? from : syms.objectType;
} else if (qtype.hasTag(UNDETVAR)) {
- if (resultInfo.pt.isReference()) {
- if (needsEagerInstantiation((UndetVar)qtype, to, inferenceContext)) {
- to = generateReferenceToTargetConstraint(tree, (UndetVar)qtype, to, resultInfo, inferenceContext);
- }
- } else {
- if (to.isPrimitive()) {
- to = generateReturnConstraintsPrimitive(tree, (UndetVar)qtype, to,
- resultInfo, inferenceContext);
- }
+ if (needsEagerInstantiation((UndetVar)qtype, to, inferenceContext) &&
+ (allowGraphInference || !to.isPrimitive())) {
+ to = generateReferenceToTargetConstraint(tree, (UndetVar)qtype, to, resultInfo, inferenceContext);
+ } else if (to.isPrimitive()) {
+ to = types.boxedClass(to).type;
}
} else if (rsInfoInfContext.free(resultInfo.pt)) {
//propagation - cache captured vars
@@ -432,26 +428,21 @@
return from;
}
- private Type generateReturnConstraintsPrimitive(JCTree tree, UndetVar from,
- Type to, Attr.ResultInfo resultInfo, InferenceContext inferenceContext) {
- if (!allowGraphInference) {
- //if legacy, just return boxed type
- return types.boxedClass(to).type;
+ private boolean needsEagerInstantiation(UndetVar from, Type to, InferenceContext inferenceContext) {
+ if (to.isPrimitive()) {
+ /* T is a primitive type, and one of the primitive wrapper classes is an instantiation,
+ * upper bound, or lower bound for alpha in B2.
+ */
+ for (Type t : from.getBounds(InferenceBound.values())) {
+ Type boundAsPrimitive = types.unboxedType(t);
+ if (boundAsPrimitive == null || boundAsPrimitive.hasTag(NONE)) {
+ continue;
+ }
+ return true;
+ }
+ return false;
}
- //if graph inference we need to skip conflicting boxed bounds...
- for (Type t : from.getBounds(InferenceBound.EQ, InferenceBound.UPPER,
- InferenceBound.LOWER)) {
- Type boundAsPrimitive = types.unboxedType(t);
- if (boundAsPrimitive == null || boundAsPrimitive.hasTag(NONE)) {
- continue;
- }
- return generateReferenceToTargetConstraint(tree, from, to,
- resultInfo, inferenceContext);
- }
- return types.boxedClass(to).type;
- }
- private boolean needsEagerInstantiation(UndetVar from, Type to, InferenceContext inferenceContext) {
Type captureOfTo = types.capture(to);
/* T is a reference type, but is not a wildcard-parameterized type, and either
*/
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java Wed Nov 09 10:04:43 2016 -0800
@@ -36,7 +36,6 @@
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Map;
-import java.util.Map.Entry;
import java.util.Set;
import java.util.function.Consumer;
import java.util.function.Predicate;
@@ -59,6 +58,7 @@
import com.sun.tools.javac.code.Directive.UsesDirective;
import com.sun.tools.javac.code.Flags;
import com.sun.tools.javac.code.Kinds;
+import com.sun.tools.javac.code.Lint.LintCategory;
import com.sun.tools.javac.code.ModuleFinder;
import com.sun.tools.javac.code.Source;
import com.sun.tools.javac.code.Symbol;
@@ -131,6 +131,7 @@
private final Types types;
private final JavaFileManager fileManager;
private final ModuleFinder moduleFinder;
+ private final Source source;
private final boolean allowModules;
public final boolean multiModuleMode;
@@ -151,6 +152,8 @@
private final String limitModsOpt;
private final Set<String> extraLimitMods = new HashSet<>();
+ private final boolean lintOptions;
+
private Set<ModuleSymbol> rootModules = null;
public static Modules instance(Context context) {
@@ -170,9 +173,12 @@
moduleFinder = ModuleFinder.instance(context);
types = Types.instance(context);
fileManager = context.get(JavaFileManager.class);
- allowModules = Source.instance(context).allowModules();
+ source = Source.instance(context);
+ allowModules = source.allowModules();
Options options = Options.instance(context);
+ lintOptions = options.isUnset(Option.XLINT_CUSTOM, "-" + LintCategory.OPTIONS.option);
+
moduleOverride = options.get(Option.XMODULE);
multiModuleMode = fileManager.hasLocation(StandardLocation.MODULE_SOURCE_PATH);
@@ -487,7 +493,7 @@
ModuleSymbol msym = moduleFinder.findModule((ModuleSymbol) sym);
if (msym.kind == Kinds.Kind.ERR) {
- log.error(Errors.CantFindModule(msym));
+ log.error(Errors.ModuleNotFound(msym));
//make sure the module is initialized:
msym.directives = List.nil();
msym.exports = List.nil();
@@ -684,15 +690,10 @@
}
private ModuleSymbol lookupModule(JCExpression moduleName) {
- try {
Name name = TreeInfo.fullName(moduleName);
ModuleSymbol msym = moduleFinder.findModule(name);
TreeInfo.setSymbol(moduleName, msym);
return msym;
- } catch (Throwable t) {
- System.err.println("Module " + sym + "; lookup export " + moduleName);
- throw t;
- }
}
}
@@ -776,8 +777,6 @@
log.error(tree.implName.pos(), Errors.ServiceImplementationIsAbstract(impl));
} else if (impl.isInner()) {
log.error(tree.implName.pos(), Errors.ServiceImplementationIsInner(impl));
- } else if (service.isInner()) {
- log.error(tree.serviceName.pos(), Errors.ServiceDefinitionIsInner(service));
} else {
MethodSymbol constr = noArgsConstructor(impl);
if (constr == null) {
@@ -884,6 +883,8 @@
Set<ModuleSymbol> limitMods = new HashSet<>();
if (limitModsOpt != null) {
for (String limit : limitModsOpt.split(",")) {
+ if (!isValidName(limit))
+ continue;
limitMods.add(syms.enterModule(names.fromString(limit)));
}
}
@@ -892,6 +893,14 @@
}
observable = computeTransitiveClosure(limitMods, null);
observable.addAll(rootModules);
+ if (lintOptions) {
+ for (ModuleSymbol msym : limitMods) {
+ if (!observable.contains(msym)) {
+ log.warning(LintCategory.OPTIONS,
+ Warnings.ModuleForOptionNotFound(Option.LIMIT_MODULES, msym));
+ }
+ }
+ }
}
Predicate<ModuleSymbol> observablePred = sym -> observable == null || observable.contains(sym);
@@ -944,6 +953,8 @@
.filter(systemModulePred.negate().and(observablePred));
break;
default:
+ if (!isValidName(added))
+ continue;
modules = Stream.of(syms.enterModule(names.fromString(added)));
break;
}
@@ -1141,8 +1152,9 @@
addVisiblePackages(msym, seen, rm, rm.exports);
}
- for (Entry<ModuleSymbol, Set<ExportsDirective>> addExportsEntry : addExports.entrySet())
- addVisiblePackages(msym, seen, addExportsEntry.getKey(), addExportsEntry.getValue());
+ addExports.forEach((exportsFrom, exports) -> {
+ addVisiblePackages(msym, seen, exportsFrom, exports);
+ });
}
private void addVisiblePackages(ModuleSymbol msym,
@@ -1180,12 +1192,11 @@
return;
addExports = new LinkedHashMap<>();
+ Set<ModuleSymbol> unknownModules = new HashSet<>();
if (addExportsOpt == null)
return;
-// System.err.println("Modules.addExports:\n " + addExportsOpt.replace("\0", "\n "));
-
Pattern ep = Pattern.compile("([^/]+)/([^=]+)=(.*)");
for (String s: addExportsOpt.split("\0+")) {
if (s.isEmpty())
@@ -1203,7 +1214,15 @@
String packageName = em.group(2);
String targetNames = em.group(3);
+ if (!isValidName(moduleName))
+ continue;
+
ModuleSymbol msym = syms.enterModule(names.fromString(moduleName));
+ if (!isKnownModule(msym, unknownModules))
+ continue;
+
+ if (!isValidName(packageName))
+ continue;
PackageSymbol p = syms.enterPackage(msym, names.fromString(packageName));
p.modle = msym; // TODO: do we need this?
@@ -1213,11 +1232,11 @@
if (toModule.equals("ALL-UNNAMED")) {
m = syms.unnamedModule;
} else {
- if (!SourceVersion.isName(toModule)) {
- // TODO: error: invalid module name
+ if (!isValidName(toModule))
continue;
- }
m = syms.enterModule(names.fromString(toModule));
+ if (!isKnownModule(m, unknownModules))
+ continue;
}
targetModules = targetModules.prepend(m);
}
@@ -1228,6 +1247,21 @@
}
}
+ private boolean isKnownModule(ModuleSymbol msym, Set<ModuleSymbol> unknownModules) {
+ if (allModules.contains(msym)) {
+ return true;
+ }
+
+ if (!unknownModules.contains(msym)) {
+ if (lintOptions) {
+ log.warning(LintCategory.OPTIONS,
+ Warnings.ModuleForOptionNotFound(Option.ADD_EXPORTS, msym));
+ }
+ unknownModules.add(msym);
+ }
+ return false;
+ }
+
private void initAddReads() {
if (addReads != null)
return;
@@ -1237,8 +1271,6 @@
if (addReadsOpt == null)
return;
-// System.err.println("Modules.addReads:\n " + addReadsOpt.replace("\0", "\n "));
-
Pattern rp = Pattern.compile("([^=]+)=(.*)");
for (String s : addReadsOpt.split("\0+")) {
if (s.isEmpty())
@@ -1249,26 +1281,40 @@
}
// Terminology comes from
- // --add-reads target-module=source-module,...
+ // --add-reads source-module=target-module,...
// Compare to
- // module target-module { requires source-module; ... }
- String targetName = rm.group(1);
- String sources = rm.group(2);
+ // module source-module { requires target-module; ... }
+ String sourceName = rm.group(1);
+ String targetNames = rm.group(2);
+
+ if (!isValidName(sourceName))
+ continue;
- ModuleSymbol msym = syms.enterModule(names.fromString(targetName));
- for (String source : sources.split("[ ,]+")) {
- ModuleSymbol sourceModule;
- if (source.equals("ALL-UNNAMED")) {
- sourceModule = syms.unnamedModule;
+ ModuleSymbol msym = syms.enterModule(names.fromString(sourceName));
+ if (!allModules.contains(msym)) {
+ if (lintOptions) {
+ log.warning(Warnings.ModuleForOptionNotFound(Option.ADD_READS, msym));
+ }
+ continue;
+ }
+
+ for (String targetName : targetNames.split("[ ,]+", -1)) {
+ ModuleSymbol targetModule;
+ if (targetName.equals("ALL-UNNAMED")) {
+ targetModule = syms.unnamedModule;
} else {
- if (!SourceVersion.isName(source)) {
- // TODO: error: invalid module name
+ if (!isValidName(targetName))
+ continue;
+ targetModule = syms.enterModule(names.fromString(targetName));
+ if (!allModules.contains(targetModule)) {
+ if (lintOptions) {
+ log.warning(LintCategory.OPTIONS, Warnings.ModuleForOptionNotFound(Option.ADD_READS, targetModule));
+ }
continue;
}
- sourceModule = syms.enterModule(names.fromString(source));
}
addReads.computeIfAbsent(msym, m -> new HashSet<>())
- .add(new RequiresDirective(sourceModule, EnumSet.of(RequiresFlag.EXTRA)));
+ .add(new RequiresDirective(targetModule, EnumSet.of(RequiresFlag.EXTRA)));
}
}
}
@@ -1301,6 +1347,10 @@
}
}
+ private boolean isValidName(CharSequence name) {
+ return SourceVersion.isName(name, Source.toSourceVersion(source));
+ }
+
// DEBUG
private String toString(ModuleSymbol msym) {
return msym.name + "["
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java Wed Nov 09 10:04:43 2016 -0800
@@ -554,7 +554,8 @@
} else if (mt.hasTag(FORALL) && typeargtypes.nonEmpty()) {
ForAll pmt = (ForAll) mt;
if (typeargtypes.length() != pmt.tvars.length())
- throw inapplicableMethodException.setMessage("arg.length.mismatch"); // not enough args
+ // not enough args
+ throw inapplicableMethodException.setMessage("wrong.number.type.args", Integer.toString(pmt.tvars.length()));
// Check type arguments are within bounds
List<Type> formals = pmt.tvars;
List<Type> actuals = typeargtypes;
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java Wed Nov 09 10:04:43 2016 -0800
@@ -39,6 +39,7 @@
import java.nio.file.FileSystemNotFoundException;
import java.nio.file.FileSystems;
import java.nio.file.Files;
+import java.nio.file.InvalidPathException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.ProviderNotFoundException;
@@ -66,6 +67,7 @@
import javax.lang.model.SourceVersion;
import javax.tools.JavaFileManager;
import javax.tools.JavaFileManager.Location;
+import javax.tools.JavaFileObject;
import javax.tools.StandardJavaFileManager;
import javax.tools.StandardJavaFileManager.PathFactory;
import javax.tools.StandardLocation;
@@ -137,7 +139,11 @@
}
Path getPath(String first, String... more) {
- return pathFactory.getPath(first, more);
+ try {
+ return pathFactory.getPath(first, more);
+ } catch (InvalidPathException ipe) {
+ throw new IllegalArgumentException(ipe);
+ }
}
public void close() throws IOException {
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java Wed Nov 09 10:04:43 2016 -0800
@@ -1328,7 +1328,7 @@
} else {
((ClassType)sym.type).setEnclosingType(Type.noType);
}
- enterTypevars(self);
+ enterTypevars(self, self.type);
if (!missingTypeVariables.isEmpty()) {
ListBuffer<Type> typeVars = new ListBuffer<>();
for (Type typevar : missingTypeVariables) {
@@ -2353,19 +2353,17 @@
/** Enter type variables of this classtype and all enclosing ones in
* `typevars'.
*/
- protected void enterTypevars(Type t) {
- if (t.getEnclosingType() != null && t.getEnclosingType().hasTag(CLASS))
- enterTypevars(t.getEnclosingType());
- for (List<Type> xs = t.getTypeArguments(); xs.nonEmpty(); xs = xs.tail)
+ protected void enterTypevars(Symbol sym, Type t) {
+ if (t.getEnclosingType() != null) {
+ if (!t.getEnclosingType().hasTag(TypeTag.NONE)) {
+ enterTypevars(sym.owner, t.getEnclosingType());
+ }
+ } else if (sym.kind == MTH && !sym.isStatic()) {
+ enterTypevars(sym.owner, sym.owner.type);
+ }
+ for (List<Type> xs = t.getTypeArguments(); xs.nonEmpty(); xs = xs.tail) {
typevars.enter(xs.head.tsym);
- }
-
- protected void enterTypevars(Symbol sym) {
- if (sym.owner.kind == MTH) {
- enterTypevars(sym.owner);
- enterTypevars(sym.owner.owner);
}
- enterTypevars(sym.type);
}
protected ClassSymbol enterClass(Name name) {
@@ -2388,7 +2386,7 @@
// prepare type variable table
typevars = typevars.dup(currentOwner);
if (ct.getEnclosingType().hasTag(CLASS))
- enterTypevars(ct.getEnclosingType());
+ enterTypevars(c.owner, ct.getEnclosingType());
// read flags, or skip if this is an inner class
long f = nextChar();
@@ -2545,6 +2543,11 @@
types.subst(ct.supertype_field, missing, found);
ct.interfaces_field =
types.subst(ct.interfaces_field, missing, found);
+ ct.typarams_field =
+ types.substBounds(ct.typarams_field, missing, found);
+ for (List<Type> types = ct.typarams_field; types.nonEmpty(); types = types.tail) {
+ types.head.tsym.type = types.head;
+ }
} else if (missingTypeVariables.isEmpty() !=
foundTypeVariables.isEmpty()) {
Name name = missingTypeVariables.head.tsym.name;
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Arguments.java Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Arguments.java Wed Nov 09 10:04:43 2016 -0800
@@ -43,6 +43,7 @@
import java.util.regex.Pattern;
import java.util.stream.Stream;
+import javax.lang.model.SourceVersion;
import javax.tools.JavaFileManager;
import javax.tools.JavaFileManager.Location;
import javax.tools.JavaFileObject;
@@ -400,7 +401,7 @@
/**
* Validates the overall consistency of the options and operands
* processed by processOptions.
- * @return true if all args are successfully validating; false otherwise.
+ * @return true if all args are successfully validated; false otherwise.
* @throws IllegalStateException if a problem is found and errorMode is set to
* ILLEGAL_STATE
*/
@@ -610,62 +611,143 @@
if (obsoleteOptionFound)
log.warning(LintCategory.OPTIONS, "option.obsolete.suppression");
+ SourceVersion sv = Source.toSourceVersion(source);
+ validateAddExports(sv);
+ validateAddModules(sv);
+ validateAddReads(sv);
+ validateLimitModules(sv);
+
+ return !errors && (log.nerrors == 0);
+ }
+
+ private void validateAddExports(SourceVersion sv) {
String addExports = options.get(Option.ADD_EXPORTS);
if (addExports != null) {
- // Each entry must be of the form module/package=target-list where target-list is a
- // comma-separated list of module or ALL-UNNAMED.
- // All module/package pairs must be unique.
- Pattern p = Pattern.compile("([^/]+)/([^=]+)=(.*)");
- Map<String,List<String>> map = new LinkedHashMap<>();
- for (String e: addExports.split("\0")) {
+ // Each entry must be of the form sourceModule/sourcePackage=target-list where
+ // target-list is a comma separated list of module or ALL-UNNAMED.
+ // Empty items in the target-list are ignored.
+ // There must be at least one item in the list; this is handled in Option.ADD_EXPORTS.
+ Pattern p = Option.ADD_EXPORTS.getPattern();
+ for (String e : addExports.split("\0")) {
Matcher m = p.matcher(e);
- if (!m.matches()) {
- log.error(Errors.XaddexportsMalformedEntry(e));
- continue;
+ if (m.matches()) {
+ String sourceModuleName = m.group(1);
+ if (!SourceVersion.isName(sourceModuleName, sv)) {
+ // syntactically invalid source name: e.g. --add-exports m!/p1=m2
+ log.warning(Warnings.BadNameForOption(Option.ADD_EXPORTS, sourceModuleName));
+ }
+ String sourcePackageName = m.group(2);
+ if (!SourceVersion.isName(sourcePackageName, sv)) {
+ // syntactically invalid source name: e.g. --add-exports m1/p!=m2
+ log.warning(Warnings.BadNameForOption(Option.ADD_EXPORTS, sourcePackageName));
+ }
+
+ String targetNames = m.group(3);
+ for (String targetName : targetNames.split(",")) {
+ switch (targetName) {
+ case "":
+ case "ALL-UNNAMED":
+ break;
+
+ default:
+ if (!SourceVersion.isName(targetName, sv)) {
+ // syntactically invalid target name: e.g. --add-exports m1/p1=m!
+ log.warning(Warnings.BadNameForOption(Option.ADD_EXPORTS, targetName));
+ }
+ break;
+ }
+ }
}
- String eModule = m.group(1); // TODO: check a valid dotted identifier
- String ePackage = m.group(2); // TODO: check a valid dotted identifier
- String eTargets = m.group(3); // TODO: check a valid list of dotted identifier or ALL-UNNAMED
- String eModPkg = eModule + '/' + ePackage;
- List<String> l = map.get(eModPkg);
- map.put(eModPkg, (l == null) ? List.of(eTargets) : l.prepend(eTargets));
}
- map.forEach((key, value) -> {
- if (value.size() > 1) {
- log.error(Errors.XaddexportsTooMany(key));
- // TODO: consider adding diag fragments for the entries
- }
- });
}
+ }
+ private void validateAddReads(SourceVersion sv) {
String addReads = options.get(Option.ADD_READS);
if (addReads != null) {
- // Each entry must be of the form module=source-list where source-list is a
- // comma separated list of module or ALL-UNNAMED.
- // All target modules (i.e. on left of '=') must be unique.
- Pattern p = Pattern.compile("([^=]+)=(.*)");
- Map<String,List<String>> map = new LinkedHashMap<>();
- for (String e: addReads.split("\0")) {
+ // Each entry must be of the form source=target-list where target-list is a
+ // comma-separated list of module or ALL-UNNAMED.
+ // Empty items in the target list are ignored.
+ // There must be at least one item in the list; this is handled in Option.ADD_READS.
+ Pattern p = Option.ADD_READS.getPattern();
+ for (String e : addReads.split("\0")) {
Matcher m = p.matcher(e);
- if (!m.matches()) {
- log.error(Errors.XaddreadsMalformedEntry(e));
- continue;
+ if (m.matches()) {
+ String sourceName = m.group(1);
+ if (!SourceVersion.isName(sourceName, sv)) {
+ // syntactically invalid source name: e.g. --add-reads m!=m2
+ log.warning(Warnings.BadNameForOption(Option.ADD_READS, sourceName));
+ }
+
+ String targetNames = m.group(2);
+ for (String targetName : targetNames.split(",", -1)) {
+ switch (targetName) {
+ case "":
+ case "ALL-UNNAMED":
+ break;
+
+ default:
+ if (!SourceVersion.isName(targetName, sv)) {
+ // syntactically invalid target name: e.g. --add-reads m1=m!
+ log.warning(Warnings.BadNameForOption(Option.ADD_READS, targetName));
+ }
+ break;
+ }
+ }
}
- String eModule = m.group(1); // TODO: check a valid dotted identifier
- String eSources = m.group(2); // TODO: check a valid list of dotted identifier or ALL-UNNAMED
- List<String> l = map.get(eModule);
- map.put(eModule, (l == null) ? List.of(eSources) : l.prepend(eSources));
}
- map.forEach((key, value) -> {
- if (value.size() > 1) {
- log.error(Errors.XaddreadsTooMany(key));
- // TODO: consider adding diag fragments for the entries
+ }
+ }
+
+ private void validateAddModules(SourceVersion sv) {
+ String addModules = options.get(Option.ADD_MODULES);
+ if (addModules != null) {
+ // Each entry must be of the form target-list where target-list is a
+ // comma separated list of module names, or ALL-DEFAULT, ALL-SYSTEM,
+ // or ALL-MODULE_PATH.
+ // Empty items in the target list are ignored.
+ // There must be at least one item in the list; this is handled in Option.ADD_MODULES.
+ for (String moduleName : addModules.split(",")) {
+ switch (moduleName) {
+ case "":
+ case "ALL-DEFAULT":
+ case "ALL-SYSTEM":
+ case "ALL-MODULE-PATH":
+ break;
+
+ default:
+ if (!SourceVersion.isName(moduleName, sv)) {
+ // syntactically invalid module name: e.g. --add-modules m1,m!
+ log.warning(Warnings.BadNameForOption(Option.ADD_MODULES, moduleName));
+ }
+ break;
}
- });
+ }
}
+ }
+ private void validateLimitModules(SourceVersion sv) {
+ String limitModules = options.get(Option.LIMIT_MODULES);
+ if (limitModules != null) {
+ // Each entry must be of the form target-list where target-list is a
+ // comma separated list of module names, or ALL-DEFAULT, ALL-SYSTEM,
+ // or ALL-MODULE_PATH.
+ // Empty items in the target list are ignored.
+ // There must be at least one item in the list; this is handled in Option.LIMIT_EXPORTS.
+ for (String moduleName : limitModules.split(",")) {
+ switch (moduleName) {
+ case "":
+ break;
- return !errors;
+ default:
+ if (!SourceVersion.isName(moduleName, sv)) {
+ // syntactically invalid module name: e.g. --limit-modules m1,m!
+ log.warning(Warnings.BadNameForOption(Option.LIMIT_MODULES, moduleName));
+ }
+ break;
+ }
+ }
+ }
}
/**
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Option.java Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Option.java Wed Nov 09 10:04:43 2016 -0800
@@ -43,6 +43,7 @@
import java.util.ServiceLoader;
import java.util.Set;
import java.util.TreeSet;
+import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
@@ -556,18 +557,44 @@
ADD_EXPORTS("--add-exports", "opt.arg.addExports", "opt.addExports", EXTENDED, BASIC) {
@Override
public boolean process(OptionHelper helper, String option, String arg) {
- String prev = helper.get(ADD_EXPORTS);
- helper.put(ADD_EXPORTS.primaryName, (prev == null) ? arg : prev + '\0' + arg);
- return false;
+ if (arg.isEmpty()) {
+ helper.error("err.no.value.for.option", option);
+ return true;
+ } else if (getPattern().matcher(arg).matches()) {
+ String prev = helper.get(ADD_EXPORTS);
+ helper.put(ADD_EXPORTS.primaryName, (prev == null) ? arg : prev + '\0' + arg);
+ return false;
+ } else {
+ helper.error("err.bad.value.for.option", option, arg);
+ return true;
+ }
+ }
+
+ @Override
+ public Pattern getPattern() {
+ return Pattern.compile("([^/]+)/([^=]+)=(,*[^,].*)");
}
},
ADD_READS("--add-reads", "opt.arg.addReads", "opt.addReads", EXTENDED, BASIC) {
@Override
public boolean process(OptionHelper helper, String option, String arg) {
- String prev = helper.get(ADD_READS);
- helper.put(ADD_READS.primaryName, (prev == null) ? arg : prev + '\0' + arg);
- return false;
+ if (arg.isEmpty()) {
+ helper.error("err.no.value.for.option", option);
+ return true;
+ } else if (getPattern().matcher(arg).matches()) {
+ String prev = helper.get(ADD_READS);
+ helper.put(ADD_READS.primaryName, (prev == null) ? arg : prev + '\0' + arg);
+ return false;
+ } else {
+ helper.error("err.bad.value.for.option", option, arg);
+ return true;
+ }
+ }
+
+ @Override
+ public Pattern getPattern() {
+ return Pattern.compile("([^=]+)=(,*[^,].*)");
}
},
@@ -577,6 +604,7 @@
String prev = helper.get(XMODULE);
if (prev != null) {
helper.error("err.option.too.many", XMODULE.primaryName);
+ return true;
}
helper.put(XMODULE.primaryName, arg);
return false;
@@ -585,9 +613,50 @@
MODULE("--module -m", "opt.arg.m", "opt.m", STANDARD, BASIC),
- ADD_MODULES("--add-modules", "opt.arg.addmods", "opt.addmods", STANDARD, BASIC),
+ ADD_MODULES("--add-modules", "opt.arg.addmods", "opt.addmods", STANDARD, BASIC) {
+ @Override
+ public boolean process(OptionHelper helper, String option, String arg) {
+ if (arg.isEmpty()) {
+ helper.error("err.no.value.for.option", option);
+ return true;
+ } else if (getPattern().matcher(arg).matches()) {
+ String prev = helper.get(ADD_MODULES);
+ // since the individual values are simple names, we can simply join the
+ // values of multiple --add-modules options with ','
+ helper.put(ADD_MODULES.primaryName, (prev == null) ? arg : prev + ',' + arg);
+ return false;
+ } else {
+ helper.error("err.bad.value.for.option", option, arg);
+ return true;
+ }
+ }
- LIMIT_MODULES("--limit-modules", "opt.arg.limitmods", "opt.limitmods", STANDARD, BASIC),
+ @Override
+ public Pattern getPattern() {
+ return Pattern.compile(",*[^,].*");
+ }
+ },
+
+ LIMIT_MODULES("--limit-modules", "opt.arg.limitmods", "opt.limitmods", STANDARD, BASIC) {
+ @Override
+ public boolean process(OptionHelper helper, String option, String arg) {
+ if (arg.isEmpty()) {
+ helper.error("err.no.value.for.option", option);
+ return true;
+ } else if (getPattern().matcher(arg).matches()) {
+ helper.put(LIMIT_MODULES.primaryName, arg); // last one wins
+ return false;
+ } else {
+ helper.error("err.bad.value.for.option", option, arg);
+ return true;
+ }
+ }
+
+ @Override
+ public Pattern getPattern() {
+ return Pattern.compile(",*[^,].*");
+ }
+ },
// This option exists only for the purpose of documenting itself.
// It's actually implemented by the CommandLine class.
@@ -963,20 +1032,24 @@
*/
public boolean handleOption(OptionHelper helper, String arg, Iterator<String> rest) {
if (hasArg()) {
+ String option;
String operand;
int sep = findSeparator(arg);
if (getArgKind() == Option.ArgKind.ADJACENT) {
+ option = primaryName; // aliases not supported
operand = arg.substring(primaryName.length());
} else if (sep > 0) {
+ option = arg.substring(0, sep);
operand = arg.substring(sep + 1);
} else {
if (!rest.hasNext()) {
helper.error("err.req.arg", arg);
return false;
}
+ option = arg;
operand = rest.next();
}
- return !process(helper, arg, operand);
+ return !process(helper, option, operand);
} else {
return !process(helper, arg);
}
@@ -1033,6 +1106,15 @@
}
/**
+ * Returns a pattern to analyze the value for an option.
+ * @return the pattern
+ * @throws UnsupportedOperationException if an option does not provide a pattern.
+ */
+ public Pattern getPattern() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
* Scans a word to find the first separator character, either colon or equals.
* @param word the word to be scanned
* @return the position of the first':' or '=' character in the word,
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties Wed Nov 09 10:04:43 2016 -0800
@@ -2124,6 +2124,10 @@
compiler.misc.arg.length.mismatch=\
actual and formal argument lists differ in length
+# 0: string
+compiler.misc.wrong.number.type.args=\
+ wrong number of type arguments; required {0}
+
# 0: message segment
compiler.misc.no.conforming.assignment.exists=\
argument mismatch; {0}
@@ -2766,10 +2770,6 @@
the service implementation is an inner class: {0}
# 0: symbol
-compiler.err.service.definition.is.inner=\
- the service definition is an inner class: {0}
-
-# 0: symbol
compiler.err.service.definition.is.enum=\
the service definition is an enum: {0}
@@ -2844,21 +2844,13 @@
compiler.err.duplicate.module.on.path=\
duplicate module on {0}\nmodule in {1}
-# 0: string
-compiler.err.xaddexports.malformed.entry=\
- bad value for --add-exports {0}
-
-# 0: string
-compiler.err.xaddexports.too.many=\
- multiple --add-exports options for {0}
-
-# 0: string
-compiler.err.xaddreads.malformed.entry=\
- bad value for --add-reads {0}
-
-# 0: string
-compiler.err.xaddreads.too.many=\
- multiple --add-reads options for {0}
+# 0: option name, 1: string
+compiler.warn.bad.name.for.option=\
+ bad name in value for {0} option: ''{1}''
+
+# 0: option name, 1: symbol
+compiler.warn.module.for.option.not.found=\
+ module name in {0} option not found: {1}
compiler.err.addmods.all.module.path.invalid=\
--add-modules ALL-MODULE-PATH can only be used when compiling the unnamed module
@@ -2878,10 +2870,6 @@
compiler.misc.cant.resolve.modules=\
cannot resolve modules
-# 0: symbol
-compiler.err.cant.find.module=\
- cannot find module: {0}
-
# 0: string
compiler.err.invalid.module.specifier=\
module specifier not allowed: {0}
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac.properties Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac.properties Wed Nov 09 10:04:43 2016 -0800
@@ -357,6 +357,10 @@
not a file: {0}
javac.err.cannot.access.runtime.env=\
cannot access runtime environment
+javac.err.bad.value.for.option=\
+ bad value for {0} option: ''{1}''
+javac.err.no.value.for.option=\
+ no value for {0} option
## messages
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/AbstractDiagnosticFormatter.java Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/AbstractDiagnosticFormatter.java Wed Nov 09 10:04:43 2016 -0800
@@ -48,6 +48,7 @@
import com.sun.tools.javac.code.Type.CapturedType;
import com.sun.tools.javac.file.PathFileObject;
import com.sun.tools.javac.jvm.Profile;
+import com.sun.tools.javac.main.Option;
import com.sun.tools.javac.tree.JCTree.*;
import com.sun.tools.javac.tree.Pretty;
@@ -204,6 +205,9 @@
else if (arg instanceof Profile) {
return ((Profile)arg).name;
}
+ else if (arg instanceof Option) {
+ return ((Option)arg).primaryName;
+ }
else if (arg instanceof Formattable) {
return ((Formattable)arg).toString(l, messages);
}
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Iterators.java Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Iterators.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -62,9 +62,9 @@
}
public O next() {
- if (!hasNext())
+ if (currentIterator == EMPTY && !hasNext()) {
throw new NoSuchElementException();
-
+ }
return currentIterator.next();
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/jdk.compiler/share/classes/jdk/internal/shellsupport/doc/JavadocFormatter.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,706 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package jdk.internal.shellsupport.doc;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.IdentityHashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.ResourceBundle;
+import java.util.Stack;
+
+import javax.lang.model.element.Name;
+import javax.tools.JavaFileObject.Kind;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.ToolProvider;
+
+import com.sun.source.doctree.AttributeTree;
+import com.sun.source.doctree.DocCommentTree;
+import com.sun.source.doctree.DocTree;
+import com.sun.source.doctree.EndElementTree;
+import com.sun.source.doctree.EntityTree;
+import com.sun.source.doctree.InlineTagTree;
+import com.sun.source.doctree.LinkTree;
+import com.sun.source.doctree.LiteralTree;
+import com.sun.source.doctree.ParamTree;
+import com.sun.source.doctree.ReturnTree;
+import com.sun.source.doctree.StartElementTree;
+import com.sun.source.doctree.TextTree;
+import com.sun.source.doctree.ThrowsTree;
+import com.sun.source.util.DocTreeScanner;
+import com.sun.source.util.DocTrees;
+import com.sun.source.util.JavacTask;
+import com.sun.tools.doclint.Entity;
+import com.sun.tools.doclint.HtmlTag;
+import com.sun.tools.javac.util.DefinedBy;
+import com.sun.tools.javac.util.DefinedBy.Api;
+import com.sun.tools.javac.util.StringUtils;
+
+/**A javadoc to plain text formatter.
+ *
+ */
+public class JavadocFormatter {
+
+ private static final String CODE_RESET = "\033[0m";
+ private static final String CODE_HIGHLIGHT = "\033[1m";
+ private static final String CODE_UNDERLINE = "\033[4m";
+
+ private final int lineLimit;
+ private final boolean escapeSequencesSupported;
+
+ /** Construct the formatter.
+ *
+ * @param lineLimit maximum line length
+ * @param escapeSequencesSupported whether escape sequences are supported
+ */
+ public JavadocFormatter(int lineLimit, boolean escapeSequencesSupported) {
+ this.lineLimit = lineLimit;
+ this.escapeSequencesSupported = escapeSequencesSupported;
+ }
+
+ private static final int MAX_LINE_LENGTH = 95;
+ private static final int SHORTEST_LINE = 30;
+ private static final int INDENT = 4;
+
+ /**Format javadoc to plain text.
+ *
+ * @param header element caption that should be used
+ * @param javadoc to format
+ * @return javadoc formatted to plain text
+ */
+ public String formatJavadoc(String header, String javadoc) {
+ try {
+ StringBuilder result = new StringBuilder();
+
+ result.append(escape(CODE_HIGHLIGHT)).append(header).append(escape(CODE_RESET)).append("\n");
+
+ if (javadoc == null) {
+ return result.toString();
+ }
+
+ JavacTask task = (JavacTask) ToolProvider.getSystemJavaCompiler().getTask(null, null, null, null, null, null);
+ DocTrees trees = DocTrees.instance(task);
+ DocCommentTree docComment = trees.getDocCommentTree(new SimpleJavaFileObject(new URI("mem://doc.html"), Kind.HTML) {
+ @Override @DefinedBy(Api.COMPILER)
+ public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException {
+ return "<body>" + javadoc + "</body>";
+ }
+ });
+
+ new FormatJavadocScanner(result, task).scan(docComment, null);
+
+ addNewLineIfNeeded(result);
+
+ return result.toString();
+ } catch (URISyntaxException ex) {
+ throw new InternalError("Unexpected exception", ex);
+ }
+ }
+
+ private class FormatJavadocScanner extends DocTreeScanner<Object, Object> {
+ private final StringBuilder result;
+ private final JavacTask task;
+ private int reflownTo;
+ private int indent;
+ private int limit = Math.min(lineLimit, MAX_LINE_LENGTH);
+ private boolean pre;
+ private Map<StartElementTree, Integer> tableColumns;
+
+ public FormatJavadocScanner(StringBuilder result, JavacTask task) {
+ this.result = result;
+ this.task = task;
+ }
+
+ @Override @DefinedBy(Api.COMPILER_TREE)
+ public Object visitDocComment(DocCommentTree node, Object p) {
+ tableColumns = countTableColumns(node);
+ reflownTo = result.length();
+ scan(node.getFirstSentence(), p);
+ scan(node.getBody(), p);
+ reflow(result, reflownTo, indent, limit);
+ for (Sections current : docSections.keySet()) {
+ boolean seenAny = false;
+ for (DocTree t : node.getBlockTags()) {
+ if (current.matches(t)) {
+ if (!seenAny) {
+ seenAny = true;
+ if (result.charAt(result.length() - 1) != '\n')
+ result.append("\n");
+ result.append("\n");
+ result.append(escape(CODE_UNDERLINE))
+ .append(docSections.get(current))
+ .append(escape(CODE_RESET))
+ .append("\n");
+ }
+
+ scan(t, null);
+ }
+ }
+ }
+ return null;
+ }
+
+ @Override @DefinedBy(Api.COMPILER_TREE)
+ public Object visitText(TextTree node, Object p) {
+ String text = node.getBody();
+ if (!pre) {
+ text = text.replaceAll("[ \t\r\n]+", " ").trim();
+ if (text.isEmpty()) {
+ text = " ";
+ }
+ } else {
+ text = text.replaceAll("\n", "\n" + indentString(indent));
+ }
+ result.append(text);
+ return null;
+ }
+
+ @Override @DefinedBy(Api.COMPILER_TREE)
+ public Object visitLink(LinkTree node, Object p) {
+ if (!node.getLabel().isEmpty()) {
+ scan(node.getLabel(), p);
+ } else {
+ result.append(node.getReference().getSignature());
+ }
+ return null;
+ }
+
+ @Override @DefinedBy(Api.COMPILER_TREE)
+ public Object visitParam(ParamTree node, Object p) {
+ return formatDef(node.getName().getName(), node.getDescription());
+ }
+
+ @Override @DefinedBy(Api.COMPILER_TREE)
+ public Object visitThrows(ThrowsTree node, Object p) {
+ return formatDef(node.getExceptionName().getSignature(), node.getDescription());
+ }
+
+ public Object formatDef(CharSequence name, List<? extends DocTree> description) {
+ result.append(name);
+ result.append(" - ");
+ reflownTo = result.length();
+ indent = name.length() + 3;
+
+ if (limit - indent < SHORTEST_LINE) {
+ result.append("\n");
+ result.append(indentString(INDENT));
+ indent = INDENT;
+ reflownTo += INDENT;
+ }
+ try {
+ return scan(description, null);
+ } finally {
+ reflow(result, reflownTo, indent, limit);
+ result.append("\n");
+ }
+ }
+
+ @Override @DefinedBy(Api.COMPILER_TREE)
+ public Object visitLiteral(LiteralTree node, Object p) {
+ return scan(node.getBody(), p);
+ }
+
+ @Override @DefinedBy(Api.COMPILER_TREE)
+ public Object visitReturn(ReturnTree node, Object p) {
+ reflownTo = result.length();
+ try {
+ return super.visitReturn(node, p);
+ } finally {
+ reflow(result, reflownTo, 0, limit);
+ }
+ }
+
+ Stack<Integer> listStack = new Stack<>();
+ Stack<Integer> defStack = new Stack<>();
+ Stack<Integer> tableStack = new Stack<>();
+ Stack<List<Integer>> cellsStack = new Stack<>();
+ Stack<List<Boolean>> headerStack = new Stack<>();
+
+ @Override @DefinedBy(Api.COMPILER_TREE)
+ public Object visitStartElement(StartElementTree node, Object p) {
+ switch (HtmlTag.get(node.getName())) {
+ case P:
+ if (lastNode!= null && lastNode.getKind() == DocTree.Kind.START_ELEMENT &&
+ HtmlTag.get(((StartElementTree) lastNode).getName()) == HtmlTag.LI) {
+ //ignore
+ break;
+ }
+ reflowTillNow();
+ addNewLineIfNeeded(result);
+ result.append(indentString(indent));
+ reflownTo = result.length();
+ break;
+ case BLOCKQUOTE:
+ reflowTillNow();
+ indent += INDENT;
+ break;
+ case PRE:
+ reflowTillNow();
+ pre = true;
+ break;
+ case UL:
+ reflowTillNow();
+ listStack.push(-1);
+ indent += INDENT;
+ break;
+ case OL:
+ reflowTillNow();
+ listStack.push(1);
+ indent += INDENT;
+ break;
+ case DL:
+ reflowTillNow();
+ defStack.push(indent);
+ break;
+ case LI:
+ reflowTillNow();
+ if (!listStack.empty()) {
+ addNewLineIfNeeded(result);
+
+ int top = listStack.pop();
+
+ if (top == (-1)) {
+ result.append(indentString(indent - 2));
+ result.append("* ");
+ } else {
+ result.append(indentString(indent - 3));
+ result.append("" + top++ + ". ");
+ }
+
+ listStack.push(top);
+
+ reflownTo = result.length();
+ }
+ break;
+ case DT:
+ reflowTillNow();
+ if (!defStack.isEmpty()) {
+ addNewLineIfNeeded(result);
+ indent = defStack.peek();
+ result.append(escape(CODE_HIGHLIGHT));
+ }
+ break;
+ case DD:
+ reflowTillNow();
+ if (!defStack.isEmpty()) {
+ if (indent == defStack.peek()) {
+ result.append(escape(CODE_RESET));
+ }
+ addNewLineIfNeeded(result);
+ indent = defStack.peek() + INDENT;
+ result.append(indentString(indent));
+ }
+ break;
+ case H1: case H2: case H3:
+ case H4: case H5: case H6:
+ reflowTillNow();
+ addNewLineIfNeeded(result);
+ result.append("\n")
+ .append(escape(CODE_UNDERLINE));
+ reflownTo = result.length();
+ break;
+ case TABLE:
+ int columns = tableColumns.get(node);
+
+ if (columns == 0) {
+ break; //broken input
+ }
+
+ reflowTillNow();
+ addNewLineIfNeeded(result);
+ reflownTo = result.length();
+
+ tableStack.push(limit);
+
+ limit = (limit - 1) / columns - 3;
+
+ for (int sep = 0; sep < (limit + 3) * columns + 1; sep++) {
+ result.append("-");
+ }
+
+ result.append("\n");
+
+ break;
+ case TR:
+ if (cellsStack.size() >= tableStack.size()) {
+ //unclosed <tr>:
+ handleEndElement(node.getName());
+ }
+ cellsStack.push(new ArrayList<>());
+ headerStack.push(new ArrayList<>());
+ break;
+ case TH:
+ case TD:
+ if (cellsStack.isEmpty()) {
+ //broken code
+ break;
+ }
+ reflowTillNow();
+ result.append("\n");
+ reflownTo = result.length();
+ cellsStack.peek().add(result.length());
+ headerStack.peek().add(HtmlTag.get(node.getName()) == HtmlTag.TH);
+ break;
+ case IMG:
+ for (DocTree attr : node.getAttributes()) {
+ if (attr.getKind() != DocTree.Kind.ATTRIBUTE) {
+ continue;
+ }
+ AttributeTree at = (AttributeTree) attr;
+ if ("alt".equals(StringUtils.toLowerCase(at.getName().toString()))) {
+ addSpaceIfNeeded(result);
+ scan(at.getValue(), null);
+ addSpaceIfNeeded(result);
+ break;
+ }
+ }
+ break;
+ default:
+ addSpaceIfNeeded(result);
+ break;
+ }
+ return null;
+ }
+
+ @Override @DefinedBy(Api.COMPILER_TREE)
+ public Object visitEndElement(EndElementTree node, Object p) {
+ handleEndElement(node.getName());
+ return super.visitEndElement(node, p);
+ }
+
+ private void handleEndElement(Name name) {
+ switch (HtmlTag.get(name)) {
+ case BLOCKQUOTE:
+ indent -= INDENT;
+ break;
+ case PRE:
+ pre = false;
+ addNewLineIfNeeded(result);
+ reflownTo = result.length();
+ break;
+ case UL: case OL:
+ if (listStack.isEmpty()) { //ignore stray closing tag
+ break;
+ }
+ reflowTillNow();
+ listStack.pop();
+ indent -= INDENT;
+ addNewLineIfNeeded(result);
+ break;
+ case DL:
+ if (defStack.isEmpty()) {//ignore stray closing tag
+ break;
+ }
+ reflowTillNow();
+ if (indent == defStack.peek()) {
+ result.append(escape(CODE_RESET));
+ }
+ indent = defStack.pop();
+ addNewLineIfNeeded(result);
+ break;
+ case H1: case H2: case H3:
+ case H4: case H5: case H6:
+ reflowTillNow();
+ result.append(escape(CODE_RESET))
+ .append("\n");
+ reflownTo = result.length();
+ break;
+ case TABLE:
+ if (cellsStack.size() >= tableStack.size()) {
+ //unclosed <tr>:
+ handleEndElement(task.getElements().getName("tr"));
+ }
+
+ if (tableStack.isEmpty()) {
+ break;
+ }
+
+ limit = tableStack.pop();
+ break;
+ case TR:
+ if (cellsStack.isEmpty()) {
+ break;
+ }
+
+ reflowTillNow();
+
+ List<Integer> cells = cellsStack.pop();
+ List<Boolean> headerFlags = headerStack.pop();
+ List<String[]> content = new ArrayList<>();
+ int maxLines = 0;
+
+ result.append("\n");
+
+ while (!cells.isEmpty()) {
+ int currentCell = cells.remove(cells.size() - 1);
+ String[] lines = result.substring(currentCell, result.length()).split("\n");
+
+ result.delete(currentCell - 1, result.length());
+
+ content.add(lines);
+ maxLines = Math.max(maxLines, lines.length);
+ }
+
+ Collections.reverse(content);
+
+ for (int line = 0; line < maxLines; line++) {
+ for (int column = 0; column < content.size(); column++) {
+ String[] lines = content.get(column);
+ String currentLine = line < lines.length ? lines[line] : "";
+ result.append("| ");
+ boolean header = headerFlags.get(column);
+ if (header) {
+ result.append(escape(CODE_HIGHLIGHT));
+ }
+ result.append(currentLine);
+ if (header) {
+ result.append(escape(CODE_RESET));
+ }
+ int padding = limit - currentLine.length();
+ if (padding > 0)
+ result.append(indentString(padding));
+ result.append(" ");
+ }
+ result.append("|\n");
+ }
+
+ for (int sep = 0; sep < (limit + 3) * content.size() + 1; sep++) {
+ result.append("-");
+ }
+
+ result.append("\n");
+
+ reflownTo = result.length();
+ break;
+ case TD:
+ case TH:
+ break;
+ default:
+ addSpaceIfNeeded(result);
+ break;
+ }
+ }
+
+ @Override @DefinedBy(Api.COMPILER_TREE)
+ public Object visitEntity(EntityTree node, Object p) {
+ String name = node.getName().toString();
+ int code = -1;
+ if (name.startsWith("#")) {
+ try {
+ int v = StringUtils.toLowerCase(name).startsWith("#x")
+ ? Integer.parseInt(name.substring(2), 16)
+ : Integer.parseInt(name.substring(1), 10);
+ if (Entity.isValid(v)) {
+ code = v;
+ }
+ } catch (NumberFormatException ex) {
+ //ignore
+ }
+ } else {
+ Entity entity = Entity.get(name);
+ if (entity != null) {
+ code = entity.code;
+ }
+ }
+ if (code != (-1)) {
+ result.appendCodePoint(code);
+ } else {
+ result.append(node.toString());
+ }
+ return super.visitEntity(node, p);
+ }
+
+ private DocTree lastNode;
+
+ @Override @DefinedBy(Api.COMPILER_TREE)
+ public Object scan(DocTree node, Object p) {
+ if (node instanceof InlineTagTree) {
+ addSpaceIfNeeded(result);
+ }
+ try {
+ return super.scan(node, p);
+ } finally {
+ if (node instanceof InlineTagTree) {
+ addSpaceIfNeeded(result);
+ }
+ lastNode = node;
+ }
+ }
+
+ private void reflowTillNow() {
+ while (result.length() > 0 && result.charAt(result.length() - 1) == ' ')
+ result.delete(result.length() - 1, result.length());
+ reflow(result, reflownTo, indent, limit);
+ reflownTo = result.length();
+ }
+ };
+
+ private String escape(String sequence) {
+ return this.escapeSequencesSupported ? sequence : "";
+ }
+
+ private static final Map<Sections, String> docSections = new LinkedHashMap<>();
+
+ static {
+ ResourceBundle bundle =
+ ResourceBundle.getBundle("jdk.internal.shellsupport.doc.resources.javadocformatter");
+ docSections.put(Sections.TYPE_PARAMS, bundle.getString("CAP_TypeParameters"));
+ docSections.put(Sections.PARAMS, bundle.getString("CAP_Parameters"));
+ docSections.put(Sections.RETURNS, bundle.getString("CAP_Returns"));
+ docSections.put(Sections.THROWS, bundle.getString("CAP_Thrown_Exceptions"));
+ }
+
+ private static String indentString(int indent) {
+ char[] content = new char[indent];
+ Arrays.fill(content, ' ');
+ return new String(content);
+ }
+
+ private static void reflow(StringBuilder text, int from, int indent, int limit) {
+ int lineStart = from;
+
+ while (lineStart > 0 && text.charAt(lineStart - 1) != '\n') {
+ lineStart--;
+ }
+
+ int lineChars = from - lineStart;
+ int pointer = from;
+ int lastSpace = -1;
+
+ while (pointer < text.length()) {
+ if (text.charAt(pointer) == ' ')
+ lastSpace = pointer;
+ if (lineChars >= limit) {
+ if (lastSpace != (-1)) {
+ text.setCharAt(lastSpace, '\n');
+ text.insert(lastSpace + 1, indentString(indent));
+ lineChars = indent + pointer - lastSpace - 1;
+ pointer += indent;
+ lastSpace = -1;
+ }
+ }
+ lineChars++;
+ pointer++;
+ }
+ }
+
+ private static void addNewLineIfNeeded(StringBuilder text) {
+ if (text.length() > 0 && text.charAt(text.length() - 1) != '\n') {
+ text.append("\n");
+ }
+ }
+
+ private static void addSpaceIfNeeded(StringBuilder text) {
+ if (text.length() == 0)
+ return ;
+
+ char last = text.charAt(text.length() - 1);
+
+ if (last != ' ' && last != '\n') {
+ text.append(" ");
+ }
+ }
+
+ private static Map<StartElementTree, Integer> countTableColumns(DocCommentTree dct) {
+ Map<StartElementTree, Integer> result = new IdentityHashMap<>();
+
+ new DocTreeScanner<Void, Void>() {
+ private StartElementTree currentTable;
+ private int currentMaxColumns;
+ private int currentRowColumns;
+
+ @Override @DefinedBy(Api.COMPILER_TREE)
+ public Void visitStartElement(StartElementTree node, Void p) {
+ switch (HtmlTag.get(node.getName())) {
+ case TABLE: currentTable = node; break;
+ case TR:
+ currentMaxColumns = Math.max(currentMaxColumns, currentRowColumns);
+ currentRowColumns = 0;
+ break;
+ case TD:
+ case TH: currentRowColumns++; break;
+ }
+ return super.visitStartElement(node, p);
+ }
+
+ @Override @DefinedBy(Api.COMPILER_TREE)
+ public Void visitEndElement(EndElementTree node, Void p) {
+ if (HtmlTag.get(node.getName()) == HtmlTag.TABLE) {
+ closeTable();
+ }
+ return super.visitEndElement(node, p);
+ }
+
+ @Override @DefinedBy(Api.COMPILER_TREE)
+ public Void visitDocComment(DocCommentTree node, Void p) {
+ try {
+ return super.visitDocComment(node, p);
+ } finally {
+ closeTable();
+ }
+ }
+
+ private void closeTable() {
+ if (currentTable != null) {
+ result.put(currentTable, Math.max(currentMaxColumns, currentRowColumns));
+ currentTable = null;
+ }
+ }
+ }.scan(dct, null);
+
+ return result;
+ }
+
+ private enum Sections {
+ TYPE_PARAMS {
+ @Override public boolean matches(DocTree t) {
+ return t.getKind() == DocTree.Kind.PARAM && ((ParamTree) t).isTypeParameter();
+ }
+ },
+ PARAMS {
+ @Override public boolean matches(DocTree t) {
+ return t.getKind() == DocTree.Kind.PARAM && !((ParamTree) t).isTypeParameter();
+ }
+ },
+ RETURNS {
+ @Override public boolean matches(DocTree t) {
+ return t.getKind() == DocTree.Kind.RETURN;
+ }
+ },
+ THROWS {
+ @Override public boolean matches(DocTree t) {
+ return t.getKind() == DocTree.Kind.THROWS;
+ }
+ };
+
+ public abstract boolean matches(DocTree t);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/jdk.compiler/share/classes/jdk/internal/shellsupport/doc/JavadocHelper.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,661 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package jdk.internal.shellsupport.doc;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.IdentityHashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Objects;
+import java.util.Set;
+import java.util.Stack;
+import java.util.TreeMap;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import javax.lang.model.element.Element;
+import javax.lang.model.element.ElementKind;
+import javax.lang.model.element.ExecutableElement;
+import javax.lang.model.element.TypeElement;
+import javax.lang.model.element.VariableElement;
+import javax.lang.model.type.DeclaredType;
+import javax.lang.model.type.TypeKind;
+import javax.lang.model.util.ElementFilter;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileManager;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.StandardLocation;
+import javax.tools.ToolProvider;
+
+import com.sun.source.doctree.DocCommentTree;
+import com.sun.source.doctree.DocTree;
+import com.sun.source.doctree.InheritDocTree;
+import com.sun.source.doctree.ParamTree;
+import com.sun.source.doctree.ReturnTree;
+import com.sun.source.doctree.ThrowsTree;
+import com.sun.source.tree.ClassTree;
+import com.sun.source.tree.CompilationUnitTree;
+import com.sun.source.tree.MethodTree;
+import com.sun.source.tree.VariableTree;
+import com.sun.source.util.DocTreePath;
+import com.sun.source.util.DocTreeScanner;
+import com.sun.source.util.DocTrees;
+import com.sun.source.util.JavacTask;
+import com.sun.source.util.TreePath;
+import com.sun.source.util.TreePathScanner;
+import com.sun.source.util.Trees;
+import com.sun.tools.javac.api.JavacTaskImpl;
+import com.sun.tools.javac.util.DefinedBy;
+import com.sun.tools.javac.util.DefinedBy.Api;
+import com.sun.tools.javac.util.Pair;
+
+/**Helper to find javadoc and resolve @inheritDoc.
+ */
+public abstract class JavadocHelper implements AutoCloseable {
+ private static final JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
+
+ /**Create the helper.
+ *
+ * @param mainTask JavacTask from which the further Elements originate
+ * @param sourceLocations paths where source files should be searched
+ * @return a JavadocHelper
+ */
+ public static JavadocHelper create(JavacTask mainTask, Collection<? extends Path> sourceLocations) {
+ StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null);
+ try {
+ fm.setLocationFromPaths(StandardLocation.SOURCE_PATH, sourceLocations);
+ return new OnDemandJavadocHelper(mainTask, fm);
+ } catch (IOException ex) {
+ try {
+ fm.close();
+ } catch (IOException closeEx) {
+ }
+ return new JavadocHelper() {
+ @Override
+ public String getResolvedDocComment(Element forElement) throws IOException {
+ return null;
+ }
+ @Override
+ public Element getSourceElement(Element forElement) throws IOException {
+ return forElement;
+ }
+ @Override
+ public void close() throws IOException {}
+ };
+ }
+ }
+
+ /**Returns javadoc for the given element, if it can be found, or null otherwise. The javadoc
+ * will have @inheritDoc resolved.
+ *
+ * @param forElement element for which the javadoc should be searched
+ * @return javadoc if found, null otherwise
+ * @throws IOException if something goes wrong in the search
+ */
+ public abstract String getResolvedDocComment(Element forElement) throws IOException;
+
+ /**Returns an element representing the same given program element, but the returned element will
+ * be resolved from source, if it can be found. Returns the original element if the source for
+ * the given element cannot be found.
+ *
+ * @param forElement element for which the source element should be searched
+ * @return source element if found, the original element otherwise
+ * @throws IOException if something goes wrong in the search
+ */
+ public abstract Element getSourceElement(Element forElement) throws IOException;
+
+ /**Closes the helper.
+ *
+ * @throws IOException if something foes wrong during the close
+ */
+ @Override
+ public abstract void close() throws IOException;
+
+ private static final class OnDemandJavadocHelper extends JavadocHelper {
+ private final JavacTask mainTask;
+ private final JavaFileManager baseFileManager;
+ private final StandardJavaFileManager fm;
+ private final Map<String, Pair<JavacTask, TreePath>> signature2Source = new HashMap<>();
+
+ private OnDemandJavadocHelper(JavacTask mainTask, StandardJavaFileManager fm) {
+ this.mainTask = mainTask;
+ this.baseFileManager = ((JavacTaskImpl) mainTask).getContext().get(JavaFileManager.class);
+ this.fm = fm;
+ }
+
+ @Override
+ public String getResolvedDocComment(Element forElement) throws IOException {
+ Pair<JavacTask, TreePath> sourceElement = getSourceElement(mainTask, forElement);
+
+ if (sourceElement == null)
+ return null;
+
+ return getResolvedDocComment(sourceElement.fst, sourceElement.snd);
+ }
+
+ @Override
+ public Element getSourceElement(Element forElement) throws IOException {
+ Pair<JavacTask, TreePath> sourceElement = getSourceElement(mainTask, forElement);
+
+ if (sourceElement == null)
+ return forElement;
+
+ Element result = Trees.instance(sourceElement.fst).getElement(sourceElement.snd);
+
+ if (result == null)
+ return forElement;
+
+ return result;
+ }
+
+ private String getResolvedDocComment(JavacTask task, TreePath el) throws IOException {
+ DocTrees trees = DocTrees.instance(task);
+ Element element = trees.getElement(el);
+ String docComment = trees.getDocComment(el);
+
+ if (docComment == null && element.getKind() == ElementKind.METHOD) {
+ ExecutableElement executableElement = (ExecutableElement) element;
+ Iterable<Element> superTypes =
+ () -> superTypeForInheritDoc(task, element.getEnclosingElement()).iterator();
+ for (Element sup : superTypes) {
+ for (ExecutableElement supMethod : ElementFilter.methodsIn(sup.getEnclosedElements())) {
+ TypeElement clazz = (TypeElement) executableElement.getEnclosingElement();
+ if (task.getElements().overrides(executableElement, supMethod, clazz)) {
+ Pair<JavacTask, TreePath> source = getSourceElement(task, supMethod);
+
+ if (source != null) {
+ String overriddenComment = getResolvedDocComment(source.fst, source.snd);
+
+ if (overriddenComment != null) {
+ return overriddenComment;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ DocCommentTree docCommentTree = parseDocComment(task, docComment);
+ IOException[] exception = new IOException[1];
+ Map<int[], String> replace = new TreeMap<>((span1, span2) -> span2[0] - span1[0]);
+
+ new DocTreeScanner<Void, Void>() {
+ private Stack<DocTree> interestingParent = new Stack<>();
+ private DocCommentTree dcTree;
+ private JavacTask inheritedJavacTask;
+ private TreePath inheritedTreePath;
+ private String inherited;
+ private Map<DocTree, String> syntheticTrees = new IdentityHashMap<>();
+ private long lastPos = 0;
+ @Override @DefinedBy(Api.COMPILER_TREE)
+ public Void visitDocComment(DocCommentTree node, Void p) {
+ dcTree = node;
+ interestingParent.push(node);
+ try {
+ scan(node.getFirstSentence(), p);
+ scan(node.getBody(), p);
+ List<DocTree> augmentedBlockTags = new ArrayList<>(node.getBlockTags());
+ if (element.getKind() == ElementKind.METHOD) {
+ ExecutableElement executableElement = (ExecutableElement) element;
+ List<String> parameters =
+ executableElement.getParameters()
+ .stream()
+ .map(param -> param.getSimpleName().toString())
+ .collect(Collectors.toList());
+ List<String> throwsList =
+ executableElement.getThrownTypes()
+ .stream()
+ .map(exc -> exc.toString())
+ .collect(Collectors.toList());
+ Set<String> missingParams = new HashSet<>(parameters);
+ Set<String> missingThrows = new HashSet<>(throwsList);
+ boolean hasReturn = false;
+
+ for (DocTree dt : augmentedBlockTags) {
+ switch (dt.getKind()) {
+ case PARAM:
+ missingParams.remove(((ParamTree) dt).getName().getName().toString());
+ break;
+ case THROWS:
+ missingThrows.remove(getThrownException(task, el, docCommentTree, (ThrowsTree) dt));
+ break;
+ case RETURN:
+ hasReturn = true;
+ break;
+ }
+ }
+
+ for (String missingParam : missingParams) {
+ DocTree syntheticTag = parseBlockTag(task, "@param " + missingParam + " {@inheritDoc}");
+ syntheticTrees.put(syntheticTag, "@param " + missingParam + " ");
+ insertTag(augmentedBlockTags, syntheticTag, parameters, throwsList);
+ }
+
+ for (String missingThrow : missingThrows) {
+ DocTree syntheticTag = parseBlockTag(task, "@throws " + missingThrow + " {@inheritDoc}");
+ syntheticTrees.put(syntheticTag, "@throws " + missingThrow + " ");
+ insertTag(augmentedBlockTags, syntheticTag, parameters, throwsList);
+ }
+
+ if (!hasReturn) {
+ DocTree syntheticTag = parseBlockTag(task, "@return {@inheritDoc}");
+ syntheticTrees.put(syntheticTag, "@return ");
+ insertTag(augmentedBlockTags, syntheticTag, parameters, throwsList);
+ }
+ }
+ scan(augmentedBlockTags, p);
+ return null;
+ } finally {
+ interestingParent.pop();
+ }
+ }
+ @Override @DefinedBy(Api.COMPILER_TREE)
+ public Void visitParam(ParamTree node, Void p) {
+ interestingParent.push(node);
+ try {
+ return super.visitParam(node, p);
+ } finally {
+ interestingParent.pop();
+ }
+ }
+ @Override @DefinedBy(Api.COMPILER_TREE)
+ public Void visitThrows(ThrowsTree node, Void p) {
+ interestingParent.push(node);
+ try {
+ return super.visitThrows(node, p);
+ } finally {
+ interestingParent.pop();
+ }
+ }
+ @Override @DefinedBy(Api.COMPILER_TREE)
+ public Void visitReturn(ReturnTree node, Void p) {
+ interestingParent.push(node);
+ try {
+ return super.visitReturn(node, p);
+ } finally {
+ interestingParent.pop();
+ }
+ }
+ @Override @DefinedBy(Api.COMPILER_TREE)
+ public Void visitInheritDoc(InheritDocTree node, Void p) {
+ if (inherited == null) {
+ try {
+ if (element.getKind() == ElementKind.METHOD) {
+ ExecutableElement executableElement = (ExecutableElement) element;
+ Iterable<Element> superTypes = () -> superTypeForInheritDoc(task, element.getEnclosingElement()).iterator();
+ OUTER: for (Element sup : superTypes) {
+ for (ExecutableElement supMethod : ElementFilter.methodsIn(sup.getEnclosedElements())) {
+ if (task.getElements().overrides(executableElement, supMethod, (TypeElement) executableElement.getEnclosingElement())) {
+ Pair<JavacTask, TreePath> source = getSourceElement(task, supMethod);
+
+ if (source != null) {
+ String overriddenComment = getResolvedDocComment(source.fst, source.snd);
+
+ if (overriddenComment != null) {
+ inheritedJavacTask = source.fst;
+ inheritedTreePath = source.snd;
+ inherited = overriddenComment;
+ break OUTER;
+ }
+ }
+ }
+ }
+ }
+ }
+ } catch (IOException ex) {
+ exception[0] = ex;
+ return null;
+ }
+ }
+ if (inherited == null) {
+ return null;
+ }
+ DocCommentTree inheritedDocTree = parseDocComment(inheritedJavacTask, inherited);
+ List<List<? extends DocTree>> inheritedText = new ArrayList<>();
+ DocTree parent = interestingParent.peek();
+ switch (parent.getKind()) {
+ case DOC_COMMENT:
+ inheritedText.add(inheritedDocTree.getFullBody());
+ break;
+ case PARAM:
+ String paramName = ((ParamTree) parent).getName().getName().toString();
+ new DocTreeScanner<Void, Void>() {
+ @Override @DefinedBy(Api.COMPILER_TREE)
+ public Void visitParam(ParamTree node, Void p) {
+ if (node.getName().getName().contentEquals(paramName)) {
+ inheritedText.add(node.getDescription());
+ }
+ return super.visitParam(node, p);
+ }
+ }.scan(inheritedDocTree, null);
+ break;
+ case THROWS:
+ String thrownName = getThrownException(task, el, docCommentTree, (ThrowsTree) parent);
+ new DocTreeScanner<Void, Void>() {
+ @Override @DefinedBy(Api.COMPILER_TREE)
+ public Void visitThrows(ThrowsTree node, Void p) {
+ if (Objects.equals(getThrownException(inheritedJavacTask, inheritedTreePath, inheritedDocTree, node), thrownName)) {
+ inheritedText.add(node.getDescription());
+ }
+ return super.visitThrows(node, p);
+ }
+ }.scan(inheritedDocTree, null);
+ break;
+ case RETURN:
+ new DocTreeScanner<Void, Void>() {
+ @Override @DefinedBy(Api.COMPILER_TREE)
+ public Void visitReturn(ReturnTree node, Void p) {
+ inheritedText.add(node.getDescription());
+ return super.visitReturn(node, p);
+ }
+ }.scan(inheritedDocTree, null);
+ break;
+ }
+ if (!inheritedText.isEmpty()) {
+ long offset = trees.getSourcePositions().getStartPosition(null, inheritedDocTree, inheritedDocTree);
+ long start = Long.MAX_VALUE;
+ long end = Long.MIN_VALUE;
+
+ for (DocTree t : inheritedText.get(0)) {
+ start = Math.min(start, trees.getSourcePositions().getStartPosition(null, inheritedDocTree, t) - offset);
+ end = Math.max(end, trees.getSourcePositions().getEndPosition(null, inheritedDocTree, t) - offset);
+ }
+ String text = inherited.substring((int) start, (int) end);
+
+ if (syntheticTrees.containsKey(parent)) {
+ replace.put(new int[] {(int) lastPos + 1, (int) lastPos}, "\n" + syntheticTrees.get(parent) + text);
+ } else {
+ long inheritedStart = trees.getSourcePositions().getStartPosition(null, dcTree, node);
+ long inheritedEnd = trees.getSourcePositions().getEndPosition(null, dcTree, node);
+
+ replace.put(new int[] {(int) inheritedStart, (int) inheritedEnd}, text);
+ }
+ }
+ return super.visitInheritDoc(node, p);
+ }
+ private boolean inSynthetic;
+ @Override @DefinedBy(Api.COMPILER_TREE)
+ public Void scan(DocTree tree, Void p) {
+ if (exception[0] != null) {
+ return null;
+ }
+ boolean prevInSynthetic = inSynthetic;
+ try {
+ inSynthetic |= syntheticTrees.containsKey(tree);
+ return super.scan(tree, p);
+ } finally {
+ if (!inSynthetic) {
+ lastPos = trees.getSourcePositions().getEndPosition(null, dcTree, tree);
+ }
+ inSynthetic = prevInSynthetic;
+ }
+ }
+
+ private void insertTag(List<DocTree> tags, DocTree toInsert, List<String> parameters, List<String> throwsTypes) {
+ Comparator<DocTree> comp = (tag1, tag2) -> {
+ if (tag1.getKind() == tag2.getKind()) {
+ switch (toInsert.getKind()) {
+ case PARAM: {
+ ParamTree p1 = (ParamTree) tag1;
+ ParamTree p2 = (ParamTree) tag2;
+ int i1 = parameters.indexOf(p1.getName().getName().toString());
+ int i2 = parameters.indexOf(p2.getName().getName().toString());
+
+ return i1 - i2;
+ }
+ case THROWS: {
+ ThrowsTree t1 = (ThrowsTree) tag1;
+ ThrowsTree t2 = (ThrowsTree) tag2;
+ int i1 = throwsTypes.indexOf(getThrownException(task, el, docCommentTree, t1));
+ int i2 = throwsTypes.indexOf(getThrownException(task, el, docCommentTree, t2));
+
+ return i1 - i2;
+ }
+ }
+ }
+
+ int i1 = tagOrder.indexOf(tag1.getKind());
+ int i2 = tagOrder.indexOf(tag2.getKind());
+
+ return i1 - i2;
+ };
+
+ for (int i = 0; i < tags.size(); i++) {
+ if (comp.compare(tags.get(i), toInsert) >= 0) {
+ tags.add(i, toInsert);
+ return ;
+ }
+ }
+ tags.add(toInsert);
+ }
+
+ private final List<DocTree.Kind> tagOrder = Arrays.asList(DocTree.Kind.PARAM, DocTree.Kind.THROWS, DocTree.Kind.RETURN);
+ }.scan(docCommentTree, null);
+
+ if (replace.isEmpty())
+ return docComment;
+
+ StringBuilder replacedInheritDoc = new StringBuilder(docComment);
+ int offset = (int) trees.getSourcePositions().getStartPosition(null, docCommentTree, docCommentTree);
+
+ for (Entry<int[], String> e : replace.entrySet()) {
+ replacedInheritDoc.delete(e.getKey()[0] - offset, e.getKey()[1] - offset + 1);
+ replacedInheritDoc.insert(e.getKey()[0] - offset, e.getValue());
+ }
+
+ return replacedInheritDoc.toString();
+ }
+
+ private Stream<Element> superTypeForInheritDoc(JavacTask task, Element type) {
+ TypeElement clazz = (TypeElement) type;
+ Stream<Element> result = interfaces(clazz);
+ result = Stream.concat(result, interfaces(clazz).flatMap(el -> superTypeForInheritDoc(task, el)));
+
+ if (clazz.getSuperclass().getKind() == TypeKind.DECLARED) {
+ Element superClass = ((DeclaredType) clazz.getSuperclass()).asElement();
+ result = Stream.concat(result, Stream.of(superClass));
+ result = Stream.concat(result, superTypeForInheritDoc(task, superClass));
+ }
+
+ return result;
+ }
+ //where:
+ private Stream<Element> interfaces(TypeElement clazz) {
+ return clazz.getInterfaces()
+ .stream()
+ .filter(tm -> tm.getKind() == TypeKind.DECLARED)
+ .map(tm -> ((DeclaredType) tm).asElement());
+ }
+
+ private DocTree parseBlockTag(JavacTask task, String blockTag) {
+ DocCommentTree dc = parseDocComment(task, blockTag);
+
+ return dc.getBlockTags().get(0);
+ }
+
+ private DocCommentTree parseDocComment(JavacTask task, String javadoc) {
+ DocTrees trees = DocTrees.instance(task);
+ try {
+ return trees.getDocCommentTree(new SimpleJavaFileObject(new URI("mem://doc.html"), javax.tools.JavaFileObject.Kind.HTML) {
+ @Override @DefinedBy(Api.COMPILER)
+ public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException {
+ return "<body>" + javadoc + "</body>";
+ }
+ });
+ } catch (URISyntaxException ex) {
+ return null;
+ }
+ }
+
+ private String getThrownException(JavacTask task, TreePath rootOn, DocCommentTree comment, ThrowsTree tt) {
+ DocTrees trees = DocTrees.instance(task);
+ Element exc = trees.getElement(new DocTreePath(new DocTreePath(rootOn, comment), tt.getExceptionName()));
+ return exc != null ? exc.toString() : null;
+ }
+
+ private Pair<JavacTask, TreePath> getSourceElement(JavacTask origin, Element el) throws IOException {
+ String handle = elementSignature(el);
+ Pair<JavacTask, TreePath> cached = signature2Source.get(handle);
+
+ if (cached != null) {
+ return cached.fst != null ? cached : null;
+ }
+
+ TypeElement type = topLevelType(el);
+
+ if (type == null)
+ return null;
+
+ String binaryName = origin.getElements().getBinaryName(type).toString();
+ Pair<JavacTask, CompilationUnitTree> source = findSource(binaryName);
+
+ if (source == null)
+ return null;
+
+ fillElementCache(source.fst, source.snd);
+
+ cached = signature2Source.get(handle);
+
+ if (cached != null) {
+ return cached;
+ } else {
+ signature2Source.put(handle, Pair.of(null, null));
+ return null;
+ }
+ }
+ //where:
+ private String elementSignature(Element el) {
+ switch (el.getKind()) {
+ case ANNOTATION_TYPE: case CLASS: case ENUM: case INTERFACE:
+ return ((TypeElement) el).getQualifiedName().toString();
+ case FIELD:
+ return elementSignature(el.getEnclosingElement()) + "." + el.getSimpleName() + ":" + el.asType();
+ case ENUM_CONSTANT:
+ return elementSignature(el.getEnclosingElement()) + "." + el.getSimpleName();
+ case EXCEPTION_PARAMETER: case LOCAL_VARIABLE: case PARAMETER: case RESOURCE_VARIABLE:
+ return el.getSimpleName() + ":" + el.asType();
+ case CONSTRUCTOR: case METHOD:
+ StringBuilder header = new StringBuilder();
+ header.append(elementSignature(el.getEnclosingElement()));
+ if (el.getKind() == ElementKind.METHOD) {
+ header.append(".");
+ header.append(el.getSimpleName());
+ }
+ header.append("(");
+ String sep = "";
+ ExecutableElement method = (ExecutableElement) el;
+ for (Iterator<? extends VariableElement> i = method.getParameters().iterator(); i.hasNext();) {
+ VariableElement p = i.next();
+ header.append(sep);
+ header.append(p.asType());
+ sep = ", ";
+ }
+ header.append(")");
+ return header.toString();
+ default:
+ return el.toString();
+ }
+ }
+
+ private TypeElement topLevelType(Element el) {
+ if (el.getKind() == ElementKind.PACKAGE)
+ return null;
+
+ while (el != null && el.getEnclosingElement().getKind() != ElementKind.PACKAGE) {
+ el = el.getEnclosingElement();
+ }
+
+ return el != null && (el.getKind().isClass() || el.getKind().isInterface()) ? (TypeElement) el : null;
+ }
+
+ private void fillElementCache(JavacTask task, CompilationUnitTree cut) throws IOException {
+ Trees trees = Trees.instance(task);
+
+ new TreePathScanner<Void, Void>() {
+ @Override @DefinedBy(Api.COMPILER_TREE)
+ public Void visitMethod(MethodTree node, Void p) {
+ handleDeclaration();
+ return null;
+ }
+
+ @Override @DefinedBy(Api.COMPILER_TREE)
+ public Void visitClass(ClassTree node, Void p) {
+ handleDeclaration();
+ return super.visitClass(node, p);
+ }
+
+ @Override @DefinedBy(Api.COMPILER_TREE)
+ public Void visitVariable(VariableTree node, Void p) {
+ handleDeclaration();
+ return super.visitVariable(node, p);
+ }
+
+ private void handleDeclaration() {
+ Element currentElement = trees.getElement(getCurrentPath());
+
+ if (currentElement != null) {
+ signature2Source.put(elementSignature(currentElement), Pair.of(task, getCurrentPath()));
+ }
+ }
+ }.scan(cut, null);
+ }
+
+ private Pair<JavacTask, CompilationUnitTree> findSource(String binaryName) throws IOException {
+ JavaFileObject jfo = fm.getJavaFileForInput(StandardLocation.SOURCE_PATH,
+ binaryName,
+ JavaFileObject.Kind.SOURCE);
+
+ if (jfo == null)
+ return null;
+
+ List<JavaFileObject> jfos = Arrays.asList(jfo);
+ JavacTaskImpl task = (JavacTaskImpl) compiler.getTask(null, baseFileManager, d -> {}, null, null, jfos);
+ Iterable<? extends CompilationUnitTree> cuts = task.parse();
+
+ task.enter();
+
+ return Pair.of(task, cuts.iterator().next());
+ }
+
+ @Override
+ public void close() throws IOException {
+ fm.close();
+ }
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/jdk.compiler/share/classes/jdk/internal/shellsupport/doc/resources/javadocformatter.properties Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,29 @@
+#
+# Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation. Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+CAP_TypeParameters=Type Parameters:
+CAP_Parameters=Parameters:
+CAP_Returns=Returns:
+CAP_Thrown_Exceptions=Thrown Exceptions:
--- a/langtools/src/jdk.compiler/share/classes/module-info.java Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/src/jdk.compiler/share/classes/module-info.java Wed Nov 09 10:04:43 2016 -0800
@@ -65,6 +65,9 @@
jdk.jdeps,
jdk.javadoc,
jdk.jshell;
+ exports jdk.internal.shellsupport.doc to
+ jdk.jshell,
+ jdk.scripting.nashorn.shell;
uses javax.annotation.processing.Processor;
uses com.sun.source.util.Plugin;
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/Main.java Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/Main.java Wed Nov 09 10:04:43 2016 -0800
@@ -638,6 +638,8 @@
// now the scanning phase
+ boolean scanStatus = true;
+
switch (scanMode) {
case LIST:
for (DeprData dd : deprList) {
@@ -661,24 +663,22 @@
Scan scan = new Scan(out, err, cp, db, verbose);
for (String a : args) {
- boolean success;
-
+ boolean s;
if (a.endsWith(".jar")) {
- success = scan.scanJar(a);
+ s = scan.scanJar(a);
+ } else if (a.endsWith(".class")) {
+ s = scan.processClassFile(a);
} else if (Files.isDirectory(Paths.get(a))) {
- success = scan.scanDir(a);
+ s = scan.scanDir(a);
} else {
- success = scan.processClassName(a.replace('.', '/'));
+ s = scan.processClassName(a.replace('.', '/'));
}
-
- if (!success) {
- return false;
- }
+ scanStatus = scanStatus && s;
}
break;
}
- return true;
+ return scanStatus;
}
/**
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/Messages.java Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/Messages.java Wed Nov 09 10:04:43 2016 -0800
@@ -34,6 +34,10 @@
* Message handling class for localization.
*/
public class Messages {
+ /** Indicates whether line separators in messages need replacement. */
+ static final boolean REPLACE_LINESEP = ! System.lineSeparator().equals("\n");
+
+ /** The resource bundle, must be non-null. */
static final ResourceBundle bundle;
static {
@@ -41,13 +45,25 @@
try {
bundle = ResourceBundle.getBundle("com.sun.tools.jdeprscan.resources.jdeprscan", locale);
} catch (MissingResourceException e) {
- throw new InternalError("Cannot find jdeps resource bundle for locale " + locale, e);
+ throw new InternalError("Cannot find jdeprscan resource bundle for locale " + locale, e);
}
}
+ /**
+ * Gets a message from the resource bundle. If necessary, translates "\n",
+ * the line break string used in the message file, to the system-specific
+ * line break string.
+ *
+ * @param key the message key
+ * @param args the message arguments
+ */
public static String get(String key, Object... args) {
try {
- return MessageFormat.format(bundle.getString(key), args);
+ String msg = MessageFormat.format(bundle.getString(key), args);
+ if (REPLACE_LINESEP) {
+ msg = msg.replace("\n", System.lineSeparator());
+ }
+ return msg;
} catch (MissingResourceException e) {
throw new InternalError("Missing message: " + key, e);
}
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/readme.md Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/readme.md Wed Nov 09 10:04:43 2016 -0800
@@ -92,6 +92,9 @@
that jar file and report information about how those classes use
deprecated APIs.
+Given a class file, **jdeprscan** will scan that class and report
+its use of deprecated APIs.
+
Given a class name, **jdeprscan** will search for that class on the
classpath, scan that class, and report information about how that
class uses deprecated APIs. The class name must use the fully
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/resources/jdeprscan.properties Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/resources/jdeprscan.properties Wed Nov 09 10:04:43 2016 -0800
@@ -14,9 +14,9 @@
main.help=\
Scans each argument for usages of deprecated APIs. An argument\n\
may be a directory specifying the root of a package hierarchy,\n\
-a JAR file, or a class name. The class name must be specified\n\
-using a fully qualified class name using the $ separator character\n\
-for nested classes, for example,\n\
+a JAR file, a class file, or a class name. The class name must be\n\
+specified using a fully qualified class name using the $ separator\n\
+character for nested classes, for example,\n\
\n\
\ java.lang.Thread$State\n\
\n\
@@ -73,24 +73,26 @@
\ Prints a CSV file containing the loaded deprecation information\n\
\ instead of scanning any classes or JAR files.
-error.prefix=Error:
-
scan.process.class=Processing class {0}...
-scan.dep.normal=deprecated
-scan.dep.removal=deprecated FOR REMOVAL
+scan.dep.normal=
+scan.dep.removal=(forRemoval=true)
+
+scan.err.exception=error: unexpected exception {0}
+scan.err.noclass=error: cannot find class {0}
+scan.err.nofile=error: cannot find file {0}
+scan.err.nomethod=error: cannot resolve Methodref {0}.{1}:{2}
+
+scan.head.jar=Jar file {0}:
+scan.head.dir=Directory {0}:
-scan.out.extends={0} {1} extends class {2} {3}
-scan.out.implements={0} {1} implements interface {2} {3}
-scan.out.usestype={0} {1} uses type {2} {3}
-scan.out.usesmethodintype={0} {1} uses method in type {2} {3}
-scan.out.usesmethod={0} {1} uses method {2} {3} {4} {5}
-scan.out.usesintfmethodintype={0} {1} uses interface method in type {2} {3}
-scan.out.usesintfmethod={0} {1} uses interface method {2} {3} {4} {5}
-scan.out.usesfieldintype={0} {1} uses field in type {2} {3}
-scan.out.usesfield={0} {1} uses field {2} {3} {4}
-scan.out.usesfieldoftype={0} {1} uses field of type {2} {3} {4} {5}
-scan.out.hasfield={0} {1} has field {2} of type {3} {4}
-scan.out.methodparmtype={0} {1} method {2} has parameter type {3} {4}
-scan.out.methodrettype={0} {1} method {2} has return type {3} {4}
-scan.out.methodoverride={0} {1} overrides method {2} {3} {4} {5}
+scan.out.extends={0} {1} extends deprecated class {2} {3}
+scan.out.implements={0} {1} implements deprecated interface {2} {3}
+scan.out.usesclass={0} {1} uses deprecated class {2} {3}
+scan.out.usesmethod={0} {1} uses deprecated method {2}::{3}{4} {5}
+scan.out.usesintfmethod={0} {1} uses deprecated method {2}::{3}{4} {5}
+scan.out.usesfield={0} {1} uses deprecated field {2}::{3} {4}
+scan.out.hasfield={0} {1} has field named {2} of deprecated type {3} {4}
+scan.out.methodparmtype={0} {1} has method named {2} having deprecated parameter type {3} {4}
+scan.out.methodrettype={0} {1} has method named {2} having deprecated return type {3} {4}
+scan.out.methodoverride={0} {1} overrides deprecated method {2}::{3}{4} {5}
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/scan/Scan.java Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/scan/Scan.java Wed Nov 09 10:04:43 2016 -0800
@@ -28,6 +28,7 @@
import java.io.IOException;
import java.io.PrintStream;
import java.nio.file.Files;
+import java.nio.file.NoSuchFileException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayDeque;
@@ -62,7 +63,7 @@
final boolean verbose;
final ClassFinder finder;
- boolean error = false;
+ boolean errorOccurred = false;
public Scan(PrintStream out,
PrintStream err,
@@ -124,71 +125,72 @@
}
}
- void printType(String key, ClassFile cf, String cname, boolean forRemoval)
+ String dep(boolean forRemoval) {
+ return Messages.get(forRemoval ? "scan.dep.removal" : "scan.dep.normal");
+ }
+
+ void printType(String key, ClassFile cf, String cname, boolean r)
throws ConstantPoolException {
- String dep = Messages.get(forRemoval ? "scan.dep.removal" : "scan.dep.normal");
- out.println(Messages.get(key, typeKind(cf), cf.getName(), cname, dep));
+ out.println(Messages.get(key, typeKind(cf), cf.getName(), cname, dep(r)));
}
void printMethod(String key, ClassFile cf, String cname, String mname, String rtype,
- boolean forRemoval) throws ConstantPoolException {
- String dep = Messages.get(forRemoval ? "scan.dep.removal" : "scan.dep.normal");
- out.println(Messages.get(key, typeKind(cf), cf.getName(), cname, mname, rtype, dep));
+ boolean r) throws ConstantPoolException {
+ out.println(Messages.get(key, typeKind(cf), cf.getName(), cname, mname, rtype, dep(r)));
}
void printField(String key, ClassFile cf, String cname, String fname,
- boolean forRemoval) throws ConstantPoolException {
- String dep = Messages.get(forRemoval ? "scan.dep.removal" : "scan.dep.normal");
- out.println(Messages.get(key, typeKind(cf), cf.getName(), cname, fname, dep));
+ boolean r) throws ConstantPoolException {
+ out.println(Messages.get(key, typeKind(cf), cf.getName(), cname, fname, dep(r)));
}
void printFieldType(String key, ClassFile cf, String cname, String fname, String type,
- boolean forRemoval) throws ConstantPoolException {
- String dep = Messages.get(forRemoval ? "scan.dep.removal" : "scan.dep.normal");
- out.println(Messages.get(key, typeKind(cf), cf.getName(), cname, fname, type, dep));
+ boolean r) throws ConstantPoolException {
+ out.println(Messages.get(key, typeKind(cf), cf.getName(), cname, fname, type, dep(r)));
}
- void printHasField(ClassFile cf, String fname, String type, boolean forRemoval)
+ void printHasField(ClassFile cf, String fname, String type, boolean r)
throws ConstantPoolException {
- String dep = Messages.get(forRemoval ? "scan.dep.removal" : "scan.dep.normal");
- out.println(Messages.get("scan.out.hasfield", typeKind(cf), cf.getName(), fname, type, dep));
+ out.println(Messages.get("scan.out.hasfield", typeKind(cf), cf.getName(), fname, type, dep(r)));
}
- void printHasMethodParmType(ClassFile cf, String mname, String parmType, boolean forRemoval)
+ void printHasMethodParmType(ClassFile cf, String mname, String parmType, boolean r)
throws ConstantPoolException {
- String dep = Messages.get(forRemoval ? "scan.dep.removal" : "scan.dep.normal");
- out.println(Messages.get("scan.out.methodparmtype", typeKind(cf), cf.getName(), mname, parmType, dep));
+ out.println(Messages.get("scan.out.methodparmtype", typeKind(cf), cf.getName(), mname, parmType, dep(r)));
}
- void printHasMethodRetType(ClassFile cf, String mname, String retType, boolean forRemoval)
+ void printHasMethodRetType(ClassFile cf, String mname, String retType, boolean r)
throws ConstantPoolException {
- String dep = Messages.get(forRemoval ? "scan.dep.removal" : "scan.dep.normal");
- out.println(Messages.get("scan.out.methodrettype", typeKind(cf), cf.getName(), mname, retType, dep));
+ out.println(Messages.get("scan.out.methodrettype", typeKind(cf), cf.getName(), mname, retType, dep(r)));
}
- void printHasOverriddenMethod(ClassFile cf, String overridden, String mname, String desc, boolean forRemoval)
+ void printHasOverriddenMethod(ClassFile cf, String overridden, String mname, String desc, boolean r)
throws ConstantPoolException {
- String dep = Messages.get(forRemoval ? "scan.dep.removal" : "scan.dep.normal");
out.println(Messages.get("scan.out.methodoverride", typeKind(cf), cf.getName(), overridden,
- mname, desc, dep));
+ mname, desc, dep(r)));
+ }
+
+ void errorException(Exception ex) {
+ errorOccurred = true;
+ err.println(Messages.get("scan.err.exception", ex.toString()));
+ if (verbose) {
+ ex.printStackTrace(err);
+ }
}
- // format should not have a newline
- void err(String format, Object... args) {
- error = true;
- err.print("error: ");
- err.printf(format, args);
- err.println();
+ void errorNoClass(String className) {
+ errorOccurred = true;
+ err.println(Messages.get("scan.err.noclass", className));
}
- void printException(Exception ex) {
- err.print(Messages.get("error.prefix"));
- err.print(" ");
- if (verbose) {
- ex.printStackTrace(err);
- } else {
- err.print(ex);
- }
+ void errorNoFile(String fileName) {
+ errorOccurred = true;
+ err.println(Messages.get("scan.err.nofile", fileName));
+ }
+
+ void errorNoMethod(String className, String methodName, String desc) {
+ errorOccurred = true;
+ err.println(Messages.get("scan.err.nomethod", className, methodName, desc));
}
/**
@@ -271,7 +273,7 @@
} else {
startClass = finder.find(startClassName);
if (startClass == null) {
- err("can't find class %s", startClassName);
+ errorNoClass(startClassName);
return startClassName;
}
}
@@ -295,7 +297,7 @@
String superName = curClass.getSuperclassName();
curClass = finder.find(superName);
if (curClass == null) {
- err("can't find class %s", superName);
+ errorNoClass(superName);
break;
}
addInterfaces(intfs, curClass);
@@ -310,7 +312,7 @@
String intf = intfs.removeFirst();
curClass = finder.find(intf);
if (curClass == null) {
- err("can't find interface %s", intf);
+ errorNoClass(intf);
break;
}
@@ -324,8 +326,7 @@
if (curClass == null) {
if (checkStartClass) {
- err("can't resolve methodref %s %s %s",
- startClassName, findName, findDesc);
+ errorNoMethod(startClassName, findName, findDesc);
return startClassName;
} else {
// TODO: refactor this
@@ -372,18 +373,18 @@
}
/**
- * Checks types referred to from the constant pool.
+ * Checks Class_info entries in the constant pool.
*
* @param cf the ClassFile of this class
* @param entries constant pool entries collected from this class
* @throws ConstantPoolException if a constant pool entry cannot be found
*/
- void checkTypes(ClassFile cf, CPEntries entries) throws ConstantPoolException {
+ void checkClasses(ClassFile cf, CPEntries entries) throws ConstantPoolException {
for (ConstantPool.CONSTANT_Class_info ci : entries.classes) {
- String typeName = ci.getName();
- DeprData dd = db.getTypeDeprecated(flatten(typeName));
+ String className = ci.getName();
+ DeprData dd = db.getTypeDeprecated(flatten(className));
if (dd != null) {
- printType("scan.out.usestype", cf, typeName, dd.isForRemoval());
+ printType("scan.out.usesclass", cf, className, dd.isForRemoval());
}
}
}
@@ -394,26 +395,19 @@
* @param cf the ClassFile of this class
* @param nti the NameAndType_info from a MethodRef or InterfaceMethodRef entry
* @param clname the class name
- * @param typeKey key for the type message
- * @param methKey key for the method message
+ * @param msgKey message key for localization
* @throws ConstantPoolException if a constant pool entry cannot be found
*/
void checkMethodRef(ClassFile cf,
+ String clname,
CONSTANT_NameAndType_info nti,
- String clname,
- String typeKey,
- String methKey) throws ConstantPoolException {
- DeprData dd = db.getTypeDeprecated(flatten(clname));
- if (dd != null) {
- printType(typeKey, cf, clname, dd.isForRemoval());
- }
-
+ String msgKey) throws ConstantPoolException {
String name = nti.getName();
String type = nti.getType();
clname = resolveMember(cf, flatten(clname), name, type, true, true);
- dd = db.getMethodDeprecated(clname, name, type);
+ DeprData dd = db.getMethodDeprecated(clname, name, type);
if (dd != null) {
- printMethod(methKey, cf, clname, name, type, dd.isForRemoval());
+ printMethod(msgKey, cf, clname, name, type, dd.isForRemoval());
}
}
@@ -425,26 +419,16 @@
*/
void checkFieldRef(ClassFile cf,
ConstantPool.CONSTANT_Fieldref_info fri) throws ConstantPoolException {
+ String clname = fri.getClassName();
CONSTANT_NameAndType_info nti = fri.getNameAndTypeInfo();
- String clname = fri.getClassName();
String name = nti.getName();
String type = nti.getType();
- DeprData dd = db.getTypeDeprecated(clname);
-
- if (dd != null) {
- printType("scan.out.usesfieldintype", cf, clname, dd.isForRemoval());
- }
clname = resolveMember(cf, flatten(clname), name, type, false, true);
- dd = db.getFieldDeprecated(clname, name);
+ DeprData dd = db.getFieldDeprecated(clname, name);
if (dd != null) {
printField("scan.out.usesfield", cf, clname, name, dd.isForRemoval());
}
-
- dd = db.getTypeDeprecated(flatten(type));
- if (dd != null) {
- printFieldType("scan.out.usesfieldoftype", cf, clname, name, type, dd.isForRemoval());
- }
}
/**
@@ -515,18 +499,18 @@
checkSuper(cf);
checkInterfaces(cf);
- checkTypes(cf, entries);
+ checkClasses(cf, entries);
for (ConstantPool.CONSTANT_Methodref_info mri : entries.methodRefs) {
+ String clname = mri.getClassName();
CONSTANT_NameAndType_info nti = mri.getNameAndTypeInfo();
- String clname = mri.getClassName();
- checkMethodRef(cf, nti, clname, "scan.out.usesmethodintype", "scan.out.usesmethod");
+ checkMethodRef(cf, clname, nti, "scan.out.usesmethod");
}
for (ConstantPool.CONSTANT_InterfaceMethodref_info imri : entries.intfMethodRefs) {
+ String clname = imri.getClassName();
CONSTANT_NameAndType_info nti = imri.getNameAndTypeInfo();
- String clname = imri.getClassName();
- checkMethodRef(cf, nti, clname, "scan.out.usesintfmethodintype", "scan.out.usesintfmethod");
+ checkMethodRef(cf, clname, nti, "scan.out.usesintfmethod");
}
for (ConstantPool.CONSTANT_Fieldref_info fri : entries.fieldRefs) {
@@ -545,6 +529,7 @@
*/
public boolean scanJar(String jarname) {
try (JarFile jf = new JarFile(jarname)) {
+ out.println(Messages.get("scan.head.jar", jarname));
finder.addJar(jarname);
Enumeration<JarEntry> entries = jf.entries();
while (entries.hasMoreElements()) {
@@ -557,10 +542,12 @@
}
}
return true;
+ } catch (NoSuchFileException nsfe) {
+ errorNoFile(jarname);
} catch (IOException | ConstantPoolException ex) {
- printException(ex);
- return false;
+ errorException(ex);
}
+ return false;
}
/**
@@ -580,12 +567,15 @@
.filter(path -> !path.toString().endsWith("package-info.class"))
.filter(path -> !path.toString().endsWith("module-info.class"))
.collect(Collectors.toList());
+
+ out.println(Messages.get("scan.head.dir", dirname));
+
for (Path p : classes) {
processClass(ClassFile.read(p));
}
return true;
} catch (IOException | ConstantPoolException ex) {
- printException(ex);
+ errorException(ex);
return false;
}
}
@@ -600,15 +590,35 @@
try {
ClassFile cf = finder.find(className);
if (cf == null) {
- err("can't find class %s", className);
+ errorNoClass(className);
return false;
} else {
processClass(cf);
return true;
}
} catch (ConstantPoolException ex) {
- printException(ex);
+ errorException(ex);
return false;
}
}
+
+ /**
+ * Scans the named class file for uses of deprecated APIs.
+ *
+ * @param fileName the class file to scan
+ * @return true on success, false on failure
+ */
+ public boolean processClassFile(String fileName) {
+ Path path = Paths.get(fileName);
+ try {
+ ClassFile cf = ClassFile.read(path);
+ processClass(cf);
+ return true;
+ } catch (NoSuchFileException nsfe) {
+ errorNoFile(fileName);
+ } catch (IOException | ConstantPoolException ex) {
+ errorException(ex);
+ }
+ return false;
+ }
}
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/DepsAnalyzer.java Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/DepsAnalyzer.java Wed Nov 09 10:04:43 2016 -0800
@@ -50,7 +50,7 @@
*
* Type of filters:
* source filter: -include <pattern>
- * target filter: -package, -regex, -requires
+ * target filter: -package, -regex, --require
*
* The initial archive set for analysis includes
* 1. archives specified in the command line arguments
@@ -146,7 +146,9 @@
// analyze the dependencies collected
analyzer.run(archives, finder.locationToArchive());
- writer.generateOutput(archives, analyzer);
+ if (writer != null) {
+ writer.generateOutput(archives, analyzer);
+ }
} finally {
finder.shutdown();
}
@@ -156,7 +158,7 @@
/**
* Returns the archives for reporting that has matching dependences.
*
- * If -requires is set, they should be excluded.
+ * If --require is set, they should be excluded.
*/
Set<Archive> archives() {
if (filter.requiresFilter().isEmpty()) {
@@ -165,7 +167,7 @@
.filter(Archive::hasDependences)
.collect(Collectors.toSet());
} else {
- // use the archives that have dependences and not specified in -requires
+ // use the archives that have dependences and not specified in --require
return archives.stream()
.filter(filter::include)
.filter(source -> !filter.requiresFilter().contains(source))
@@ -360,16 +362,17 @@
Archive source = dep.originArchive();
Archive target = dep.targetArchive();
String pn = dep.target();
- if ((verbose == CLASS || verbose == VERBOSE)) {
+ if (verbose == CLASS || verbose == VERBOSE) {
int i = dep.target().lastIndexOf('.');
pn = i > 0 ? dep.target().substring(0, i) : "";
}
final Info info;
+ Module targetModule = target.getModule();
if (source == target) {
info = Info.MODULE_PRIVATE;
- } else if (!target.getModule().isNamed()) {
+ } else if (!targetModule.isNamed()) {
info = Info.EXPORTED_API;
- } else if (target.getModule().isExported(pn)) {
+ } else if (targetModule.isExported(pn) && !targetModule.isJDKUnsupported()) {
info = Info.EXPORTED_API;
} else {
Module module = target.getModule();
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsConfiguration.java Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsConfiguration.java Wed Nov 09 10:04:43 2016 -0800
@@ -397,6 +397,11 @@
}
@Override
+ public Stream<String> list() {
+ return Stream.empty();
+ }
+
+ @Override
public void close() throws IOException {
}
};
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsFilter.java Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsFilter.java Wed Nov 09 10:04:43 2016 -0800
@@ -41,7 +41,7 @@
* 2. -filter:package to filter out same-package dependencies
* This filter is applied when jdeps parses the class files
* and filtered dependencies are not stored in the Analyzer.
- * 3. -requires specifies to match target dependence from the given module
+ * 3. --require specifies to match target dependence from the given module
* This gets expanded into package lists to be filtered.
* 4. -filter:archive to filter out same-archive dependencies
* This filter is applied later in the Analyzer as the
@@ -166,7 +166,7 @@
// accepts target that is JDK class but not exported
Module module = targetArchive.getModule();
return originArchive != targetArchive &&
- module.isJDK() && !module.isExported(target.getPackageName());
+ isJDKInternalPackage(module, target.getPackageName());
} else if (filterSameArchive) {
// accepts origin and target that from different archive
return originArchive != targetArchive;
@@ -174,6 +174,18 @@
return true;
}
+ /**
+ * Tests if the package is an internal package of the given module.
+ */
+ public boolean isJDKInternalPackage(Module module, String pn) {
+ if (module.isJDKUnsupported()) {
+ // its exported APIs are unsupported
+ return true;
+ }
+
+ return module.isJDK() && !module.isExported(pn);
+ }
+
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsTask.java Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsTask.java Wed Nov 09 10:04:43 2016 -0800
@@ -221,6 +221,12 @@
}
}
},
+ new Option(false, "--list-deps", "--list-reduced-deps") {
+ void process(JdepsTask task, String opt, String arg) {
+ task.options.showModulesAddExports = true;
+ task.options.reduced = opt.equals("--list-reduced-deps");
+ }
+ },
// ---- paths option ----
new Option(true, "-cp", "-classpath", "--class-path") {
@@ -517,13 +523,13 @@
.forEach(e -> System.out.format("split package: %s %s%n", e.getKey(),
e.getValue().toString()));
- // check if any module specified in -requires is missing
+ // check if any module specified in --require is missing
Stream.concat(options.addmods.stream(), options.requires.stream())
.filter(mn -> !config.isValidToken(mn))
.forEach(mn -> config.findModule(mn).orElseThrow(() ->
new UncheckedBadArgs(new BadArgs("err.module.not.found", mn))));
- // --gen-module-info
+ // --generate-module-info
if (options.genModuleInfo != null) {
return genModuleInfo(config);
}
@@ -533,6 +539,13 @@
return new ModuleAnalyzer(config, log, options.checkModuleDeps).run();
}
+ if (options.showModulesAddExports) {
+ return new ModuleExportsAnalyzer(config,
+ dependencyFilter(config),
+ options.reduced,
+ log).run();
+ }
+
if (options.dotOutputDir != null &&
(options.verbose == SUMMARY || options.verbose == MODULE) &&
!options.addmods.isEmpty() && inputArgs.isEmpty()) {
@@ -555,7 +568,7 @@
.appModulePath(options.modulePath)
.addmods(options.addmods);
- if (options.checkModuleDeps != null) {
+ if (options.checkModuleDeps != null || options.showModulesAddExports) {
// check all system modules in the image
builder.allModules();
}
@@ -597,10 +610,10 @@
// analyze the dependencies
DepsAnalyzer analyzer = new DepsAnalyzer(config,
- dependencyFilter(config),
- writer,
- options.verbose,
- options.apiOnly);
+ dependencyFilter(config),
+ writer,
+ options.verbose,
+ options.apiOnly);
boolean ok = analyzer.run(options.compileTimeView, options.depth);
@@ -727,7 +740,7 @@
* Returns a filter used during dependency analysis
*/
private JdepsFilter dependencyFilter(JdepsConfiguration config) {
- // Filter specified by -filter, -package, -regex, and -requires options
+ // Filter specified by -filter, -package, -regex, and --require options
JdepsFilter.Builder builder = new JdepsFilter.Builder();
// source filters
@@ -737,7 +750,7 @@
builder.filter(options.filterSamePackage, options.filterSameArchive);
builder.findJDKInternals(options.findJDKInternals);
- // -requires
+ // --require
if (!options.requires.isEmpty()) {
options.requires.stream()
.forEach(mn -> {
@@ -757,8 +770,8 @@
// check if system module is set
config.rootModules().stream()
- .map(Module::name)
- .forEach(builder::includeIfSystemModule);
+ .map(Module::name)
+ .forEach(builder::includeIfSystemModule);
return builder.build();
}
@@ -886,6 +899,8 @@
String rootModule;
Set<String> addmods = new HashSet<>();
Runtime.Version multiRelease;
+ boolean showModulesAddExports;
+ boolean reduced;
boolean hasFilter() {
return numFilters() > 0;
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsWriter.java Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsWriter.java Wed Nov 09 10:04:43 2016 -0800
@@ -50,7 +50,7 @@
final boolean showProfile;
final boolean showModule;
- private JdepsWriter(Analyzer.Type type, boolean showProfile, boolean showModule) {
+ JdepsWriter(Analyzer.Type type, boolean showProfile, boolean showModule) {
this.type = type;
this.showProfile = showProfile;
this.showModule = showModule;
@@ -318,8 +318,7 @@
}
// exported API
- boolean jdkunsupported = Module.JDK_UNSUPPORTED.equals(module.name());
- if (module.isExported(pn) && !jdkunsupported) {
+ if (module.isExported(pn) && !module.isJDKUnsupported()) {
return showProfileOrModule(module);
}
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Module.java Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Module.java Wed Nov 09 10:04:43 2016 -0800
@@ -126,12 +126,13 @@
* Tests if the package of the given name is exported.
*/
public boolean isExported(String pn) {
- if (JDK_UNSUPPORTED.equals(this.name())) {
- return false;
- }
return exports.containsKey(pn) ? exports.get(pn).isEmpty() : false;
}
+ public boolean isJDKUnsupported() {
+ return JDK_UNSUPPORTED.equals(this.name());
+ }
+
/**
* Converts this module to a strict module with the given dependences
*
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleAnalyzer.java Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleAnalyzer.java Wed Nov 09 10:04:43 2016 -0800
@@ -41,10 +41,8 @@
import java.nio.file.Path;
import java.util.Collections;
import java.util.Comparator;
-import java.util.Deque;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.LinkedList;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
@@ -179,50 +177,43 @@
return builder.build();
}
- ModuleDescriptor reduced() {
- Graph.Builder<Module> bd = new Graph.Builder<>();
+ private Graph<Module> buildReducedGraph() {
+ ModuleGraphBuilder rpBuilder = new ModuleGraphBuilder(configuration);
+ rpBuilder.addModule(root);
requiresPublic.stream()
- .forEach(m -> {
- bd.addNode(m);
- bd.addEdge(root, m);
- });
+ .forEach(m -> rpBuilder.addEdge(root, m));
// requires public graph
- Graph<Module> rbg = bd.build().reduce();
+ Graph<Module> rbg = rpBuilder.build().reduce();
+
+ ModuleGraphBuilder gb = new ModuleGraphBuilder(configuration);
+ gb.addModule(root);
+ requires.stream()
+ .forEach(m -> gb.addEdge(root, m));
// transitive reduction
- Graph<Module> newGraph = buildGraph(requires).reduce(rbg);
+ Graph<Module> newGraph = gb.buildGraph().reduce(rbg);
if (DEBUG) {
System.err.println("after transitive reduction: ");
newGraph.printGraph(log);
}
-
- return descriptor(requiresPublic, newGraph.adjacentNodes(root));
+ return newGraph;
}
+ /**
+ * Apply the transitive reduction on the module graph
+ * and returns the corresponding ModuleDescriptor
+ */
+ ModuleDescriptor reduced() {
+ Graph<Module> g = buildReducedGraph();
+ return descriptor(requiresPublic, g.adjacentNodes(root));
+ }
/**
* Apply transitive reduction on the resulting graph and reports
* recommended requires.
*/
private void analyzeDeps() {
- Graph.Builder<Module> builder = new Graph.Builder<>();
- requiresPublic.stream()
- .forEach(m -> {
- builder.addNode(m);
- builder.addEdge(root, m);
- });
-
- // requires public graph
- Graph<Module> rbg = buildGraph(requiresPublic).reduce();
-
- // transitive reduction
- Graph<Module> newGraph = buildGraph(requires).reduce(builder.build().reduce());
- if (DEBUG) {
- System.err.println("after transitive reduction: ");
- newGraph.printGraph(log);
- }
-
printModuleDescriptor(log, root);
ModuleDescriptor analyzedDescriptor = descriptor();
@@ -277,45 +268,6 @@
/**
- * Returns a graph of modules required by the specified module.
- *
- * Requires public edges of the dependences are added to the graph.
- */
- private Graph<Module> buildGraph(Set<Module> deps) {
- Graph.Builder<Module> builder = new Graph.Builder<>();
- builder.addNode(root);
- Set<Module> visited = new HashSet<>();
- visited.add(root);
- Deque<Module> deque = new LinkedList<>();
- deps.stream()
- .forEach(m -> {
- deque.add(m);
- builder.addEdge(root, m);
- });
-
- // read requires public from ModuleDescription
- Module source;
- while ((source = deque.poll()) != null) {
- if (visited.contains(source))
- continue;
-
- visited.add(source);
- builder.addNode(source);
- Module from = source;
- source.descriptor().requires().stream()
- .filter(req -> req.modifiers().contains(PUBLIC))
- .map(ModuleDescriptor.Requires::name)
- .map(configuration::findModule)
- .flatMap(Optional::stream)
- .forEach(m -> {
- deque.add(m);
- builder.addEdge(from, m);
- });
- }
- return builder.build();
- }
-
- /**
* Detects any qualified exports not used by the target module.
*/
private Map<String, Set<String>> unusedQualifiedExports() {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleExportsAnalyzer.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,176 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.jdeps;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.lang.module.ModuleDescriptor;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import static com.sun.tools.jdeps.Analyzer.NOT_FOUND;
+
+/**
+ * Analyze module dependences and any reference to JDK internal APIs.
+ * It can apply transition reduction on the resulting module graph.
+ *
+ * The result prints one line per module it depends on
+ * one line per JDK internal API package it references:
+ * $MODULE[/$PACKAGE]
+ *
+ */
+public class ModuleExportsAnalyzer extends DepsAnalyzer {
+ // source archive to its dependences and JDK internal APIs it references
+ private final Map<Archive, Map<Archive,Set<String>>> deps = new HashMap<>();
+ private final boolean reduced;
+ private final PrintWriter writer;
+ public ModuleExportsAnalyzer(JdepsConfiguration config,
+ JdepsFilter filter,
+ boolean reduced,
+ PrintWriter writer) {
+ super(config, filter, null,
+ Analyzer.Type.PACKAGE,
+ false /* all classes */);
+ this.reduced = reduced;
+ this.writer = writer;
+ }
+
+ @Override
+ public boolean run() throws IOException {
+ // analyze dependences
+ boolean rc = super.run();
+
+ // A visitor to record the module-level dependences as well as
+ // use of JDK internal APIs
+ Analyzer.Visitor visitor = new Analyzer.Visitor() {
+ @Override
+ public void visitDependence(String origin, Archive originArchive,
+ String target, Archive targetArchive)
+ {
+ Set<String> jdkInternals =
+ deps.computeIfAbsent(originArchive, _k -> new HashMap<>())
+ .computeIfAbsent(targetArchive, _k -> new HashSet<>());
+
+ Module module = targetArchive.getModule();
+ if (originArchive.getModule() != module &&
+ module.isJDK() && !module.isExported(target)) {
+ // use of JDK internal APIs
+ jdkInternals.add(target);
+ }
+ }
+ };
+
+ // visit the dependences
+ archives.stream()
+ .filter(analyzer::hasDependences)
+ .sorted(Comparator.comparing(Archive::getName))
+ .forEach(archive -> analyzer.visitDependences(archive, visitor));
+
+
+ // print the dependences on named modules
+ printDependences();
+
+ // print the dependences on unnamed module
+ deps.values().stream()
+ .flatMap(map -> map.keySet().stream())
+ .filter(archive -> !archive.getModule().isNamed())
+ .map(archive -> archive != NOT_FOUND
+ ? "unnamed module: " + archive.getPathName()
+ : archive.getPathName())
+ .distinct()
+ .sorted()
+ .forEach(archive -> writer.format(" %s%n", archive));
+
+ return rc;
+ }
+
+ private void printDependences() {
+ // find use of JDK internals
+ Map<Module, Set<String>> jdkinternals = new HashMap<>();
+ deps.keySet().stream()
+ .filter(source -> !source.getModule().isNamed())
+ .map(deps::get)
+ .flatMap(map -> map.entrySet().stream())
+ .filter(e -> e.getValue().size() > 0)
+ .forEach(e -> jdkinternals.computeIfAbsent(e.getKey().getModule(),
+ _k -> new HashSet<>())
+ .addAll(e.getValue()));
+
+
+ // build module graph
+ ModuleGraphBuilder builder = new ModuleGraphBuilder(configuration);
+ Module root = new RootModule("root");
+ builder.addModule(root);
+ // find named module dependences
+ deps.keySet().stream()
+ .filter(source -> !source.getModule().isNamed())
+ .map(deps::get)
+ .flatMap(map -> map.keySet().stream())
+ .filter(m -> m.getModule().isNamed())
+ .map(Archive::getModule)
+ .forEach(m -> builder.addEdge(root, m));
+
+ // module dependences
+ Set<Module> modules = builder.build().adjacentNodes(root);
+
+ // if reduced is set, apply transition reduction
+ Set<Module> reducedSet = reduced ? builder.reduced().adjacentNodes(root)
+ : modules;
+
+ modules.stream()
+ .sorted(Comparator.comparing(Module::name))
+ .forEach(m -> {
+ if (jdkinternals.containsKey(m)) {
+ jdkinternals.get(m).stream()
+ .sorted()
+ .forEach(pn -> writer.format(" %s/%s%n", m, pn));
+ } else if (reducedSet.contains(m)){
+ // if the transition reduction is applied, show the reduced graph
+ writer.format(" %s%n", m);
+ }
+ });
+ }
+
+
+ private class RootModule extends Module {
+ final ModuleDescriptor descriptor;
+ RootModule(String name) {
+ super(name);
+
+ ModuleDescriptor.Builder builder = new ModuleDescriptor.Builder(name);
+ this.descriptor = builder.build();
+ }
+
+ @Override
+ public ModuleDescriptor descriptor() {
+ return descriptor;
+ }
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleGraphBuilder.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,130 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.jdeps;
+
+import java.io.PrintWriter;
+import java.lang.module.ModuleDescriptor;
+import java.util.Deque;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+import java.util.stream.Stream;
+
+import static java.lang.module.ModuleDescriptor.Requires.Modifier.*;
+import static com.sun.tools.jdeps.Module.*;
+
+/**
+ * A builder to create a Graph<Module>
+ */
+public class ModuleGraphBuilder extends Graph.Builder<Module> {
+ final JdepsConfiguration config;
+
+ ModuleGraphBuilder(JdepsConfiguration config) {
+ this.config = config;
+ }
+
+ /**
+ * Adds a module to the graph.
+ */
+ ModuleGraphBuilder addModule(Module module) {
+ addNode(module);
+ return this;
+ }
+
+ /**
+ * Apply transitive reduction on the resulting graph
+ */
+ public Graph<Module> reduced() {
+ Graph<Module> graph = build();
+ // transitive reduction
+ Graph<Module> newGraph = buildGraph(graph.edges()).reduce();
+
+ if (DEBUG) {
+ PrintWriter log = new PrintWriter(System.err);
+ System.err.println("before transitive reduction: ");
+ graph.printGraph(log);
+ System.err.println("after transitive reduction: ");
+ newGraph.printGraph(log);
+ }
+
+ return newGraph;
+ }
+
+ public Graph<Module> buildGraph() {
+ Graph<Module> graph = build();
+ return buildGraph(graph.edges());
+ }
+
+ /**
+ * Build a graph of module from the given dependences.
+ *
+ * It transitively includes all implied read edges.
+ */
+ private Graph<Module> buildGraph(Map<Module, Set<Module>> edges) {
+ Graph.Builder<Module> builder = new Graph.Builder<>();
+ Set<Module> visited = new HashSet<>();
+ Deque<Module> deque = new LinkedList<>();
+ edges.entrySet().stream().forEach(e -> {
+ Module m = e.getKey();
+ deque.add(m);
+ e.getValue().stream().forEach(v -> {
+ deque.add(v);
+ builder.addEdge(m, v);
+ });
+ });
+
+ // read requires public from ModuleDescriptor
+ Module source;
+ while ((source = deque.poll()) != null) {
+ if (visited.contains(source))
+ continue;
+
+ visited.add(source);
+ builder.addNode(source);
+ Module from = source;
+ requiresPublic(from).forEach(m -> {
+ deque.add(m);
+ builder.addEdge(from, m);
+ });
+ }
+ return builder.build();
+ }
+
+ /*
+ * Returns a stream of modules upon which the given module `requires public`
+ */
+ public Stream<Module> requiresPublic(Module m) {
+ // find requires public
+ return m.descriptor()
+ .requires().stream()
+ .filter(req -> req.modifiers().contains(PUBLIC))
+ .map(ModuleDescriptor.Requires::name)
+ .map(config::findModule)
+ .flatMap(Optional::stream);
+ }
+}
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/resources/jdeps.properties Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/resources/jdeps.properties Wed Nov 09 10:04:43 2016 -0800
@@ -149,6 +149,15 @@
\ used with -p, -e and -s options.\n\
\ WARNING: JDK internal APIs are inaccessible.
+main.opt.list-deps=\
+\ --list-deps Lists the dependences and use of JDK internal\n\
+\ APIs.\n\
+\ --list-reduced-deps Same as --list-deps with not listing\n\
+\ the implied reads edges from the module graph\n\
+\ If module M1 depends on M2 and M3,\n\
+\ M2 requires public on M3, then M1 reading M3 is\n\
+\ implied and removed from the module graph.
+
main.opt.depth=\
\ -depth=<depth> Specify the depth of the transitive\n\
\ dependency analysis
--- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ConsoleIOContext.java Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ConsoleIOContext.java Wed Nov 09 10:04:43 2016 -0800
@@ -25,36 +25,39 @@
package jdk.internal.jshell.tool;
+import jdk.jshell.SourceCodeAnalysis.Documentation;
import jdk.jshell.SourceCodeAnalysis.QualifiedNames;
import jdk.jshell.SourceCodeAnalysis.Suggestion;
-import java.awt.event.ActionListener;
import java.io.IOException;
import java.io.InputStream;
import java.io.InterruptedIOException;
import java.io.PrintStream;
import java.io.UncheckedIOException;
-import java.lang.reflect.Method;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
-import java.util.function.Supplier;
+import java.util.function.Function;
import java.util.prefs.BackingStoreException;
import java.util.stream.Collectors;
import java.util.stream.Stream;
+import jdk.internal.shellsupport.doc.JavadocFormatter;
import jdk.internal.jline.NoInterruptUnixTerminal;
import jdk.internal.jline.Terminal;
import jdk.internal.jline.TerminalFactory;
import jdk.internal.jline.TerminalSupport;
import jdk.internal.jline.WindowsTerminal;
import jdk.internal.jline.console.ConsoleReader;
+import jdk.internal.jline.console.CursorBuffer;
import jdk.internal.jline.console.KeyMap;
import jdk.internal.jline.console.UserInterruptException;
import jdk.internal.jline.console.completer.Completer;
@@ -167,10 +170,10 @@
return anchor[0];
}
});
- bind(DOCUMENTATION_SHORTCUT, (ActionListener) evt -> documentation(repl));
+ bind(DOCUMENTATION_SHORTCUT, (Runnable) () -> documentation(repl));
for (FixComputer computer : FIX_COMPUTERS) {
for (String shortcuts : SHORTCUT_FIXES) {
- bind(shortcuts + computer.shortcut, (ActionListener) evt -> fixes(computer));
+ bind(shortcuts + computer.shortcut, (Runnable) () -> fixes(computer));
}
}
try {
@@ -259,22 +262,118 @@
"\u001BO3P" //Alt-F1 (Linux)
};
+ private String lastDocumentationBuffer;
+ private int lastDocumentationCursor = (-1);
+
private void documentation(JShellTool repl) {
String buffer = in.getCursorBuffer().buffer.toString();
int cursor = in.getCursorBuffer().cursor;
- String doc;
+ boolean firstInvocation = !buffer.equals(lastDocumentationBuffer) || cursor != lastDocumentationCursor;
+ lastDocumentationBuffer = buffer;
+ lastDocumentationCursor = cursor;
+ List<String> doc;
+ String seeMore;
+ Terminal term = in.getTerminal();
if (prefix.isEmpty() && buffer.trim().startsWith("/")) {
- doc = repl.commandDocumentation(buffer, cursor);
+ doc = Arrays.asList(repl.commandDocumentation(buffer, cursor, firstInvocation));
+ seeMore = "jshell.console.see.help";
} else {
- doc = repl.analysis.documentation(prefix + buffer, cursor + prefix.length());
+ JavadocFormatter formatter = new JavadocFormatter(term.getWidth(),
+ term.isAnsiSupported());
+ Function<Documentation, String> convertor;
+ if (firstInvocation) {
+ convertor = d -> d.signature();
+ } else {
+ convertor = d -> formatter.formatJavadoc(d.signature(),
+ d.javadoc() != null ? d.javadoc()
+ : repl.messageFormat("jshell.console.no.javadoc"));
+ }
+ doc = repl.analysis.documentation(prefix + buffer, cursor + prefix.length(), !firstInvocation)
+ .stream()
+ .map(convertor)
+ .collect(Collectors.toList());
+ seeMore = "jshell.console.see.javadoc";
}
try {
- if (doc != null) {
- in.println();
- in.println(doc);
- in.redrawLine();
- in.flush();
+ if (doc != null && !doc.isEmpty()) {
+ if (firstInvocation) {
+ in.println();
+ in.println(doc.stream().collect(Collectors.joining("\n")));
+ in.println(repl.messageFormat(seeMore));
+ in.redrawLine();
+ in.flush();
+ } else {
+ in.println();
+
+ int height = term.getHeight();
+ String lastNote = "";
+
+ PRINT_DOC: for (Iterator<String> docIt = doc.iterator(); docIt.hasNext(); ) {
+ String currentDoc = docIt.next();
+ String[] lines = currentDoc.split("\n");
+ int firstLine = 0;
+
+ PRINT_PAGE: while (true) {
+ int toPrint = height - 1;
+
+ while (toPrint > 0 && firstLine < lines.length) {
+ in.println(lines[firstLine++]);
+ toPrint--;
+ }
+
+ if (firstLine >= lines.length) {
+ break;
+ }
+
+ lastNote = repl.getResourceString("jshell.console.see.next.page");
+ in.print(lastNote + ConsoleReader.RESET_LINE);
+ in.flush();
+
+ while (true) {
+ int r = in.readCharacter();
+
+ switch (r) {
+ case ' ': continue PRINT_PAGE;
+ case 'q':
+ case 3:
+ break PRINT_DOC;
+ default:
+ in.beep();
+ break;
+ }
+ }
+ }
+
+ if (docIt.hasNext()) {
+ lastNote = repl.getResourceString("jshell.console.see.next.javadoc");
+ in.print(lastNote + ConsoleReader.RESET_LINE);
+ in.flush();
+
+ while (true) {
+ int r = in.readCharacter();
+
+ switch (r) {
+ case ' ': continue PRINT_DOC;
+ case 'q':
+ case 3:
+ break PRINT_DOC;
+ default:
+ in.beep();
+ break;
+ }
+ }
+ }
+ }
+ //clear the "press space" line:
+ in.getCursorBuffer().buffer.replace(0, buffer.length(), lastNote);
+ in.getCursorBuffer().cursor = 0;
+ in.killLine();
+ in.getCursorBuffer().buffer.append(buffer);
+ in.getCursorBuffer().cursor = cursor;
+ in.redrawLine();
+ in.flush();
+ }
} else {
in.beep();
}
--- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/EditPad.java Wed Nov 09 15:20:30 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,129 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.internal.jshell.tool;
-
-import java.awt.BorderLayout;
-import java.awt.FlowLayout;
-import java.awt.event.KeyEvent;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-import java.util.concurrent.CountDownLatch;
-import java.util.function.Consumer;
-import javax.swing.JButton;
-import javax.swing.JFrame;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.JTextArea;
-import javax.swing.SwingUtilities;
-
-/**
- * A minimal Swing editor as a fallback when the user does not specify an
- * external editor.
- */
-@SuppressWarnings("serial") // serialVersionUID intentionally omitted
-public class EditPad extends JFrame implements Runnable {
- private final Consumer<String> errorHandler; // For possible future error handling
- private final String initialText;
- private final CountDownLatch closeLock;
- private final Consumer<String> saveHandler;
-
- EditPad(Consumer<String> errorHandler, String initialText,
- CountDownLatch closeLock, Consumer<String> saveHandler) {
- super("JShell Edit Pad");
- this.errorHandler = errorHandler;
- this.initialText = initialText;
- this.closeLock = closeLock;
- this.saveHandler = saveHandler;
- }
-
- @Override
- public void run() {
- addWindowListener(new WindowAdapter() {
- @Override
- public void windowClosing(WindowEvent e) {
- EditPad.this.dispose();
- closeLock.countDown();
- }
- });
- setLocationRelativeTo(null);
- setLayout(new BorderLayout());
- JTextArea textArea = new JTextArea(initialText);
- add(new JScrollPane(textArea), BorderLayout.CENTER);
- add(buttons(textArea), BorderLayout.SOUTH);
-
- setSize(800, 600);
- setVisible(true);
- }
-
- private JPanel buttons(JTextArea textArea) {
- FlowLayout flow = new FlowLayout();
- flow.setHgap(35);
- JPanel buttons = new JPanel(flow);
- JButton cancel = new JButton("Cancel");
- cancel.setMnemonic(KeyEvent.VK_C);
- JButton accept = new JButton("Accept");
- accept.setMnemonic(KeyEvent.VK_A);
- JButton exit = new JButton("Exit");
- exit.setMnemonic(KeyEvent.VK_X);
- buttons.add(cancel);
- buttons.add(accept);
- buttons.add(exit);
-
- cancel.addActionListener(e -> {
- close();
- });
- accept.addActionListener(e -> {
- saveHandler.accept(textArea.getText());
- });
- exit.addActionListener(e -> {
- saveHandler.accept(textArea.getText());
- close();
- });
-
- return buttons;
- }
-
- private void close() {
- setVisible(false);
- dispose();
- closeLock.countDown();
- }
-
- public static void edit(Consumer<String> errorHandler, String initialText,
- Consumer<String> saveHandler) {
- CountDownLatch closeLock = new CountDownLatch(1);
- SwingUtilities.invokeLater(
- new EditPad(errorHandler, initialText, closeLock, saveHandler));
- do {
- try {
- closeLock.await();
- break;
- } catch (InterruptedException ex) {
- // ignore and loop
- }
- } while (true);
- }
-}
--- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ExternalEditor.java Wed Nov 09 15:20:30 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,170 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.internal.jshell.tool;
-
-import java.io.IOException;
-import java.nio.charset.Charset;
-import java.nio.file.ClosedWatchServiceException;
-import java.nio.file.FileSystems;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.WatchKey;
-import java.nio.file.WatchService;
-import java.util.Arrays;
-import java.util.Scanner;
-import java.util.function.Consumer;
-import java.util.stream.Collectors;
-import static java.nio.file.StandardWatchEventKinds.ENTRY_CREATE;
-import static java.nio.file.StandardWatchEventKinds.ENTRY_DELETE;
-import static java.nio.file.StandardWatchEventKinds.ENTRY_MODIFY;
-
-/**
- * Wrapper for controlling an external editor.
- */
-public class ExternalEditor {
- private final Consumer<String> errorHandler;
- private final Consumer<String> saveHandler;
- private final Consumer<String> printHandler;
- private final IOContext input;
- private final boolean wait;
-
- private WatchService watcher;
- private Thread watchedThread;
- private Path dir;
- private Path tmpfile;
-
- ExternalEditor(Consumer<String> errorHandler, Consumer<String> saveHandler,
- IOContext input, boolean wait, Consumer<String> printHandler) {
- this.errorHandler = errorHandler;
- this.saveHandler = saveHandler;
- this.printHandler = printHandler;
- this.input = input;
- this.wait = wait;
- }
-
- private void edit(String[] cmd, String initialText) {
- try {
- setupWatch(initialText);
- launch(cmd);
- } catch (IOException ex) {
- errorHandler.accept(ex.getMessage());
- }
- }
-
- /**
- * Creates a WatchService and registers the given directory
- */
- private void setupWatch(String initialText) throws IOException {
- this.watcher = FileSystems.getDefault().newWatchService();
- this.dir = Files.createTempDirectory("jshelltemp");
- this.tmpfile = Files.createTempFile(dir, null, ".java");
- Files.write(tmpfile, initialText.getBytes(Charset.forName("UTF-8")));
- dir.register(watcher,
- ENTRY_CREATE,
- ENTRY_DELETE,
- ENTRY_MODIFY);
- watchedThread = new Thread(() -> {
- for (;;) {
- WatchKey key;
- try {
- key = watcher.take();
- } catch (ClosedWatchServiceException ex) {
- // The watch service has been closed, we are done
- break;
- } catch (InterruptedException ex) {
- // tolerate an interrupt
- continue;
- }
-
- if (!key.pollEvents().isEmpty()) {
- // Changes have occurred in temp edit directory,
- // transfer the new sources to JShell (unless the editor is
- // running directly in JShell's window -- don't make a mess)
- if (!input.terminalEditorRunning()) {
- saveFile();
- }
- }
-
- boolean valid = key.reset();
- if (!valid) {
- // The watch service has been closed, we are done
- break;
- }
- }
- });
- watchedThread.start();
- }
-
- private void launch(String[] cmd) throws IOException {
- String[] params = Arrays.copyOf(cmd, cmd.length + 1);
- params[cmd.length] = tmpfile.toString();
- ProcessBuilder pb = new ProcessBuilder(params);
- pb = pb.inheritIO();
-
- try {
- input.suspend();
- Process process = pb.start();
- // wait to exit edit mode in one of these ways...
- if (wait) {
- // -wait option -- ignore process exit, wait for carriage-return
- Scanner scanner = new Scanner(System.in);
- printHandler.accept("jshell.msg.press.return.to.leave.edit.mode");
- scanner.nextLine();
- } else {
- // wait for process to exit
- process.waitFor();
- }
- } catch (IOException ex) {
- errorHandler.accept("process IO failure: " + ex.getMessage());
- } catch (InterruptedException ex) {
- errorHandler.accept("process interrupt: " + ex.getMessage());
- } finally {
- try {
- watcher.close();
- watchedThread.join(); //so that saveFile() is finished.
- saveFile();
- } catch (InterruptedException ex) {
- errorHandler.accept("process interrupt: " + ex.getMessage());
- } finally {
- input.resume();
- }
- }
- }
-
- private void saveFile() {
- try {
- saveHandler.accept(Files.lines(tmpfile).collect(Collectors.joining("\n", "", "\n")));
- } catch (IOException ex) {
- errorHandler.accept("Failure in read edit file: " + ex.getMessage());
- }
- }
-
- static void edit(String[] cmd, Consumer<String> errorHandler, String initialText,
- Consumer<String> saveHandler, IOContext input, boolean wait, Consumer<String> printHandler) {
- ExternalEditor ed = new ExternalEditor(errorHandler, saveHandler, input, wait, printHandler);
- ed.edit(cmd, initialText);
- }
-}
--- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/Feedback.java Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/Feedback.java Wed Nov 09 10:04:43 2016 -0800
@@ -116,6 +116,10 @@
name, type, value, unresolved, errorLines);
}
+ public String truncateVarValue(String value) {
+ return mode.truncateVarValue(value);
+ }
+
public String getPrompt(String nextId) {
return mode.getPrompt(nextId);
}
@@ -416,6 +420,45 @@
return sb.toString();
}
+ String truncateVarValue(String value) {
+ return truncateValue(value,
+ bits(FormatCase.VARVALUE, FormatAction.ADDED,
+ FormatWhen.PRIMARY, FormatResolve.OK,
+ FormatUnresolved.UNRESOLVED0, FormatErrors.ERROR0));
+ }
+
+ String truncateValue(String value, long bits) {
+ if (value==null) {
+ return "";
+ } else {
+ // Retrieve the truncation length
+ String truncField = format(TRUNCATION_FIELD, bits);
+ if (truncField.isEmpty()) {
+ // No truncation set, use whole value
+ return value;
+ } else {
+ // Convert truncation length to int
+ // this is safe since it has been tested before it is set
+ int trunc = Integer.parseUnsignedInt(truncField);
+ int len = value.length();
+ if (len > trunc) {
+ if (trunc <= 13) {
+ // Very short truncations have no room for "..."
+ return value.substring(0, trunc);
+ } else {
+ // Normal truncation, make total length equal truncation length
+ int endLen = trunc / 3;
+ int startLen = trunc - 5 - endLen;
+ return value.substring(0, startLen) + " ... " + value.substring(len -endLen);
+ }
+ } else {
+ // Within truncation length, use whole value
+ return value;
+ }
+ }
+ }
+ }
+
// Compute the display output given full context and values
String format(FormatCase fc, FormatAction fa, FormatWhen fw,
FormatResolve fr, FormatUnresolved fu, FormatErrors fe,
@@ -425,33 +468,7 @@
String fname = name==null? "" : name;
String ftype = type==null? "" : type;
// Compute the representation of value
- String fvalue;
- if (value==null) {
- fvalue = "";
- } else {
- // Retrieve the truncation length
- String truncField = format(TRUNCATION_FIELD, bits);
- if (truncField.isEmpty()) {
- // No truncation set, use whole value
- fvalue = value;
- } else {
- // Convert truncation length to int
- // this is safe since it has been tested before it is set
- int trunc = Integer.parseUnsignedInt(truncField);
- if (value.length() > trunc) {
- if (trunc <= 5) {
- // Very short truncations have no room for "..."
- fvalue = value.substring(0, trunc);
- } else {
- // Normal truncation, make total length equal truncation length
- fvalue = value.substring(0, trunc - 4) + " ...";
- }
- } else {
- // Within truncation length, use whole value
- fvalue = value;
- }
- }
- }
+ String fvalue = truncateValue(value, bits);
String funresolved = unresolved==null? "" : unresolved;
String errors = errorLines.stream()
.map(el -> String.format(
--- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java Wed Nov 09 10:04:43 2016 -0800
@@ -89,6 +89,7 @@
import java.util.MissingResourceException;
import java.util.Optional;
import java.util.ResourceBundle;
+import java.util.ServiceLoader;
import java.util.Spliterators;
import java.util.function.Function;
import java.util.function.Supplier;
@@ -99,6 +100,8 @@
import jdk.internal.jshell.tool.Feedback.FormatResolve;
import jdk.internal.jshell.tool.Feedback.FormatUnresolved;
import jdk.internal.jshell.tool.Feedback.FormatWhen;
+import jdk.internal.editor.spi.BuildInEditorProvider;
+import jdk.internal.editor.external.ExternalEditor;
import static java.util.Arrays.asList;
import static java.util.Arrays.stream;
import static java.util.stream.Collectors.joining;
@@ -323,7 +326,7 @@
}
/**
- * Print using resource bundle look-up and adding prefix and postfix
+ * Resource bundle look-up
*
* @param key the resource key
*/
@@ -523,7 +526,7 @@
runFile(loadFile, "jshell");
}
- if (regenerateOnDeath) {
+ if (regenerateOnDeath && feedback.shouldDisplayCommandFluff()) {
hardmsg("jshell.msg.welcome", version());
}
@@ -565,6 +568,8 @@
private List<String> processCommandArgs(String[] args) {
OptionParser parser = new OptionParser();
OptionSpec<String> cp = parser.accepts("class-path").withRequiredArg();
+ OptionSpec<String> mpath = parser.accepts("module-path").withRequiredArg();
+ OptionSpec<String> amods = parser.accepts("add-modules").withRequiredArg();
OptionSpec<String> st = parser.accepts("startup").withRequiredArg();
parser.acceptsAll(asList("n", "no-startup"));
OptionSpec<String> fb = parser.accepts("feedback").withRequiredArg();
@@ -658,6 +663,18 @@
if (options.has(c)) {
compilerOptions.addAll(options.valuesOf(c));
}
+ if (options.has(mpath)) {
+ compilerOptions.add("--module-path");
+ compilerOptions.addAll(options.valuesOf(mpath));
+ remoteVMOptions.add("--module-path");
+ remoteVMOptions.addAll(options.valuesOf(mpath));
+ }
+ if (options.has(amods)) {
+ compilerOptions.add("--add-modules");
+ compilerOptions.addAll(options.valuesOf(amods));
+ remoteVMOptions.add("--add-modules");
+ remoteVMOptions.addAll(options.valuesOf(amods));
+ }
if (options.has(addExports)) {
List<String> exports = options.valuesOf(addExports).stream()
@@ -1294,7 +1311,7 @@
return commandCompletions.completionSuggestions(code, cursor, anchor);
}
- public String commandDocumentation(String code, int cursor) {
+ public String commandDocumentation(String code, int cursor, boolean shortDescription) {
code = code.substring(0, cursor);
int space = code.indexOf(' ');
@@ -1302,7 +1319,7 @@
String cmd = code.substring(0, space);
Command command = commands.get(cmd);
if (command != null) {
- return getResourceString(command.helpKey + ".summary");
+ return getResourceString(command.helpKey + (shortDescription ? ".summary" : ""));
}
}
@@ -1964,20 +1981,59 @@
Consumer<String> saveHandler = new SaveHandler(src, srcSet);
Consumer<String> errorHandler = s -> hard("Edit Error: %s", s);
if (editor == BUILT_IN_EDITOR) {
- try {
- EditPad.edit(errorHandler, src, saveHandler);
- } catch (RuntimeException ex) {
- errormsg("jshell.err.cant.launch.editor", ex);
- fluffmsg("jshell.msg.try.set.editor");
- return false;
+ return builtInEdit(src, saveHandler, errorHandler);
+ } else {
+ // Changes have occurred in temp edit directory,
+ // transfer the new sources to JShell (unless the editor is
+ // running directly in JShell's window -- don't make a mess)
+ String[] buffer = new String[1];
+ Consumer<String> extSaveHandler = s -> {
+ if (input.terminalEditorRunning()) {
+ buffer[0] = s;
+ } else {
+ saveHandler.accept(s);
+ }
+ };
+ ExternalEditor.edit(editor.cmd, src,
+ errorHandler, extSaveHandler,
+ () -> input.suspend(),
+ () -> input.resume(),
+ editor.wait,
+ () -> hardrb("jshell.msg.press.return.to.leave.edit.mode"));
+ if (buffer[0] != null) {
+ saveHandler.accept(buffer[0]);
}
- } else {
- ExternalEditor.edit(editor.cmd, errorHandler, src, saveHandler, input,
- editor.wait, this::hardrb);
}
return true;
}
//where
+ // start the built-in editor
+ private boolean builtInEdit(String initialText,
+ Consumer<String> saveHandler, Consumer<String> errorHandler) {
+ try {
+ ServiceLoader<BuildInEditorProvider> sl
+ = ServiceLoader.load(BuildInEditorProvider.class);
+ // Find the highest ranking provider
+ BuildInEditorProvider provider = null;
+ for (BuildInEditorProvider p : sl) {
+ if (provider == null || p.rank() > provider.rank()) {
+ provider = p;
+ }
+ }
+ if (provider != null) {
+ provider.edit(getResourceString("jshell.label.editpad"),
+ initialText, saveHandler, errorHandler);
+ return true;
+ } else {
+ errormsg("jshell.err.no.builtin.editor");
+ }
+ } catch (RuntimeException ex) {
+ errormsg("jshell.err.cant.launch.editor", ex);
+ }
+ fluffmsg("jshell.msg.try.set.editor");
+ return false;
+ }
+ //where
// receives editor requests to save
private class SaveHandler implements Consumer<String> {
@@ -2184,7 +2240,7 @@
stream.forEachOrdered(vk ->
{
String val = state.status(vk) == Status.VALID
- ? state.varValue(vk)
+ ? feedback.truncateVarValue(state.varValue(vk))
: getResourceString("jshell.msg.vars.not.active");
hard(" %s %s = %s", vk.typeName(), vk.name(), val);
});
--- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/resources/l10n.properties Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/resources/l10n.properties Wed Nov 09 10:04:43 2016 -0800
@@ -54,10 +54,12 @@
jshell.err.command.ambiguous = Command: ''{0}'' is ambiguous: {1}
jshell.msg.set.editor.set = Editor set to: {0}
jshell.msg.set.editor.retain = Editor setting retained: {0}
-jshell.err.cant.launch.editor = Cannot launch editor -- unexpected exception: {0}
-jshell.msg.try.set.editor = Try /set editor to use external editor.
+jshell.err.no.builtin.editor = Built-in editor not available.
+jshell.err.cant.launch.editor = Cannot launch built-in editor -- unexpected exception: {0}
+jshell.msg.try.set.editor = See ''/help /set editor'' to use external editor.
jshell.msg.press.return.to.leave.edit.mode = Press return to leave edit mode.
jshell.err.wait.applies.to.external.editor = -wait applies to external editors
+jshell.label.editpad = JShell Edit Pad
jshell.err.setting.to.retain.must.be.specified = The setting to retain must be specified -- {0}
jshell.msg.set.show.mode.settings = \nTo show mode settings use ''/set prompt'', ''/set truncation'', ...\n\
@@ -145,6 +147,11 @@
jshell.err.retained.mode.failure = Failure in retained modes (modes cleared) -- {0} {1}
jshell.console.see.more = <press tab to see more>
+jshell.console.see.javadoc = <press shift-tab again to see javadoc>
+jshell.console.see.help = <press shift-tab again to see detailed help>
+jshell.console.see.next.page = -- Press space for next page, Q to quit. --
+jshell.console.see.next.javadoc = -- Press space for next javadoc, Q to quit. --
+jshell.console.no.javadoc = <no javadoc found>
jshell.console.do.nothing = Do nothing
jshell.console.choice = Choice: \
@@ -158,6 +165,10 @@
Usage: jshell <options> <load files>\n\
where possible options include:\n\
\ --class-path <path> Specify where to find user class files\n\
+\ --module-path <path> Specify where to find application modules\n\
+\ --add-modules <module>(,<module>)*\n\
+\ Specify modules to resolve, or all modules on the\n\
+\ module path if <module> is ALL-MODULE-PATHs\n\
\ --startup <file> One run replacement for the start-up definitions\n\
\ --no-startup Do not run the start-up definitions\n\
\ --feedback <mode> Specify the initial feedback mode. The mode may be\n\
@@ -316,8 +327,8 @@
help.reload.summary = reset and replay relevant history -- current or previous (-restore)
help.reload.args = [-restore] [-quiet]
help.reload =\
-Reset the jshell tool code and execution state then replay each\n\
-jshell valid command and valid snippet in the order they were entered.\n\
+Reset the jshell tool code and execution state then replay each valid snippet\n\
+and any /drop or /classpath commands in the order they were entered.\n\
\n\
/reload\n\t\
Reset and replay the valid history since jshell was entered, or\n\t\
@@ -327,7 +338,7 @@
Reset and replay the valid history between the previous and most\n\t\
recent time that jshell was entered, or a /reset, or /reload\n\t\
command was executed. This can thus be used to restore a previous\n\t\
- jshell tool sesson.\n\n\
+ jshell tool session.\n\n\
/reload [-restore] -quiet\n\t\
With the '-quiet' argument the replay is not shown. Errors will display.
@@ -790,7 +801,7 @@
/set format verbose unrerr '{unresolved} is declared and these errors are corrected: {errors}' unresolved1-error2 \n\
/set format verbose unrerr '{unresolved} are declared and these errors are corrected: {errors}' unresolved2-error2 \n\
\n\
-/set format verbose resolve '{until}{unrerr}' added,modified,replaced,used \n\
+/set format verbose resolve '{until}{unrerr}' defined,notdefined-added,modified,replaced,used \n\
\n\
/set format verbose typeKind 'class' class \n\
/set format verbose typeKind 'interface' interface \n\
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/Eval.java Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/Eval.java Wed Nov 09 10:04:43 2016 -0800
@@ -855,6 +855,8 @@
case PUBLIC:
case PROTECTED:
case PRIVATE:
+ // quietly ignore, user cannot see effects one way or the other
+ break;
case STATIC:
case FINAL:
list.add(mod);
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/JShell.java Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/JShell.java Wed Nov 09 10:04:43 2016 -0800
@@ -47,7 +47,7 @@
import java.util.stream.Stream;
import jdk.internal.jshell.debug.InternalDebugControl;
import jdk.jshell.Snippet.Status;
-import jdk.jshell.execution.JDIDefaultExecutionControl;
+import jdk.jshell.execution.JdiDefaultExecutionControl;
import jdk.jshell.spi.ExecutionControl.EngineTerminationException;
import jdk.jshell.spi.ExecutionControl.ExecutionControlException;
import jdk.jshell.spi.ExecutionEnv;
@@ -117,10 +117,9 @@
this.extraRemoteVMOptions = b.extraRemoteVMOptions;
this.extraCompilerOptions = b.extraCompilerOptions;
this.executionControlGenerator = b.executionControlGenerator==null
- ? failOverExecutionControlGenerator(
- JDIDefaultExecutionControl.launch(),
- JDIDefaultExecutionControl.listen("localhost"),
- JDIDefaultExecutionControl.listen(null))
+ ? failOverExecutionControlGenerator(JdiDefaultExecutionControl.launch(),
+ JdiDefaultExecutionControl.listen("localhost"),
+ JdiDefaultExecutionControl.listen(null))
: b.executionControlGenerator;
this.maps = new SnippetMaps(this);
@@ -506,6 +505,9 @@
if (!closed) {
closeDown();
executionControl().close();
+ if (sourceCodeAnalysis != null) {
+ sourceCodeAnalysis.close();
+ }
}
}
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/MaskCommentsAndModifiers.java Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/MaskCommentsAndModifiers.java Wed Nov 09 10:04:43 2016 -0800
@@ -36,10 +36,14 @@
*/
class MaskCommentsAndModifiers {
- private final static Set<String> IGNORED_MODIFERS =
+ private final static Set<String> IGNORED_MODIFIERS =
Stream.of( "public", "protected", "private", "static", "final" )
.collect( Collectors.toSet() );
+ private final static Set<String> OTHER_MODIFIERS =
+ Stream.of( "abstract", "strictfp", "transient", "volatile", "synchronized", "native", "default" )
+ .collect( Collectors.toSet() );
+
// Builder to accumulate non-masked characters
private final StringBuilder sbCleared = new StringBuilder();
@@ -52,24 +56,28 @@
// Entire input string length
private final int length;
- // Should leading modifiers be masked away
- private final boolean maskModifiers;
-
- // The next character
+ // The next character position
private int next = 0;
- // We have past any point where a top-level modifier could be
- private boolean inside = false;
+ // The current character
+ private int c;
+
+ // Do we mask-off ignored modifiers? Set by parameter and turned off after
+ // initial modifier section
+ private boolean maskModifiers;
// Does the string end with an unclosed '/*' style comment?
private boolean openComment = false;
- @SuppressWarnings("empty-statement")
MaskCommentsAndModifiers(String s, boolean maskModifiers) {
this.str = s;
this.length = s.length();
this.maskModifiers = maskModifiers;
- do { } while (next());
+ read();
+ while (c >= 0) {
+ next();
+ read();
+ }
}
String cleared() {
@@ -90,24 +98,33 @@
* Read the next character
*/
private int read() {
- if (next >= length) {
- return -1;
- }
- return str.charAt(next++);
+ return c = (next >= length)
+ ? -1
+ : str.charAt(next++);
}
- private void write(StringBuilder sb, int ch) {
+ private void unread() {
+ if (c >= 0) {
+ --next;
+ }
+ }
+
+ private void writeTo(StringBuilder sb, int ch) {
sb.append((char)ch);
}
private void write(int ch) {
- write(sbCleared, ch);
- write(sbMask, Character.isWhitespace(ch) ? ch : ' ');
+ if (ch != -1) {
+ writeTo(sbCleared, ch);
+ writeTo(sbMask, Character.isWhitespace(ch) ? ch : ' ');
+ }
}
private void writeMask(int ch) {
- write(sbMask, ch);
- write(sbCleared, Character.isWhitespace(ch) ? ch : ' ');
+ if (ch != -1) {
+ writeTo(sbMask, ch);
+ writeTo(sbCleared, Character.isWhitespace(ch) ? ch : ' ');
+ }
}
private void write(CharSequence s) {
@@ -122,99 +139,105 @@
}
}
- private boolean next() {
- return next(read());
- }
-
- private boolean next(int c) {
- if (c < 0) {
- return false;
- }
-
- if (c == '\'' || c == '"') {
- inside = true;
- write(c);
- int match = c;
- c = read();
- while (c != match) {
- if (c < 0) {
- return false;
- }
- if (c == '\n' || c == '\r') {
- write(c);
- return true;
- }
- if (c == '\\') {
- write(c);
- c = read();
- }
+ private void next() {
+ switch (c) {
+ case '\'':
+ case '"':
+ maskModifiers = false;
write(c);
- c = read();
- }
- write(c);
- return true;
- }
-
- if (c == '/') {
- c = read();
- if (c == '*') {
- writeMask('/');
- writeMask(c);
- int prevc = 0;
- while ((c = read()) != '/' || prevc != '*') {
- if (c < 0) {
- openComment = true;
- return false;
- }
- writeMask(c);
- prevc = c;
- }
- writeMask(c);
- return true;
- } else if (c == '/') {
- writeMask('/');
- writeMask(c);
- while ((c = read()) != '\n' && c != '\r') {
- if (c < 0) {
- return false;
- }
- writeMask(c);
- }
- writeMask(c);
- return true;
- } else {
- inside = true;
- write('/');
- // read character falls through
- }
- }
-
- if (Character.isJavaIdentifierStart(c)) {
- if (maskModifiers && !inside) {
- StringBuilder sb = new StringBuilder();
- do {
- write(sb, c);
- c = read();
- } while (Character.isJavaIdentifierPart(c));
- String id = sb.toString();
- if (IGNORED_MODIFERS.contains(id)) {
- writeMask(sb);
- } else {
- write(sb);
- if (id.equals("import")) {
- inside = true;
+ int match = c;
+ while (read() >= 0 && c != match && c != '\n' && c != '\r') {
+ write(c);
+ if (c == '\\') {
+ write(read());
}
}
- return next(c); // recurse to handle left-over character
- }
- } else if (!Character.isWhitespace(c)) {
- inside = true;
+ write(c); // write match // line-end
+ break;
+ case '/':
+ read();
+ switch (c) {
+ case '*':
+ writeMask('/');
+ writeMask(c);
+ int prevc = 0;
+ while (read() >= 0 && (c != '/' || prevc != '*')) {
+ writeMask(c);
+ prevc = c;
+ }
+ writeMask(c);
+ openComment = c < 0;
+ break;
+ case '/':
+ writeMask('/');
+ writeMask(c);
+ while (read() >= 0 && c != '\n' && c != '\r') {
+ writeMask(c);
+ }
+ writeMask(c);
+ break;
+ default:
+ maskModifiers = false;
+ write('/');
+ unread();
+ break;
+ }
+ break;
+ case '@':
+ do {
+ write(c);
+ read();
+ } while (Character.isJavaIdentifierPart(c));
+ while (Character.isWhitespace(c)) {
+ write(c);
+ read();
+ }
+ // if this is an annotation with arguments, process those recursively
+ if (c == '(') {
+ write(c);
+ boolean prevMaskModifiers = maskModifiers;
+ int parenCnt = 1;
+ while (read() >= 0) {
+ if (c == ')') {
+ if (--parenCnt == 0) {
+ break;
+ }
+ } else if (c == '(') {
+ ++parenCnt;
+ }
+ next(); // recurse to handle quotes and comments
+ }
+ write(c);
+ // stuff in annotation arguments doesn't effect inside determination
+ maskModifiers = prevMaskModifiers;
+ } else {
+ unread();
+ }
+ break;
+ default:
+ if (Character.isJavaIdentifierStart(c)) {
+ StringBuilder sb = new StringBuilder();
+ do {
+ writeTo(sb, c);
+ read();
+ } while (Character.isJavaIdentifierPart(c));
+ unread();
+ String id = sb.toString();
+ if (maskModifiers && IGNORED_MODIFIERS.contains(id)) {
+ writeMask(sb);
+ } else {
+ write(sb);
+ if (maskModifiers && !OTHER_MODIFIERS.contains(id)) {
+ maskModifiers = false;
+ }
+ }
+ } else {
+ if (!Character.isWhitespace(c)) {
+ maskModifiers = false;
+ }
+ write(c);
+ }
+ break;
}
-
- if (c < 0) {
- return false;
- }
- write(c);
- return true;
}
}
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysis.java Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysis.java Wed Nov 09 10:04:43 2016 -0800
@@ -63,12 +63,16 @@
public abstract List<Suggestion> completionSuggestions(String input, int cursor, int[] anchor);
/**
- * Compute a description/help string for the given user's input.
+ * Compute documentation for the given user's input. Multiple {@code Documentation} objects may
+ * be returned when multiple elements match the user's input (like for overloaded methods).
* @param input the snippet the user wrote so far
* @param cursor the current position of the cursors in the given {@code input} text
- * @return description/help string for the given user's input
+ * @param computeJavadoc true if the javadoc for the given input should be computed in
+ * addition to the signature
+ * @return the documentations for the given user's input, if multiple elements match the input,
+ * multiple {@code Documentation} objects are returned.
*/
- public abstract String documentation(String input, int cursor);
+ public abstract List<Documentation> documentation(String input, int cursor, boolean computeJavadoc);
/**
* Infer the type of the given expression. The expression spans from the beginning of {@code code}
@@ -266,6 +270,26 @@
}
/**
+ * A documentation for a candidate for continuation of the given user's input.
+ */
+ public interface Documentation {
+
+ /**
+ * The signature of the given element.
+ *
+ * @return the signature
+ */
+ String signature();
+
+ /**
+ * The javadoc of the given element.
+ *
+ * @return the javadoc, or null if not found or not requested
+ */
+ String javadoc();
+ }
+
+ /**
* List of possible qualified names.
*/
public static final class QualifiedNames {
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysisImpl.java Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysisImpl.java Wed Nov 09 10:04:43 2016 -0800
@@ -42,19 +42,17 @@
import com.sun.source.tree.Tree.Kind;
import com.sun.source.tree.TypeParameterTree;
import com.sun.source.tree.VariableTree;
-import com.sun.source.util.JavacTask;
import com.sun.source.util.SourcePositions;
import com.sun.source.util.TreePath;
import com.sun.source.util.TreePathScanner;
-import com.sun.source.util.Trees;
import com.sun.tools.javac.api.JavacScope;
-import com.sun.tools.javac.api.JavacTaskImpl;
import com.sun.tools.javac.code.Flags;
import com.sun.tools.javac.code.Symbol.CompletionFailure;
import com.sun.tools.javac.code.Symbol.VarSymbol;
import com.sun.tools.javac.code.Symtab;
import com.sun.tools.javac.code.Type;
import com.sun.tools.javac.code.Type.ClassType;
+import jdk.internal.shellsupport.doc.JavadocHelper;
import com.sun.tools.javac.util.Name;
import com.sun.tools.javac.util.Names;
import com.sun.tools.javac.util.Pair;
@@ -105,6 +103,7 @@
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import static java.util.stream.Collectors.collectingAndThen;
+import static java.util.stream.Collectors.joining;
import static java.util.stream.Collectors.toCollection;
import static java.util.stream.Collectors.toList;
import static java.util.stream.Collectors.toSet;
@@ -123,15 +122,10 @@
import javax.lang.model.type.TypeKind;
import javax.lang.model.util.ElementFilter;
import javax.lang.model.util.Types;
-import javax.tools.JavaCompiler;
import javax.tools.JavaFileManager.Location;
-import javax.tools.JavaFileObject;
-import javax.tools.StandardJavaFileManager;
import javax.tools.StandardLocation;
-import javax.tools.ToolProvider;
import static jdk.jshell.Util.REPL_DOESNOTMATTER_CLASS_NAME;
-import static java.util.stream.Collectors.joining;
import static jdk.jshell.SourceCodeAnalysis.Completeness.DEFINITELY_INCOMPLETE;
import static jdk.jshell.TreeDissector.printType;
@@ -151,6 +145,7 @@
private final JShell proc;
private final CompletenessAnalyzer ca;
+ private final List<AutoCloseable> closeables = new ArrayList<>();
private final Map<Path, ClassIndex> currentIndexes = new HashMap<>();
private int indexVersion;
private int classpathVersion;
@@ -1097,10 +1092,10 @@
}
@Override
- public String documentation(String code, int cursor) {
+ public List<Documentation> documentation(String code, int cursor, boolean computeJavadoc) {
suspendIndexing();
try {
- return documentationImpl(code, cursor);
+ return documentationImpl(code, cursor, computeJavadoc);
} finally {
resumeIndexing();
}
@@ -1112,14 +1107,14 @@
"-parameters"
};
- private String documentationImpl(String code, int cursor) {
+ private List<Documentation> documentationImpl(String code, int cursor, boolean computeJavadoc) {
code = code.substring(0, cursor);
if (code.trim().isEmpty()) { //TODO: comment handling
code += ";";
}
if (guessKind(code) == Kind.IMPORT)
- return null;
+ return Collections.<Documentation>emptyList();
OuterWrap codeWrap = proc.outerMap.wrapInTrialClass(Wrap.methodWrap(code));
AnalyzeTask at = proc.taskFactory.new AnalyzeTask(codeWrap, keepParameterNames);
@@ -1128,46 +1123,120 @@
TreePath tp = pathFor(topLevel, sp, codeWrap.snippetIndexToWrapIndex(cursor));
if (tp == null)
- return null;
+ return Collections.<Documentation>emptyList();
TreePath prevPath = null;
- while (tp != null && tp.getLeaf().getKind() != Kind.METHOD_INVOCATION && tp.getLeaf().getKind() != Kind.NEW_CLASS) {
+ while (tp != null && tp.getLeaf().getKind() != Kind.METHOD_INVOCATION &&
+ tp.getLeaf().getKind() != Kind.NEW_CLASS && tp.getLeaf().getKind() != Kind.IDENTIFIER &&
+ tp.getLeaf().getKind() != Kind.MEMBER_SELECT) {
prevPath = tp;
tp = tp.getParentPath();
}
if (tp == null)
- return null;
+ return Collections.<Documentation>emptyList();
+ Stream<Element> elements;
Iterable<Pair<ExecutableElement, ExecutableType>> candidates;
List<? extends ExpressionTree> arguments;
- if (tp.getLeaf().getKind() == Kind.METHOD_INVOCATION) {
- MethodInvocationTree mit = (MethodInvocationTree) tp.getLeaf();
- candidates = methodCandidates(at, tp);
- arguments = mit.getArguments();
+ if (tp.getLeaf().getKind() == Kind.METHOD_INVOCATION || tp.getLeaf().getKind() == Kind.NEW_CLASS) {
+ if (tp.getLeaf().getKind() == Kind.METHOD_INVOCATION) {
+ MethodInvocationTree mit = (MethodInvocationTree) tp.getLeaf();
+ candidates = methodCandidates(at, tp);
+ arguments = mit.getArguments();
+ } else {
+ NewClassTree nct = (NewClassTree) tp.getLeaf();
+ candidates = newClassCandidates(at, tp);
+ arguments = nct.getArguments();
+ }
+
+ if (!isEmptyArgumentsContext(arguments)) {
+ List<TypeMirror> actuals = computeActualInvocationTypes(at, arguments, prevPath);
+ List<TypeMirror> fullActuals = actuals != null ? actuals : Collections.emptyList();
+
+ candidates =
+ this.filterExecutableTypesByArguments(at, candidates, fullActuals)
+ .stream()
+ .filter(method -> parameterType(method.fst, method.snd, fullActuals.size(), true).findAny().isPresent())
+ .collect(Collectors.toList());
+ }
+
+ elements = Util.stream(candidates).map(method -> method.fst);
+ } else if (tp.getLeaf().getKind() == Kind.IDENTIFIER || tp.getLeaf().getKind() == Kind.MEMBER_SELECT) {
+ Element el = at.trees().getElement(tp);
+
+ if (el == null ||
+ el.asType().getKind() == TypeKind.ERROR ||
+ (el.getKind() == ElementKind.PACKAGE && el.getEnclosedElements().isEmpty())) {
+ //erroneous element:
+ return Collections.<Documentation>emptyList();
+ }
+
+ elements = Stream.of(el);
} else {
- NewClassTree nct = (NewClassTree) tp.getLeaf();
- candidates = newClassCandidates(at, tp);
- arguments = nct.getArguments();
+ return Collections.<Documentation>emptyList();
+ }
+
+ List<Documentation> result = Collections.emptyList();
+
+ try (JavadocHelper helper = JavadocHelper.create(at.task, findSources())) {
+ result = elements.map(el -> constructDocumentation(at, helper, el, computeJavadoc))
+ .filter(r -> r != null)
+ .collect(Collectors.toList());
+ } catch (IOException ex) {
+ proc.debug(ex, "JavadocHelper.close()");
}
- if (!isEmptyArgumentsContext(arguments)) {
- List<TypeMirror> actuals = computeActualInvocationTypes(at, arguments, prevPath);
- List<TypeMirror> fullActuals = actuals != null ? actuals : Collections.emptyList();
+ return result;
+ }
+
+ private Documentation constructDocumentation(AnalyzeTask at, JavadocHelper helper, Element el, boolean computeJavadoc) {
+ String javadoc = null;
+ try {
+ if (hasSyntheticParameterNames(el)) {
+ el = helper.getSourceElement(el);
+ }
+ if (computeJavadoc) {
+ javadoc = helper.getResolvedDocComment(el);
+ }
+ } catch (IOException ex) {
+ proc.debug(ex, "SourceCodeAnalysisImpl.element2String(..., " + el + ")");
+ }
+ String signature = Util.expunge(elementHeader(at, el, !hasSyntheticParameterNames(el), true));
+ return new DocumentationImpl(signature, javadoc);
+ }
- candidates =
- this.filterExecutableTypesByArguments(at, candidates, fullActuals)
- .stream()
- .filter(method -> parameterType(method.fst, method.snd, fullActuals.size(), true).findAny().isPresent())
- .collect(Collectors.toList());
+ public void close() {
+ for (AutoCloseable closeable : closeables) {
+ try {
+ closeable.close();
+ } catch (Exception ex) {
+ proc.debug(ex, "SourceCodeAnalysisImpl.close()");
+ }
+ }
+ }
+
+ private static final class DocumentationImpl implements Documentation {
+
+ private final String signature;
+ private final String javadoc;
+
+ public DocumentationImpl(String signature, String javadoc) {
+ this.signature = signature;
+ this.javadoc = javadoc;
}
- try (SourceCache sourceCache = new SourceCache(at)) {
- return Util.stream(candidates)
- .map(method -> Util.expunge(element2String(sourceCache, method.fst)))
- .collect(joining("\n"));
+ @Override
+ public String signature() {
+ return signature;
}
+
+ @Override
+ public String javadoc() {
+ return javadoc;
+ }
+
}
private boolean isEmptyArgumentsContext(List<? extends ExpressionTree> arguments) {
@@ -1178,18 +1247,6 @@
return false;
}
- private String element2String(SourceCache sourceCache, Element el) {
- try {
- if (hasSyntheticParameterNames(el)) {
- el = sourceCache.getSourceMethod(el);
- }
- } catch (IOException ex) {
- proc.debug(ex, "SourceCodeAnalysisImpl.element2String(..., " + el + ")");
- }
-
- return Util.expunge(elementHeader(sourceCache.originalTask, el, !hasSyntheticParameterNames(el)));
- }
-
private boolean hasSyntheticParameterNames(Element el) {
if (el.getKind() != ElementKind.CONSTRUCTOR && el.getKind() != ElementKind.METHOD)
return false;
@@ -1204,119 +1261,6 @@
.allMatch(param -> param.getSimpleName().toString().startsWith("arg"));
}
- private final class SourceCache implements AutoCloseable {
- private final JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
- private final Map<String, Map<String, Element>> topLevelName2Signature2Method = new HashMap<>();
- private final AnalyzeTask originalTask;
- private final StandardJavaFileManager fm;
-
- public SourceCache(AnalyzeTask originalTask) {
- this.originalTask = originalTask;
- List<Path> sources = findSources();
- if (sources.iterator().hasNext()) {
- StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null);
- try {
- fm.setLocationFromPaths(StandardLocation.SOURCE_PATH, sources);
- } catch (IOException ex) {
- proc.debug(ex, "SourceCodeAnalysisImpl.SourceCache.<init>(...)");
- try {
- fm.close();
- } catch (IOException closeEx) {
- proc.debug(closeEx, "SourceCodeAnalysisImpl.SourceCache.close()");
- }
- fm = null;
- }
- this.fm = fm;
- } else {
- //don't waste time if there are no sources
- this.fm = null;
- }
- }
-
- public Element getSourceMethod(Element method) throws IOException {
- if (fm == null)
- return method;
-
- TypeElement type = topLevelType(method);
-
- if (type == null)
- return method;
-
- String binaryName = originalTask.task.getElements().getBinaryName(type).toString();
-
- Map<String, Element> cache = topLevelName2Signature2Method.get(binaryName);
-
- if (cache == null) {
- topLevelName2Signature2Method.put(binaryName, cache = createMethodCache(binaryName));
- }
-
- String handle = elementHeader(originalTask, method, false);
-
- return cache.getOrDefault(handle, method);
- }
-
- private TypeElement topLevelType(Element el) {
- while (el != null && el.getEnclosingElement().getKind() != ElementKind.PACKAGE) {
- el = el.getEnclosingElement();
- }
-
- return el != null && (el.getKind().isClass() || el.getKind().isInterface()) ? (TypeElement) el : null;
- }
-
- private Map<String, Element> createMethodCache(String binaryName) throws IOException {
- Pair<JavacTask, CompilationUnitTree> source = findSource(binaryName);
-
- if (source == null)
- return Collections.emptyMap();
-
- Map<String, Element> signature2Method = new HashMap<>();
- Trees trees = Trees.instance(source.fst);
-
- new TreePathScanner<Void, Void>() {
- @Override
- public Void visitMethod(MethodTree node, Void p) {
- Element currentMethod = trees.getElement(getCurrentPath());
-
- if (currentMethod != null) {
- signature2Method.put(elementHeader(originalTask, currentMethod, false), currentMethod);
- }
-
- return null;
- }
- }.scan(source.snd, null);
-
- return signature2Method;
- }
-
- private Pair<JavacTask, CompilationUnitTree> findSource(String binaryName) throws IOException {
- JavaFileObject jfo = fm.getJavaFileForInput(StandardLocation.SOURCE_PATH,
- binaryName,
- JavaFileObject.Kind.SOURCE);
-
- if (jfo == null)
- return null;
-
- List<JavaFileObject> jfos = Arrays.asList(jfo);
- JavacTaskImpl task = (JavacTaskImpl) compiler.getTask(null, fm, d -> {}, null, null, jfos);
- Iterable<? extends CompilationUnitTree> cuts = task.parse();
-
- task.enter();
-
- return Pair.of(task, cuts.iterator().next());
- }
-
- @Override
- public void close() {
- try {
- if (fm != null) {
- fm.close();
- }
- } catch (IOException ex) {
- proc.debug(ex, "SourceCodeAnalysisImpl.SourceCache.close()");
- }
- }
- }
-
private List<Path> availableSources;
private List<Path> findSources() {
@@ -1328,25 +1272,59 @@
Path srcZip = home.resolve("src.zip");
if (!Files.isReadable(srcZip))
srcZip = home.getParent().resolve("src.zip");
- if (Files.isReadable(srcZip))
- result.add(srcZip);
+ if (Files.isReadable(srcZip)) {
+ boolean keepOpen = false;
+ FileSystem zipFO = null;
+
+ try {
+ URI uri = URI.create("jar:" + srcZip.toUri());
+ zipFO = FileSystems.newFileSystem(uri, Collections.emptyMap());
+ Path root = zipFO.getRootDirectories().iterator().next();
+
+ if (Files.exists(root.resolve("java/lang/Object.java".replace("/", zipFO.getSeparator())))) {
+ //non-modular format:
+ result.add(srcZip);
+ } else if (Files.exists(root.resolve("java.base/java/lang/Object.java".replace("/", zipFO.getSeparator())))) {
+ //modular format:
+ try (DirectoryStream<Path> ds = Files.newDirectoryStream(root)) {
+ for (Path p : ds) {
+ if (Files.isDirectory(p)) {
+ result.add(p);
+ }
+ }
+ }
+
+ keepOpen = true;
+ }
+ } catch (IOException ex) {
+ proc.debug(ex, "SourceCodeAnalysisImpl.findSources()");
+ } finally {
+ if (zipFO != null) {
+ if (keepOpen) {
+ closeables.add(zipFO);
+ } else {
+ try {
+ zipFO.close();
+ } catch (IOException ex) {
+ proc.debug(ex, "SourceCodeAnalysisImpl.findSources()");
+ }
+ }
+ }
+ }
+ }
return availableSources = result;
}
- private String elementHeader(AnalyzeTask at, Element el) {
- return elementHeader(at, el, true);
- }
-
- private String elementHeader(AnalyzeTask at, Element el, boolean includeParameterNames) {
+ private String elementHeader(AnalyzeTask at, Element el, boolean includeParameterNames, boolean useFQN) {
switch (el.getKind()) {
case ANNOTATION_TYPE: case CLASS: case ENUM: case INTERFACE: {
TypeElement type = (TypeElement)el;
String fullname = type.getQualifiedName().toString();
Element pkg = at.getElements().getPackageOf(el);
- String name = pkg == null ? fullname :
+ String name = pkg == null || useFQN ? fullname :
proc.maps.fullClassNameAndPackageToClass(fullname, ((PackageElement)pkg).getQualifiedName().toString());
- return name + typeParametersOpt(at, type.getTypeParameters());
+ return name + typeParametersOpt(at, type.getTypeParameters(), includeParameterNames);
}
case TYPE_PARAMETER: {
TypeParameterElement tp = (TypeParameterElement)el;
@@ -1363,9 +1341,9 @@
.collect(joining(" & "));
}
case FIELD:
- return elementHeader(at, el.getEnclosingElement()) + "." + el.getSimpleName() + ":" + el.asType();
+ return elementHeader(at, el.getEnclosingElement(), includeParameterNames, false) + "." + el.getSimpleName() + ":" + el.asType();
case ENUM_CONSTANT:
- return elementHeader(at, el.getEnclosingElement()) + "." + el.getSimpleName();
+ return elementHeader(at, el.getEnclosingElement(), includeParameterNames, false) + "." + el.getSimpleName();
case EXCEPTION_PARAMETER: case LOCAL_VARIABLE: case PARAMETER: case RESOURCE_VARIABLE:
return el.getSimpleName() + ":" + el.asType();
case CONSTRUCTOR: case METHOD: {
@@ -1379,20 +1357,20 @@
header.append(printType(at, proc, method.getReturnType())).append(" ");
} else {
// type parameters for the constructor
- String typeParameters = typeParametersOpt(at, method.getTypeParameters());
+ String typeParameters = typeParametersOpt(at, method.getTypeParameters(), includeParameterNames);
if (!typeParameters.isEmpty()) {
header.append(typeParameters).append(" ");
}
}
// receiver type
- String clazz = elementHeader(at, el.getEnclosingElement());
+ String clazz = elementHeader(at, el.getEnclosingElement(), includeParameterNames, false);
header.append(clazz);
if (isMethod) {
//method name with type parameters
(clazz.isEmpty() ? header : header.append("."))
- .append(typeParametersOpt(at, method.getTypeParameters()))
+ .append(typeParametersOpt(at, method.getTypeParameters(), includeParameterNames))
.append(el.getSimpleName());
}
@@ -1435,10 +1413,10 @@
}
return arrayType;
}
- private String typeParametersOpt(AnalyzeTask at, List<? extends TypeParameterElement> typeParameters) {
+ private String typeParametersOpt(AnalyzeTask at, List<? extends TypeParameterElement> typeParameters, boolean includeParameterNames) {
return typeParameters.isEmpty() ? ""
: typeParameters.stream()
- .map(tp -> elementHeader(at, tp))
+ .map(tp -> elementHeader(at, tp, includeParameterNames, false))
.collect(joining(", ", "<", ">"));
}
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/JDIDefaultExecutionControl.java Wed Nov 09 15:20:30 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,282 +0,0 @@
-/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package jdk.jshell.execution;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.io.OutputStream;
-import java.net.ServerSocket;
-import java.net.Socket;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.function.Consumer;
-import com.sun.jdi.BooleanValue;
-import com.sun.jdi.ClassNotLoadedException;
-import com.sun.jdi.Field;
-import com.sun.jdi.IncompatibleThreadStateException;
-import com.sun.jdi.InvalidTypeException;
-import com.sun.jdi.ObjectReference;
-import com.sun.jdi.StackFrame;
-import com.sun.jdi.ThreadReference;
-import com.sun.jdi.VMDisconnectedException;
-import com.sun.jdi.VirtualMachine;
-import jdk.jshell.spi.ExecutionControl;
-import jdk.jshell.spi.ExecutionEnv;
-import static jdk.jshell.execution.Util.remoteInputOutput;
-
-/**
- * The implementation of {@link jdk.jshell.spi.ExecutionControl} that the
- * JShell-core uses by default.
- * Launches a remote process -- the "remote agent".
- * Interfaces to the remote agent over a socket and via JDI.
- * Designed to work with {@link RemoteExecutionControl}.
- *
- * @author Robert Field
- * @author Jan Lahoda
- */
-public class JDIDefaultExecutionControl extends JDIExecutionControl {
-
- private static final String REMOTE_AGENT = RemoteExecutionControl.class.getName();
-
- private VirtualMachine vm;
- private Process process;
-
- private final Object STOP_LOCK = new Object();
- private boolean userCodeRunning = false;
-
- /**
- * Creates an ExecutionControl instance based on a JDI
- * {@code LaunchingConnector}.
- *
- * @return the generator
- */
- public static ExecutionControl.Generator launch() {
- return env -> create(env, true, null);
- }
-
- /**
- * Creates an ExecutionControl instance based on a JDI
- * {@code ListeningConnector}.
- *
- * @param host explicit hostname to use, if null use discovered
- * hostname, applies to listening only (!isLaunch)
- * @return the generator
- */
- public static ExecutionControl.Generator listen(String host) {
- return env -> create(env, false, host);
- }
-
- /**
- * Creates an ExecutionControl instance based on a JDI
- * {@code ListeningConnector} or {@code LaunchingConnector}.
- *
- * Initialize JDI and use it to launch the remote JVM. Set-up a socket for
- * commands and results. This socket also transports the user
- * input/output/error.
- *
- * @param env the context passed by
- * {@link jdk.jshell.spi.ExecutionControl#start(jdk.jshell.spi.ExecutionEnv) }
- * @param isLaunch does JDI do the launch? That is, LaunchingConnector,
- * otherwise we start explicitly and use ListeningConnector
- * @param host explicit hostname to use, if null use discovered
- * hostname, applies to listening only (!isLaunch)
- * @return the channel
- * @throws IOException if there are errors in set-up
- */
- private static ExecutionControl create(ExecutionEnv env,
- boolean isLaunch, String host) throws IOException {
- try (final ServerSocket listener = new ServerSocket(0)) {
- // timeout after 60 seconds
- listener.setSoTimeout(60000);
- int port = listener.getLocalPort();
-
- // Set-up the JDI connection
- JDIInitiator jdii = new JDIInitiator(port,
- env.extraRemoteVMOptions(), REMOTE_AGENT, isLaunch, host);
- VirtualMachine vm = jdii.vm();
- Process process = jdii.process();
-
- List<Consumer<String>> deathListeners = new ArrayList<>();
- deathListeners.add(s -> env.closeDown());
- Util.detectJDIExitEvent(vm, s -> {
- for (Consumer<String> h : deathListeners) {
- h.accept(s);
- }
- });
-
- // Set-up the commands/reslts on the socket. Piggy-back snippet
- // output.
- Socket socket = listener.accept();
- // out before in -- match remote creation so we don't hang
- OutputStream out = socket.getOutputStream();
- Map<String, OutputStream> outputs = new HashMap<>();
- outputs.put("out", env.userOut());
- outputs.put("err", env.userErr());
- Map<String, InputStream> input = new HashMap<>();
- input.put("in", env.userIn());
- return remoteInputOutput(socket.getInputStream(), out, outputs, input, (objIn, objOut) -> new JDIDefaultExecutionControl(objOut, objIn, vm, process, deathListeners));
- }
- }
-
- /**
- * Create an instance.
- *
- * @param cmdout the output for commands
- * @param cmdin the input for responses
- */
- private JDIDefaultExecutionControl(ObjectOutput cmdout, ObjectInput cmdin,
- VirtualMachine vm, Process process, List<Consumer<String>> deathListeners) {
- super(cmdout, cmdin);
- this.vm = vm;
- this.process = process;
- deathListeners.add(s -> disposeVM());
- }
-
- @Override
- public String invoke(String classname, String methodname)
- throws RunException,
- EngineTerminationException, InternalException {
- String res;
- synchronized (STOP_LOCK) {
- userCodeRunning = true;
- }
- try {
- res = super.invoke(classname, methodname);
- } finally {
- synchronized (STOP_LOCK) {
- userCodeRunning = false;
- }
- }
- return res;
- }
-
- /**
- * Interrupts a running remote invoke by manipulating remote variables
- * and sending a stop via JDI.
- *
- * @throws EngineTerminationException the execution engine has terminated
- * @throws InternalException an internal problem occurred
- */
- @Override
- public void stop() throws EngineTerminationException, InternalException {
- synchronized (STOP_LOCK) {
- if (!userCodeRunning) {
- return;
- }
-
- vm().suspend();
- try {
- OUTER:
- for (ThreadReference thread : vm().allThreads()) {
- // could also tag the thread (e.g. using name), to find it easier
- for (StackFrame frame : thread.frames()) {
- if (REMOTE_AGENT.equals(frame.location().declaringType().name()) &&
- ( "invoke".equals(frame.location().method().name())
- || "varValue".equals(frame.location().method().name()))) {
- ObjectReference thiz = frame.thisObject();
- Field inClientCode = thiz.referenceType().fieldByName("inClientCode");
- Field expectingStop = thiz.referenceType().fieldByName("expectingStop");
- Field stopException = thiz.referenceType().fieldByName("stopException");
- if (((BooleanValue) thiz.getValue(inClientCode)).value()) {
- thiz.setValue(expectingStop, vm().mirrorOf(true));
- ObjectReference stopInstance = (ObjectReference) thiz.getValue(stopException);
-
- vm().resume();
- debug("Attempting to stop the client code...\n");
- thread.stop(stopInstance);
- thiz.setValue(expectingStop, vm().mirrorOf(false));
- }
-
- break OUTER;
- }
- }
- }
- } catch (ClassNotLoadedException | IncompatibleThreadStateException | InvalidTypeException ex) {
- throw new InternalException("Exception on remote stop: " + ex);
- } finally {
- vm().resume();
- }
- }
- }
-
- @Override
- public void close() {
- super.close();
- disposeVM();
- }
-
- private synchronized void disposeVM() {
- try {
- if (vm != null) {
- vm.dispose(); // This could NPE, so it is caught below
- vm = null;
- }
- } catch (VMDisconnectedException ex) {
- // Ignore if already closed
- } catch (Throwable ex) {
- debug(ex, "disposeVM");
- } finally {
- if (process != null) {
- process.destroy();
- process = null;
- }
- }
- }
-
- @Override
- protected synchronized VirtualMachine vm() throws EngineTerminationException {
- if (vm == null) {
- throw new EngineTerminationException("VM closed");
- } else {
- return vm;
- }
- }
-
- /**
- * Log debugging information. Arguments as for {@code printf}.
- *
- * @param format a format string as described in Format string syntax
- * @param args arguments referenced by the format specifiers in the format
- * string.
- */
- private static void debug(String format, Object... args) {
- // Reserved for future logging
- }
-
- /**
- * Log a serious unexpected internal exception.
- *
- * @param ex the exception
- * @param where a description of the context of the exception
- */
- private static void debug(Throwable ex, String where) {
- // Reserved for future logging
- }
-
-}
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/JDIEventHandler.java Wed Nov 09 15:20:30 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,140 +0,0 @@
-/*
- * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.jshell.execution;
-
-import java.util.function.Consumer;
-import com.sun.jdi.*;
-import com.sun.jdi.event.*;
-
-/**
- * Handler of Java Debug Interface events.
- * Adapted from jdb EventHandler.
- * Only exit and disconnect events processed.
- */
-class JDIEventHandler implements Runnable {
-
- private final Thread thread;
- private volatile boolean connected = true;
- private boolean completed = false;
- private final VirtualMachine vm;
- private final Consumer<String> reportVMExit;
-
- /**
- * Creates an event handler. Start with {@code start()}.
- *
- * @param vm the virtual machine for which to handle events
- * @param reportVMExit callback to report exit/disconnect
- * (passed true if the VM has died)
- */
- JDIEventHandler(VirtualMachine vm, Consumer<String> reportVMExit) {
- this.vm = vm;
- this.reportVMExit = reportVMExit;
- this.thread = new Thread(this, "event-handler");
- this.thread.setDaemon(true);
- }
-
- /**
- * Starts the event handler.
- */
- void start() {
- thread.start();
- }
-
- synchronized void shutdown() {
- connected = false; // force run() loop termination
- thread.interrupt();
- while (!completed) {
- try {wait();} catch (InterruptedException exc) {}
- }
- }
-
- @Override
- public void run() {
- EventQueue queue = vm.eventQueue();
- while (connected) {
- try {
- EventSet eventSet = queue.remove();
- boolean resumeStoppedApp = false;
- EventIterator it = eventSet.eventIterator();
- while (it.hasNext()) {
- resumeStoppedApp |= handleEvent(it.nextEvent());
- }
-
- if (resumeStoppedApp) {
- eventSet.resume();
- }
- } catch (InterruptedException exc) {
- // Do nothing. Any changes will be seen at top of loop.
- } catch (VMDisconnectedException discExc) {
- handleDisconnectedException();
- break;
- }
- }
- synchronized (this) {
- completed = true;
- notifyAll();
- }
- }
-
- private boolean handleEvent(Event event) {
- handleExitEvent(event);
- return true;
- }
-
- private void handleExitEvent(Event event) {
- if (event instanceof VMDeathEvent) {
- reportVMExit.accept("VM Died");
- } else if (event instanceof VMDisconnectEvent) {
- connected = false;
- reportVMExit.accept("VM Disconnected");
- } else {
- // ignore everything else
- }
- }
-
- private synchronized void handleDisconnectedException() {
- /*
- * A VMDisconnectedException has happened while dealing with
- * another event. We need to flush the event queue, dealing only
- * with exit events (VMDeath, VMDisconnect) so that we terminate
- * correctly.
- */
- EventQueue queue = vm.eventQueue();
- while (connected) {
- try {
- EventSet eventSet = queue.remove();
- EventIterator iter = eventSet.eventIterator();
- while (iter.hasNext()) {
- handleExitEvent(iter.next());
- }
- } catch (InterruptedException exc) {
- // ignore
- } catch (InternalError exc) {
- // ignore
- }
- }
- }
-}
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/JDIExecutionControl.java Wed Nov 09 15:20:30 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,117 +0,0 @@
-/*
- * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.jshell.execution;
-
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Stream;
-import com.sun.jdi.ReferenceType;
-import com.sun.jdi.VirtualMachine;
-import jdk.jshell.spi.ExecutionControl;
-import static java.util.stream.Collectors.toMap;
-
-/**
- * Abstract JDI implementation of {@link jdk.jshell.spi.ExecutionControl}
- */
-public abstract class JDIExecutionControl extends StreamingExecutionControl implements ExecutionControl {
-
- /**
- * Mapping from class names to JDI {@link ReferenceType}.
- */
- private final Map<String, ReferenceType> toReferenceType = new HashMap<>();
-
- /**
- * Create an instance.
- * @param out the output from the remote agent
- * @param in the input to the remote agent
- */
- protected JDIExecutionControl(ObjectOutput out, ObjectInput in) {
- super(out, in);
- }
-
- /**
- * Returns the JDI {@link VirtualMachine} instance.
- *
- * @return the virtual machine
- * @throws EngineTerminationException if the VM is dead/disconnected
- */
- protected abstract VirtualMachine vm() throws EngineTerminationException;
-
- /**
- * Redefine the specified classes. Where 'redefine' is, as in JDI and JVMTI,
- * an in-place replacement of the classes (preserving class identity) --
- * that is, existing references to the class do not need to be recompiled.
- * This implementation uses JDI
- * {@link com.sun.jdi.VirtualMachine#redefineClasses(java.util.Map) }.
- * It will be unsuccessful if
- * the signature of the class has changed (see the JDI spec). The
- * JShell-core is designed to adapt to unsuccessful redefine.
- */
- @Override
- public void redefine(ClassBytecodes[] cbcs)
- throws ClassInstallException, EngineTerminationException {
- try {
- // Convert to the JDI ReferenceType to class bytes map form needed
- // by JDI.
- VirtualMachine vm = vm();
- Map<ReferenceType, byte[]> rmp = Stream.of(cbcs)
- .collect(toMap(
- cbc -> referenceType(vm, cbc.name()),
- cbc -> cbc.bytecodes()));
- // Attempt redefine. Throws exceptions on failure.
- vm().redefineClasses(rmp);
- } catch (EngineTerminationException ex) {
- throw ex;
- } catch (Exception ex) {
- throw new ClassInstallException("redefine: " + ex.getMessage(), new boolean[cbcs.length]);
- }
- }
-
- /**
- * Returns the JDI {@link ReferenceType} corresponding to the specified
- * class name.
- *
- * @param vm the current JDI {@link VirtualMachine} as returned by
- * {@code vm()}
- * @param name the class name to look-up
- * @return the corresponding {@link ReferenceType}
- */
- protected ReferenceType referenceType(VirtualMachine vm, String name) {
- return toReferenceType.computeIfAbsent(name, n -> nameToRef(vm, n));
- }
-
- private static ReferenceType nameToRef(VirtualMachine vm, String name) {
- List<ReferenceType> rtl = vm.classesByName(name);
- if (rtl.size() != 1) {
- return null;
- }
- return rtl.get(0);
- }
-
-}
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/JDIInitiator.java Wed Nov 09 15:20:30 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,223 +0,0 @@
-/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package jdk.jshell.execution;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import com.sun.jdi.Bootstrap;
-import com.sun.jdi.VirtualMachine;
-import com.sun.jdi.connect.Connector;
-import com.sun.jdi.connect.LaunchingConnector;
-import com.sun.jdi.connect.ListeningConnector;
-
-/**
- * Sets up a JDI connection, providing the resulting JDI {@link VirtualMachine}
- * and the {@link Process} the remote agent is running in.
- */
-public class JDIInitiator {
-
- private VirtualMachine vm;
- private Process process = null;
- private final Connector connector;
- private final String remoteAgent;
- private final Map<String, com.sun.jdi.connect.Connector.Argument> connectorArgs;
-
- /**
- * Start the remote agent and establish a JDI connection to it.
- *
- * @param port the socket port for (non-JDI) commands
- * @param remoteVMOptions any user requested VM options
- * @param remoteAgent full class name of remote agent to launch
- * @param isLaunch does JDI do the launch? That is, LaunchingConnector,
- * otherwise we start explicitly and use ListeningConnector
- * @param host explicit hostname to use, if null use discovered
- * hostname, applies to listening only (!isLaunch)
- */
- public JDIInitiator(int port, List<String> remoteVMOptions, String remoteAgent,
- boolean isLaunch, String host) {
- this.remoteAgent = remoteAgent;
- String connectorName
- = isLaunch
- ? "com.sun.jdi.CommandLineLaunch"
- : "com.sun.jdi.SocketListen";
- this.connector = findConnector(connectorName);
- if (connector == null) {
- throw new IllegalArgumentException("No connector named: " + connectorName);
- }
- Map<String, String> argumentName2Value
- = isLaunch
- ? launchArgs(port, String.join(" ", remoteVMOptions))
- : new HashMap<>();
- if (host != null && !isLaunch) {
- argumentName2Value.put("localAddress", host);
- }
- this.connectorArgs = mergeConnectorArgs(connector, argumentName2Value);
- this.vm = isLaunch
- ? launchTarget()
- : listenTarget(port, remoteVMOptions);
-
- }
-
- /**
- * Returns the resulting {@code VirtualMachine} instance.
- *
- * @return the virtual machine
- */
- public VirtualMachine vm() {
- return vm;
- }
-
- /**
- * Returns the launched process.
- *
- * @return the remote agent process
- */
- public Process process() {
- return process;
- }
-
- /* launch child target vm */
- private VirtualMachine launchTarget() {
- LaunchingConnector launcher = (LaunchingConnector) connector;
- try {
- VirtualMachine new_vm = launcher.launch(connectorArgs);
- process = new_vm.process();
- return new_vm;
- } catch (Exception ex) {
- reportLaunchFail(ex, "launch");
- }
- return null;
- }
-
- /**
- * Directly launch the remote agent and connect JDI to it with a
- * ListeningConnector.
- */
- private VirtualMachine listenTarget(int port, List<String> remoteVMOptions) {
- ListeningConnector listener = (ListeningConnector) connector;
- try {
- // Start listening, get the JDI connection address
- String addr = listener.startListening(connectorArgs);
- debug("Listening at address: " + addr);
-
- // Launch the RemoteAgent requesting a connection on that address
- String javaHome = System.getProperty("java.home");
- List<String> args = new ArrayList<>();
- args.add(javaHome == null
- ? "java"
- : javaHome + File.separator + "bin" + File.separator + "java");
- args.add("-agentlib:jdwp=transport=" + connector.transport().name() +
- ",address=" + addr);
- args.addAll(remoteVMOptions);
- args.add(remoteAgent);
- args.add("" + port);
- ProcessBuilder pb = new ProcessBuilder(args);
- process = pb.start();
-
- // Forward out, err, and in
- // Accept the connection from the remote agent
- vm = listener.accept(connectorArgs);
- listener.stopListening(connectorArgs);
- return vm;
- } catch (Exception ex) {
- reportLaunchFail(ex, "listen");
- }
- return null;
- }
-
- private Connector findConnector(String name) {
- for (Connector cntor
- : Bootstrap.virtualMachineManager().allConnectors()) {
- if (cntor.name().equals(name)) {
- return cntor;
- }
- }
- return null;
- }
-
- private Map<String, Connector.Argument> mergeConnectorArgs(Connector connector, Map<String, String> argumentName2Value) {
- Map<String, Connector.Argument> arguments = connector.defaultArguments();
-
- for (Entry<String, String> argumentEntry : argumentName2Value.entrySet()) {
- String name = argumentEntry.getKey();
- String value = argumentEntry.getValue();
- Connector.Argument argument = arguments.get(name);
-
- if (argument == null) {
- throw new IllegalArgumentException("Argument is not defined for connector:" +
- name + " -- " + connector.name());
- }
-
- argument.setValue(value);
- }
-
- return arguments;
- }
-
- /**
- * The JShell specific Connector args for the LaunchingConnector.
- *
- * @param portthe socket port for (non-JDI) commands
- * @param remoteVMOptions any user requested VM options
- * @return the argument map
- */
- private Map<String, String> launchArgs(int port, String remoteVMOptions) {
- Map<String, String> argumentName2Value = new HashMap<>();
- argumentName2Value.put("main", remoteAgent + " " + port);
- argumentName2Value.put("options", remoteVMOptions);
- return argumentName2Value;
- }
-
- private void reportLaunchFail(Exception ex, String context) {
- throw new InternalError("Failed remote " + context + ": " + connector +
- " -- " + connectorArgs, ex);
- }
-
- /**
- * Log debugging information. Arguments as for {@code printf}.
- *
- * @param format a format string as described in Format string syntax
- * @param args arguments referenced by the format specifiers in the format
- * string.
- */
- private void debug(String format, Object... args) {
- // Reserved for future logging
- }
-
- /**
- * Log a serious unexpected internal exception.
- *
- * @param ex the exception
- * @param where a description of the context of the exception
- */
- private void debug(Throwable ex, String where) {
- // Reserved for future logging
- }
-
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/JdiDefaultExecutionControl.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,282 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package jdk.jshell.execution;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.io.OutputStream;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.function.Consumer;
+import com.sun.jdi.BooleanValue;
+import com.sun.jdi.ClassNotLoadedException;
+import com.sun.jdi.Field;
+import com.sun.jdi.IncompatibleThreadStateException;
+import com.sun.jdi.InvalidTypeException;
+import com.sun.jdi.ObjectReference;
+import com.sun.jdi.StackFrame;
+import com.sun.jdi.ThreadReference;
+import com.sun.jdi.VMDisconnectedException;
+import com.sun.jdi.VirtualMachine;
+import jdk.jshell.spi.ExecutionControl;
+import jdk.jshell.spi.ExecutionEnv;
+import static jdk.jshell.execution.Util.remoteInputOutput;
+
+/**
+ * The implementation of {@link jdk.jshell.spi.ExecutionControl} that the
+ * JShell-core uses by default.
+ * Launches a remote process -- the "remote agent".
+ * Interfaces to the remote agent over a socket and via JDI.
+ * Designed to work with {@link RemoteExecutionControl}.
+ *
+ * @author Robert Field
+ * @author Jan Lahoda
+ */
+public class JdiDefaultExecutionControl extends JdiExecutionControl {
+
+ private static final String REMOTE_AGENT = RemoteExecutionControl.class.getName();
+
+ private VirtualMachine vm;
+ private Process process;
+
+ private final Object STOP_LOCK = new Object();
+ private boolean userCodeRunning = false;
+
+ /**
+ * Creates an ExecutionControl instance based on a JDI
+ * {@code LaunchingConnector}.
+ *
+ * @return the generator
+ */
+ public static ExecutionControl.Generator launch() {
+ return env -> create(env, true, null);
+ }
+
+ /**
+ * Creates an ExecutionControl instance based on a JDI
+ * {@code ListeningConnector}.
+ *
+ * @param host explicit hostname to use, if null use discovered
+ * hostname, applies to listening only (!isLaunch)
+ * @return the generator
+ */
+ public static ExecutionControl.Generator listen(String host) {
+ return env -> create(env, false, host);
+ }
+
+ /**
+ * Creates an ExecutionControl instance based on a JDI
+ * {@code ListeningConnector} or {@code LaunchingConnector}.
+ *
+ * Initialize JDI and use it to launch the remote JVM. Set-up a socket for
+ * commands and results. This socket also transports the user
+ * input/output/error.
+ *
+ * @param env the context passed by
+ * {@link jdk.jshell.spi.ExecutionControl#start(jdk.jshell.spi.ExecutionEnv) }
+ * @param isLaunch does JDI do the launch? That is, LaunchingConnector,
+ * otherwise we start explicitly and use ListeningConnector
+ * @param host explicit hostname to use, if null use discovered
+ * hostname, applies to listening only (!isLaunch)
+ * @return the channel
+ * @throws IOException if there are errors in set-up
+ */
+ private static ExecutionControl create(ExecutionEnv env,
+ boolean isLaunch, String host) throws IOException {
+ try (final ServerSocket listener = new ServerSocket(0)) {
+ // timeout after 60 seconds
+ listener.setSoTimeout(60000);
+ int port = listener.getLocalPort();
+
+ // Set-up the JDI connection
+ JdiInitiator jdii = new JdiInitiator(port,
+ env.extraRemoteVMOptions(), REMOTE_AGENT, isLaunch, host);
+ VirtualMachine vm = jdii.vm();
+ Process process = jdii.process();
+
+ List<Consumer<String>> deathListeners = new ArrayList<>();
+ deathListeners.add(s -> env.closeDown());
+ Util.detectJdiExitEvent(vm, s -> {
+ for (Consumer<String> h : deathListeners) {
+ h.accept(s);
+ }
+ });
+
+ // Set-up the commands/reslts on the socket. Piggy-back snippet
+ // output.
+ Socket socket = listener.accept();
+ // out before in -- match remote creation so we don't hang
+ OutputStream out = socket.getOutputStream();
+ Map<String, OutputStream> outputs = new HashMap<>();
+ outputs.put("out", env.userOut());
+ outputs.put("err", env.userErr());
+ Map<String, InputStream> input = new HashMap<>();
+ input.put("in", env.userIn());
+ return remoteInputOutput(socket.getInputStream(), out, outputs, input, (objIn, objOut) -> new JdiDefaultExecutionControl(objOut, objIn, vm, process, deathListeners));
+ }
+ }
+
+ /**
+ * Create an instance.
+ *
+ * @param cmdout the output for commands
+ * @param cmdin the input for responses
+ */
+ private JdiDefaultExecutionControl(ObjectOutput cmdout, ObjectInput cmdin,
+ VirtualMachine vm, Process process, List<Consumer<String>> deathListeners) {
+ super(cmdout, cmdin);
+ this.vm = vm;
+ this.process = process;
+ deathListeners.add(s -> disposeVM());
+ }
+
+ @Override
+ public String invoke(String classname, String methodname)
+ throws RunException,
+ EngineTerminationException, InternalException {
+ String res;
+ synchronized (STOP_LOCK) {
+ userCodeRunning = true;
+ }
+ try {
+ res = super.invoke(classname, methodname);
+ } finally {
+ synchronized (STOP_LOCK) {
+ userCodeRunning = false;
+ }
+ }
+ return res;
+ }
+
+ /**
+ * Interrupts a running remote invoke by manipulating remote variables
+ * and sending a stop via JDI.
+ *
+ * @throws EngineTerminationException the execution engine has terminated
+ * @throws InternalException an internal problem occurred
+ */
+ @Override
+ public void stop() throws EngineTerminationException, InternalException {
+ synchronized (STOP_LOCK) {
+ if (!userCodeRunning) {
+ return;
+ }
+
+ vm().suspend();
+ try {
+ OUTER:
+ for (ThreadReference thread : vm().allThreads()) {
+ // could also tag the thread (e.g. using name), to find it easier
+ for (StackFrame frame : thread.frames()) {
+ if (REMOTE_AGENT.equals(frame.location().declaringType().name()) &&
+ ( "invoke".equals(frame.location().method().name())
+ || "varValue".equals(frame.location().method().name()))) {
+ ObjectReference thiz = frame.thisObject();
+ Field inClientCode = thiz.referenceType().fieldByName("inClientCode");
+ Field expectingStop = thiz.referenceType().fieldByName("expectingStop");
+ Field stopException = thiz.referenceType().fieldByName("stopException");
+ if (((BooleanValue) thiz.getValue(inClientCode)).value()) {
+ thiz.setValue(expectingStop, vm().mirrorOf(true));
+ ObjectReference stopInstance = (ObjectReference) thiz.getValue(stopException);
+
+ vm().resume();
+ debug("Attempting to stop the client code...\n");
+ thread.stop(stopInstance);
+ thiz.setValue(expectingStop, vm().mirrorOf(false));
+ }
+
+ break OUTER;
+ }
+ }
+ }
+ } catch (ClassNotLoadedException | IncompatibleThreadStateException | InvalidTypeException ex) {
+ throw new InternalException("Exception on remote stop: " + ex);
+ } finally {
+ vm().resume();
+ }
+ }
+ }
+
+ @Override
+ public void close() {
+ super.close();
+ disposeVM();
+ }
+
+ private synchronized void disposeVM() {
+ try {
+ if (vm != null) {
+ vm.dispose(); // This could NPE, so it is caught below
+ vm = null;
+ }
+ } catch (VMDisconnectedException ex) {
+ // Ignore if already closed
+ } catch (Throwable ex) {
+ debug(ex, "disposeVM");
+ } finally {
+ if (process != null) {
+ process.destroy();
+ process = null;
+ }
+ }
+ }
+
+ @Override
+ protected synchronized VirtualMachine vm() throws EngineTerminationException {
+ if (vm == null) {
+ throw new EngineTerminationException("VM closed");
+ } else {
+ return vm;
+ }
+ }
+
+ /**
+ * Log debugging information. Arguments as for {@code printf}.
+ *
+ * @param format a format string as described in Format string syntax
+ * @param args arguments referenced by the format specifiers in the format
+ * string.
+ */
+ private static void debug(String format, Object... args) {
+ // Reserved for future logging
+ }
+
+ /**
+ * Log a serious unexpected internal exception.
+ *
+ * @param ex the exception
+ * @param where a description of the context of the exception
+ */
+ private static void debug(Throwable ex, String where) {
+ // Reserved for future logging
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/JdiEventHandler.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,140 @@
+/*
+ * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.jshell.execution;
+
+import java.util.function.Consumer;
+import com.sun.jdi.*;
+import com.sun.jdi.event.*;
+
+/**
+ * Handler of Java Debug Interface events.
+ * Adapted from jdb EventHandler.
+ * Only exit and disconnect events processed.
+ */
+class JdiEventHandler implements Runnable {
+
+ private final Thread thread;
+ private volatile boolean connected = true;
+ private boolean completed = false;
+ private final VirtualMachine vm;
+ private final Consumer<String> reportVMExit;
+
+ /**
+ * Creates an event handler. Start with {@code start()}.
+ *
+ * @param vm the virtual machine for which to handle events
+ * @param reportVMExit callback to report exit/disconnect
+ * (passed true if the VM has died)
+ */
+ JdiEventHandler(VirtualMachine vm, Consumer<String> reportVMExit) {
+ this.vm = vm;
+ this.reportVMExit = reportVMExit;
+ this.thread = new Thread(this, "event-handler");
+ this.thread.setDaemon(true);
+ }
+
+ /**
+ * Starts the event handler.
+ */
+ void start() {
+ thread.start();
+ }
+
+ synchronized void shutdown() {
+ connected = false; // force run() loop termination
+ thread.interrupt();
+ while (!completed) {
+ try {wait();} catch (InterruptedException exc) {}
+ }
+ }
+
+ @Override
+ public void run() {
+ EventQueue queue = vm.eventQueue();
+ while (connected) {
+ try {
+ EventSet eventSet = queue.remove();
+ boolean resumeStoppedApp = false;
+ EventIterator it = eventSet.eventIterator();
+ while (it.hasNext()) {
+ resumeStoppedApp |= handleEvent(it.nextEvent());
+ }
+
+ if (resumeStoppedApp) {
+ eventSet.resume();
+ }
+ } catch (InterruptedException exc) {
+ // Do nothing. Any changes will be seen at top of loop.
+ } catch (VMDisconnectedException discExc) {
+ handleDisconnectedException();
+ break;
+ }
+ }
+ synchronized (this) {
+ completed = true;
+ notifyAll();
+ }
+ }
+
+ private boolean handleEvent(Event event) {
+ handleExitEvent(event);
+ return true;
+ }
+
+ private void handleExitEvent(Event event) {
+ if (event instanceof VMDeathEvent) {
+ reportVMExit.accept("VM Died");
+ } else if (event instanceof VMDisconnectEvent) {
+ connected = false;
+ reportVMExit.accept("VM Disconnected");
+ } else {
+ // ignore everything else
+ }
+ }
+
+ private synchronized void handleDisconnectedException() {
+ /*
+ * A VMDisconnectedException has happened while dealing with
+ * another event. We need to flush the event queue, dealing only
+ * with exit events (VMDeath, VMDisconnect) so that we terminate
+ * correctly.
+ */
+ EventQueue queue = vm.eventQueue();
+ while (connected) {
+ try {
+ EventSet eventSet = queue.remove();
+ EventIterator iter = eventSet.eventIterator();
+ while (iter.hasNext()) {
+ handleExitEvent(iter.next());
+ }
+ } catch (InterruptedException exc) {
+ // ignore
+ } catch (InternalError exc) {
+ // ignore
+ }
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/JdiExecutionControl.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.jshell.execution;
+
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Stream;
+import com.sun.jdi.ReferenceType;
+import com.sun.jdi.VirtualMachine;
+import jdk.jshell.spi.ExecutionControl;
+import static java.util.stream.Collectors.toMap;
+
+/**
+ * Abstract JDI implementation of {@link jdk.jshell.spi.ExecutionControl}
+ */
+public abstract class JdiExecutionControl extends StreamingExecutionControl implements ExecutionControl {
+
+ /**
+ * Mapping from class names to JDI {@link ReferenceType}.
+ */
+ private final Map<String, ReferenceType> toReferenceType = new HashMap<>();
+
+ /**
+ * Create an instance.
+ * @param out the output from the remote agent
+ * @param in the input to the remote agent
+ */
+ protected JdiExecutionControl(ObjectOutput out, ObjectInput in) {
+ super(out, in);
+ }
+
+ /**
+ * Returns the JDI {@link VirtualMachine} instance.
+ *
+ * @return the virtual machine
+ * @throws EngineTerminationException if the VM is dead/disconnected
+ */
+ protected abstract VirtualMachine vm() throws EngineTerminationException;
+
+ /**
+ * Redefine the specified classes. Where 'redefine' is, as in JDI and JVMTI,
+ * an in-place replacement of the classes (preserving class identity) --
+ * that is, existing references to the class do not need to be recompiled.
+ * This implementation uses JDI
+ * {@link com.sun.jdi.VirtualMachine#redefineClasses(java.util.Map) }.
+ * It will be unsuccessful if
+ * the signature of the class has changed (see the JDI spec). The
+ * JShell-core is designed to adapt to unsuccessful redefine.
+ */
+ @Override
+ public void redefine(ClassBytecodes[] cbcs)
+ throws ClassInstallException, EngineTerminationException {
+ try {
+ // Convert to the JDI ReferenceType to class bytes map form needed
+ // by JDI.
+ VirtualMachine vm = vm();
+ Map<ReferenceType, byte[]> rmp = Stream.of(cbcs)
+ .collect(toMap(
+ cbc -> referenceType(vm, cbc.name()),
+ cbc -> cbc.bytecodes()));
+ // Attempt redefine. Throws exceptions on failure.
+ vm().redefineClasses(rmp);
+ } catch (EngineTerminationException ex) {
+ throw ex;
+ } catch (Exception ex) {
+ throw new ClassInstallException("redefine: " + ex.getMessage(), new boolean[cbcs.length]);
+ }
+ }
+
+ /**
+ * Returns the JDI {@link ReferenceType} corresponding to the specified
+ * class name.
+ *
+ * @param vm the current JDI {@link VirtualMachine} as returned by
+ * {@code vm()}
+ * @param name the class name to look-up
+ * @return the corresponding {@link ReferenceType}
+ */
+ protected ReferenceType referenceType(VirtualMachine vm, String name) {
+ return toReferenceType.computeIfAbsent(name, n -> nameToRef(vm, n));
+ }
+
+ private static ReferenceType nameToRef(VirtualMachine vm, String name) {
+ List<ReferenceType> rtl = vm.classesByName(name);
+ if (rtl.size() != 1) {
+ return null;
+ }
+ return rtl.get(0);
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/JdiInitiator.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,223 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package jdk.jshell.execution;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import com.sun.jdi.Bootstrap;
+import com.sun.jdi.VirtualMachine;
+import com.sun.jdi.connect.Connector;
+import com.sun.jdi.connect.LaunchingConnector;
+import com.sun.jdi.connect.ListeningConnector;
+
+/**
+ * Sets up a JDI connection, providing the resulting JDI {@link VirtualMachine}
+ * and the {@link Process} the remote agent is running in.
+ */
+public class JdiInitiator {
+
+ private VirtualMachine vm;
+ private Process process = null;
+ private final Connector connector;
+ private final String remoteAgent;
+ private final Map<String, com.sun.jdi.connect.Connector.Argument> connectorArgs;
+
+ /**
+ * Start the remote agent and establish a JDI connection to it.
+ *
+ * @param port the socket port for (non-JDI) commands
+ * @param remoteVMOptions any user requested VM options
+ * @param remoteAgent full class name of remote agent to launch
+ * @param isLaunch does JDI do the launch? That is, LaunchingConnector,
+ * otherwise we start explicitly and use ListeningConnector
+ * @param host explicit hostname to use, if null use discovered
+ * hostname, applies to listening only (!isLaunch)
+ */
+ public JdiInitiator(int port, List<String> remoteVMOptions, String remoteAgent,
+ boolean isLaunch, String host) {
+ this.remoteAgent = remoteAgent;
+ String connectorName
+ = isLaunch
+ ? "com.sun.jdi.CommandLineLaunch"
+ : "com.sun.jdi.SocketListen";
+ this.connector = findConnector(connectorName);
+ if (connector == null) {
+ throw new IllegalArgumentException("No connector named: " + connectorName);
+ }
+ Map<String, String> argumentName2Value
+ = isLaunch
+ ? launchArgs(port, String.join(" ", remoteVMOptions))
+ : new HashMap<>();
+ if (host != null && !isLaunch) {
+ argumentName2Value.put("localAddress", host);
+ }
+ this.connectorArgs = mergeConnectorArgs(connector, argumentName2Value);
+ this.vm = isLaunch
+ ? launchTarget()
+ : listenTarget(port, remoteVMOptions);
+
+ }
+
+ /**
+ * Returns the resulting {@code VirtualMachine} instance.
+ *
+ * @return the virtual machine
+ */
+ public VirtualMachine vm() {
+ return vm;
+ }
+
+ /**
+ * Returns the launched process.
+ *
+ * @return the remote agent process
+ */
+ public Process process() {
+ return process;
+ }
+
+ /* launch child target vm */
+ private VirtualMachine launchTarget() {
+ LaunchingConnector launcher = (LaunchingConnector) connector;
+ try {
+ VirtualMachine new_vm = launcher.launch(connectorArgs);
+ process = new_vm.process();
+ return new_vm;
+ } catch (Exception ex) {
+ reportLaunchFail(ex, "launch");
+ }
+ return null;
+ }
+
+ /**
+ * Directly launch the remote agent and connect JDI to it with a
+ * ListeningConnector.
+ */
+ private VirtualMachine listenTarget(int port, List<String> remoteVMOptions) {
+ ListeningConnector listener = (ListeningConnector) connector;
+ try {
+ // Start listening, get the JDI connection address
+ String addr = listener.startListening(connectorArgs);
+ debug("Listening at address: " + addr);
+
+ // Launch the RemoteAgent requesting a connection on that address
+ String javaHome = System.getProperty("java.home");
+ List<String> args = new ArrayList<>();
+ args.add(javaHome == null
+ ? "java"
+ : javaHome + File.separator + "bin" + File.separator + "java");
+ args.add("-agentlib:jdwp=transport=" + connector.transport().name() +
+ ",address=" + addr);
+ args.addAll(remoteVMOptions);
+ args.add(remoteAgent);
+ args.add("" + port);
+ ProcessBuilder pb = new ProcessBuilder(args);
+ process = pb.start();
+
+ // Forward out, err, and in
+ // Accept the connection from the remote agent
+ vm = listener.accept(connectorArgs);
+ listener.stopListening(connectorArgs);
+ return vm;
+ } catch (Exception ex) {
+ reportLaunchFail(ex, "listen");
+ }
+ return null;
+ }
+
+ private Connector findConnector(String name) {
+ for (Connector cntor
+ : Bootstrap.virtualMachineManager().allConnectors()) {
+ if (cntor.name().equals(name)) {
+ return cntor;
+ }
+ }
+ return null;
+ }
+
+ private Map<String, Connector.Argument> mergeConnectorArgs(Connector connector, Map<String, String> argumentName2Value) {
+ Map<String, Connector.Argument> arguments = connector.defaultArguments();
+
+ for (Entry<String, String> argumentEntry : argumentName2Value.entrySet()) {
+ String name = argumentEntry.getKey();
+ String value = argumentEntry.getValue();
+ Connector.Argument argument = arguments.get(name);
+
+ if (argument == null) {
+ throw new IllegalArgumentException("Argument is not defined for connector:" +
+ name + " -- " + connector.name());
+ }
+
+ argument.setValue(value);
+ }
+
+ return arguments;
+ }
+
+ /**
+ * The JShell specific Connector args for the LaunchingConnector.
+ *
+ * @param portthe socket port for (non-JDI) commands
+ * @param remoteVMOptions any user requested VM options
+ * @return the argument map
+ */
+ private Map<String, String> launchArgs(int port, String remoteVMOptions) {
+ Map<String, String> argumentName2Value = new HashMap<>();
+ argumentName2Value.put("main", remoteAgent + " " + port);
+ argumentName2Value.put("options", remoteVMOptions);
+ return argumentName2Value;
+ }
+
+ private void reportLaunchFail(Exception ex, String context) {
+ throw new InternalError("Failed remote " + context + ": " + connector +
+ " -- " + connectorArgs, ex);
+ }
+
+ /**
+ * Log debugging information. Arguments as for {@code printf}.
+ *
+ * @param format a format string as described in Format string syntax
+ * @param args arguments referenced by the format specifiers in the format
+ * string.
+ */
+ private void debug(String format, Object... args) {
+ // Reserved for future logging
+ }
+
+ /**
+ * Log a serious unexpected internal exception.
+ *
+ * @param ex the exception
+ * @param where a description of the context of the exception
+ */
+ private void debug(Throwable ex, String where) {
+ // Reserved for future logging
+ }
+
+}
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/RemoteExecutionControl.java Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/RemoteExecutionControl.java Wed Nov 09 10:04:43 2016 -0800
@@ -41,7 +41,7 @@
* process). This agent loads code over a socket from the main JShell process,
* executes the code, and other misc, Specialization of
* {@link DirectExecutionControl} which adds stop support controlled by
- * an external process. Designed to work with {@link JDIDefaultExecutionControl}.
+ * an external process. Designed to work with {@link JdiDefaultExecutionControl}.
*
* @author Jan Lahoda
* @author Robert Field
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/Util.java Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/Util.java Wed Nov 09 10:04:43 2016 -0800
@@ -239,9 +239,9 @@
* @param unbiddenExitHandler the handler, which will accept the exit
* information
*/
- public static void detectJDIExitEvent(VirtualMachine vm, Consumer<String> unbiddenExitHandler) {
+ public static void detectJdiExitEvent(VirtualMachine vm, Consumer<String> unbiddenExitHandler) {
if (vm.canBeModified()) {
- new JDIEventHandler(vm, unbiddenExitHandler).start();
+ new JdiEventHandler(vm, unbiddenExitHandler).start();
}
}
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/spi/ExecutionControl.java Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/spi/ExecutionControl.java Wed Nov 09 10:04:43 2016 -0800
@@ -44,12 +44,13 @@
* To install an {@code ExecutionControl}, its {@code Generator} is passed to
* {@link jdk.jshell.JShell.Builder#executionEngine(ExecutionControl.Generator) }.
*/
-public interface ExecutionControl {
+public interface ExecutionControl extends AutoCloseable {
/**
* Defines a functional interface for creating {@link ExecutionControl}
* instances.
*/
+ @FunctionalInterface
public interface Generator {
/**
--- a/langtools/src/jdk.jshell/share/classes/module-info.java Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/src/jdk.jshell/share/classes/module-info.java Wed Nov 09 10:04:43 2016 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -30,14 +30,16 @@
*/
module jdk.jshell {
requires public java.compiler;
- requires java.desktop;
requires java.prefs;
requires jdk.compiler;
requires jdk.internal.le;
+ requires jdk.internal.ed;
requires jdk.internal.opt;
requires jdk.jdi;
exports jdk.jshell;
exports jdk.jshell.spi;
exports jdk.jshell.execution;
+
+ uses jdk.internal.editor.spi.BuildInEditorProvider;
}
--- a/langtools/test/Makefile Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/test/Makefile Wed Nov 09 10:04:43 2016 -0800
@@ -253,7 +253,7 @@
# Is the test JVM 32-bit?
DATA_MODEL := \
- $(shell $(JT_JAVA)/bin/java -XshowSettings:properties -version 2>&1 | \
+ $(shell $(TESTJAVA)/bin/java -XshowSettings:properties -version 2>&1 | \
grep 'sun\.arch\.data\.model' | \
awk '{print $$3}')
ifeq ($(DATA_MODEL), 32)
--- a/langtools/test/ProblemList.txt Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/test/ProblemList.txt Wed Nov 09 10:04:43 2016 -0800
@@ -55,6 +55,7 @@
tools/javac/annotations/typeAnnotations/referenceinfos/NestedTypes.java 8057687 generic-all emit correct byte code an attributes for type annotations
tools/javac/warnings/suppress/TypeAnnotations.java 8057683 generic-all improve ordering of errors with type annotations
tools/javac/modules/T8159439/NPEForModuleInfoWithNonZeroSuperClassTest.java 8160396 generic-all current version of jtreg needs a new promotion to include lastes version of ASM
+tools/javac/T8132562/ClassPathWithDoubleQuotesTest.java 8169005 windows-all
###########################################################################
#
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/internal/shellsupport/doc/JavadocFormatterTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,393 @@
+/*
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8131019
+ * @summary Test JavadocFormatter
+ * @library /tools/lib
+ * @modules jdk.compiler/jdk.internal.shellsupport.doc
+ * @run testng JavadocFormatterTest
+ */
+
+import java.util.Objects;
+
+import jdk.internal.shellsupport.doc.JavadocFormatter;
+import org.testng.annotations.Test;
+
+@Test
+public class JavadocFormatterTest {
+
+ private static final String CODE_RESET = "\033[0m";
+ private static final String CODE_HIGHLIGHT = "\033[1m";
+ private static final String CODE_UNDERLINE = "\033[4m";
+
+ public void testReflow() {
+ String actual;
+ String expected;
+
+ actual = new JavadocFormatter(25, true).formatJavadoc(
+ "test",
+ "1234 1234\n1234\n1234 12345 123456789012345678901234567890 1234 1234\n1234 {@code 1234} 1234 1234\n1234 1234 123456 123456\n<b>123456</b>\n123456 123456 {@link String string} 1");
+
+ expected = CODE_HIGHLIGHT + "test" + CODE_RESET + "\n" +
+ "1234 1234 1234 1234 12345\n" +
+ "123456789012345678901234567890\n" +
+ "1234 1234 1234 1234 1234\n" +
+ "1234 1234 1234 123456\n" +
+ "123456 123456 123456\n" +
+ "123456 string 1\n";
+
+ if (!Objects.equals(actual, expected)) {
+ throw new AssertionError("Incorrect output: " + actual);
+ }
+
+ actual = new JavadocFormatter(66, true).formatJavadoc("test",
+ "@param <T> 51234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234\n" +
+ "@param <E> 61234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234\n" +
+ "@param shortName 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 " +
+ "1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234" +
+ " 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234" +
+ " 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 \n" +
+ "@param aVeryLongName1234567890123456789012345678901234567890 " +
+ "1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 " +
+ "1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 " +
+ " 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234" +
+ " 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 \n");
+
+ expected = CODE_HIGHLIGHT + "test" + CODE_RESET + "\n" +
+ "\n" +
+ CODE_UNDERLINE + "Type Parameters:" + CODE_RESET + "\n" +
+ "T - 51234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234\n" +
+ "E - 61234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234\n" +
+ "\n" +
+ CODE_UNDERLINE + "Parameters:" + CODE_RESET + "\n" +
+ "shortName - 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234\n" +
+ " 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234\n" +
+ " 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234\n" +
+ " 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234\n" +
+ " 1234 1234 1234 1234\n" +
+ "aVeryLongName1234567890123456789012345678901234567890 - \n" +
+ " 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234\n" +
+ " 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234\n" +
+ " 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234\n" +
+ " 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234\n";
+
+ if (!Objects.equals(actual, expected)) {
+ throw new AssertionError("Incorrect output: " + actual);
+ }
+
+ actual = new JavadocFormatter(66, true).formatJavadoc("test",
+ "@throws ShortExcp 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 " +
+ "1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234" +
+ " 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234" +
+ " 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 \n" +
+ "@throws aVeryLongException1234567890123456789012345678901234567890 " +
+ "1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 " +
+ "1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 " +
+ " 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234" +
+ " 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 \n");
+
+ expected = CODE_HIGHLIGHT + "test" + CODE_RESET + "\n" +
+ "\n" +
+ CODE_UNDERLINE + "Thrown Exceptions:" + CODE_RESET + "\n" +
+ "ShortExcp - 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234\n" +
+ " 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234\n" +
+ " 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234\n" +
+ " 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234\n" +
+ " 1234 1234 1234 1234\n" +
+ "aVeryLongException1234567890123456789012345678901234567890 - \n" +
+ " 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234\n" +
+ " 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234\n" +
+ " 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234\n" +
+ " 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234\n";
+
+ if (!Objects.equals(actual, expected)) {
+ throw new AssertionError("Incorrect output: " + actual);
+ }
+ actual = new JavadocFormatter(66, true).formatJavadoc("test",
+ "@return 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 " +
+ "1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234" +
+ " 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234" +
+ " 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 \n");
+
+ expected = CODE_HIGHLIGHT + "test" + CODE_RESET + "\n" +
+ "\n" +
+ CODE_UNDERLINE + "Returns:" + CODE_RESET + "\n" +
+ "1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234\n" +
+ "1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234\n" +
+ "1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234\n" +
+ "1234 1234 1234 1234 1234 1234 1234 1234 1234\n";
+
+ if (!Objects.equals(actual, expected)) {
+ throw new AssertionError("Incorrect output: " + actual);
+ }
+
+ //handling of <p>, <pre>:
+ actual = new JavadocFormatter(66, true).formatJavadoc("test",
+ "1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 " +
+ "1234 1234 1234 1234 1234 <p>1234 1234 <p>1234 1234 1234 1234 1234 " +
+ "1234 1234 1234 1234 1234 1234 1234 1234 <p>1234 1234 1234 1234 " +
+ "1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 \n" +
+ "<blockquote><pre>\n" +
+ "for (String data : content) {\n" +
+ " System.err.println(data);\n" +
+ "}\n" +
+ "</pre></blockquote>\n");
+
+ expected = CODE_HIGHLIGHT + "test" + CODE_RESET + "\n" +
+ "1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234\n" +
+ "1234 1234 1234 1234\n" +
+ "1234 1234\n" +
+ "1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234\n" +
+ "1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234\n" +
+ "1234 1234 1234\n" +
+ " for (String data : content) {\n" +
+ " System.err.println(data);\n" +
+ " }\n" +
+ " \n";
+
+ if (!Objects.equals(actual, expected)) {
+ throw new AssertionError("Incorrect output: " + actual);
+ }
+
+ //list handling:
+ actual = new JavadocFormatter(66, true).formatJavadoc("test",
+ "<ul>" +
+ " <li>A 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234</li>" +
+ " <li>B 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234" +
+ " <li>C 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234<ol>" +
+ " <li>D 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234</li>" +
+ " <li>E 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234<ul>" +
+ " <li>F 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234<ol>" +
+ " <li>G 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234" +
+ " </ol>" +
+ " </ul>" +
+ " </OL>" +
+ " <LI><p>H 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 <p>1234 1234 1234 1234 1234 1234 1234<ul>" +
+ " <li>I 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234" +
+ " </ul>" +
+ "</ul> followup" +
+ "<dl>" +
+ "<dt>Term1</dt>" +
+ "<dd>A 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234</dd>" +
+ "<dt>Term2" +
+ "<dd>B 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234" +
+ "<dt>Term3" +
+ "<dd>C 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234" +
+ "</dl>" +
+ "<dl>" +
+ "<dt>TermUnfinished" +
+ "</dl> followup");
+
+ expected = CODE_HIGHLIGHT + "test" + CODE_RESET + "\n" +
+ " * A 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234\n" +
+ " 1234 1234 1234 1234 1234\n" +
+ " * B 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234\n" +
+ " 1234 1234 1234 1234 1234\n" +
+ " * C 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234\n" +
+ " 1234 1234 1234 1234 1234\n" +
+ " 1. D 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234\n" +
+ " 1234 1234 1234 1234 1234 1234\n" +
+ " 2. E 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234\n" +
+ " 1234 1234 1234 1234 1234 1234\n" +
+ " * F 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234\n" +
+ " 1234 1234 1234 1234 1234 1234 1234\n" +
+ " 1. G 1234 1234 1234 1234 1234 1234 1234 1234 1234\n" +
+ " 1234 1234 1234 1234 1234 1234 1234 1234\n" +
+ " * H 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234\n" +
+ " 1234 1234 1234 1234 1234 1234 1234\n" +
+ " * I 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234\n" +
+ " 1234 1234 1234 1234 1234 1234\n" +
+ "followup\n" +
+ CODE_HIGHLIGHT + "Term1" + CODE_RESET + "\n" +
+ " A 1234 1234 1234 1234 1234 1234 1234 1234 1234\n" +
+ " 1234 1234 1234 1234 1234 1234 1234 1234\n" +
+ CODE_HIGHLIGHT + "Term2" + CODE_RESET + "\n" +
+ " B 1234 1234 1234 1234 1234 1234 1234 1234 1234\n" +
+ " 1234 1234 1234 1234 1234 1234 1234 1234\n" +
+ CODE_HIGHLIGHT + "Term3" + CODE_RESET + "\n" +
+ " C 1234 1234 1234 1234 1234 1234 1234 1234 1234\n" +
+ " 1234 1234 1234 1234 1234 1234 1234 1234\n" +
+ CODE_HIGHLIGHT + "TermUnfinished" + CODE_RESET + "\n" +
+ "followup\n";
+
+ if (!Objects.equals(actual, expected)) {
+ throw new AssertionError("Incorrect output: " + actual);
+ }
+
+ //sections:
+ actual = new JavadocFormatter(66, true).formatJavadoc("test",
+ "text 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 " +
+ "1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 " +
+ "<h3>1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234</h3>" +
+ "1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 " +
+ "1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234");
+
+ expected = CODE_HIGHLIGHT + "test" + CODE_RESET + "\n" +
+ "text 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234\n" +
+ "1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234\n" +
+ "1234 1234 1234 1234 1234 1234 1234 1234 1234\n" +
+ "\n" +
+ CODE_UNDERLINE + "1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234\n" +
+ "1234 1234 1234 1234 1234" + CODE_RESET + "\n" +
+ "1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234\n" +
+ "1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234\n" +
+ "1234 1234 1234 1234 1234 1234 1234 1234\n";
+
+ if (!Objects.equals(actual, expected)) {
+ throw new AssertionError("Incorrect output: " + actual);
+ }
+
+ //table:
+ actual = new JavadocFormatter(66, true).formatJavadoc("test",
+ "<table>" +
+ "<tr>" +
+ "<th>A 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234</th>" +
+ "<th>B 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234</th>" +
+ "<th>C 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234</th>" +
+ "</tr>" +
+ "<tr>" +
+ "<td>A 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234</td> \n" +
+ "<td>B 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234" +
+ "<td>C 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234" +
+ "<tr>" +
+ "<td>A 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234</td>" +
+ "<td>B 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234</td>" +
+ "<td>C 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234</td>" +
+ "</tr>" +
+ "<tr>" +
+ "<td>1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234</td>" +
+ "<td>1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234</td>" +
+ "</table>");
+
+ expected = CODE_HIGHLIGHT + "test" + CODE_RESET + "\n" +
+ "----------------------------------------------------------------\n" +
+ "| " + CODE_HIGHLIGHT + "A 1234 1234 1234" + CODE_RESET + " | " + CODE_HIGHLIGHT + "B 1234 1234 1234" + CODE_RESET + " | " + CODE_HIGHLIGHT + "C 1234 1234 1234" + CODE_RESET + " |\n" +
+ "| " + CODE_HIGHLIGHT + "1234 1234 1234" + CODE_RESET + " | " + CODE_HIGHLIGHT + "1234 1234 1234" + CODE_RESET + " | " + CODE_HIGHLIGHT + "1234 1234 1234" + CODE_RESET + " |\n" +
+ "| " + CODE_HIGHLIGHT + "1234 1234 1234" + CODE_RESET + " | " + CODE_HIGHLIGHT + "1234 1234 1234" + CODE_RESET + " | " + CODE_HIGHLIGHT + "1234 1234 1234" + CODE_RESET + " |\n" +
+ "| " + CODE_HIGHLIGHT + "1234 1234 1234" + CODE_RESET + " | " + CODE_HIGHLIGHT + "1234 1234 1234" + CODE_RESET + " | " + CODE_HIGHLIGHT + "1234 1234 1234" + CODE_RESET + " |\n" +
+ "| " + CODE_HIGHLIGHT + "1234 1234 1234" + CODE_RESET + " | " + CODE_HIGHLIGHT + "1234 1234 1234" + CODE_RESET + " | " + CODE_HIGHLIGHT + "1234 1234 1234" + CODE_RESET + " |\n" +
+ "| " + CODE_HIGHLIGHT + "1234 1234" + CODE_RESET + " | " + CODE_HIGHLIGHT + "1234 1234" + CODE_RESET + " | " + CODE_HIGHLIGHT + "1234 1234" + CODE_RESET + " |\n" +
+ "----------------------------------------------------------------\n" +
+ "| A 1234 1234 1234 | B 1234 1234 1234 | C 1234 1234 1234 |\n" +
+ "| 1234 1234 1234 | 1234 1234 1234 | 1234 1234 1234 |\n" +
+ "| 1234 1234 1234 | 1234 1234 1234 | 1234 1234 1234 |\n" +
+ "| 1234 1234 1234 | 1234 1234 1234 | 1234 1234 1234 |\n" +
+ "| 1234 1234 1234 | 1234 1234 1234 | 1234 1234 1234 |\n" +
+ "| 1234 1234 | 1234 1234 | 1234 1234 |\n" +
+ "----------------------------------------------------------------\n" +
+ "| A 1234 1234 1234 | B 1234 1234 1234 | C 1234 1234 1234 |\n" +
+ "| 1234 1234 1234 | 1234 1234 1234 | 1234 1234 1234 |\n" +
+ "| 1234 1234 1234 | 1234 1234 1234 | 1234 1234 1234 |\n" +
+ "| 1234 1234 1234 | 1234 1234 1234 | 1234 1234 1234 |\n" +
+ "| 1234 1234 1234 | 1234 1234 1234 | 1234 1234 1234 |\n" +
+ "| 1234 1234 | 1234 1234 | 1234 1234 |\n" +
+ "----------------------------------------------------------------\n" +
+ "| 1234 1234 1234 | 1234 1234 1234 |\n" +
+ "| 1234 1234 1234 | 1234 1234 1234 |\n" +
+ "| 1234 1234 1234 | 1234 1234 1234 |\n" +
+ "| 1234 1234 1234 | 1234 1234 1234 |\n" +
+ "| 1234 1234 1234 | 1234 1234 1234 |\n" +
+ "| 1234 1234 | 1234 1234 |\n" +
+ "-------------------------------------------\n";
+
+ if (!Objects.equals(actual, expected)) {
+ throw new AssertionError("Incorrect output: " + actual);
+ }
+
+ //no escape sequences:
+ actual = new JavadocFormatter(66, false).formatJavadoc("test",
+ "@param shortName 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 " +
+ "1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234" +
+ " 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234" +
+ " 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 \n" +
+ "@param aVeryLongName1234567890123456789012345678901234567890 " +
+ "1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 " +
+ "1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 " +
+ " 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234" +
+ " 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 \n");
+
+ expected = "test\n" +
+ "\n" +
+ "Parameters:\n" +
+ "shortName - 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234\n" +
+ " 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234\n" +
+ " 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234\n" +
+ " 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234\n" +
+ " 1234 1234 1234 1234\n" +
+ "aVeryLongName1234567890123456789012345678901234567890 - \n" +
+ " 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234\n" +
+ " 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234\n" +
+ " 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234\n" +
+ " 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234\n";
+
+ if (!Objects.equals(actual, expected)) {
+ throw new AssertionError("Incorrect output: " + actual);
+ }
+
+ //null javadoc:
+ actual = new JavadocFormatter(66, true).formatJavadoc("test", null);
+
+ expected = CODE_HIGHLIGHT + "test" + CODE_RESET + "\n";
+
+ if (!Objects.equals(actual, expected)) {
+ throw new AssertionError("Incorrect output: " + actual);
+ }
+
+ //stray tags:
+ for (String tag : new String[] {"li", "ol", "h3", "table", "tr", "td", "dl", "dt", "dd"}) {
+ for (boolean closing : new boolean[] {false, true}) {
+ actual = new JavadocFormatter(66, true).formatJavadoc("test",
+ "<" + (closing ? "/" : "") + tag + ">text");
+
+ if (!actual.contains("text")) {
+ throw new AssertionError("Incorrect output: " + actual);
+ }
+ }
+ }
+
+ //entities:
+ actual = new JavadocFormatter(66, false).formatJavadoc("test",
+ "α < A B > &broken; � �\n");
+
+ expected = "test\n" +
+ "\u03b1 < A B > &broken; � �\n";
+
+ if (!Objects.equals(actual, expected)) {
+ throw new AssertionError("Incorrect output: " + actual);
+ }
+
+ //img:
+ actual = new JavadocFormatter(66, true).formatJavadoc("test",
+ "1234 <img src='any.png' alt='text'/> 1234");
+
+ expected = CODE_HIGHLIGHT + "test" + CODE_RESET + "\n" +
+ "1234 text 1234\n";
+
+ if (!Objects.equals(actual, expected)) {
+ throw new AssertionError("Incorrect output: " + actual);
+ }
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/internal/shellsupport/doc/JavadocHelperTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,296 @@
+/*
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8131019
+ * @summary Test JavadocHelper
+ * @library /tools/lib
+ * @modules jdk.compiler/com.sun.tools.javac.api
+ * jdk.compiler/com.sun.tools.javac.main
+ * jdk.compiler/jdk.internal.shellsupport.doc
+ * @build toolbox.ToolBox toolbox.JarTask toolbox.JavacTask
+ * @run testng JavadocHelperTest
+ */
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Arrays;
+import java.util.function.Function;
+import java.util.jar.JarEntry;
+import java.util.jar.JarOutputStream;
+
+import javax.lang.model.element.Element;
+import javax.lang.model.util.ElementFilter;
+import javax.tools.Diagnostic.Kind;
+import javax.tools.DiagnosticListener;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.StandardLocation;
+import javax.tools.ToolProvider;
+
+import com.sun.source.util.JavacTask;
+import jdk.internal.shellsupport.doc.JavadocHelper;
+import org.testng.annotations.Test;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
+@Test
+public class JavadocHelperTest {
+
+ public void testJavadoc() throws Exception {
+ doTestJavadoc("",
+ t -> t.getElements().getTypeElement("test.Super"),
+ "Top level. ");
+ doTestJavadoc("",
+ t -> getFirstMethod(t, "test.Super"),
+ " javadoc1A\n" +
+ "\n" +
+ " @param p1 param1A\n" +
+ " @param p2 param2A\n" +
+ " @param p3 param3A\n" +
+ " @throws IllegalStateException exc1A\n" +
+ " @throws IllegalArgumentException exc2A\n" +
+ " @throws IllegalAccessException exc3A\n" +
+ " @return valueA\n");
+ }
+
+ private Element getFirstMethod(JavacTask task, String typeName) {
+ return ElementFilter.methodsIn(task.getElements().getTypeElement(typeName).getEnclosedElements()).get(0);
+ }
+
+ private Function<JavacTask, Element> getSubTest = t -> getFirstMethod(t, "test.Sub");
+
+ public void testInheritNoJavadoc() throws Exception {
+ doTestJavadoc("",
+ getSubTest,
+ " javadoc1A\n" +
+ "\n" +
+ " @param p1 param1A\n" +
+ " @param p2 param2A\n" +
+ " @param p3 param3A\n" +
+ " @throws IllegalStateException exc1A\n" +
+ " @throws IllegalArgumentException exc2A\n" +
+ " @throws IllegalAccessException exc3A\n" +
+ " @return valueA\n");
+ }
+
+ public void testInheritFull() throws Exception {
+ doTestJavadoc(" /**\n" +
+ " * Prefix {@inheritDoc} suffix.\n" +
+ " *\n" +
+ " * @param p1 prefix {@inheritDoc} suffix\n" +
+ " * @param p2 prefix {@inheritDoc} suffix\n" +
+ " * @param p3 prefix {@inheritDoc} suffix\n" +
+ " * @throws IllegalStateException prefix {@inheritDoc} suffix\n" +
+ " * @throws IllegalArgumentException prefix {@inheritDoc} suffix\n" +
+ " * @throws IllegalAccessException prefix {@inheritDoc} suffix\n" +
+ " * @return prefix {@inheritDoc} suffix\n" +
+ " */\n",
+ getSubTest,
+ " Prefix javadoc1 suffix.\n" +
+ "\n" +
+ " @param p1 prefix param1 suffix\n" +
+ " @param p2 prefix param2 suffix\n" +
+ " @param p3 prefix param3 suffix\n" +
+ " @throws IllegalStateException prefix exc1 suffix\n" +
+ " @throws IllegalArgumentException prefix exc2 suffix\n" +
+ " @throws IllegalAccessException prefix exc3 suffix\n" +
+ " @return prefix value suffix\n");
+ }
+
+ public void testInheritMissingParam() throws Exception {
+ doTestJavadoc(" /**\n" +
+ " * Prefix {@inheritDoc} suffix.\n" +
+ " *\n" +
+ " * @param p1 prefix {@inheritDoc} suffix\n" +
+ " * @param p3 prefix {@inheritDoc} suffix\n" +
+ " * @throws IllegalStateException prefix {@inheritDoc} suffix\n" +
+ " * @throws IllegalArgumentException prefix {@inheritDoc} suffix\n" +
+ " * @throws IllegalAccessException prefix {@inheritDoc} suffix\n" +
+ " * @return prefix {@inheritDoc} suffix\n" +
+ " */\n",
+ getSubTest,
+ " Prefix javadoc1 suffix.\n" +
+ "\n" +
+ " @param p1 prefix param1 suffix\n" +
+ "@param p2 param2\n" +
+ " @param p3 prefix param3 suffix\n" +
+ " @throws IllegalStateException prefix exc1 suffix\n" +
+ " @throws IllegalArgumentException prefix exc2 suffix\n" +
+ " @throws IllegalAccessException prefix exc3 suffix\n" +
+ " @return prefix value suffix\n");
+ }
+
+ public void testInheritMissingFirstParam() throws Exception {
+ doTestJavadoc(" /**\n" +
+ " * Prefix {@inheritDoc} suffix.\n" +
+ " *\n" +
+ " * @param p2 prefix {@inheritDoc} suffix\n" +
+ " * @param p3 prefix {@inheritDoc} suffix\n" +
+ " * @throws IllegalStateException prefix {@inheritDoc} suffix\n" +
+ " * @throws IllegalArgumentException prefix {@inheritDoc} suffix\n" +
+ " * @throws IllegalAccessException prefix {@inheritDoc} suffix\n" +
+ " * @return prefix {@inheritDoc} suffix\n" +
+ " */\n",
+ getSubTest,
+ " Prefix javadoc1 suffix.\n" +
+ "@param p1 param1\n" +
+ "\n" +
+ " @param p2 prefix param2 suffix\n" +
+ " @param p3 prefix param3 suffix\n" +
+ " @throws IllegalStateException prefix exc1 suffix\n" +
+ " @throws IllegalArgumentException prefix exc2 suffix\n" +
+ " @throws IllegalAccessException prefix exc3 suffix\n" +
+ " @return prefix value suffix\n");
+ }
+
+ public void testInheritMissingThrows() throws Exception {
+ doTestJavadoc(" /**\n" +
+ " * Prefix {@inheritDoc} suffix.\n" +
+ " *\n" +
+ " * @param p1 prefix {@inheritDoc} suffix\n" +
+ " * @param p2 prefix {@inheritDoc} suffix\n" +
+ " * @param p3 prefix {@inheritDoc} suffix\n" +
+ " * @throws IllegalStateException prefix {@inheritDoc} suffix\n" +
+ " * @throws IllegalAccessException prefix {@inheritDoc} suffix\n" +
+ " * @return prefix {@inheritDoc} suffix\n" +
+ " */\n",
+ getSubTest,
+ " Prefix javadoc1 suffix.\n" +
+ "\n" +
+ " @param p1 prefix param1 suffix\n" +
+ " @param p2 prefix param2 suffix\n" +
+ " @param p3 prefix param3 suffix\n" +
+ " @throws IllegalStateException prefix exc1 suffix\n" +
+ "@throws java.lang.IllegalArgumentException exc2\n" +
+ " @throws IllegalAccessException prefix exc3 suffix\n" +
+ " @return prefix value suffix\n");
+ }
+
+ public void testInheritMissingReturn() throws Exception {
+ doTestJavadoc(" /**\n" +
+ " * Prefix {@inheritDoc} suffix.\n" +
+ " *\n" +
+ " * @param p1 prefix {@inheritDoc} suffix\n" +
+ " * @param p2 prefix {@inheritDoc} suffix\n" +
+ " * @param p3 prefix {@inheritDoc} suffix\n" +
+ " * @throws IllegalStateException prefix {@inheritDoc} suffix\n" +
+ " * @throws IllegalArgumentException prefix {@inheritDoc} suffix\n" +
+ " * @throws IllegalAccessException prefix {@inheritDoc} suffix\n" +
+ " */\n",
+ getSubTest,
+ " Prefix javadoc1 suffix.\n" +
+ "\n" +
+ " @param p1 prefix param1 suffix\n" +
+ " @param p2 prefix param2 suffix\n" +
+ " @param p3 prefix param3 suffix\n" +
+ " @throws IllegalStateException prefix exc1 suffix\n" +
+ " @throws IllegalArgumentException prefix exc2 suffix\n" +
+ " @throws IllegalAccessException prefix exc3 suffix\n" +
+ "@return value\n");
+ }
+
+
+ private void doTestJavadoc(String origJavadoc, Function<JavacTask, Element> getElement, String expectedJavadoc) throws Exception {
+ JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
+ String subClass =
+ "package test;\n" +
+ "public class Sub extends Super {\n" +
+ origJavadoc +
+ " public String test(int p1, int p2, int p3) throws IllegalStateException, IllegalArgumentException, IllegalAccessException { return null;} \n" +
+ "}\n";
+ String superClass =
+ "package test;\n" +
+ "/**Top level." +
+ " */\n" +
+ "public class Super {\n" +
+ " /**\n" +
+ " * javadoc1A\n" +
+ " *\n" +
+ " * @param p1 param1A\n" +
+ " * @param p2 param2A\n" +
+ " * @param p3 param3A\n" +
+ " * @throws IllegalStateException exc1A\n" +
+ " * @throws IllegalArgumentException exc2A\n" +
+ " * @throws IllegalAccessException exc3A\n" +
+ " * @return valueA\n" +
+ " */\n" +
+ " public String test(int p1, int p2, int p3) throws IllegalStateException, IllegalArgumentException, IllegalAccessException { return null;} \n" +
+ "}\n";
+
+ Path srcZip = Paths.get("src.zip");
+
+ try (JarOutputStream out = new JarOutputStream(Files.newOutputStream(srcZip))) {
+ out.putNextEntry(new JarEntry("test/Sub.java"));
+ out.write(subClass.getBytes());
+ out.putNextEntry(new JarEntry("test/Super.java"));
+ out.write(superClass.getBytes());
+ } catch (IOException ex) {
+ throw new IllegalStateException(ex);
+ }
+
+ DiagnosticListener<? super JavaFileObject> noErrors = d -> {
+ if (d.getKind() == Kind.ERROR) {
+ throw new AssertionError(d.getMessage(null));
+ }
+ };
+
+ assertTrue(compiler.getTask(null, null, noErrors, Arrays.asList("-d", "."), null, Arrays.asList(new JFOImpl("Super", superClass), new JFOImpl("Sub", subClass))).call());
+
+ try (StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null)) {
+ fm.setLocationFromPaths(StandardLocation.CLASS_PATH, Arrays.asList(Paths.get(".").toAbsolutePath()));
+ JavacTask task = (JavacTask) compiler.getTask(null, fm, noErrors, null, null, null);
+
+ Element el = getElement.apply(task);
+
+ try (JavadocHelper helper = JavadocHelper.create(task, Arrays.asList(srcZip))) {
+ String javadoc = helper.getResolvedDocComment(el);
+
+ assertEquals(javadoc, expectedJavadoc);
+ }
+ }
+ }
+
+ private static final class JFOImpl extends SimpleJavaFileObject {
+
+ private final String code;
+
+ public JFOImpl(String name, String code) throws URISyntaxException {
+ super(new URI("mem:///" + name + ".java"), Kind.SOURCE);
+ this.code = code;
+ }
+
+ @Override
+ public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException {
+ return code;
+ }
+
+ }
+}
--- a/langtools/test/jdk/jshell/ClassMembersTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/test/jdk/jshell/ClassMembersTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -38,6 +38,9 @@
import jdk.jshell.SourceCodeAnalysis;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
+import jdk.jshell.TypeDeclSnippet;
+import static jdk.jshell.Snippet.Status.OVERWRITTEN;
+import static jdk.jshell.Snippet.Status.VALID;
public class ClassMembersTest extends KullaTesting {
@@ -141,29 +144,36 @@
new ExpectedDiagnostic("compiler.err.non-static.cant.be.ref", 0, 8, 1, -1, -1, Diagnostic.Kind.ERROR));
}
- @Test(enabled = false) // TODO 8080354
- public void annotationTest() {
+ @Test(dataProvider = "retentionPolicyTestCase")
+ public void annotationTest(RetentionPolicy policy) {
assertEval("import java.lang.annotation.*;");
+ String annotationSource =
+ "@Retention(RetentionPolicy." + policy.toString() + ")\n" +
+ "@interface A {}";
+ assertEval(annotationSource);
+ String classSource =
+ "@A class C {\n" +
+ " @A C() {}\n" +
+ " @A void f() {}\n" +
+ " @A int f;\n" +
+ " @A class Inner {}\n" +
+ "}";
+ assertEval(classSource);
+ String isRuntimeVisible = policy == RetentionPolicy.RUNTIME ? "true" : "false";
+ assertEval("C.class.getAnnotationsByType(A.class).length > 0;", isRuntimeVisible);
+ assertEval("C.class.getDeclaredConstructor().getAnnotationsByType(A.class).length > 0;", isRuntimeVisible);
+ assertEval("C.class.getDeclaredMethod(\"f\").getAnnotationsByType(A.class).length > 0;", isRuntimeVisible);
+ assertEval("C.class.getDeclaredField(\"f\").getAnnotationsByType(A.class).length > 0;", isRuntimeVisible);
+ assertEval("C.Inner.class.getAnnotationsByType(A.class).length > 0;", isRuntimeVisible);
+ }
+
+ @DataProvider(name = "retentionPolicyTestCase")
+ public Object[][] retentionPolicyTestCaseGenerator() {
+ List<Object[]> list = new ArrayList<>();
for (RetentionPolicy policy : RetentionPolicy.values()) {
- String annotationSource =
- "@Retention(RetentionPolicy." + policy.toString() + ")\n" +
- "@interface A {}";
- assertEval(annotationSource);
- String classSource =
- "@A class C {\n" +
- " @A C() {}\n" +
- " @A void f() {}\n" +
- " @A int f;\n" +
- " @A class Inner {}\n" +
- "}";
- assertEval(classSource);
- String isRuntimeVisible = policy == RetentionPolicy.RUNTIME ? "true" : "false";
- assertEval("C.class.getAnnotationsByType(A.class).length > 0;", isRuntimeVisible);
- assertEval("C.class.getDeclaredConstructor().getAnnotationsByType(A.class).length > 0;", isRuntimeVisible);
- assertEval("C.class.getDeclaredMethod(\"f\").getAnnotationsByType(A.class).length > 0;", isRuntimeVisible);
- assertEval("C.class.getDeclaredField(\"f\").getAnnotationsByType(A.class).length > 0;", isRuntimeVisible);
- assertEval("C.Inner.class.getAnnotationsByType(A.class).length > 0;", isRuntimeVisible);
+ list.add(new Object[]{policy});
}
+ return list.toArray(new Object[list.size()][]);
}
@DataProvider(name = "memberTestCase")
--- a/langtools/test/jdk/jshell/ClassesTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/test/jdk/jshell/ClassesTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 8145239
+ * @bug 8145239 8129559 8080354
* @summary Tests for EvaluationState.classes
* @build KullaTesting TestingInputStream ExpectedDiagnostic
* @run testng ClassesTest
@@ -247,14 +247,30 @@
}
public void classesIgnoredModifiers() {
- assertDeclareWarn1("public interface A { }",
- new ExpectedDiagnostic("jdk.eval.warn.illegal.modifiers", 0, 6, 0, -1, -1, Diagnostic.Kind.WARNING));
+ assertEval("public interface A { }");
assertDeclareWarn1("static class B implements A { }",
new ExpectedDiagnostic("jdk.eval.warn.illegal.modifiers", 0, 6, 0, -1, -1, Diagnostic.Kind.WARNING));
assertDeclareWarn1("final interface C extends A { }",
new ExpectedDiagnostic("jdk.eval.warn.illegal.modifiers", 0, 5, 0, -1, -1, Diagnostic.Kind.WARNING));
- assertDeclareWarn1("protected enum D implements C { }",
+ assertActiveKeys();
+ }
+
+ public void classesIgnoredModifiersAnnotation() {
+ assertEval("public @interface X { }");
+ assertEval("@X public interface A { }");
+ assertDeclareWarn1("@X static class B implements A { }",
new ExpectedDiagnostic("jdk.eval.warn.illegal.modifiers", 0, 9, 0, -1, -1, Diagnostic.Kind.WARNING));
+ assertDeclareWarn1("@X final interface C extends A { }",
+ new ExpectedDiagnostic("jdk.eval.warn.illegal.modifiers", 0, 8, 0, -1, -1, Diagnostic.Kind.WARNING));
+ assertActiveKeys();
+ }
+
+ public void classesIgnoredModifiersOtherModifiers() {
+ assertEval("strictfp public interface A { }");
+ assertDeclareWarn1("strictfp static class B implements A { }",
+ new ExpectedDiagnostic("jdk.eval.warn.illegal.modifiers", 0, 15, 0, -1, -1, Diagnostic.Kind.WARNING));
+ assertDeclareWarn1("strictfp final interface C extends A { }",
+ new ExpectedDiagnostic("jdk.eval.warn.illegal.modifiers", 0, 14, 0, -1, -1, Diagnostic.Kind.WARNING));
assertActiveKeys();
}
--- a/langtools/test/jdk/jshell/CompletenessTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/test/jdk/jshell/CompletenessTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 8149524 8131024 8165211 8080071 8130454 8167343
+ * @bug 8149524 8131024 8165211 8080071 8130454 8167343 8129559
* @summary Test SourceCodeAnalysis
* @build KullaTesting TestingInputStream
* @run testng CompletenessTest
@@ -176,6 +176,7 @@
"@interface Anno",
"void f()",
"void f() throws E",
+ "@A(",
};
static final String[] unknown = new String[] {
--- a/langtools/test/jdk/jshell/CompletionSuggestionTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/test/jdk/jshell/CompletionSuggestionTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -23,12 +23,12 @@
/*
* @test
- * @bug 8131025 8141092 8153761 8145263
+ * @bug 8131025 8141092 8153761 8145263 8131019
* @summary Test Completion and Documentation
+ * @library /tools/lib
* @modules jdk.compiler/com.sun.tools.javac.api
* jdk.compiler/com.sun.tools.javac.main
* jdk.jdeps/com.sun.tools.javap
- * @library /tools/lib
* @build toolbox.ToolBox toolbox.JarTask toolbox.JavacTask
* @build KullaTesting TestingInputStream Compiler
* @run testng CompletionSuggestionTest
@@ -305,26 +305,26 @@
public void testDocumentation() throws Exception {
dontReadParameterNamesFromClassFile();
- assertDocumentation("System.getProperty(|",
+ assertSignature("System.getProperty(|",
"String System.getProperty(String key)",
"String System.getProperty(String key, String def)");
assertEval("char[] chars = null;");
- assertDocumentation("new String(chars, |",
+ assertSignature("new String(chars, |",
"String(char[], int, int)");
- assertDocumentation("String.format(|",
+ assertSignature("String.format(|",
"String String.format(String, Object...)",
"String String.format(java.util.Locale, String, Object...)");
- assertDocumentation("\"\".getBytes(\"\"|", "void String.getBytes(int, int, byte[], int)",
+ assertSignature("\"\".getBytes(\"\"|", "void String.getBytes(int, int, byte[], int)",
"byte[] String.getBytes(String) throws java.io.UnsupportedEncodingException",
"byte[] String.getBytes(java.nio.charset.Charset)");
- assertDocumentation("\"\".getBytes(\"\" |", "void String.getBytes(int, int, byte[], int)",
+ assertSignature("\"\".getBytes(\"\" |", "void String.getBytes(int, int, byte[], int)",
"byte[] String.getBytes(String) throws java.io.UnsupportedEncodingException",
"byte[] String.getBytes(java.nio.charset.Charset)");
}
public void testMethodsWithNoArguments() throws Exception {
dontReadParameterNamesFromClassFile();
- assertDocumentation("System.out.println(|",
+ assertSignature("System.out.println(|",
"void java.io.PrintStream.println()",
"void java.io.PrintStream.println(boolean)",
"void java.io.PrintStream.println(char)",
@@ -339,6 +339,7 @@
public void testErroneous() {
assertCompletion("Undefined.|");
+ assertSignature("does.not.exist|");
}
public void testClinit() {
@@ -474,59 +475,63 @@
public void testDocumentationOfUserDefinedMethods() {
assertEval("void f() {}");
- assertDocumentation("f(|", "void f()");
+ assertSignature("f(|", "void f()");
assertEval("void f(int i) {}");
- assertDocumentation("f(|", "void f()", "void f(int i)");
+ assertSignature("f(|", "void f()", "void f(int i)");
assertEval("<T> void f(T... ts) {}", DiagCheck.DIAG_WARNING, DiagCheck.DIAG_OK);
- assertDocumentation("f(|", "void f()", "void f(int i)", "void <T>f(T... ts)");
+ assertSignature("f(|", "void f()", "void f(int i)", "void <T>f(T... ts)");
assertEval("class A {}");
assertEval("void f(A a) {}");
- assertDocumentation("f(|", "void f()", "void f(int i)", "void <T>f(T... ts)", "void f(A a)");
+ assertSignature("f(|", "void f()", "void f(int i)", "void <T>f(T... ts)", "void f(A a)");
+ }
+
+ public void testClass() {
+ assertSignature("String|", "java.lang.String");
}
public void testDocumentationOfUserDefinedConstructors() {
Snippet a = classKey(assertEval("class A {}"));
- assertDocumentation("new A(|", "A()");
+ assertSignature("new A(|", "A()");
Snippet a2 = classKey(assertEval("class A { A() {} A(int i) {}}",
ste(MAIN_SNIPPET, VALID, VALID, true, null),
ste(a, VALID, OVERWRITTEN, false, MAIN_SNIPPET)));
- assertDocumentation("new A(|", "A()", "A(int i)");
+ assertSignature("new A(|", "A()", "A(int i)");
assertEval("class A<T> { A(T a) {} A(int i) {} <U> A(T t, U u) {}}",
ste(MAIN_SNIPPET, VALID, VALID, true, null),
ste(a2, VALID, OVERWRITTEN, false, MAIN_SNIPPET));
- assertDocumentation("new A(|", "A<T>(T a)", "A<T>(int i)", "<U> A<T>(T t, U u)");
+ assertSignature("new A(|", "A<T>(T a)", "A<T>(int i)", "<U> A<T>(T t, U u)");
}
public void testDocumentationOfOverriddenMethods() throws Exception {
dontReadParameterNamesFromClassFile();
- assertDocumentation("\"\".wait(|",
+ assertSignature("\"\".wait(|",
"void Object.wait(long) throws InterruptedException",
"void Object.wait(long, int) throws InterruptedException",
"void Object.wait() throws InterruptedException");
assertEval("class Base {void method() {}}");
Snippet e = classKey(assertEval("class Extend extends Base {}"));
- assertDocumentation("new Extend().method(|", "void Base.method()");
+ assertSignature("new Extend().method(|", "void Base.method()");
assertEval("class Extend extends Base {void method() {}}",
ste(MAIN_SNIPPET, VALID, VALID, true, null),
ste(e, VALID, OVERWRITTEN, false, MAIN_SNIPPET));
- assertDocumentation("new Extend().method(|", "void Extend.method()");
+ assertSignature("new Extend().method(|", "void Extend.method()");
}
public void testDocumentationOfInvisibleMethods() {
- assertDocumentation("Object.wait(|", "");
- assertDocumentation("\"\".indexOfSupplementary(|", "");
+ assertSignature("Object.wait(|");
+ assertSignature("\"\".indexOfSupplementary(|");
Snippet a = classKey(assertEval("class A {void method() {}}"));
- assertDocumentation("A.method(|", "");
+ assertSignature("A.method(|");
assertEval("class A {private void method() {}}",
ste(MAIN_SNIPPET, VALID, VALID, true, null),
ste(a, VALID, OVERWRITTEN, false, MAIN_SNIPPET));
- assertDocumentation("new A().method(|", "");
+ assertSignature("new A().method(|");
}
public void testDocumentationOfInvisibleConstructors() {
- assertDocumentation("new Compiler(|", "");
+ assertSignature("new Compiler(|");
assertEval("class A { private A() {} }");
- assertDocumentation("new A(|", "");
+ assertSignature("new A(|");
}
public void testDocumentationWithBoxing() {
@@ -535,13 +540,13 @@
assertEval("Object object = null;");
assertEval("void method(int n, Object o) { }");
assertEval("void method(Object n, int o) { }");
- assertDocumentation("method(primitive,|",
+ assertSignature("method(primitive,|",
"void method(int n, Object o)",
"void method(Object n, int o)");
- assertDocumentation("method(boxed,|",
+ assertSignature("method(boxed,|",
"void method(int n, Object o)",
"void method(Object n, int o)");
- assertDocumentation("method(object,|",
+ assertSignature("method(object,|",
"void method(Object n, int o)");
}
@@ -567,7 +572,7 @@
void assertDoc(String generics, String expectedGenerics) {
assertEval(evalFormatter.apply(generics, count));
- assertDocumentation(codeFacotry.apply(count), docFormatter.apply(expectedGenerics, count));
+ assertSignature(codeFacotry.apply(count), docFormatter.apply(expectedGenerics, count));
count++;
}
}
--- a/langtools/test/jdk/jshell/EditorPadTest.java Wed Nov 09 15:20:30 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,246 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * @test
- * @bug 8139872
- * @summary Testing built-in editor.
- * @modules java.desktop/java.awt
- * jdk.jshell/jdk.internal.jshell.tool
- * @build ReplToolTesting EditorTestBase
- * @run testng EditorPadTest
- */
-
-import java.awt.AWTException;
-import java.awt.Component;
-import java.awt.Container;
-import java.awt.Dimension;
-import java.awt.Frame;
-import java.awt.GraphicsEnvironment;
-import java.awt.Point;
-import java.awt.Robot;
-import java.awt.event.InputEvent;
-import java.awt.event.WindowEvent;
-import java.lang.reflect.InvocationTargetException;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
-import java.util.function.Consumer;
-
-import javax.swing.JButton;
-import javax.swing.JFrame;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.JTextArea;
-import javax.swing.JViewport;
-import javax.swing.SwingUtilities;
-
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-public class EditorPadTest extends EditorTestBase {
-
- private static final int DELAY = 500;
-
- private static Robot robot;
- private static JFrame frame = null;
- private static JTextArea area = null;
- private static JButton cancel = null;
- private static JButton accept = null;
- private static JButton exit = null;
-
- // Do not actually run if we are headless
- @Override
- public void testEditor(boolean defaultStartup, String[] args, ReplTest... tests) {
- if (!GraphicsEnvironment.isHeadless()) {
- test(defaultStartup, args, tests);
- }
- }
-
- @BeforeClass
- public static void setUpEditorPadTest() {
- if (!GraphicsEnvironment.isHeadless()) {
- try {
- robot = new Robot();
- robot.setAutoWaitForIdle(true);
- robot.setAutoDelay(DELAY);
- } catch (AWTException e) {
- throw new ExceptionInInitializerError(e);
- }
- }
- }
-
- @AfterClass
- public static void shutdown() {
- executorShutdown();
- }
-
- @Override
- public void writeSource(String s) {
- SwingUtilities.invokeLater(() -> area.setText(s));
- }
-
- @Override
- public String getSource() {
- try {
- String[] s = new String[1];
- SwingUtilities.invokeAndWait(() -> s[0] = area.getText());
- return s[0];
- } catch (InvocationTargetException | InterruptedException e) {
- throw new RuntimeException(e);
- }
- }
-
- @Override
- public void accept() {
- clickOn(accept);
- }
-
- @Override
- public void exit() {
- clickOn(exit);
- }
-
- @Override
- public void cancel() {
- clickOn(cancel);
- }
-
- @Override
- public void shutdownEditor() {
- SwingUtilities.invokeLater(this::clearElements);
- waitForIdle();
- }
-
- @Test
- public void testShuttingDown() {
- testEditor(
- (a) -> assertEditOutput(a, "/ed", "", this::shutdownEditor)
- );
- }
-
- private void waitForIdle() {
- robot.waitForIdle();
- robot.delay(DELAY);
- }
-
- private Future<?> task;
- @Override
- public void assertEdit(boolean after, String cmd,
- Consumer<String> checkInput, Consumer<String> checkOutput, Action action) {
- if (!after) {
- setCommandInput(cmd + "\n");
- task = getExecutor().submit(() -> {
- try {
- waitForIdle();
- SwingUtilities.invokeLater(this::seekElements);
- waitForIdle();
- checkInput.accept(getSource());
- action.accept();
- } catch (Throwable e) {
- shutdownEditor();
- if (e instanceof AssertionError) {
- throw (AssertionError) e;
- }
- throw new RuntimeException(e);
- }
- });
- } else {
- try {
- task.get();
- waitForIdle();
- checkOutput.accept(getCommandOutput());
- } catch (ExecutionException e) {
- if (e.getCause() instanceof AssertionError) {
- throw (AssertionError) e.getCause();
- }
- throw new RuntimeException(e);
- } catch (Exception e) {
- throw new RuntimeException(e);
- } finally {
- shutdownEditor();
- }
- }
- }
-
- private void seekElements() {
- for (Frame f : Frame.getFrames()) {
- if (f.getTitle().contains("Edit Pad")) {
- frame = (JFrame) f;
- // workaround
- frame.setLocation(0, 0);
- Container root = frame.getContentPane();
- for (Component c : root.getComponents()) {
- if (c instanceof JScrollPane) {
- JScrollPane scrollPane = (JScrollPane) c;
- for (Component comp : scrollPane.getComponents()) {
- if (comp instanceof JViewport) {
- JViewport view = (JViewport) comp;
- area = (JTextArea) view.getComponent(0);
- }
- }
- }
- if (c instanceof JPanel) {
- JPanel p = (JPanel) c;
- for (Component comp : p.getComponents()) {
- if (comp instanceof JButton) {
- JButton b = (JButton) comp;
- switch (b.getText()) {
- case "Cancel":
- cancel = b;
- break;
- case "Exit":
- exit = b;
- break;
- case "Accept":
- accept = b;
- break;
- }
- }
- }
- }
- }
- }
- }
- }
-
- private void clearElements() {
- if (frame != null) {
- frame.dispatchEvent(new WindowEvent(frame, WindowEvent.WINDOW_CLOSING));
- frame = null;
- }
- area = null;
- accept = null;
- cancel = null;
- exit = null;
- }
-
- private void clickOn(JButton button) {
- waitForIdle();
- Point p = button.getLocationOnScreen();
- Dimension d = button.getSize();
- robot.mouseMove(p.x + d.width / 2, p.y + d.height / 2);
- robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
- robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
- }
-}
--- a/langtools/test/jdk/jshell/ErrorTranslationTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/test/jdk/jshell/ErrorTranslationTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -63,11 +63,8 @@
List<ReplTest> list = new ArrayList<>();
ExpectedDiagnostic[] diagnostics = new ExpectedDiagnostic[]{
newExpectedDiagnostic(0, 6, 0, -1, -1, Diagnostic.Kind.WARNING),
- newExpectedDiagnostic(0, 9, 0, -1, -1, Diagnostic.Kind.WARNING),
- newExpectedDiagnostic(0, 7, 0, -1, -1, Diagnostic.Kind.WARNING),
- newExpectedDiagnostic(0, 6, 0, -1, -1, Diagnostic.Kind.WARNING),
newExpectedDiagnostic(0, 5, 0, -1, -1, Diagnostic.Kind.WARNING)};
- String[] mods = {"public", "protected", "private", "static", "final"};
+ String[] mods = {"static", "final"};
for (int i = 0; i < mods.length; ++i) {
for (String code : new String[] {"class A {}", "void f() {}", "int a;"}) {
final int finalI = i;
--- a/langtools/test/jdk/jshell/FailOverExecutionControlTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/test/jdk/jshell/FailOverExecutionControlTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -33,7 +33,7 @@
import org.testng.annotations.Test;
import org.testng.annotations.BeforeMethod;
-import jdk.jshell.execution.JDIDefaultExecutionControl;
+import jdk.jshell.execution.JdiDefaultExecutionControl;
import jdk.jshell.spi.ExecutionControl;
import jdk.jshell.spi.ExecutionEnv;
import static jdk.jshell.execution.Util.failOverExecutionControlGenerator;
@@ -47,7 +47,7 @@
setUp(builder -> builder.executionEngine(failOverExecutionControlGenerator(
new AlwaysFailingGenerator(),
new AlwaysFailingGenerator(),
- JDIDefaultExecutionControl.launch())));
+ JdiDefaultExecutionControl.launch())));
}
class AlwaysFailingGenerator implements ExecutionControl.Generator {
--- a/langtools/test/jdk/jshell/IgnoreTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/test/jdk/jshell/IgnoreTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -22,7 +22,7 @@
*/
/*
- * @test
+ * @test 8129559
* @summary Test the ignoring of comments and certain modifiers
* @build KullaTesting TestingInputStream
* @run testng IgnoreTest
@@ -58,38 +58,67 @@
}
public void testVarModifier() {
- VarSnippet x1 = (VarSnippet) assertDeclareWarn1("public int x1;", "jdk.eval.warn.illegal.modifiers");
- assertVariableDeclSnippet(x1, "x1", "int", VALID, VAR_DECLARATION_SUBKIND, 0, 1);
- VarSnippet x2 = (VarSnippet) assertDeclareWarn1("protected int x2;", "jdk.eval.warn.illegal.modifiers");
- assertVariableDeclSnippet(x2, "x2", "int", VALID, VAR_DECLARATION_SUBKIND, 0, 1);
- VarSnippet x3 = (VarSnippet) assertDeclareWarn1("private int x3;", "jdk.eval.warn.illegal.modifiers");
- assertVariableDeclSnippet(x3, "x3", "int", VALID, VAR_DECLARATION_SUBKIND, 0, 1);
+ VarSnippet x1 = varKey(assertEval("public int x1;"));
+ assertVariableDeclSnippet(x1, "x1", "int", VALID, VAR_DECLARATION_SUBKIND, 0, 0);
+ VarSnippet x2 = varKey(assertEval("protected int x2;"));
+ assertVariableDeclSnippet(x2, "x2", "int", VALID, VAR_DECLARATION_SUBKIND, 0, 0);
+ VarSnippet x3 = varKey(assertEval("private int x3;"));
+ assertVariableDeclSnippet(x3, "x3", "int", VALID, VAR_DECLARATION_SUBKIND, 0, 0);
VarSnippet x4 = (VarSnippet) assertDeclareWarn1("static int x4;", "jdk.eval.warn.illegal.modifiers");
assertVariableDeclSnippet(x4, "x4", "int", VALID, VAR_DECLARATION_SUBKIND, 0, 1);
VarSnippet x5 = (VarSnippet) assertDeclareWarn1("final int x5;", "jdk.eval.warn.illegal.modifiers");
assertVariableDeclSnippet(x5, "x5", "int", VALID, VAR_DECLARATION_SUBKIND, 0, 1);
}
+ public void testVarModifierAnnotation() {
+ assertEval("@interface A { int value() default 0; }");
+ VarSnippet x1 = varKey(assertEval("@A public int x1;"));
+ assertVariableDeclSnippet(x1, "x1", "int", VALID, VAR_DECLARATION_SUBKIND, 0, 0);
+ VarSnippet x2 = varKey(assertEval("@A(14) protected int x2;"));
+ assertVariableDeclSnippet(x2, "x2", "int", VALID, VAR_DECLARATION_SUBKIND, 0, 0);
+ VarSnippet x3 = varKey(assertEval("@A(value=111)private int x3;"));
+ assertVariableDeclSnippet(x3, "x3", "int", VALID, VAR_DECLARATION_SUBKIND, 0, 0);
+ VarSnippet x4 = (VarSnippet) assertDeclareWarn1("@A static int x4;", "jdk.eval.warn.illegal.modifiers");
+ assertVariableDeclSnippet(x4, "x4", "int", VALID, VAR_DECLARATION_SUBKIND, 0, 1);
+ VarSnippet x5 = (VarSnippet) assertDeclareWarn1("@A(1111) final int x5;", "jdk.eval.warn.illegal.modifiers");
+ assertVariableDeclSnippet(x5, "x5", "int", VALID, VAR_DECLARATION_SUBKIND, 0, 1);
+ }
+
+ public void testVarModifierOtherModifier() {
+ VarSnippet x1 = varKey(assertEval("volatile public int x1;"));
+ assertVariableDeclSnippet(x1, "x1", "int", VALID, VAR_DECLARATION_SUBKIND, 0, 0);
+ VarSnippet x2 = varKey(assertEval("transient protected int x2;"));
+ assertVariableDeclSnippet(x2, "x2", "int", VALID, VAR_DECLARATION_SUBKIND, 0, 0);
+ VarSnippet x3 = varKey(assertEval("transient private int x3;"));
+ assertVariableDeclSnippet(x3, "x3", "int", VALID, VAR_DECLARATION_SUBKIND, 0, 0);
+ VarSnippet x4 = (VarSnippet) assertDeclareWarn1("volatile static int x4;", "jdk.eval.warn.illegal.modifiers");
+ assertVariableDeclSnippet(x4, "x4", "int", VALID, VAR_DECLARATION_SUBKIND, 0, 1);
+ VarSnippet x5 = (VarSnippet) assertDeclareWarn1("transient final int x5;", "jdk.eval.warn.illegal.modifiers");
+ assertVariableDeclSnippet(x5, "x5", "int", VALID, VAR_DECLARATION_SUBKIND, 0, 1);
+ }
+
+ public void testMisplacedIgnoredModifier() {
+ assertEvalFail("int public y;");
+ assertEvalFail("String private x;");
+ assertEvalFail("(protected 34);");
+ }
+
public void testMethodModifier() {
- MethodSnippet m1 = (MethodSnippet) assertDeclareWarn1("public void m1() {}", "jdk.eval.warn.illegal.modifiers");
- assertMethodDeclSnippet(m1, "m1", "()void", VALID, 0, 1);
- MethodSnippet m2 = (MethodSnippet) assertDeclareWarn1("protected void m2() {}", "jdk.eval.warn.illegal.modifiers");
- assertMethodDeclSnippet(m2, "m2", "()void", VALID, 0, 1);
- MethodSnippet m3 = (MethodSnippet) assertDeclareWarn1("private void m3() {}", "jdk.eval.warn.illegal.modifiers");
- assertMethodDeclSnippet(m3, "m3", "()void", VALID, 0, 1);
MethodSnippet m4 = (MethodSnippet) assertDeclareWarn1("static void m4() {}", "jdk.eval.warn.illegal.modifiers");
assertMethodDeclSnippet(m4, "m4", "()void", VALID, 0, 1);
MethodSnippet m5 = (MethodSnippet) assertDeclareWarn1("final void m5() {}", "jdk.eval.warn.illegal.modifiers");
assertMethodDeclSnippet(m5, "m5", "()void", VALID, 0, 1);
}
+ public void testMethodModifierAnnotation() {
+ assertEval("@interface A { int value() default 0; }");
+ MethodSnippet m4 = (MethodSnippet) assertDeclareWarn1("@A static void m4() {}", "jdk.eval.warn.illegal.modifiers");
+ assertMethodDeclSnippet(m4, "m4", "()void", VALID, 0, 1);
+ MethodSnippet m5 = (MethodSnippet) assertDeclareWarn1("@A(value=66)final void m5() {}", "jdk.eval.warn.illegal.modifiers");
+ assertMethodDeclSnippet(m5, "m5", "()void", VALID, 0, 1);
+ }
+
public void testClassModifier() {
- TypeDeclSnippet c1 = (TypeDeclSnippet) assertDeclareWarn1("public class C1 {}", "jdk.eval.warn.illegal.modifiers");
- assertTypeDeclSnippet(c1, "C1", VALID, CLASS_SUBKIND, 0, 1);
- TypeDeclSnippet c2 = (TypeDeclSnippet) assertDeclareWarn1("protected class C2 {}", "jdk.eval.warn.illegal.modifiers");
- assertTypeDeclSnippet(c2, "C2", VALID, CLASS_SUBKIND, 0, 1);
- TypeDeclSnippet c3 = (TypeDeclSnippet) assertDeclareWarn1("private class C3 {}", "jdk.eval.warn.illegal.modifiers");
- assertTypeDeclSnippet(c3, "C3", VALID, CLASS_SUBKIND, 0, 1);
TypeDeclSnippet c4 = (TypeDeclSnippet) assertDeclareWarn1("static class C4 {}", "jdk.eval.warn.illegal.modifiers");
assertTypeDeclSnippet(c4, "C4", VALID, CLASS_SUBKIND, 0, 1);
TypeDeclSnippet c5 = (TypeDeclSnippet) assertDeclareWarn1("final class C5 {}", "jdk.eval.warn.illegal.modifiers");
--- a/langtools/test/jdk/jshell/JDILaunchingExecutionControlTest.java Wed Nov 09 15:20:30 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * @test
- * @bug 8164518
- * @summary Tests for standard JDI connector (without failover) -- launching
- * @modules jdk.jshell/jdk.jshell.execution
- * @build KullaTesting ExecutionControlTestBase
- * @run testng JDILaunchingExecutionControlTest
- */
-
-
-import org.testng.annotations.Test;
-import org.testng.annotations.BeforeMethod;
-import jdk.jshell.execution.JDIDefaultExecutionControl;
-
-@Test
-public class JDILaunchingExecutionControlTest extends ExecutionControlTestBase {
-
- @BeforeMethod
- @Override
- public void setUp() {
- setUp(builder -> builder.executionEngine(JDIDefaultExecutionControl.launch()));
- }
-}
--- a/langtools/test/jdk/jshell/JDIListeningExecutionControlTest.java Wed Nov 09 15:20:30 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * @test
- * @bug 8131029 8159935 8160127 8164518
- * @summary Tests for alternate JDI connector -- listening
- * @modules jdk.jshell/jdk.jshell.execution
- * @build KullaTesting ExecutionControlTestBase
- * @run testng JDIListeningExecutionControlTest
- */
-
-
-import org.testng.annotations.Test;
-import org.testng.annotations.BeforeMethod;
-import jdk.jshell.execution.JDIDefaultExecutionControl;
-
-@Test
-public class JDIListeningExecutionControlTest extends ExecutionControlTestBase {
-
- @BeforeMethod
- @Override
- public void setUp() {
- setUp(builder -> builder.executionEngine(JDIDefaultExecutionControl.listen(null)));
- }
-}
--- a/langtools/test/jdk/jshell/JDIListeningLocalhostExecutionControlTest.java Wed Nov 09 15:20:30 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * @test
- * @bug 8164518
- * @summary Tests for alternate JDI connector -- listening to "localhost"
- * @modules jdk.jshell/jdk.jshell.execution
- * @build KullaTesting ExecutionControlTestBase
- * @run testng JDIListeningLocalhostExecutionControlTest
- */
-
-
-import org.testng.annotations.Test;
-import org.testng.annotations.BeforeMethod;
-import jdk.jshell.execution.JDIDefaultExecutionControl;
-
-@Test
-public class JDIListeningLocalhostExecutionControlTest extends ExecutionControlTestBase {
-
- @BeforeMethod
- @Override
- public void setUp() {
- setUp(builder -> builder.executionEngine(JDIDefaultExecutionControl.listen("localhost")));
- }
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/jshell/JavadocTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8131019
+ * @summary Test Javadoc
+ * @library /tools/lib
+ * @modules jdk.compiler/com.sun.tools.javac.api
+ * jdk.compiler/com.sun.tools.javac.main
+ * jdk.jshell
+ * @build toolbox.ToolBox toolbox.JarTask toolbox.JavacTask
+ * @build KullaTesting TestingInputStream Compiler
+ * @run testng JavadocTest
+ */
+
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Arrays;
+import java.util.jar.JarEntry;
+import java.util.jar.JarOutputStream;
+
+import org.testng.annotations.Test;
+
+@Test
+public class JavadocTest extends KullaTesting {
+
+ private final Compiler compiler = new Compiler();
+
+ public void testJavadoc() {
+ prepareZip();
+ assertJavadoc("test.Clazz|", "test.Clazz\n" +
+ "Top level. ");
+ assertEval("test.Clazz clz = null;");
+ assertJavadoc("clz.test(|", "String test.Clazz.test(int p) throws IllegalStateException\n" +
+ " javadoc1A\n" +
+ "\n" +
+ " @param p param\n" +
+ " @throws IllegalStateException exc\n" +
+ " @return value\n");
+ //undefined handling:
+ assertJavadoc("clz.undef|");
+ }
+
+ private void prepareZip() {
+ String clazz =
+ "package test;\n" +
+ "/**Top level." +
+ " */\n" +
+ "public class Clazz {\n" +
+ " /**\n" +
+ " * javadoc1A\n" +
+ " *\n" +
+ " * @param p param\n" +
+ " * @throws IllegalStateException exc\n" +
+ " * @return value\n" +
+ " */\n" +
+ " public String test(int p) throws IllegalStateException { return null;}\n" +
+ "}\n";
+
+ Path srcZip = Paths.get("src.zip");
+
+ try (JarOutputStream out = new JarOutputStream(Files.newOutputStream(srcZip))) {
+ out.putNextEntry(new JarEntry("test/Clazz.java"));
+ out.write(clazz.getBytes());
+ } catch (IOException ex) {
+ throw new IllegalStateException(ex);
+ }
+
+ compiler.compile(clazz);
+
+ try {
+ Field availableSources = getAnalysis().getClass().getDeclaredField("availableSources");
+ availableSources.setAccessible(true);
+ availableSources.set(getAnalysis(), Arrays.asList(srcZip));
+ } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException ex) {
+ throw new IllegalStateException(ex);
+ }
+ addToClasspath(compiler.getClassDir());
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/jshell/JdiLaunchingExecutionControlTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8164518
+ * @summary Tests for standard JDI connector (without failover) -- launching
+ * @modules jdk.jshell/jdk.jshell.execution
+ * @build KullaTesting ExecutionControlTestBase
+ * @run testng JdiLaunchingExecutionControlTest
+ */
+
+
+import org.testng.annotations.Test;
+import org.testng.annotations.BeforeMethod;
+import jdk.jshell.execution.JdiDefaultExecutionControl;
+
+@Test
+public class JdiLaunchingExecutionControlTest extends ExecutionControlTestBase {
+
+ @BeforeMethod
+ @Override
+ public void setUp() {
+ setUp(builder -> builder.executionEngine(JdiDefaultExecutionControl.launch()));
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/jshell/JdiListeningExecutionControlTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8131029 8159935 8160127 8164518
+ * @summary Tests for alternate JDI connector -- listening
+ * @modules jdk.jshell/jdk.jshell.execution
+ * @build KullaTesting ExecutionControlTestBase
+ * @run testng JdiListeningExecutionControlTest
+ */
+
+
+import org.testng.annotations.Test;
+import org.testng.annotations.BeforeMethod;
+import jdk.jshell.execution.JdiDefaultExecutionControl;
+
+@Test
+public class JdiListeningExecutionControlTest extends ExecutionControlTestBase {
+
+ @BeforeMethod
+ @Override
+ public void setUp() {
+ setUp(builder -> builder.executionEngine(JdiDefaultExecutionControl.listen(null)));
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/jshell/JdiListeningLocalhostExecutionControlTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8164518
+ * @summary Tests for alternate JDI connector -- listening to "localhost"
+ * @modules jdk.jshell/jdk.jshell.execution
+ * @build KullaTesting ExecutionControlTestBase
+ * @run testng JdiListeningLocalhostExecutionControlTest
+ */
+
+
+import org.testng.annotations.Test;
+import org.testng.annotations.BeforeMethod;
+import jdk.jshell.execution.JdiDefaultExecutionControl;
+
+@Test
+public class JdiListeningLocalhostExecutionControlTest extends ExecutionControlTestBase {
+
+ @BeforeMethod
+ @Override
+ public void setUp() {
+ setUp(builder -> builder.executionEngine(JdiDefaultExecutionControl.listen("localhost")));
+ }
+}
--- a/langtools/test/jdk/jshell/KullaTesting.java Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/test/jdk/jshell/KullaTesting.java Wed Nov 09 10:04:43 2016 -0800
@@ -72,11 +72,14 @@
import org.testng.annotations.BeforeMethod;
import jdk.jshell.Diag;
+
import static java.util.stream.Collectors.toList;
import static java.util.stream.Collectors.toSet;
+
import static jdk.jshell.Snippet.Status.*;
import static org.testng.Assert.*;
import static jdk.jshell.Snippet.SubKind.METHOD_SUBKIND;
+import jdk.jshell.SourceCodeAnalysis.Documentation;
public class KullaTesting {
@@ -946,54 +949,56 @@
}
}
- public void assertDocumentation(String code, String... expected) {
+ public void assertSignature(String code, String... expected) {
int cursor = code.indexOf('|');
code = code.replace("|", "");
assertTrue(cursor > -1, "'|' expected, but not found in: " + code);
- String documentation = getAnalysis().documentation(code, cursor);
- Set<String> docSet = Stream.of(documentation.split("\r?\n")).collect(Collectors.toSet());
+ List<Documentation> documentation = getAnalysis().documentation(code, cursor, false);
+ Set<String> docSet = documentation.stream().map(doc -> doc.signature()).collect(Collectors.toSet());
+ Set<String> expectedSet = Stream.of(expected).collect(Collectors.toSet());
+ assertEquals(docSet, expectedSet, "Input: " + code);
+ }
+
+ public void assertJavadoc(String code, String... expected) {
+ int cursor = code.indexOf('|');
+ code = code.replace("|", "");
+ assertTrue(cursor > -1, "'|' expected, but not found in: " + code);
+ List<Documentation> documentation = getAnalysis().documentation(code, cursor, true);
+ Set<String> docSet = documentation.stream()
+ .map(doc -> doc.signature() + "\n" + doc.javadoc())
+ .collect(Collectors.toSet());
Set<String> expectedSet = Stream.of(expected).collect(Collectors.toSet());
assertEquals(docSet, expectedSet, "Input: " + code);
}
public enum ClassType {
- CLASS("CLASS_SUBKIND") {
- @Override
- public String toString() {
- return "class";
- }
- },
- ENUM("ENUM_SUBKIND") {
- @Override
- public String toString() {
- return "enum";
- }
- },
- INTERFACE("INTERFACE_SUBKIND") {
- @Override
- public String toString() {
- return "interface";
- }
- },
- ANNOTATION("ANNOTATION_TYPE_SUBKIND") {
- @Override
- public String toString() {
- return "@interface";
- }
- };
+ CLASS("CLASS_SUBKIND", "class", "class"),
+ ENUM("ENUM_SUBKIND", "enum", "enum"),
+ INTERFACE("INTERFACE_SUBKIND", "interface", "interface"),
+ ANNOTATION("ANNOTATION_TYPE_SUBKIND", "@interface", "annotation interface");
private final String classType;
+ private final String name;
+ private final String displayed;
- ClassType(String classType) {
+ ClassType(String classType, String name, String displayed) {
this.classType = classType;
+ this.name = name;
+ this.displayed = displayed;
}
public String getClassType() {
return classType;
}
+ public String getDisplayed() {
+ return displayed;
+ }
+
@Override
- public abstract String toString();
+ public String toString() {
+ return name;
+ }
}
public static MemberInfo variable(String type, String name) {
--- a/langtools/test/jdk/jshell/MethodsTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/test/jdk/jshell/MethodsTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 8080357
+ * @bug 8080357 8167643
* @summary Tests for EvaluationState.methods
* @build KullaTesting TestingInputStream ExpectedDiagnostic
* @run testng MethodsTest
@@ -230,31 +230,30 @@
assertActiveKeys();
}
- public void methodsWarn() {
- Snippet f = assertDeclareWarn1("public String f() {return null;}",
- new ExpectedDiagnostic("jdk.eval.warn.illegal.modifiers", 0, 6, 0, -1, -1, Diagnostic.Kind.WARNING),
- added(VALID));
+
+ public void methodsAccessModifierIgnored() {
+ Snippet f = methodKey(assertEval("public String f() {return null;}",
+ added(VALID)));
assertNumberOfActiveMethods(1);
assertActiveKeys();
- f = assertDeclareWarn1("protected String f() {return null;}",
- new ExpectedDiagnostic("jdk.eval.warn.illegal.modifiers", 0, 9, 0, -1, -1, Diagnostic.Kind.WARNING),
+ f = methodKey(assertEval("protected String f() {return null;}",
+ ste(MAIN_SNIPPET, VALID, VALID, false, null),
+ ste(f, VALID, OVERWRITTEN, false, MAIN_SNIPPET)));
+ assertNumberOfActiveMethods(1);
+ assertActiveKeys();
+
+ assertEval("private String f() {return null;}",
ste(MAIN_SNIPPET, VALID, VALID, false, null),
ste(f, VALID, OVERWRITTEN, false, MAIN_SNIPPET));
assertNumberOfActiveMethods(1);
assertActiveKeys();
+ }
- f = assertDeclareWarn1("private String f() {return null;}",
- new ExpectedDiagnostic("jdk.eval.warn.illegal.modifiers", 0, 7, 0, -1, -1, Diagnostic.Kind.WARNING),
- ste(MAIN_SNIPPET, VALID, VALID, false, null),
- ste(f, VALID, OVERWRITTEN, false, MAIN_SNIPPET));
- assertNumberOfActiveMethods(1);
- assertActiveKeys();
-
- f = assertDeclareWarn1("static String f() {return null;}",
+ public void methodsWarn() {
+ Snippet f = assertDeclareWarn1("static String f() {return null;}",
new ExpectedDiagnostic("jdk.eval.warn.illegal.modifiers", 0, 6, 0, -1, -1, Diagnostic.Kind.WARNING),
- ste(MAIN_SNIPPET, VALID, VALID, false, null),
- ste(f, VALID, OVERWRITTEN, false, MAIN_SNIPPET));
+ added(VALID));
assertNumberOfActiveMethods(1);
assertActiveKeys();
--- a/langtools/test/jdk/jshell/ModifiersTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/test/jdk/jshell/ModifiersTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -22,7 +22,7 @@
*/
/*
- * @test
+ * @test 8167643 8129559
* @summary Tests for modifiers
* @build KullaTesting TestingInputStream ExpectedDiagnostic
* @run testng ModifiersTest
@@ -31,6 +31,7 @@
import java.util.ArrayList;
import java.util.List;
+import java.util.function.Consumer;
import javax.tools.Diagnostic;
import org.testng.annotations.DataProvider;
@@ -43,22 +44,55 @@
public Object[][] getTestCases() {
List<Object[]> testCases = new ArrayList<>();
String[] ignoredModifiers = new String[] {
- "public", "protected", "private", "static", "final"
+ "static", "final"
+ };
+ String[] silentlyIgnoredModifiers = new String[] {
+ "public", "protected", "private"
};
+ String[] before = new String[] {
+ "strictfp", "abstract", "@X", "@X(value=9)"
+ };
+ String context = "@interface X { int value() default 0; }";
+ Consumer<String> eval = this::assertEval;
+ Consumer<String> evalWarn = s -> assertDeclareWarn1(s, "jdk.eval.warn.illegal.modifiers");
for (String ignoredModifier : ignoredModifiers) {
for (ClassType classType : ClassType.values()) {
- testCases.add(new Object[] { ignoredModifier, classType });
+ testCases.add(new Object[] { ignoredModifier, classType, evalWarn, "", null });
+ }
+ }
+ for (String ignoredModifier : ignoredModifiers) {
+ for (String preface : before) {
+ testCases.add(new Object[] { ignoredModifier, ClassType.CLASS, evalWarn, preface, context});
+ }
+ }
+ for (String ignoredModifier : silentlyIgnoredModifiers) {
+ for (ClassType classType : ClassType.values()) {
+ testCases.add(new Object[] { ignoredModifier, classType, eval, "", null });
+ }
+ }
+ for (String ignoredModifier : silentlyIgnoredModifiers) {
+ for (String preface : before) {
+ testCases.add(new Object[] { ignoredModifier, ClassType.CLASS, eval, preface, context});
}
}
return testCases.toArray(new Object[testCases.size()][]);
}
@Test(dataProvider = "ignoredModifiers")
- public void ignoredModifiers(String modifier, ClassType classType) {
- assertDeclareWarn1(
- String.format("%s %s A {}", modifier, classType), "jdk.eval.warn.illegal.modifiers");
- assertNumberOfActiveClasses(1);
- assertClasses(clazz(classType, "A"));
+ public void ignoredModifiers(String modifier, ClassType classType,
+ Consumer<String> eval, String preface, String context) {
+ if (context != null) {
+ assertEval(context);
+ }
+ String decl = String.format("%s %s %s A {}", preface, modifier, classType);
+ eval.accept(decl);
+ if (context != null) {
+ assertNumberOfActiveClasses(2);
+ assertClasses(clazz(ClassType.ANNOTATION, "X"), clazz(classType, "A"));
+ } else {
+ assertNumberOfActiveClasses(1);
+ assertClasses(clazz(classType, "A"));
+ }
assertActiveKeys();
}
--- a/langtools/test/jdk/jshell/ToolBasicTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/test/jdk/jshell/ToolBasicTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 8143037 8142447 8144095 8140265 8144906 8146138 8147887 8147886 8148316 8148317 8143955 8157953 8080347 8154714
+ * @bug 8143037 8142447 8144095 8140265 8144906 8146138 8147887 8147886 8148316 8148317 8143955 8157953 8080347 8154714 8166649 8167643
* @summary Tests for Basic tests for REPL tool
* @modules jdk.compiler/com.sun.tools.javac.api
* jdk.compiler/com.sun.tools.javac.main
@@ -289,6 +289,21 @@
);
}
+ public void testModulePath() {
+ Compiler compiler = new Compiler();
+ Path modsDir = Paths.get("mods");
+ Path outDir = Paths.get("mods", "org.astro");
+ compiler.compile(outDir, "package org.astro; public class World { public static String name() { return \"world\"; } }");
+ compiler.compile(outDir, "module org.astro { exports org.astro; }");
+ Path modsPath = compiler.getPath(modsDir);
+ test(new String[] { "--module-path", modsPath.toString(), "--add-modules", "org.astro" },
+ (a) -> assertCommand(a, "import org.astro.World;", ""),
+ (a) -> evaluateExpression(a, "String",
+ "String.format(\"Greetings %s!\", World.name());",
+ "\"Greetings world!\"")
+ );
+ }
+
public void testStartupFileOption() {
try {
Compiler compiler = new Compiler();
@@ -505,7 +520,7 @@
a -> assertCommand(a, "int a", ""),
a -> assertCommand(a, "void f() {}", ""),
a -> assertCommandCheckOutput(a, "aaaa", assertStartsWith("| Error:")),
- a -> assertCommandCheckOutput(a, "public void f() {}", assertStartsWith("| Warning:"))
+ a -> assertCommandCheckOutput(a, "static void f() {}", assertStartsWith("| Warning:"))
);
}
}
--- a/langtools/test/jdk/jshell/ToolFormatTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/test/jdk/jshell/ToolFormatTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 8148316 8148317 8151755 8152246 8153551 8154812 8157261 8163840
+ * @bug 8148316 8148317 8151755 8152246 8153551 8154812 8157261 8163840 8166637 8161969
* @summary Tests for output customization
* @library /tools/lib
* @modules jdk.compiler/com.sun.tools.javac.api
@@ -220,8 +220,8 @@
test(
(a) -> assertCommandOutputStartsWith(a, "/set feedback normal", ""),
(a) -> assertCommand(a, "String s = java.util.stream.IntStream.range(65, 74)"+
- ".mapToObj(i -> \"\"+(char)i).reduce((a,b) -> a + b + a).get()",
- "s ==> \"ABACABADABACABAEABACABADABACABAFABACABADABACABAEABACABADABACABAGABACABADABA ..."),
+ ".mapToObj(i -> \"\"+(char)i).reduce((a,b) -> a + b + a).get() + \"XYZ\"",
+ "s ==> \"ABACABADABACABAEABACABADABACABAFABACABADABACABAE ... BACABAEABACABADABACABAXYZ\""),
(a) -> assertCommandOutputStartsWith(a, "/set mode test -quiet", ""),
(a) -> assertCommandOutputStartsWith(a, "/set feedback test", ""),
(a) -> assertCommand(a, "/set format test display '{type}:{value}' primary", ""),
@@ -234,8 +234,9 @@
"/set truncation test 10 varvalue"),
(a) -> assertCommandOutputContains(a, "/set truncation test",
"/set truncation test 10 varvalue"),
- (a) -> assertCommand(a, "String r = s", "String:\"ABACABADABACABA ..."),
- (a) -> assertCommand(a, "r", "String:\"ABACA ..."),
+ (a) -> assertCommand(a, "/var", "| String s = \"ABACABADA"),
+ (a) -> assertCommand(a, "String r = s", "String:\"ABACABAD ... BAXYZ\""),
+ (a) -> assertCommand(a, "r", "String:\"ABACABADA"),
(a) -> assertCommand(a, "r=s", "String:\"AB")
);
} finally {
--- a/langtools/test/jdk/jshell/ToolRetainTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/test/jdk/jshell/ToolRetainTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -23,13 +23,14 @@
/*
* @test
- * @bug 8157200 8163840
+ * @bug 8157200 8163840 8154513
* @summary Tests of what information is retained across jshell tool runs
* @modules jdk.jshell/jdk.internal.jshell.tool
* @build ToolRetainTest ReplToolTesting
* @run testng ToolRetainTest
*/
+import java.util.Locale;
import org.testng.annotations.Test;
@Test
@@ -62,14 +63,14 @@
(a) -> assertCommand(a, "/set mode -retain trm1", ""),
(a) -> assertCommand(a, "/exit", "")
);
- test(
+ test(Locale.ROOT, true, new String[0], "",
(a) -> assertCommand(a, "/set mode trm2 -quiet", ""),
(a) -> assertCommand(a, "/set format trm2 display '{name}={value}'", ""),
(a) -> assertCommand(a, "int x = 45", "x:45"),
(a) -> assertCommand(a, "/set mode -retain trm2", ""),
(a) -> assertCommand(a, "/exit", "")
);
- test(
+ test(Locale.ROOT, true, new String[0], "",
(a) -> assertCommandOutputContains(a, "/set mode trm1",
"/set format trm1 display \"{name}:{value}\""),
(a) -> assertCommand(a, "/set format trm2 display",
--- a/langtools/test/jdk/jshell/ToolSimpleTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/test/jdk/jshell/ToolSimpleTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 8153716 8143955 8151754 8150382 8153920 8156910 8131024 8160089 8153897 8167128
+ * @bug 8153716 8143955 8151754 8150382 8153920 8156910 8131024 8160089 8153897 8167128 8154513
* @summary Simple jshell tool tests
* @modules jdk.compiler/com.sun.tools.javac.api
* jdk.compiler/com.sun.tools.javac.main
@@ -35,6 +35,7 @@
import java.util.Arrays;
import java.util.ArrayList;
import java.util.List;
+import java.util.Locale;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -465,14 +466,14 @@
}
public void testOptionQ() {
- test(new String[]{"-q", "--no-startup"},
+ test(Locale.ROOT, false, new String[]{"-q", "--no-startup"}, "",
(a) -> assertCommand(a, "1+1", "$1 ==> 2"),
(a) -> assertCommand(a, "int x = 5", "")
);
}
public void testOptionS() {
- test(new String[]{"-s", "--no-startup"},
+ test(Locale.ROOT, false, new String[]{"-s", "--no-startup"}, "",
(a) -> assertCommand(a, "1+1", "")
);
}
@@ -486,7 +487,7 @@
}
public void testOptionFeedback() {
- test(new String[]{"--feedback", "concise", "--no-startup"},
+ test(Locale.ROOT, false, new String[]{"--feedback", "concise", "--no-startup"}, "",
(a) -> assertCommand(a, "1+1", "$1 ==> 2"),
(a) -> assertCommand(a, "int x = 5", "")
);
@@ -498,17 +499,17 @@
.filter(l -> !l.isEmpty())
.count(), "Expected no lines: " + s);
};
- test(new String[]{"-nq"},
+ test(Locale.ROOT, false, new String[]{"-nq"}, "",
(a) -> assertCommandCheckOutput(a, "/list -all", confirmNoStartup),
(a) -> assertCommand(a, "1+1", "$1 ==> 2"),
(a) -> assertCommand(a, "int x = 5", "")
);
- test(new String[]{"-qn"},
+ test(Locale.ROOT, false, new String[]{"-qn"}, "",
(a) -> assertCommandCheckOutput(a, "/list -all", confirmNoStartup),
(a) -> assertCommand(a, "1+1", "$1 ==> 2"),
(a) -> assertCommand(a, "int x = 5", "")
);
- test(new String[]{"-ns"},
+ test(Locale.ROOT, false, new String[]{"-ns"}, "",
(a) -> assertCommandCheckOutput(a, "/list -all", confirmNoStartup),
(a) -> assertCommand(a, "1+1", "")
);
--- a/langtools/test/jdk/jshell/UserJDIUserRemoteTest.java Wed Nov 09 15:20:30 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,286 +0,0 @@
-/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
- /*
- * @test
- * @bug 8160128 8159935
- * @summary Tests for Aux channel, custom remote agents, custom JDI implementations.
- * @build KullaTesting ExecutionControlTestBase
- * @run testng UserJDIUserRemoteTest
- */
-import java.io.ByteArrayOutputStream;
-import org.testng.annotations.Test;
-import org.testng.annotations.BeforeMethod;
-import jdk.jshell.Snippet;
-import static jdk.jshell.Snippet.Status.OVERWRITTEN;
-import static jdk.jshell.Snippet.Status.VALID;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.net.ServerSocket;
-import java.util.ArrayList;
-import java.util.List;
-import com.sun.jdi.VMDisconnectedException;
-import com.sun.jdi.VirtualMachine;
-import jdk.jshell.VarSnippet;
-import jdk.jshell.execution.DirectExecutionControl;
-import jdk.jshell.execution.JDIExecutionControl;
-import jdk.jshell.execution.JDIInitiator;
-import jdk.jshell.execution.Util;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.PrintStream;
-import java.net.Socket;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.function.Consumer;
-import jdk.jshell.spi.ExecutionControl;
-import jdk.jshell.spi.ExecutionControl.ExecutionControlException;
-import jdk.jshell.spi.ExecutionEnv;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.fail;
-import static jdk.jshell.execution.Util.forwardExecutionControlAndIO;
-import static jdk.jshell.execution.Util.remoteInputOutput;
-
-@Test
-public class UserJDIUserRemoteTest extends ExecutionControlTestBase {
-
- ExecutionControl currentEC;
- ByteArrayOutputStream auxStream;
-
- @BeforeMethod
- @Override
- public void setUp() {
- auxStream = new ByteArrayOutputStream();
- setUp(builder -> builder.executionEngine(MyExecutionControl.create(this)));
- }
-
- public void testVarValue() {
- VarSnippet dv = varKey(assertEval("double aDouble = 1.5;"));
- String vd = getState().varValue(dv);
- assertEquals(vd, "1.5");
- assertEquals(auxStream.toString(), "aDouble");
- }
-
- public void testExtension() throws ExecutionControlException {
- assertEval("42;");
- Object res = currentEC.extensionCommand("FROG", "test");
- assertEquals(res, "ribbit");
- }
-
- public void testRedefine() {
- Snippet vx = varKey(assertEval("int x;"));
- Snippet mu = methodKey(assertEval("int mu() { return x * 4; }"));
- Snippet c = classKey(assertEval("class C { String v() { return \"#\" + mu(); } }"));
- assertEval("C c0 = new C();");
- assertEval("c0.v();", "\"#0\"");
- assertEval("int x = 10;", "10",
- ste(MAIN_SNIPPET, VALID, VALID, false, null),
- ste(vx, VALID, OVERWRITTEN, false, MAIN_SNIPPET));
- assertEval("c0.v();", "\"#40\"");
- assertEval("C c = new C();");
- assertEval("c.v();", "\"#40\"");
- assertEval("int mu() { return x * 3; }",
- ste(MAIN_SNIPPET, VALID, VALID, false, null),
- ste(mu, VALID, OVERWRITTEN, false, MAIN_SNIPPET));
- assertEval("c.v();", "\"#30\"");
- assertEval("class C { String v() { return \"@\" + mu(); } }",
- ste(MAIN_SNIPPET, VALID, VALID, false, null),
- ste(c, VALID, OVERWRITTEN, false, MAIN_SNIPPET));
- assertEval("c0.v();", "\"@30\"");
- assertEval("c = new C();");
- assertEval("c.v();", "\"@30\"");
- assertActiveKeys();
- }
-}
-
-class MyExecutionControl extends JDIExecutionControl {
-
- private static final String REMOTE_AGENT = MyRemoteExecutionControl.class.getName();
-
- private VirtualMachine vm;
- private Process process;
-
- /**
- * Creates an ExecutionControl instance based on a JDI
- * {@code LaunchingConnector}.
- *
- * @return the generator
- */
- public static ExecutionControl.Generator create(UserJDIUserRemoteTest test) {
- return env -> make(env, test);
- }
-
- /**
- * Creates an ExecutionControl instance based on a JDI
- * {@code ListeningConnector} or {@code LaunchingConnector}.
- *
- * Initialize JDI and use it to launch the remote JVM. Set-up a socket for
- * commands and results. This socket also transports the user
- * input/output/error.
- *
- * @param env the context passed by
- * {@link jdk.jshell.spi.ExecutionControl#start(jdk.jshell.spi.ExecutionEnv) }
- * @return the channel
- * @throws IOException if there are errors in set-up
- */
- static ExecutionControl make(ExecutionEnv env, UserJDIUserRemoteTest test) throws IOException {
- try (final ServerSocket listener = new ServerSocket(0)) {
- // timeout after 60 seconds
- listener.setSoTimeout(60000);
- int port = listener.getLocalPort();
-
- // Set-up the JDI connection
- List<String> opts = new ArrayList<>(env.extraRemoteVMOptions());
- opts.add("-classpath");
- opts.add(System.getProperty("java.class.path")
- + System.getProperty("path.separator")
- + System.getProperty("user.dir"));
- JDIInitiator jdii = new JDIInitiator(port,
- opts, REMOTE_AGENT, true, null);
- VirtualMachine vm = jdii.vm();
- Process process = jdii.process();
-
- List<Consumer<String>> deathListeners = new ArrayList<>();
- deathListeners.add(s -> env.closeDown());
- Util.detectJDIExitEvent(vm, s -> {
- for (Consumer<String> h : deathListeners) {
- h.accept(s);
- }
- });
-
- // Set-up the commands/reslts on the socket. Piggy-back snippet
- // output.
- Socket socket = listener.accept();
- // out before in -- match remote creation so we don't hang
- OutputStream out = socket.getOutputStream();
- Map<String, OutputStream> outputs = new HashMap<>();
- outputs.put("out", env.userOut());
- outputs.put("err", env.userErr());
- outputs.put("aux", test.auxStream);
- Map<String, InputStream> input = new HashMap<>();
- input.put("in", env.userIn());
- ExecutionControl myec = remoteInputOutput(socket.getInputStream(), out, outputs, input, (objIn, objOut) -> new MyExecutionControl(objOut, objIn, vm, process, deathListeners));
- test.currentEC = myec;
- return myec;
- }
- }
-
- /**
- * Create an instance.
- *
- * @param out the output for commands
- * @param in the input for responses
- */
- private MyExecutionControl(ObjectOutput out, ObjectInput in,
- VirtualMachine vm, Process process,
- List<Consumer<String>> deathListeners) {
- super(out, in);
- this.vm = vm;
- this.process = process;
- deathListeners.add(s -> disposeVM());
- }
-
- @Override
- public void close() {
- super.close();
- disposeVM();
- }
-
- private synchronized void disposeVM() {
- try {
- if (vm != null) {
- vm.dispose(); // This could NPE, so it is caught below
- vm = null;
- }
- } catch (VMDisconnectedException ex) {
- // Ignore if already closed
- } catch (Throwable e) {
- fail("disposeVM threw: " + e);
- } finally {
- if (process != null) {
- process.destroy();
- process = null;
- }
- }
- }
-
- @Override
- protected synchronized VirtualMachine vm() throws EngineTerminationException {
- if (vm == null) {
- throw new EngineTerminationException("VM closed");
- } else {
- return vm;
- }
- }
-
-}
-
-class MyRemoteExecutionControl extends DirectExecutionControl implements ExecutionControl {
-
- static PrintStream auxPrint;
-
- /**
- * Launch the agent, connecting to the JShell-core over the socket specified
- * in the command-line argument.
- *
- * @param args standard command-line arguments, expectation is the socket
- * number is the only argument
- * @throws Exception any unexpected exception
- */
- public static void main(String[] args) throws Exception {
- try {
- String loopBack = null;
- Socket socket = new Socket(loopBack, Integer.parseInt(args[0]));
- InputStream inStream = socket.getInputStream();
- OutputStream outStream = socket.getOutputStream();
- Map<String, Consumer<OutputStream>> outputs = new HashMap<>();
- outputs.put("out", st -> System.setOut(new PrintStream(st, true)));
- outputs.put("err", st -> System.setErr(new PrintStream(st, true)));
- outputs.put("aux", st -> { auxPrint = new PrintStream(st, true); });
- Map<String, Consumer<InputStream>> input = new HashMap<>();
- input.put("in", st -> System.setIn(st));
- forwardExecutionControlAndIO(new MyRemoteExecutionControl(), inStream, outStream, outputs, input);
- } catch (Throwable ex) {
- throw ex;
- }
- }
-
- @Override
- public String varValue(String className, String varName)
- throws RunException, EngineTerminationException, InternalException {
- auxPrint.print(varName);
- return super.varValue(className, varName);
- }
-
- @Override
- public Object extensionCommand(String className, Object arg)
- throws RunException, EngineTerminationException, InternalException {
- if (!arg.equals("test")) {
- throw new InternalException("expected extensionCommand arg to be 'test' got: " + arg);
- }
- return "ribbit";
- }
-
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/jshell/UserJdiUserRemoteTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,286 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+ /*
+ * @test
+ * @bug 8160128 8159935
+ * @summary Tests for Aux channel, custom remote agents, custom JDI implementations.
+ * @build KullaTesting ExecutionControlTestBase
+ * @run testng UserJdiUserRemoteTest
+ */
+import java.io.ByteArrayOutputStream;
+import org.testng.annotations.Test;
+import org.testng.annotations.BeforeMethod;
+import jdk.jshell.Snippet;
+import static jdk.jshell.Snippet.Status.OVERWRITTEN;
+import static jdk.jshell.Snippet.Status.VALID;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.net.ServerSocket;
+import java.util.ArrayList;
+import java.util.List;
+import com.sun.jdi.VMDisconnectedException;
+import com.sun.jdi.VirtualMachine;
+import jdk.jshell.VarSnippet;
+import jdk.jshell.execution.DirectExecutionControl;
+import jdk.jshell.execution.JdiExecutionControl;
+import jdk.jshell.execution.JdiInitiator;
+import jdk.jshell.execution.Util;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PrintStream;
+import java.net.Socket;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.function.Consumer;
+import jdk.jshell.spi.ExecutionControl;
+import jdk.jshell.spi.ExecutionControl.ExecutionControlException;
+import jdk.jshell.spi.ExecutionEnv;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.fail;
+import static jdk.jshell.execution.Util.forwardExecutionControlAndIO;
+import static jdk.jshell.execution.Util.remoteInputOutput;
+
+@Test
+public class UserJdiUserRemoteTest extends ExecutionControlTestBase {
+
+ ExecutionControl currentEC;
+ ByteArrayOutputStream auxStream;
+
+ @BeforeMethod
+ @Override
+ public void setUp() {
+ auxStream = new ByteArrayOutputStream();
+ setUp(builder -> builder.executionEngine(MyExecutionControl.create(this)));
+ }
+
+ public void testVarValue() {
+ VarSnippet dv = varKey(assertEval("double aDouble = 1.5;"));
+ String vd = getState().varValue(dv);
+ assertEquals(vd, "1.5");
+ assertEquals(auxStream.toString(), "aDouble");
+ }
+
+ public void testExtension() throws ExecutionControlException {
+ assertEval("42;");
+ Object res = currentEC.extensionCommand("FROG", "test");
+ assertEquals(res, "ribbit");
+ }
+
+ public void testRedefine() {
+ Snippet vx = varKey(assertEval("int x;"));
+ Snippet mu = methodKey(assertEval("int mu() { return x * 4; }"));
+ Snippet c = classKey(assertEval("class C { String v() { return \"#\" + mu(); } }"));
+ assertEval("C c0 = new C();");
+ assertEval("c0.v();", "\"#0\"");
+ assertEval("int x = 10;", "10",
+ ste(MAIN_SNIPPET, VALID, VALID, false, null),
+ ste(vx, VALID, OVERWRITTEN, false, MAIN_SNIPPET));
+ assertEval("c0.v();", "\"#40\"");
+ assertEval("C c = new C();");
+ assertEval("c.v();", "\"#40\"");
+ assertEval("int mu() { return x * 3; }",
+ ste(MAIN_SNIPPET, VALID, VALID, false, null),
+ ste(mu, VALID, OVERWRITTEN, false, MAIN_SNIPPET));
+ assertEval("c.v();", "\"#30\"");
+ assertEval("class C { String v() { return \"@\" + mu(); } }",
+ ste(MAIN_SNIPPET, VALID, VALID, false, null),
+ ste(c, VALID, OVERWRITTEN, false, MAIN_SNIPPET));
+ assertEval("c0.v();", "\"@30\"");
+ assertEval("c = new C();");
+ assertEval("c.v();", "\"@30\"");
+ assertActiveKeys();
+ }
+}
+
+class MyExecutionControl extends JdiExecutionControl {
+
+ private static final String REMOTE_AGENT = MyRemoteExecutionControl.class.getName();
+
+ private VirtualMachine vm;
+ private Process process;
+
+ /**
+ * Creates an ExecutionControl instance based on a JDI
+ * {@code LaunchingConnector}.
+ *
+ * @return the generator
+ */
+ public static ExecutionControl.Generator create(UserJdiUserRemoteTest test) {
+ return env -> make(env, test);
+ }
+
+ /**
+ * Creates an ExecutionControl instance based on a JDI
+ * {@code ListeningConnector} or {@code LaunchingConnector}.
+ *
+ * Initialize JDI and use it to launch the remote JVM. Set-up a socket for
+ * commands and results. This socket also transports the user
+ * input/output/error.
+ *
+ * @param env the context passed by
+ * {@link jdk.jshell.spi.ExecutionControl#start(jdk.jshell.spi.ExecutionEnv) }
+ * @return the channel
+ * @throws IOException if there are errors in set-up
+ */
+ static ExecutionControl make(ExecutionEnv env, UserJdiUserRemoteTest test) throws IOException {
+ try (final ServerSocket listener = new ServerSocket(0)) {
+ // timeout after 60 seconds
+ listener.setSoTimeout(60000);
+ int port = listener.getLocalPort();
+
+ // Set-up the JDI connection
+ List<String> opts = new ArrayList<>(env.extraRemoteVMOptions());
+ opts.add("-classpath");
+ opts.add(System.getProperty("java.class.path")
+ + System.getProperty("path.separator")
+ + System.getProperty("user.dir"));
+ JdiInitiator jdii = new JdiInitiator(port,
+ opts, REMOTE_AGENT, true, null);
+ VirtualMachine vm = jdii.vm();
+ Process process = jdii.process();
+
+ List<Consumer<String>> deathListeners = new ArrayList<>();
+ deathListeners.add(s -> env.closeDown());
+ Util.detectJdiExitEvent(vm, s -> {
+ for (Consumer<String> h : deathListeners) {
+ h.accept(s);
+ }
+ });
+
+ // Set-up the commands/reslts on the socket. Piggy-back snippet
+ // output.
+ Socket socket = listener.accept();
+ // out before in -- match remote creation so we don't hang
+ OutputStream out = socket.getOutputStream();
+ Map<String, OutputStream> outputs = new HashMap<>();
+ outputs.put("out", env.userOut());
+ outputs.put("err", env.userErr());
+ outputs.put("aux", test.auxStream);
+ Map<String, InputStream> input = new HashMap<>();
+ input.put("in", env.userIn());
+ ExecutionControl myec = remoteInputOutput(socket.getInputStream(), out, outputs, input, (objIn, objOut) -> new MyExecutionControl(objOut, objIn, vm, process, deathListeners));
+ test.currentEC = myec;
+ return myec;
+ }
+ }
+
+ /**
+ * Create an instance.
+ *
+ * @param out the output for commands
+ * @param in the input for responses
+ */
+ private MyExecutionControl(ObjectOutput out, ObjectInput in,
+ VirtualMachine vm, Process process,
+ List<Consumer<String>> deathListeners) {
+ super(out, in);
+ this.vm = vm;
+ this.process = process;
+ deathListeners.add(s -> disposeVM());
+ }
+
+ @Override
+ public void close() {
+ super.close();
+ disposeVM();
+ }
+
+ private synchronized void disposeVM() {
+ try {
+ if (vm != null) {
+ vm.dispose(); // This could NPE, so it is caught below
+ vm = null;
+ }
+ } catch (VMDisconnectedException ex) {
+ // Ignore if already closed
+ } catch (Throwable e) {
+ fail("disposeVM threw: " + e);
+ } finally {
+ if (process != null) {
+ process.destroy();
+ process = null;
+ }
+ }
+ }
+
+ @Override
+ protected synchronized VirtualMachine vm() throws EngineTerminationException {
+ if (vm == null) {
+ throw new EngineTerminationException("VM closed");
+ } else {
+ return vm;
+ }
+ }
+
+}
+
+class MyRemoteExecutionControl extends DirectExecutionControl implements ExecutionControl {
+
+ static PrintStream auxPrint;
+
+ /**
+ * Launch the agent, connecting to the JShell-core over the socket specified
+ * in the command-line argument.
+ *
+ * @param args standard command-line arguments, expectation is the socket
+ * number is the only argument
+ * @throws Exception any unexpected exception
+ */
+ public static void main(String[] args) throws Exception {
+ try {
+ String loopBack = null;
+ Socket socket = new Socket(loopBack, Integer.parseInt(args[0]));
+ InputStream inStream = socket.getInputStream();
+ OutputStream outStream = socket.getOutputStream();
+ Map<String, Consumer<OutputStream>> outputs = new HashMap<>();
+ outputs.put("out", st -> System.setOut(new PrintStream(st, true)));
+ outputs.put("err", st -> System.setErr(new PrintStream(st, true)));
+ outputs.put("aux", st -> { auxPrint = new PrintStream(st, true); });
+ Map<String, Consumer<InputStream>> input = new HashMap<>();
+ input.put("in", st -> System.setIn(st));
+ forwardExecutionControlAndIO(new MyRemoteExecutionControl(), inStream, outStream, outputs, input);
+ } catch (Throwable ex) {
+ throw ex;
+ }
+ }
+
+ @Override
+ public String varValue(String className, String varName)
+ throws RunException, EngineTerminationException, InternalException {
+ auxPrint.print(varName);
+ return super.varValue(className, varName);
+ }
+
+ @Override
+ public Object extensionCommand(String className, Object arg)
+ throws RunException, EngineTerminationException, InternalException {
+ if (!arg.equals("test")) {
+ throw new InternalException("expected extensionCommand arg to be 'test' got: " + arg);
+ }
+ return "ribbit";
+ }
+
+}
--- a/langtools/test/tools/doclint/moduleTests/bad/module-info.java Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/test/tools/doclint/moduleTests/bad/module-info.java Wed Nov 09 10:04:43 2016 -0800
@@ -6,7 +6,7 @@
* @modules jdk.compiler/com.sun.tools.doclint
* @build DocLintTester
* @run main DocLintTester -ref module-info.out module-info.java
- * @compile/fail/ref=module-info.javac.out -XDrawDiagnostics -Werror -Xdoclint:all module-info.java
+ * @compile/fail/ref=module-info.javac.out -XDrawDiagnostics -Werror -Xlint:-options -Xdoclint:all module-info.java
*/
// missing doc comment
--- a/langtools/test/tools/doclint/moduleTests/good/module-info.java Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/test/tools/doclint/moduleTests/good/module-info.java Wed Nov 09 10:04:43 2016 -0800
@@ -29,7 +29,7 @@
* @modules jdk.compiler/com.sun.tools.doclint
* @build DocLintTester
* @run main DocLintTester module-info.java
- * @compile -Xdoclint:all -Werror module-info.java
+ * @compile -Xdoclint:all -Werror -Xlint:-options module-info.java
*/
/** good module */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/AnonymousClass/AnonymousCtorExceptionTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8166367
+ * @summary Missing ExceptionTable attribute in anonymous class constructors
+ * @library /tools/lib
+ * @modules jdk.compiler/com.sun.tools.javac.api
+ * jdk.compiler/com.sun.tools.javac.main
+ * jdk.jdeps/com.sun.tools.javap
+ * @build toolbox.ToolBox toolbox.JavapTask
+ * @run compile -g AnonymousCtorExceptionTest.java
+ * @run main AnonymousCtorExceptionTest
+ */
+
+import java.io.IOException;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import toolbox.JavapTask;
+import toolbox.Task;
+import toolbox.ToolBox;
+
+public class AnonymousCtorExceptionTest {
+
+ AnonymousCtorExceptionTest() throws IOException {
+ }
+
+ public static void main(String args[]) throws Exception {
+
+ new AnonymousCtorExceptionTest() {
+ };
+
+ ToolBox tb = new ToolBox();
+ Path classPath = Paths.get(ToolBox.testClasses, "AnonymousCtorExceptionTest$1.class");
+ String javapOut = new JavapTask(tb)
+ .options("-v", "-p")
+ .classes(classPath.toString())
+ .run()
+ .getOutput(Task.OutputKind.DIRECT);
+ if (!javapOut.contains("AnonymousCtorExceptionTest$1() throws java.io.IOException;"))
+ throw new AssertionError("Unexpected output " + javapOut);
+ if (!javapOut.contains("Exceptions:"))
+ throw new AssertionError("Unexpected output " + javapOut);
+ }
+}
\ No newline at end of file
--- a/langtools/test/tools/javac/T6403466.java Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/test/tools/javac/T6403466.java Wed Nov 09 10:04:43 2016 -0800
@@ -58,9 +58,7 @@
fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrcDir, self + ".java")));
Iterable<String> options = Arrays.asList(
- "--add-exports",
- "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED,"
- + "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
+ "--add-exports", "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
"--processor-path", testClassDir,
"-processor", self,
"-s", ".",
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/T8132562/ClassPathWithDoubleQuotesTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8132562
+ * @summary javac fails with CLASSPATH with double-quotes as an environment variable
+ * @library /tools/lib
+ * @modules jdk.compiler/com.sun.tools.javac.api
+ * jdk.compiler/com.sun.tools.javac.main
+ * @build toolbox.ToolBox toolbox.JavacTask
+ * @run main ClassPathWithDoubleQuotesTest
+*/
+
+import java.io.File;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import toolbox.TestRunner;
+import toolbox.JarTask;
+import toolbox.JavacTask;
+import toolbox.Task;
+import toolbox.ToolBox;
+
+public class ClassPathWithDoubleQuotesTest extends TestRunner {
+
+ ToolBox tb;
+
+ private static final String ASrc = "public class A {}";
+ private static final String JarSrc = "public class J {}";
+ private static final String[] jarArgs = {"cf", "test/J.jar", "-C", "test", "J.java"};
+
+ public static void main(String... args) throws Exception {
+ new ClassPathWithDoubleQuotesTest().runTests();
+ }
+
+ ClassPathWithDoubleQuotesTest() {
+ super(System.err);
+ tb = new ToolBox();
+ }
+
+ public void runTests() throws Exception {
+ runTests(m -> new Object[] { Paths.get(m.getName()) });
+ }
+
+ @Test
+ public void test(Path base) throws Exception {
+ Path current = base.resolve(".");
+ tb.writeJavaFiles(current, ASrc, JarSrc);
+ new JarTask(tb).run(jarArgs).writeAll();
+
+ executeTask(new JavacTask(tb, Task.Mode.EXEC)
+ .envVar("CLASSPATH", "\"test/J.jar" + File.pathSeparator + "test\"")
+ .files("test/A.java"));
+
+ executeTask(new JavacTask(tb)
+ .classpath("\"test/J.jar" + File.pathSeparator + "test\"")
+ .files("test/A.java"));
+ }
+
+ void executeTask(JavacTask task) {
+ boolean isWindows = System.getProperty("os.name").startsWith("Windows");
+ Task.Expect whatToExpect = isWindows ? Task.Expect.FAIL : Task.Expect.SUCCESS;
+ try {
+ task.run(whatToExpect);
+ if (isWindows) {
+ throw new AssertionError("exception must be thrown");
+ }
+ } catch (IllegalArgumentException iae) {
+ if (!isWindows) {
+ throw new AssertionError("exception unexpectedly thrown");
+ }
+ } catch (Throwable t) {
+ throw new AssertionError("unexpected exception thrown");
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/BadNameForOption.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.warn.bad.name.for.option
+// options: --add-exports Bad!Name/p=java.base
+
+class BadNameForOption { }
+
--- a/langtools/test/tools/javac/diags/examples/CantFindModule/CantFindModule.java Wed Nov 09 15:20:30 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-// key: compiler.err.cant.find.module
-// key: compiler.err.doesnt.exist
-
-// options: --add-exports undef/undef=ALL-UNNAMED
-
-import undef.Any;
-
-class Test {}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/ModuleForOptionNotFound.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.warn.module.for.option.not.found
+// key: compiler.err.doesnt.exist
+
+// options: --add-exports undefModule/undefPackage=ALL-UNNAMED
+
+import undefPackage.Any;
+
+class Test {}
+
--- a/langtools/test/tools/javac/diags/examples/ServiceDefinitionInner/ServiceDefinitionInner.java Wed Nov 09 15:20:30 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,25 +0,0 @@
-/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-// key: compiler.err.service.definition.is.inner
-// key: compiler.err.encl.class.required
--- a/langtools/test/tools/javac/diags/examples/ServiceDefinitionInner/modulesourcepath/m/module-info.java Wed Nov 09 15:20:30 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-module m {
- provides p1.C1.InnerDefinition with p2.C2;
- exports p1;
-}
--- a/langtools/test/tools/javac/diags/examples/ServiceDefinitionInner/modulesourcepath/m/p1/C1.java Wed Nov 09 15:20:30 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package p1;
-
-public class C1 {
- public class InnerDefinition {}
-}
--- a/langtools/test/tools/javac/diags/examples/ServiceDefinitionInner/modulesourcepath/m/p2/C2.java Wed Nov 09 15:20:30 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,26 +0,0 @@
-/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package p2;
-
-public class C2 extends p1.C1.InnerDefinition {}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/WrongNumberTypeArgsFragment.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.err.cant.apply.symbol
+// key: compiler.misc.wrong.number.type.args
+
+import java.util.*;
+
+class WrongNumberTypeArgsFragment {
+ void test() {
+ Arrays.<String, Integer>asList("");
+ }
+}
--- a/langtools/test/tools/javac/diags/examples/XaddexportsMalformedEntry.java Wed Nov 09 15:20:30 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-// key: compiler.err.xaddexports.malformed.entry
-// options: --add-exports jdk.compiler/com.sun.tools.javac.util
-
-public class XaddexportsMalformedEntry {
-}
--- a/langtools/test/tools/javac/diags/examples/XaddexportsTooMany.java Wed Nov 09 15:20:30 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-// key: compiler.err.xaddexports.too.many
-// options: --add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
-
-public class XaddexportsTooMany {
-}
--- a/langtools/test/tools/javac/diags/examples/XaddreadsMalformedEntry.java Wed Nov 09 15:20:30 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-// key: compiler.err.xaddreads.malformed.entry
-// options: --add-reads jdk.compiler
-
-public class XaddreadsMalformedEntry {
-}
--- a/langtools/test/tools/javac/diags/examples/XaddreadsTooMany.java Wed Nov 09 15:20:30 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-// key: compiler.err.xaddreads.too.many
-// options: --add-reads jdk.compiler=ALL-UNNAMED --add-reads jdk.compiler=ALL-UNNAMED
-
-public class XaddreadsTooMany {
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/inference/8168134/T8168134.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8168134
+ * @summary Inference: javac incorrectly propagating inner constraint with primitive target
+ * @compile T8168134.java
+ */
+
+abstract class T8168134 {
+ interface W<A> {}
+ abstract <B> B f(W<B> e);
+ abstract <C> C g(C b, long i);
+
+ void h(W<Long> i) {
+ g("", f(i));
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/meth/BadPolySig.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,12 @@
+/*
+ * @test
+ * @bug 8168774
+ * @summary Polymorhic signature method check crashes javac
+ * @compile -Xmodule:java.base BadPolySig.java
+ */
+
+package java.lang.invoke;
+
+class MethodHandle {
+ native Object m();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/modules/AddExportsTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,346 @@
+/*
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @summary Test the --add-exports option
+ * @library /tools/lib
+ * @modules jdk.compiler/com.sun.tools.javac.api
+ * jdk.compiler/com.sun.tools.javac.main
+ * @build toolbox.ToolBox toolbox.JavacTask ModuleTestBase
+ * @run main AddExportsTest
+ */
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Set;
+
+import toolbox.JavacTask;
+import toolbox.Task;
+import toolbox.ToolBox;
+
+public class AddExportsTest extends ModuleTestBase {
+
+ public static void main(String... args) throws Exception {
+ new AddExportsTest().runTests();
+ }
+
+ @Test
+ public void testEmpty(Path base) throws Exception {
+ Path src = base.resolve("src");
+ tb.writeJavaFiles(src, "class Dummy { }");
+ Path classes = base.resolve("classes");
+ tb.createDirectories(classes);
+ testEmpty(src, classes, "--add-exports", "");
+ testEmpty(src, classes, "--add-exports=");
+ }
+
+ private void testEmpty(Path src, Path classes, String... options) throws Exception {
+ String log = new JavacTask(tb, Task.Mode.CMDLINE)
+ .options(options)
+ .outdir(classes)
+ .files(findJavaFiles(src))
+ .run(Task.Expect.FAIL)
+ .writeAll()
+ .getOutput(Task.OutputKind.DIRECT);
+
+ checkOutputContains(log,
+ "javac: no value for --add-exports option");
+ }
+
+ @Test
+ public void testEmptyItem(Path base) throws Exception {
+ Path src = base.resolve("src");
+ Path src_m1 = src.resolve("m1");
+ tb.writeJavaFiles(src_m1,
+ "module m1 { }",
+ "package p1; public class C1 { }");
+ Path src_m2 = src.resolve("m2");
+ tb.writeJavaFiles(src_m2,
+ "module m2 { }",
+ "package p2; class C2 { p1.C1 c1; }");
+ Path src_m3 = src.resolve("m3");
+ tb.writeJavaFiles(src_m3,
+ "module m3 { }",
+ "package p3; class C3 { p1.C1 c1; }");
+ Path classes = base.resolve("classes");
+ tb.createDirectories(classes);
+
+ testEmptyItem(src, classes, "m1/p1=,m2,m3");
+ testEmptyItem(src, classes, "m1/p1=m2,,m3");
+ testEmptyItem(src, classes, "m1/p1=m2,m3,");
+ }
+
+ void testEmptyItem(Path src, Path classes, String option) throws Exception {
+ new JavacTask(tb)
+ .options("--module-source-path", src.toString(),
+ "--add-exports", option)
+ .outdir(classes)
+ .files(findJavaFiles(src))
+ .run()
+ .writeAll();
+ }
+
+ @Test
+ public void testEmptyList(Path base) throws Exception {
+ Path src = base.resolve("src");
+ Path src_m1 = src.resolve("m1");
+ tb.writeJavaFiles(src_m1,
+ "module m1 { exports p1; }",
+ "package p1; public class C1 { }");
+ Path classes = base.resolve("classes");
+ tb.createDirectories(classes);
+
+ testEmptyList(src, classes, "m1/p1=");
+ testEmptyList(src, classes, "m1/p1=,");
+ }
+
+ void testEmptyList(Path src, Path classes, String option) throws Exception {
+ String log = new JavacTask(tb, Task.Mode.CMDLINE)
+ .options("--module-source-path", src.toString(),
+ "--add-exports", option)
+ .outdir(classes)
+ .files(findJavaFiles(src))
+ .run(Task.Expect.FAIL)
+ .writeAll()
+ .getOutput(Task.OutputKind.DIRECT);
+
+ checkOutputContains(log,
+ "javac: bad value for --add-exports option: '" + option + "'");
+ }
+
+ @Test
+ public void testMissingSourceParts(Path base) throws Exception {
+ Path src = base.resolve("src");
+ Path src_m1 = src.resolve("m1");
+ tb.writeJavaFiles(src_m1,
+ "module m1 { exports p1; }",
+ "package p1; public class C1 { }");
+ Path src_m2 = src.resolve("m2");
+ tb.writeJavaFiles(src_m2,
+ "module m2 { }",
+ "package p2; class C2 { p1.C1 c1; }");
+ Path classes = base.resolve("classes");
+ tb.createDirectories(classes);
+
+ testMissingSourcePart(src, classes, "=m2");
+ testMissingSourcePart(src, classes, "/=m2");
+ testMissingSourcePart(src, classes, "m1/=m2");
+ testMissingSourcePart(src, classes, "/p1=m2");
+ testMissingSourcePart(src, classes, "m1p1=m2");
+ }
+
+ private void testMissingSourcePart(Path src, Path classes, String option) throws Exception {
+ String log = new JavacTask(tb, Task.Mode.CMDLINE)
+ .options("--module-source-path", src.toString(),
+ "--add-exports", option)
+ .outdir(classes)
+ .files(findJavaFiles(src))
+ .run(Task.Expect.FAIL)
+ .writeAll()
+ .getOutput(Task.OutputKind.DIRECT);
+
+ checkOutputContains(log,
+ "javac: bad value for --add-exports option: '" + option + "'");
+ }
+
+ @Test
+ public void testBadSourceParts(Path base) throws Exception {
+ Path src = base.resolve("src");
+ Path src_m1 = src.resolve("m1");
+ tb.writeJavaFiles(src_m1,
+ "module m1 { exports p1; }",
+ "package p1; public class C1 { }");
+ Path src_m2 = src.resolve("m2");
+ tb.writeJavaFiles(src_m2,
+ "module m2 { }",
+ "package p2; class C2 { p1.C1 c1; }");
+ Path classes = base.resolve("classes");
+ tb.createDirectories(classes);
+
+ testBadSourcePart(src, classes, "m!/p1=m2", "m!");
+ testBadSourcePart(src, classes, "m1/p!=m2", "p!");
+ }
+
+ private void testBadSourcePart(Path src, Path classes, String option, String badName)
+ throws Exception {
+ String log = new JavacTask(tb, Task.Mode.CMDLINE)
+ .options("-XDrawDiagnostics",
+ "--module-source-path", src.toString(),
+ "--add-exports", option)
+ .outdir(classes)
+ .files(findJavaFiles(src))
+ .run(Task.Expect.FAIL)
+ .writeAll()
+ .getOutput(Task.OutputKind.DIRECT);
+
+ checkOutputContains(log,
+ "- compiler.warn.bad.name.for.option: --add-exports, " + badName);
+ }
+
+ @Test
+ public void testBadTarget(Path base) throws Exception {
+ Path src = base.resolve("src");
+ Path src_m1 = src.resolve("m1");
+ tb.writeJavaFiles(src_m1,
+ "module m1 { exports p1; }",
+ "package p1; public class C1 { }");
+ Path classes = base.resolve("classes");
+ tb.createDirectories(classes);
+
+ String log = new JavacTask(tb, Task.Mode.CMDLINE)
+ .options("-XDrawDiagnostics",
+ "--module-source-path", src.toString(),
+ "--add-exports", "m1/p1=m!")
+ .outdir(classes)
+ .files(findJavaFiles(src))
+ .run()
+ .writeAll()
+ .getOutput(Task.OutputKind.DIRECT);
+
+ checkOutputContains(log,
+ "- compiler.warn.bad.name.for.option: --add-exports, m!");
+ }
+
+ @Test
+ public void testSourceNotFound(Path base) throws Exception {
+ Path src = base.resolve("src");
+ Path src_m1 = src.resolve("m1");
+ tb.writeJavaFiles(src_m1,
+ "module m1 { }");
+ Path classes = base.resolve("classes");
+ tb.createDirectories(classes);
+
+ String log = new JavacTask(tb, Task.Mode.CMDLINE)
+ .options("-XDrawDiagnostics",
+ "--module-source-path", src.toString(),
+ "--add-exports", "DoesNotExist/p=m1")
+ .outdir(classes)
+ .files(findJavaFiles(src))
+ .run()
+ .writeAll()
+ .getOutput(Task.OutputKind.DIRECT);
+
+ checkOutputContains(log,
+ "- compiler.warn.module.for.option.not.found: --add-exports, DoesNotExist");
+ }
+
+ @Test
+ public void testTargetNotFound(Path base) throws Exception {
+ Path src = base.resolve("src");
+ Path src_m1 = src.resolve("m1");
+ tb.writeJavaFiles(src_m1,
+ "module m1 { }",
+ "package p1; class C1 { }");
+ Path classes = base.resolve("classes");
+ tb.createDirectories(classes);
+
+ String log = new JavacTask(tb, Task.Mode.CMDLINE)
+ .options("-XDrawDiagnostics",
+ "--module-source-path", src.toString(),
+ "--add-exports", "m1/p1=DoesNotExist")
+ .outdir(classes)
+ .files(findJavaFiles(src))
+ .run()
+ .writeAll()
+ .getOutput(Task.OutputKind.DIRECT);
+
+ checkOutputContains(log,
+ "- compiler.warn.module.for.option.not.found: --add-exports, DoesNotExist");
+ }
+
+ @Test
+ public void testDuplicate(Path base) throws Exception {
+ Path src = base.resolve("src");
+ Path src_m1 = src.resolve("m1");
+ tb.writeJavaFiles(src_m1,
+ "module m1 { }",
+ "package p1; public class C1 { }");
+ Path src_m2 = src.resolve("m2");
+ tb.writeJavaFiles(src_m2,
+ "module m2 { }",
+ "package p2; class C2 { p1.C1 c1; }");
+ Path classes = base.resolve("classes");
+ tb.createDirectories(classes);
+
+ new JavacTask(tb)
+ .options("--module-source-path", src.toString(),
+ "--add-exports", "m1/p1=m2,m2")
+ .outdir(classes)
+ .files(findJavaFiles(src))
+ .run()
+ .writeAll();
+ }
+
+ @Test
+ public void testRepeated_SameTarget(Path base) throws Exception {
+ Path src = base.resolve("src");
+ Path src_m1 = src.resolve("m1");
+ tb.writeJavaFiles(src_m1,
+ "module m1 { }",
+ "package p1; public class C1 { }");
+ Path src_m2 = src.resolve("m2");
+ tb.writeJavaFiles(src_m2,
+ "module m2 { }",
+ "package p2; class C2 { p1.C1 c1; }");
+ Path classes = base.resolve("classes");
+ tb.createDirectories(classes);
+
+ new JavacTask(tb)
+ .options("--module-source-path", src.toString(),
+ "--add-exports", "m1/p1=m2",
+ "--add-exports", "m1/p1=m2")
+ .outdir(classes)
+ .files(findJavaFiles(src))
+ .run()
+ .writeAll();
+ }
+
+ @Test
+ public void testRepeated_DifferentTarget(Path base) throws Exception {
+ Path src = base.resolve("src");
+ Path src_m1 = src.resolve("m1");
+ tb.writeJavaFiles(src_m1,
+ "module m1 { }",
+ "package p1; public class C1 { }");
+ Path src_m2 = src.resolve("m2");
+ tb.writeJavaFiles(src_m2,
+ "module m2 { }",
+ "package p2; class C2 { p1.C1 c1; }");
+ Path src_m3 = src.resolve("m3");
+ tb.writeJavaFiles(src_m3,
+ "module m3 { }",
+ "package p3; class C3 { p1.C1 c1; }");
+ Path classes = base.resolve("classes");
+ tb.createDirectories(classes);
+
+ new JavacTask(tb)
+ .options("--module-source-path", src.toString(),
+ "--add-exports", "m1/p1=m2",
+ "--add-exports", "m1/p1=m3")
+ .outdir(classes)
+ .files(findJavaFiles(src))
+ .run()
+ .writeAll();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/modules/AddModulesTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,232 @@
+/*
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @summary Test the --add-modules option
+ * @library /tools/lib
+ * @modules jdk.compiler/com.sun.tools.javac.api
+ * jdk.compiler/com.sun.tools.javac.main
+ * @build toolbox.ToolBox toolbox.JavacTask ModuleTestBase
+ * @run main AddModulesTest
+ */
+
+
+import java.nio.file.Path;
+
+import toolbox.JavacTask;
+import toolbox.Task;
+import toolbox.ToolBox;
+
+public class AddModulesTest extends ModuleTestBase {
+ public static void main(String... args) throws Exception {
+ new AddModulesTest().runTests();
+ }
+
+ @Test
+ public void testEmpty(Path base) throws Exception {
+ Path src = base.resolve("src");
+ tb.writeJavaFiles(src, "class Dummy { }");
+ Path classes = base.resolve("classes");
+ tb.createDirectories(classes);
+
+ testEmpty(src, classes, "--add-modules", "");
+ testEmpty(src, classes, "--add-modules=");
+ }
+
+ private void testEmpty(Path src, Path classes, String... options) throws Exception {
+ String log = new JavacTask(tb, Task.Mode.CMDLINE)
+ .options(options)
+ .outdir(classes)
+ .files(findJavaFiles(src))
+ .run(Task.Expect.FAIL)
+ .writeAll()
+ .getOutput(Task.OutputKind.DIRECT);
+
+ checkOutputContains(log,
+ "javac: no value for --add-modules option");
+ }
+
+ @Test
+ public void testEmptyItem(Path base) throws Exception {
+ Path src = base.resolve("src");
+ Path src_m1 = src.resolve("m1");
+ tb.writeJavaFiles(src_m1,
+ "module m1 { }");
+ Path src_m2 = src.resolve("m2");
+ tb.writeJavaFiles(src_m2,
+ "module m2 { }");
+ Path classes = base.resolve("classes");
+ tb.createDirectories(classes);
+
+ testEmptyItem(src, classes, ",m1");
+ testEmptyItem(src, classes, "m1,,m2");
+ testEmptyItem(src, classes, "m1,");
+ }
+
+ private void testEmptyItem(Path src, Path classes, String option) throws Exception {
+ new JavacTask(tb)
+ .options("--module-source-path", src.toString(),
+ "--add-modules", option)
+ .outdir(classes)
+ .files(findJavaFiles(src))
+ .run()
+ .writeAll();
+ }
+
+ @Test
+ public void testEmptyList(Path base) throws Exception {
+ Path src = base.resolve("src");
+ tb.writeJavaFiles(src, "class Dummy { }");
+ Path classes = base.resolve("classes");
+ tb.createDirectories(classes);
+
+ String log = new JavacTask(tb, Task.Mode.CMDLINE)
+ .options("--module-source-path", src.toString(),
+ "--add-modules", ",")
+ .outdir(classes)
+ .files(findJavaFiles(src))
+ .run(Task.Expect.FAIL)
+ .writeAll()
+ .getOutput(Task.OutputKind.DIRECT);
+
+ checkOutputContains(log,
+ "javac: bad value for --add-modules option");
+ }
+
+ @Test
+ public void testInvalidName(Path base) throws Exception {
+ Path src = base.resolve("src");
+ tb.writeJavaFiles(src, "class Dummy { }");
+ Path classes = base.resolve("classes");
+ tb.createDirectories(classes);
+
+ String log = new JavacTask(tb)
+ .options("-XDrawDiagnostics",
+ "--add-modules", "BadModule!")
+ .outdir(classes)
+ .files(findJavaFiles(src))
+ .run()
+ .writeAll()
+ .getOutput(Task.OutputKind.DIRECT);
+
+ checkOutputContains(log,
+ "- compiler.warn.bad.name.for.option: --add-modules, BadModule!");
+ }
+
+ @Test
+ public void testUnknownName(Path base) throws Exception {
+ Path src = base.resolve("src");
+ tb.writeJavaFiles(src, "class Dummy { }");
+ Path classes = base.resolve("classes");
+ tb.createDirectories(classes);
+
+ String log = new JavacTask(tb)
+ .options("-XDrawDiagnostics",
+ "--add-modules", "DoesNotExist")
+ .outdir(classes)
+ .files(findJavaFiles(src))
+ .run(Task.Expect.FAIL)
+ .writeAll()
+ .getOutput(Task.OutputKind.DIRECT);
+
+ checkOutputContains(log,
+ "- compiler.err.module.not.found: DoesNotExist");
+ }
+
+ @Test
+ public void testDuplicate(Path base) throws Exception {
+ Path src = base.resolve("src");
+
+ // setup a utility module
+ Path src_m1 = src.resolve("m1");
+ tb.writeJavaFiles(src_m1,
+ "module m1 { exports p1; }",
+ "package p1; public class C1 { }");
+ Path modules = base.resolve("modules");
+ tb.createDirectories(modules);
+
+ new JavacTask(tb)
+ .options("--module-source-path", src.toString())
+ .outdir(modules)
+ .files(findJavaFiles(src))
+ .run()
+ .writeAll();
+
+ // now test access to the module
+ Path src2 = base.resolve("src2");
+ tb.writeJavaFiles(src2,
+ "class Dummy { p1.C1 c1; }");
+ Path classes = base.resolve("classes");
+ tb.createDirectories(classes);
+
+ new JavacTask(tb)
+ .options("--module-path", modules.toString(),
+ "--add-modules", "m1,m1")
+ .outdir(classes)
+ .files(findJavaFiles(src2))
+ .run()
+ .writeAll();
+ }
+
+ @Test
+ public void testRepeatable(Path base) throws Exception {
+ Path src = base.resolve("src");
+
+ // setup some utility modules
+ Path src_m1 = src.resolve("m1");
+ tb.writeJavaFiles(src_m1,
+ "module m1 { exports p1; }",
+ "package p1; public class C1 { }");
+ Path src_m2 = src.resolve("m2");
+ tb.writeJavaFiles(src_m2,
+ "module m2 { exports p2; }",
+ "package p2; public class C2 { }");
+ Path modules = base.resolve("modules");
+ tb.createDirectories(modules);
+
+ new JavacTask(tb)
+ .options("--module-source-path", src.toString())
+ .outdir(modules)
+ .files(findJavaFiles(src))
+ .run()
+ .writeAll();
+
+ // now test access to the modules
+ Path src2 = base.resolve("src2");
+ tb.writeJavaFiles(src2,
+ "class Dummy { p1.C1 c1; p2.C2 c2; }");
+ Path classes = base.resolve("classes");
+ tb.createDirectories(classes);
+
+ new JavacTask(tb)
+ .options("--module-path", modules.toString(),
+ "--add-modules", "m1",
+ "--add-modules", "m2")
+ .outdir(classes)
+ .files(findJavaFiles(src2))
+ .run()
+ .writeAll();
+ }
+}
+
--- a/langtools/test/tools/javac/modules/AddReadsTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/test/tools/javac/modules/AddReadsTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -28,6 +28,7 @@
* @modules jdk.compiler/com.sun.tools.javac.api
* jdk.compiler/com.sun.tools.javac.main
* jdk.jdeps/com.sun.tools.javap
+ * java.desktop
* @build toolbox.ToolBox toolbox.JarTask toolbox.JavacTask toolbox.JavapTask ModuleTestBase
* @run main AddReadsTest
*/
@@ -49,7 +50,6 @@
import toolbox.JavacTask;
import toolbox.JavapTask;
import toolbox.Task;
-import toolbox.ToolBox;
public class AddReadsTest extends ModuleTestBase {
@@ -80,8 +80,8 @@
.writeAll()
.getOutput(Task.OutputKind.DIRECT);
- if (!log.contains("Test.java:1:44: compiler.err.not.def.access.package.cant.access: api.Api, api"))
- throw new Exception("expected output not found");
+ checkOutputContains(log,
+ "Test.java:1:44: compiler.err.not.def.access.package.cant.access: api.Api, api");
//test add dependencies:
new JavacTask(tb)
@@ -104,7 +104,8 @@
//cyclic dependencies OK when created through addReads:
new JavacTask(tb)
- .options("--add-reads", "m2=m1,m1=m2",
+ .options("--add-reads", "m2=m1",
+ "--add-reads", "m1=m2",
"--module-source-path", src.toString())
.outdir(classes)
.files(findJavaFiles(src))
@@ -233,7 +234,8 @@
"package impl; public class Impl { javax.swing.JButton b; }");
new JavacTask(tb)
- .options("--add-reads", "java.base=java.desktop",
+ .options("--add-modules", "java.desktop",
+ "--add-reads", "java.base=java.desktop",
"-Xmodule:java.base")
.outdir(classes)
.files(findJavaFiles(src))
@@ -308,4 +310,356 @@
.run()
.writeAll();
}
+
+ @Test
+ public void testAddSelf(Path base) throws Exception {
+ Path src = base.resolve("src");
+ Path src_m1 = src.resolve("m1");
+ tb.writeJavaFiles(src_m1,
+ "module m1 { exports p1; }",
+ "package p1; public class C1 { }");
+ Path classes = base.resolve("classes");
+ tb.createDirectories(classes);
+
+ new JavacTask(tb)
+ .options("--module-source-path", src.toString(),
+ "--add-reads", "m1=m1")
+ .outdir(classes)
+ .files(findJavaFiles(src))
+ .run()
+ .writeAll();
+ }
+
+ @Test
+ public void testEmpty(Path base) throws Exception {
+ Path src = base.resolve("src");
+ tb.writeJavaFiles(src, "class Dummy { }");
+ Path classes = base.resolve("classes");
+ tb.createDirectories(classes);
+
+ testEmpty(src, classes, "--add-reads", "");
+ testEmpty(src, classes, "--add-reads=");
+ }
+
+ private void testEmpty(Path src, Path classes, String... options) throws Exception {
+ String log = new JavacTask(tb, Task.Mode.CMDLINE)
+ .options(options)
+ .outdir(classes)
+ .files(findJavaFiles(src))
+ .run(Task.Expect.FAIL)
+ .writeAll()
+ .getOutput(Task.OutputKind.DIRECT);
+
+ checkOutputContains(log,
+ "javac: no value for --add-reads option");
+ }
+
+ @Test
+ public void testEmptyItem(Path base) throws Exception {
+ Path src = base.resolve("src");
+ Path src_m1 = src.resolve("m1");
+ tb.writeJavaFiles(src_m1,
+ "module m1 { exports p1; }",
+ "package p1; public class C1 { }");
+ Path src_m2 = src.resolve("m2");
+ tb.writeJavaFiles(src_m2,
+ "module m2 { }",
+ "package p2; class C2 { }");
+ Path src_m3 = src.resolve("m3");
+ tb.writeJavaFiles(src_m3,
+ "module m3 { }",
+ "package p3; class C3 { p1.C1 c1; }");
+ Path classes = base.resolve("classes");
+ tb.createDirectories(classes);
+
+ testEmptyItem(src, classes, "m3=,m1");
+ testEmptyItem(src, classes, "m3=m1,,m2");
+ testEmptyItem(src, classes, "m3=m1,");
+ }
+
+ private void testEmptyItem(Path src, Path classes, String option) throws Exception {
+ new JavacTask(tb)
+ .options("--module-source-path", src.toString(),
+ "--add-reads", option)
+ .outdir(classes)
+ .files(findJavaFiles(src))
+ .run()
+ .writeAll();
+ }
+
+ @Test
+ public void testEmptyList(Path base) throws Exception {
+ Path src = base.resolve("src");
+ Path src_m1 = src.resolve("m1");
+ tb.writeJavaFiles(src_m1,
+ "module m1 { exports p1; }",
+ "package p1; public class C1 { }");
+ Path src_m2 = src.resolve("m2");
+ tb.writeJavaFiles(src_m2,
+ "module m2 { }",
+ "package p2; class C2 { }");
+ Path src_m3 = src.resolve("m3");
+ tb.writeJavaFiles(src_m3,
+ "module m3 { }",
+ "package p3; class C3 { p1.C1 c1; }");
+ Path classes = base.resolve("classes");
+ tb.createDirectories(classes);
+
+ testEmptyList(src, classes, "m3=");
+ testEmptyList(src, classes, "m3=,");
+ }
+
+ private void testEmptyList(Path src, Path classes, String option) throws Exception {
+ String log = new JavacTask(tb, Task.Mode.CMDLINE)
+ .options("--module-source-path", src.toString(),
+ "--add-reads", option)
+ .outdir(classes)
+ .files(findJavaFiles(src))
+ .run(Task.Expect.FAIL)
+ .writeAll()
+ .getOutput(Task.OutputKind.DIRECT);
+
+ checkOutputContains(log,
+ "javac: bad value for --add-reads option: '" + option + "'");
+ }
+
+ @Test
+ public void testMultipleAddReads_DifferentModules(Path base) throws Exception {
+ Path src = base.resolve("src");
+ Path src_m1 = src.resolve("m1");
+ tb.writeJavaFiles(src_m1,
+ "module m1 { exports p1; }",
+ "package p1; public class C1 { }");
+ Path src_m2 = src.resolve("m2");
+ tb.writeJavaFiles(src_m2,
+ "module m2 { }",
+ "package p2; class C2 { p1.C1 c1; }");
+ Path src_m3 = src.resolve("m3");
+ tb.writeJavaFiles(src_m3,
+ "module m3 { }",
+ "package p3; class C3 { p1.C1 c1; }");
+ Path classes = base.resolve("classes");
+ tb.createDirectories(classes);
+
+ new JavacTask(tb)
+ .options("--module-source-path", src.toString(),
+ "--add-reads", "m2=m1",
+ "--add-reads", "m3=m1")
+ .outdir(classes)
+ .files(findJavaFiles(src))
+ .run()
+ .writeAll();
+ }
+
+ @Test
+ public void testMultipleAddReads_SameModule(Path base) throws Exception {
+ Path src = base.resolve("src");
+ Path src_m1 = src.resolve("m1");
+ tb.writeJavaFiles(src_m1,
+ "module m1 { exports p1; }",
+ "package p1; public class C1 { }");
+ Path src_m2 = src.resolve("m2");
+ tb.writeJavaFiles(src_m2,
+ "module m2 { exports p2; }",
+ "package p2; public class C2 { }");
+ Path src_m3 = src.resolve("m3");
+ tb.writeJavaFiles(src_m3,
+ "module m3 { }",
+ "package p3; class C3 { p1.C1 c1; p2.C2 c2; }");
+ Path classes = base.resolve("classes");
+ tb.createDirectories(classes);
+
+ new JavacTask(tb)
+ .options("--module-source-path", src.toString(),
+ "--add-reads", "m3=m1",
+ "--add-reads", "m3=m2")
+ .outdir(classes)
+ .files(findJavaFiles(src))
+ .run()
+ .writeAll();
+ }
+
+ @Test
+ public void testDuplicateAddReads_SameOption(Path base) throws Exception {
+ Path src = base.resolve("src");
+ Path src_m1 = src.resolve("m1");
+ tb.writeJavaFiles(src_m1,
+ "module m1 { exports p1; }",
+ "package p1; public class C1 { }");
+ Path src_m2 = src.resolve("m2");
+ tb.writeJavaFiles(src_m2,
+ "module m2 { exports p2; }",
+ "package p2; class C2 { p1.C1 c1; }");
+ Path classes = base.resolve("classes");
+ tb.createDirectories(classes);
+
+ new JavacTask(tb)
+ .options("--module-source-path", src.toString(),
+ "--add-reads", "m2=m1,m1")
+ .outdir(classes)
+ .files(findJavaFiles(src))
+ .run()
+ .writeAll();
+ }
+
+ @Test
+ public void testDuplicateAddReads_MultipleOptions(Path base) throws Exception {
+ Path src = base.resolve("src");
+ Path src_m1 = src.resolve("m1");
+ tb.writeJavaFiles(src_m1,
+ "module m1 { exports p1; }",
+ "package p1; public class C1 { }");
+ Path src_m2 = src.resolve("m2");
+ tb.writeJavaFiles(src_m2,
+ "module m2 { }",
+ "package p2; class C2 { p1.C1 c1; }");
+ Path classes = base.resolve("classes");
+ tb.createDirectories(classes);
+
+ new JavacTask(tb)
+ .options("--module-source-path", src.toString(),
+ "--add-reads", "m2=m1",
+ "--add-reads", "m2=m1")
+ .outdir(classes)
+ .files(findJavaFiles(src))
+ .run()
+ .writeAll();
+ }
+
+ @Test
+ public void testRepeatedAddReads(Path base) throws Exception {
+ Path src = base.resolve("src");
+ Path src_m1 = src.resolve("m1");
+ tb.writeJavaFiles(src_m1,
+ "module m1 { exports p1; }",
+ "package p1; public class C1 { }");
+ Path src_m2 = src.resolve("m2");
+ tb.writeJavaFiles(src_m2,
+ "module m2 { exports p2; }",
+ "package p2; public class C2 { }");
+ Path src_m3 = src.resolve("m3");
+ tb.writeJavaFiles(src_m3,
+ "module m3 { }",
+ "package p3; class C3 { p1.C1 c1; p2.C2 c2; }");
+ Path classes = base.resolve("classes");
+ tb.createDirectories(classes);
+
+ new JavacTask(tb)
+ .options("--module-source-path", src.toString(),
+ "--add-reads", "m3=m1",
+ "--add-reads", "m3=m2")
+ .outdir(classes)
+ .files(findJavaFiles(src))
+ .run()
+ .writeAll();
+ }
+
+ @Test
+ public void testNoEquals(Path base) throws Exception {
+ Path src = base.resolve("src");
+ tb.writeJavaFiles(src, "class Dummy { }");
+ Path classes = base.resolve("classes");
+ tb.createDirectories(classes);
+
+ String log = new JavacTask(tb, Task.Mode.CMDLINE)
+ .options("-XDrawDiagnostics",
+ "--add-reads", "m1:m2")
+ .outdir(classes)
+ .files(findJavaFiles(src))
+ .run(Task.Expect.FAIL)
+ .writeAll()
+ .getOutput(Task.OutputKind.DIRECT);
+
+ checkOutputContains(log,
+ "javac: bad value for --add-reads option: 'm1:m2'");
+ }
+
+ @Test
+ public void testBadSourceName(Path base) throws Exception {
+ Path src = base.resolve("src");
+ tb.writeJavaFiles(src, "class Dummy { }");
+ Path classes = base.resolve("classes");
+ tb.createDirectories(classes);
+
+ String log = new JavacTask(tb)
+ .options("-XDrawDiagnostics",
+ "--add-reads", "bad*Source=m2")
+ .outdir(classes)
+ .files(findJavaFiles(src))
+ .run()
+ .writeAll()
+ .getOutput(Task.OutputKind.DIRECT);
+
+ checkOutputContains(log,
+ "- compiler.warn.bad.name.for.option: --add-reads, bad*Source");
+ }
+
+ @Test
+ public void testBadTargetName(Path base) throws Exception {
+ Path src = base.resolve("src");
+ Path src_m1 = src.resolve("m1");
+ tb.writeJavaFiles(src_m1,
+ "module m1 { }",
+ "package p1; class C1 { }");
+ Path classes = base.resolve("classes");
+ tb.createDirectories(classes);
+
+ String log = new JavacTask(tb)
+ .options("-XDrawDiagnostics",
+ "--add-reads", "m1=badTarget!")
+ .outdir(classes)
+ .files(findJavaFiles(src))
+ .run()
+ .writeAll()
+ .getOutput(Task.OutputKind.DIRECT);
+
+ checkOutputContains(log,
+ "- compiler.warn.bad.name.for.option: --add-reads, badTarget!");
+ }
+
+ @Test
+ public void testSourceNameNotFound(Path base) throws Exception {
+ Path src = base.resolve("src");
+ Path src_m1 = src.resolve("m1");
+ tb.writeJavaFiles(src_m1,
+ "module m1 { exports p1; }",
+ "package p1; public class C1 { }");
+ Path classes = base.resolve("classes");
+ tb.createDirectories(classes);
+
+ String log = new JavacTask(tb)
+ .options("-XDrawDiagnostics",
+ "--add-reads", "missingSource=m1")
+ .outdir(classes)
+ .files(findJavaFiles(src))
+ .run()
+ .writeAll()
+ .getOutput(Task.OutputKind.DIRECT);
+
+ checkOutputContains(log,
+ "- compiler.warn.module.for.option.not.found: --add-reads, missingSource");
+ }
+
+ @Test
+ public void testTargetNameNotFound(Path base) throws Exception {
+ Path src = base.resolve("src");
+ Path src_m1 = src.resolve("m1");
+ tb.writeJavaFiles(src_m1,
+ "module m1 { exports p1; }",
+ "package p1; public class C1 { }");
+ Path classes = base.resolve("classes");
+ tb.createDirectories(classes);
+
+ String log = new JavacTask(tb)
+ .options("-XDrawDiagnostics",
+ "--add-reads", "m1=missingTarget")
+ .outdir(classes)
+ .files(findJavaFiles(src))
+ .run()
+ .writeAll()
+ .getOutput(Task.OutputKind.DIRECT);
+
+ checkOutputContains(log,
+ "- compiler.warn.module.for.option.not.found: --add-reads, missingTarget");
+ }
}
--- a/langtools/test/tools/javac/modules/AnnotationProcessorsInModulesTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/test/tools/javac/modules/AnnotationProcessorsInModulesTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -230,8 +230,7 @@
.run(Task.Expect.FAIL)
.writeAll()
.getOutputLines(Task.OutputKind.DIRECT);
- if (!log.equals(Arrays.asList("- compiler.err.processorpath.no.processormodulepath",
- "1 error"))) {
+ if (!log.equals(Arrays.asList("- compiler.err.processorpath.no.processormodulepath"))) {
throw new AssertionError("Unexpected output: " + log);
}
}
--- a/langtools/test/tools/javac/modules/EdgeCases.java Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/test/tools/javac/modules/EdgeCases.java Wed Nov 09 10:04:43 2016 -0800
@@ -71,21 +71,22 @@
@Test
public void testAddExportUndefinedModule(Path base) throws Exception {
Path src = base.resolve("src");
- tb.writeJavaFiles(src, "package test; import undef.Any; public class Test {}");
+ tb.writeJavaFiles(src, "package test; import undefPackage.Any; public class Test {}");
Path classes = base.resolve("classes");
tb.createDirectories(classes);
List<String> log = new JavacTask(tb)
- .options("--add-exports", "undef/undef=ALL-UNNAMED", "-XDrawDiagnostics")
+ .options("--add-exports", "undefModule/undefPackage=ALL-UNNAMED",
+ "-XDrawDiagnostics")
.outdir(classes)
.files(findJavaFiles(src))
.run(Task.Expect.FAIL)
.writeAll()
.getOutputLines(Task.OutputKind.DIRECT);
- List<String> expected = Arrays.asList("- compiler.err.cant.find.module: undef",
- "Test.java:1:27: compiler.err.doesnt.exist: undef",
- "2 errors");
+ List<String> expected = Arrays.asList("- compiler.warn.module.for.option.not.found: --add-exports, undefModule",
+ "Test.java:1:34: compiler.err.doesnt.exist: undefPackage",
+ "1 error", "1 warning");
if (!expected.equals(log))
throw new Exception("expected output not found: " + log);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/modules/LimitModulesTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,188 @@
+/*
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @summary Test the --limit-modules option
+ * @library /tools/lib
+ * @modules jdk.compiler/com.sun.tools.javac.api
+ * jdk.compiler/com.sun.tools.javac.main
+ * @build toolbox.ToolBox toolbox.JavacTask ModuleTestBase
+ * @run main LimitModulesTest
+ */
+
+
+import java.nio.file.Path;
+
+import toolbox.JavacTask;
+import toolbox.Task;
+import toolbox.ToolBox;
+
+public class LimitModulesTest extends ModuleTestBase {
+ public static void main(String... args) throws Exception {
+ new LimitModulesTest().runTests();
+ }
+
+ @Test
+ public void testEmpty(Path base) throws Exception {
+ Path src = base.resolve("src");
+ tb.writeJavaFiles(src, "class Dummy { }");
+ Path classes = base.resolve("classes");
+ tb.createDirectories(classes);
+
+ String log = new JavacTask(tb, Task.Mode.CMDLINE)
+ .options("--module-source-path", src.toString(),
+ "--limit-modules", "")
+ .outdir(classes)
+ .files(findJavaFiles(src))
+ .run(Task.Expect.FAIL)
+ .writeAll()
+ .getOutput(Task.OutputKind.DIRECT);
+
+ if (!log.contains("javac: no value for --limit-modules option"))
+ throw new Exception("expected output not found");
+
+ log = new JavacTask(tb, Task.Mode.CMDLINE)
+ .options("--module-source-path", src.toString(),
+ "--limit-modules=")
+ .outdir(classes)
+ .files(findJavaFiles(src))
+ .run(Task.Expect.FAIL)
+ .writeAll()
+ .getOutput(Task.OutputKind.DIRECT);
+
+ if (!log.contains("javac: no value for --limit-modules option"))
+ throw new Exception("expected output not found");
+ }
+
+ @Test
+ public void testEmptyItem(Path base) throws Exception {
+ Path src = base.resolve("src");
+ Path src_m1 = src.resolve("m1");
+ tb.writeJavaFiles(src_m1,
+ "module m1 { }");
+ Path src_m2 = src.resolve("m2");
+ tb.writeJavaFiles(src_m2,
+ "module m2 { }");
+ Path classes = base.resolve("classes");
+ tb.createDirectories(classes);
+
+ new JavacTask(tb)
+ .options("--module-source-path", src.toString(),
+ "--limit-modules", ",m1")
+ .outdir(classes)
+ .files(findJavaFiles(src))
+ .run()
+ .writeAll();
+
+ new JavacTask(tb)
+ .options("--module-source-path", src.toString(),
+ "--limit-modules", "m1,,m2")
+ .outdir(classes)
+ .files(findJavaFiles(src))
+ .run()
+ .writeAll();
+
+ new JavacTask(tb)
+ .options("--module-source-path", src.toString(),
+ "--limit-modules", "m1,")
+ .outdir(classes)
+ .files(findJavaFiles(src))
+ .run()
+ .writeAll();
+ }
+
+ @Test
+ public void testEmptyList(Path base) throws Exception {
+ Path src = base.resolve("src");
+ tb.writeJavaFiles(src, "class Dummy { }");
+ Path classes = base.resolve("classes");
+ tb.createDirectories(classes);
+
+ String log = new JavacTask(tb, Task.Mode.CMDLINE)
+ .options("--module-source-path", src.toString(),
+ "--limit-modules", ",")
+ .outdir(classes)
+ .files(findJavaFiles(src))
+ .run(Task.Expect.FAIL)
+ .writeAll()
+ .getOutput(Task.OutputKind.DIRECT);
+
+ if (!log.contains("javac: bad value for --limit-modules option"))
+ throw new Exception("expected output not found");
+ }
+
+ @Test
+ public void testInvalidName(Path base) throws Exception {
+ Path src = base.resolve("src");
+ tb.writeJavaFiles(src, "class Dummy { }");
+ Path classes = base.resolve("classes");
+ tb.createDirectories(classes);
+
+ String log = new JavacTask(tb)
+ .options("-XDrawDiagnostics",
+ "--limit-modules", "BadModule!")
+ .outdir(classes)
+ .files(findJavaFiles(src))
+ .run()
+ .writeAll()
+ .getOutput(Task.OutputKind.DIRECT);
+
+ if (!log.contains("- compiler.warn.bad.name.for.option: --limit-modules, BadModule!"))
+ throw new Exception("expected output not found");
+ }
+
+ @Test
+ public void testLastOneWins(Path base) throws Exception {
+ Path src = base.resolve("src");
+ tb.writeJavaFiles(src,
+ "package p; class C { com.sun.tools.javac.Main main; }");
+ Path classes = base.resolve("classes");
+ tb.createDirectories(classes);
+
+ System.err.println("case 1:");
+ new JavacTask(tb)
+ .options("-XDrawDiagnostics",
+ "--limit-modules", "java.base",
+ "--limit-modules", "jdk.compiler")
+ .outdir(classes)
+ .files(findJavaFiles(src))
+ .run()
+ .writeAll();
+
+ System.err.println("case 2:");
+ String log = new JavacTask(tb)
+ .options("-XDrawDiagnostics",
+ "--limit-modules", "jdk.compiler",
+ "--limit-modules", "java.base")
+ .outdir(classes)
+ .files(findJavaFiles(src))
+ .run(Task.Expect.FAIL)
+ .writeAll()
+ .getOutput(Task.OutputKind.DIRECT);
+
+ if (!log.contains("C.java:1:41: compiler.err.doesnt.exist: com.sun.tools.javac"))
+ throw new Exception("expected output not found");
+ }
+}
+
--- a/langtools/test/tools/javac/modules/ModuleTestBase.java Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/test/tools/javac/modules/ModuleTestBase.java Wed Nov 09 10:04:43 2016 -0800
@@ -53,4 +53,12 @@
Path[] findJavaFiles(Path... paths) throws IOException {
return tb.findJavaFiles(paths);
}
+
+ void checkOutputContains(String log, String... expect) throws Exception {
+ for (String e : expect) {
+ if (!log.contains(e)) {
+ throw new Exception("expected output not found: " + e);
+ }
+ }
+ }
}
--- a/langtools/test/tools/javac/modules/ProvidesTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/test/tools/javac/modules/ProvidesTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -24,6 +24,7 @@
/**
* @test
* @summary simple tests of module provides
+ * @bug 8168854
* @library /tools/lib
* @modules
* jdk.compiler/com.sun.tools.javac.api
@@ -39,6 +40,7 @@
import toolbox.JavacTask;
import toolbox.Task;
+import toolbox.Task.Expect;
import toolbox.ToolBox;
public class ProvidesTest extends ModuleTestBase {
@@ -415,24 +417,13 @@
tb.writeJavaFiles(src,
"module m { provides p1.C1.InnerDefinition with p2.C2; }",
"package p1; public class C1 { public class InnerDefinition { } }",
- "package p2; public class C2 extends p1.C1.InnerDefinition { }");
+ "package p2; public class C2 extends p1.C1.InnerDefinition { public C2() { new p1.C1().super(); } }");
- List<String> output = new JavacTask(tb)
+ new JavacTask(tb)
.options("-XDrawDiagnostics")
.outdir(Files.createDirectories(base.resolve("classes")))
.files(findJavaFiles(src))
- .run(Task.Expect.FAIL)
- .writeAll()
- .getOutputLines(Task.OutputKind.DIRECT);
-
- List<String> expected = Arrays.asList(
- "module-info.java:1:26: compiler.err.service.definition.is.inner: p1.C1.InnerDefinition",
- "module-info.java:1:12: compiler.warn.service.provided.but.not.exported.or.used: p1.C1.InnerDefinition",
- "C2.java:1:20: compiler.err.encl.class.required: p1.C1.InnerDefinition",
- "2 errors",
- "1 warning");
- if (!output.containsAll(expected)) {
- throw new Exception("Expected output not found");
- }
+ .run(Expect.SUCCESS)
+ .writeAll();
}
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/modules/T8168854/module-info.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,10 @@
+/*
+ * @test
+ * @bug 8168854
+ * @summary javac erroneously reject a a service interface inner class in a provides clause
+ * @compile module-info.java
+ */
+module mod {
+ exports pack1;
+ provides pack1.Outer.Inter with pack1.Outer1.Implem;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/modules/T8168854/pack1/Outer.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package pack1;
+
+public class Outer {
+ public class Inter {
+ }
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/modules/T8168854/pack1/Outer1.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package pack1;
+
+public class Outer1 {
+ public static class Implem extends Outer.Inter {
+ public Implem () {
+ new Outer().super();
+ }
+ }
+}
\ No newline at end of file
--- a/langtools/test/tools/javac/modules/XModuleTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/test/tools/javac/modules/XModuleTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -223,8 +223,7 @@
.writeAll()
.getOutputLines(Task.OutputKind.DIRECT);
- List<String> expected = Arrays.asList("- compiler.err.xmodule.no.module.sourcepath",
- "1 error");
+ List<String> expected = Arrays.asList("- compiler.err.xmodule.no.module.sourcepath");
if (!expected.equals(log))
throw new Exception("expected output not found: " + log);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/processing/model/nestedTypeVars/NestedTypeVars.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,138 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @modules jdk.compiler
+ * @build NestedTypeVars
+ * @compile/process/ref=NestedTypeVars.out -processor NestedTypeVars Test$1L1$L2$1L3$L4$L5 Test$1L1$CCheck Test$1L1 Test$1CCheck Test$CCheck Test
+ */
+
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import javax.annotation.processing.AbstractProcessor;
+import javax.annotation.processing.RoundEnvironment;
+import javax.annotation.processing.SupportedAnnotationTypes;
+import javax.lang.model.SourceVersion;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.ExecutableElement;
+import javax.lang.model.element.TypeElement;
+import javax.lang.model.element.TypeParameterElement;
+import javax.lang.model.type.TypeKind;
+import javax.lang.model.type.TypeMirror;
+import javax.lang.model.type.TypeVariable;
+import javax.lang.model.util.ElementFilter;
+
+@SupportedAnnotationTypes("*")
+public class NestedTypeVars extends AbstractProcessor{
+
+ @Override
+ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+ for (TypeElement te : ElementFilter.typesIn(roundEnv.getRootElements())) {
+ System.out.print(processingEnv.getElementUtils().getBinaryName(te));
+ System.out.print("<");
+ String separator = "";
+ for (TypeParameterElement tp : te.getTypeParameters()) {
+ System.out.print(separator);
+ separator = ", ";
+ System.out.print(tp.getSimpleName());
+ System.out.print(" extends ");
+ System.out.print(tp.getBounds().stream().map(b -> toString(b)).collect(Collectors.joining("&")));
+ }
+ System.out.println(">");
+ for (ExecutableElement m : ElementFilter.methodsIn(te.getEnclosedElements())) {
+ System.out.print(" <");
+ separator = "";
+ for (TypeParameterElement tp : m.getTypeParameters()) {
+ System.out.print(separator);
+ separator = ", ";
+ System.out.print(tp.getSimpleName());
+ System.out.print(" extends ");
+ System.out.print(tp.getBounds().
+ stream().
+ map(b -> toString(b)).
+ collect(Collectors.joining("&")));
+ }
+ System.out.print(">");
+ System.out.println(m.getSimpleName());
+ }
+ }
+
+ return false;
+ }
+
+ String toString(TypeMirror bound) {
+ if (bound.getKind() == TypeKind.TYPEVAR) {
+ TypeVariable var = (TypeVariable) bound;
+ return toString(var.asElement());
+ }
+ return bound.toString();
+ }
+
+ String toString(Element el) {
+ switch (el.getKind()) {
+ case METHOD:
+ return toString(el.getEnclosingElement()) + "." + el.getSimpleName();
+ case CLASS:
+ return processingEnv.getElementUtils().getBinaryName((TypeElement) el).toString();
+ case TYPE_PARAMETER:
+ return toString(((TypeParameterElement) el).getGenericElement()) + "." + el.getSimpleName();
+ default:
+ throw new IllegalStateException("Unexpected element: " + el + "(" + el.getKind() + ")");
+ }
+ }
+ @Override
+ public SourceVersion getSupportedSourceVersion() {
+ return SourceVersion.latestSupported();
+ }
+
+
+}
+
+class Test<T1, C> {
+ <T2, C> void m() {
+ class L1<T3, C> {
+ class L2<T4, C> {
+ <T5, C> void m() {
+ class L3<T6, C> {
+ class L4<T7, C> {
+ class L5<T1a extends T1,
+ T2a extends T2,
+ T3a extends T3,
+ T4a extends T4,
+ T5a extends T5,
+ T6a extends T6,
+ T7a extends T7> {}
+ }
+ }
+ }
+ }
+ class CCheck<T extends C> {}
+ <T extends C> void test() {}
+ }
+ class CCheck<T extends C> {}
+ }
+ class CCheck<T extends C> {}
+ <T extends C> void test() {}
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/processing/model/nestedTypeVars/NestedTypeVars.out Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,9 @@
+Test$1L1$L2$1L3$L4$L5<T1a extends Test.T1, T2a extends Test.m.T2, T3a extends Test$1L1.T3, T4a extends Test$1L1$L2.T4, T5a extends Test$1L1$L2.m.T5, T6a extends Test$1L1$L2$1L3.T6, T7a extends Test$1L1$L2$1L3$L4.T7>
+Test$1L1$CCheck<T extends Test$1L1.C>
+Test$1L1<T3 extends java.lang.Object, C extends java.lang.Object>
+ <T extends Test$1L1.C>test
+Test$1CCheck<T extends Test.m.C>
+Test$CCheck<T extends Test.C>
+Test<T1 extends java.lang.Object, C extends java.lang.Object>
+ <T2 extends java.lang.Object, C extends java.lang.Object>m
+ <T extends Test.C>test
--- a/langtools/test/tools/jdeprscan/tests/jdk/jdeprscan/TestLoad.java Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/test/tools/jdeprscan/tests/jdk/jdeprscan/TestLoad.java Wed Nov 09 10:04:43 2016 -0800
@@ -23,6 +23,7 @@
/*
* @test
+ * @bug 8145464 8164837
* @summary Test of jdeprscan tool loading and printing to aCSV file.
* @modules jdk.jdeps/com.sun.tools.jdeprscan
* @library ../../../cases
--- a/langtools/test/tools/jdeprscan/tests/jdk/jdeprscan/TestScan.java Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/test/tools/jdeprscan/tests/jdk/jdeprscan/TestScan.java Wed Nov 09 10:04:43 2016 -0800
@@ -23,6 +23,7 @@
/*
* @test
+ * @bug 8145464 8164837 8165646
* @summary Basic test of jdeprscan's scanning phase.
* @modules jdk.jdeps/com.sun.tools.jdeprscan
* @library ../../../cases
@@ -89,6 +90,7 @@
new InputStreamReader(
new ByteArrayInputStream(bytes), StandardCharsets.UTF_8))
.lines()
+ .filter(line -> !line.endsWith(":"))
.map(line -> line.split(" +"))
.map(array -> array[1])
.collect(Collectors.toSet());
--- a/langtools/test/tools/jdeps/lib/JdepsRunner.java Wed Nov 09 15:20:30 2016 +0300
+++ b/langtools/test/tools/jdeps/lib/JdepsRunner.java Wed Nov 09 10:04:43 2016 -0800
@@ -27,16 +27,19 @@
import java.io.StringWriter;
import java.util.Arrays;
import java.util.List;
+import java.util.spi.ToolProvider;
import java.util.stream.Collectors;
/**
* JdepsRunner class to invoke jdeps with the given command line argument
*/
public class JdepsRunner {
+ private static final ToolProvider JDEPS_TOOL = ToolProvider.findFirst("jdeps")
+ .orElseThrow(() -> new RuntimeException("jdeps tool not found"));
+
public static JdepsRunner run(String... args) {
JdepsRunner jdeps = new JdepsRunner(args);
- int rc = jdeps.run();
- jdeps.printStdout(System.err);
+ int rc = jdeps.run(true);
if (rc != 0)
throw new Error("jdeps failed: rc=" + rc);
return jdeps;
@@ -46,7 +49,7 @@
final StringWriter stderr = new StringWriter();
final String[] args;
public JdepsRunner(String... args) {
- System.err.println("jdeps " + Arrays.stream(args)
+ System.out.println("jdeps " + Arrays.stream(args)
.collect(Collectors.joining(" ")));
this.args = args;
}
@@ -60,10 +63,12 @@
}
public int run(boolean showOutput) {
- try (PrintWriter pw = new PrintWriter(stdout)) {
- int rc = com.sun.tools.jdeps.Main.run(args, pw);
+ try (PrintWriter pwout = new PrintWriter(stdout);
+ PrintWriter pwerr = new PrintWriter(stderr)) {
+ int rc = JDEPS_TOOL.run(pwout, pwerr, args);
if (showOutput) {
- System.err.println(stdout.toString());
+ printStdout(System.out);
+ printStderr(System.out);
}
return rc;
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/jdeps/listdeps/ListModuleDeps.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,180 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8167057
+ * @summary Tests split packages
+ * @modules java.logging
+ * java.xml
+ * jdk.compiler
+ * jdk.jdeps
+ * jdk.unsupported
+ * @library ../lib
+ * @build CompilerUtils JdepsRunner
+ * @run testng ListModuleDeps
+ */
+
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Arrays;
+
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
+public class ListModuleDeps {
+ private static final String TEST_SRC = System.getProperty("test.src");
+
+ private static final Path SRC_DIR = Paths.get(TEST_SRC, "src");
+ private static final Path CLASSES_DIR = Paths.get("classes");
+ private static final Path LIB_DIR = Paths.get("lib");
+
+ private static final Path FOO_CLASS =
+ CLASSES_DIR.resolve("z").resolve("Foo.class");
+ private static final Path BAR_CLASS =
+ CLASSES_DIR.resolve("z").resolve("Bar.class");
+ private static final Path UNSAFE_CLASS =
+ CLASSES_DIR.resolve("z").resolve("UseUnsafe.class");
+
+ /**
+ * Compiles classes used by the test
+ */
+ @BeforeTest
+ public void compileAll() throws Exception {
+ // compile library
+ assertTrue(CompilerUtils.compile(Paths.get(TEST_SRC, "src", "lib"), LIB_DIR));
+
+ // compile classes in unnamed module
+ assertTrue(CompilerUtils.compile(Paths.get(TEST_SRC, "src", "z"),
+ CLASSES_DIR,
+ "-cp", LIB_DIR.toString(),
+ "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED",
+ "--add-exports=java.base/sun.security.util=ALL-UNNAMED",
+ "--add-exports=java.xml/jdk.xml.internal=ALL-UNNAMED"
+ ));
+ }
+
+ @Test(dataProvider = "listdeps")
+ public void testListDeps(Path classes, String[] expected) {
+ JdepsRunner jdeps = JdepsRunner.run(
+ "--class-path", LIB_DIR.toString(),
+ "--list-deps", classes.toString()
+ );
+ String[] output = Arrays.stream(jdeps.output())
+ .map(s -> s.trim())
+ .toArray(String[]::new);
+ assertEquals(output, expected);
+ }
+
+ @Test(dataProvider = "reduceddeps")
+ public void testListReducedDeps(Path classes, String[] expected) {
+ JdepsRunner jdeps = JdepsRunner.run(
+ "--class-path", LIB_DIR.toString(),
+ "--list-reduced-deps", classes.toString()
+ );
+ String[] output = Arrays.stream(jdeps.output())
+ .map(s -> s.trim())
+ .toArray(String[]::new);
+ assertEquals(output, expected);
+ }
+
+
+ @DataProvider(name = "listdeps")
+ public Object[][] listdeps() {
+ return new Object[][] {
+ { CLASSES_DIR, new String[] {
+ "java.base/jdk.internal.misc",
+ "java.base/sun.security.util",
+ "java.logging",
+ "java.sql",
+ "java.xml/jdk.xml.internal",
+ "jdk.unsupported",
+ "unnamed module: lib"
+ }
+ },
+
+ { FOO_CLASS, new String[] {
+ "java.base",
+ "java.logging",
+ "java.sql",
+ "java.xml",
+ "unnamed module: lib"
+ }
+ },
+
+ { BAR_CLASS, new String[] {
+ "java.base/sun.security.util",
+ "java.xml/jdk.xml.internal",
+ }
+ },
+
+ { UNSAFE_CLASS, new String[] {
+ "java.base/jdk.internal.misc",
+ "jdk.unsupported",
+ }
+ },
+ };
+ }
+
+ @DataProvider(name = "reduceddeps")
+ public Object[][] reduceddeps() {
+ Path barClass = CLASSES_DIR.resolve("z").resolve("Bar.class");
+
+ return new Object[][] {
+ { CLASSES_DIR, new String[] {
+ "java.base/jdk.internal.misc",
+ "java.base/sun.security.util",
+ "java.sql",
+ "java.xml/jdk.xml.internal",
+ "jdk.unsupported",
+ "unnamed module: lib"
+ }
+ },
+
+
+ { FOO_CLASS, new String[] {
+ "java.base",
+ "java.sql",
+ "unnamed module: lib"
+ }
+ },
+
+ { BAR_CLASS, new String[] {
+ "java.base/sun.security.util",
+ "java.xml/jdk.xml.internal",
+ }
+ },
+
+ { UNSAFE_CLASS, new String[] {
+ "java.base/jdk.internal.misc",
+ "jdk.unsupported",
+ }
+ },
+ };
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/jdeps/listdeps/src/lib/Lib.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package lib;
+
+import javax.xml.stream.XMLInputFactory;
+
+public class Lib {
+ public static final String isCoalescing = XMLInputFactory.IS_COALESCING;
+ public static boolean check() { return true; }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/jdeps/listdeps/src/z/Bar.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package z;
+
+import sun.security.util.HostnameChecker;
+import jdk.xml.internal.JdkXmlUtils;
+
+public class Bar {
+ // internal API from java.xml
+ private static final String name = JdkXmlUtils.USE_CATALOG;
+
+ public static void main(String[] argv) throws Exception {
+ HostnameChecker hc = HostnameChecker.getInstance(HostnameChecker.TYPE_LDAP);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/jdeps/listdeps/src/z/Foo.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package z;
+
+import java.sql.Driver;
+import java.util.logging.Logger;
+import javax.xml.stream.XMLInputFactory;
+/*
+ * Dependences on java.sql and java.logging which can be reduced.
+ */
+public class Foo {
+ // dependence to java.logging
+ static Logger log = Logger.getLogger("foo");
+ static final String isCoalescing = XMLInputFactory.IS_COALESCING;
+
+ // dependence to java.sql
+ public Driver getDriver() { return null; }
+
+ // dependence to same package
+ public Bar getBar() { return new Bar(); }
+
+ // dependence to module m
+ public String isCoalescing() { return lib.Lib.isCoalescing; }
+
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/jdeps/listdeps/src/z/UseUnsafe.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package z;
+
+import sun.misc.Unsafe;
+import jdk.internal.misc.VM;
+
+public class UseUnsafe {
+ private static Unsafe unsafe = Unsafe.getUnsafe();
+
+ private static boolean booted = VM.isBooted();
+}
--- a/make/Bundles.gmk Wed Nov 09 15:20:30 2016 +0300
+++ b/make/Bundles.gmk Wed Nov 09 10:04:43 2016 -0800
@@ -256,7 +256,7 @@
$(eval $(call SetupBundleFile, BUILD_DEMOS_BUNDLE, \
BUNDLE_NAME := $(DEMOS_BUNDLE_NAME), \
- FILES := $(call DoubleDollar, $(DEMOS_BUNDLE_FILES)), \
+ FILES := $(DEMOS_BUNDLE_FILES), \
BASE_DIR := $(JDK_IMAGE_DIR), \
SUBDIR := $(JDK_BUNDLE_SUBDIR), \
))
@@ -271,7 +271,7 @@
$(eval $(call SetupBundleFile, BUILD_TEST_BUNDLE, \
BUNDLE_NAME := $(TEST_BUNDLE_NAME), \
- FILES := $(call DoubleDollar, $(TEST_BUNDLE_FILES)), \
+ FILES := $(TEST_BUNDLE_FILES), \
BASE_DIR := $(TEST_IMAGE_DIR), \
))
--- a/make/CompileJavaModules.gmk Wed Nov 09 15:20:30 2016 +0300
+++ b/make/CompileJavaModules.gmk Wed Nov 09 10:04:43 2016 -0800
@@ -95,7 +95,7 @@
################################################################################
java.desktop_ADD_JAVAC_FLAGS := -Xdoclint:all/protected,-reference \
- '-Xdoclint/package:java.*,javax.*' -Xlint:-deprecation,-exports
+ '-Xdoclint/package:java.*,javax.*' -Xlint:-deprecation,exports
java.desktop_COPY := .gif .png .wav .txt .xml .css .pf
java.desktop_CLEAN := iio-plugin.properties cursors.properties
@@ -348,7 +348,7 @@
################################################################################
-jdk.compiler_ADD_JAVAC_FLAGS := -Xdoclint:all/protected '-Xdoclint/package:-com.sun.tools.*' \
+jdk.compiler_ADD_JAVAC_FLAGS := -Xdoclint:all/protected '-Xdoclint/package:-com.sun.tools.*,-jdk.internal.*' \
-XDstringConcat=inline
jdk.compiler_CLEAN_FILES := $(wildcard \
$(patsubst %, $(JDK_TOPDIR)/src/jdk.compiler/share/classes/%/*.properties, \
@@ -365,6 +365,10 @@
################################################################################
+jdk.editpad_COPY := .properties
+
+################################################################################
+
jdk.internal.le_COPY := .properties
################################################################################
@@ -436,10 +440,6 @@
################################################################################
-jdk.jsobject_ADD_JAVAC_FLAGS := -Xlint:-exports
-
-################################################################################
-
jdk.dev_CLEAN_FILES := $(wildcard \
$(patsubst %, $(JDK_TOPDIR)/src/jdk.dev/share/classes/%/*.properties, \
com/sun/tools/script/shell))
@@ -477,6 +477,13 @@
jdk.localedata_EXCLUDE_FILES += sun/text/resources/ext/BreakIteratorRules_th.java
################################################################################
+# If this is an imported module that has prebuilt classes, only compile
+# module-info.java.
+ifneq ($(wildcard $(IMPORT_MODULES_CLASSES)/$(MODULE)), )
+ $(MODULE)_INCLUDE_FILES := module-info.java
+endif
+
+################################################################################
# Setup the compilation for the module
#
MODULE_SRC_DIRS := $(call FindModuleSrcDirs, $(MODULE))
--- a/make/CreateJmods.gmk Wed Nov 09 15:20:30 2016 +0300
+++ b/make/CreateJmods.gmk Wed Nov 09 10:04:43 2016 -0800
@@ -36,6 +36,7 @@
################################################################################
JMODS_DIR := $(IMAGES_OUTPUTDIR)/jmods
+JMODS_TEMPDIR := $(SUPPORT_OUTPUTDIR)/jmods
LIBS_DIR := $(firstword $(wildcard $(addsuffix /$(MODULE), \
$(SUPPORT_OUTPUTDIR)/modules_libs $(IMPORT_MODULES_LIBS))))
@@ -81,16 +82,19 @@
# Add dependencies on other jmod files. Only java.base needs access to other
# jmods.
ifeq ($(MODULE), java.base)
- ALL_UPGRADEABLE_MODULES = $(call FindAllUpgradeableModules)
# When creating a BUILDJDK, we don't need to add hashes to java.base
ifneq ($(CREATING_BUILDJDK), true)
- DEPS += $(patsubst %, $(JMODS_DIR)/%.jmod, \
- $(filter-out java.base $(ALL_UPGRADEABLE_MODULES), $(call FindAllModules)))
+ # When creating interim versions of jmods, skip hashes
+ ifneq ($(INTERIM_JMOD), true)
+ ALL_UPGRADEABLE_MODULES := $(call FindAllUpgradeableModules)
+ DEPS += $(patsubst %, $(JMODS_DIR)/%.jmod, \
+ $(filter-out java.base $(ALL_UPGRADEABLE_MODULES), $(call FindAllModules)))
- EXCLUDE_PATTERN := $(strip $(subst $(SPACE),|,$(strip $(ALL_UPGRADEABLE_MODULES))))
+ EXCLUDE_PATTERN := $(strip $(subst $(SPACE),|,$(strip $(ALL_UPGRADEABLE_MODULES))))
- JMOD_FLAGS += --module-path $(JMODS_DIR) \
- --hash-modules '^(?!$(EXCLUDE_PATTERN))'
+ JMOD_FLAGS += --module-path $(JMODS_DIR) \
+ --hash-modules '^(?!$(EXCLUDE_PATTERN))'
+ endif
endif
endif
@@ -102,13 +106,19 @@
DEPS += $(call CacheFind, $(JDK_OUTPUTDIR)/modules/jdk.jlink/jdk/tools/jmod)
endif
+# If creating interim versions of jmods, certain files need to be filtered out
+# to avoid false incremental rebuilds.
+ifeq ($(INTERIM_JMOD), true)
+ DEPS := $(filter-out $(SUPPORT_OUTPUTDIR)/modules_libs/java.base/classlist, $(DEPS))
+endif
+
# TODO: What about headers?
# Create jmods in a temp dir and then move them into place to keep the
# module path in $(IMAGES_OUTPUTDIR)/jmods valid at all times.
$(JMODS_DIR)/$(MODULE).jmod: $(DEPS)
$(call LogWarn, Creating $(patsubst $(OUTPUT_ROOT)/%, %, $@))
- $(call MakeDir, $(@D) $(SUPPORT_OUTPUTDIR)/jmods)
- $(RM) $@ $(SUPPORT_OUTPUTDIR)/jmods/$(notdir $@)
+ $(call MakeDir, $(JMODS_DIR) $(JMODS_TEMPDIR))
+ $(RM) $@ $(JMODS_TEMPDIR)/$(notdir $@)
$(JMOD) create \
--module-version $(VERSION_SHORT) \
--os-name $(REQUIRED_OS_NAME) \
@@ -116,10 +126,10 @@
--os-version $(REQUIRED_OS_VERSION) \
--module-path $(JMODS_DIR) \
--exclude '**{_the.*,*.diz,*.debuginfo,*.dSYM/**,*.dSYM,*.pdb,*.map}' \
- $(JMOD_FLAGS) $(SUPPORT_OUTPUTDIR)/jmods/$(notdir $@)
- $(MV) $(SUPPORT_OUTPUTDIR)/jmods/$(notdir $@) $@
+ $(JMOD_FLAGS) $(JMODS_TEMPDIR)/$(notdir $@)
+ $(MV) $(JMODS_TEMPDIR)/$(notdir $@) $@
-TARGETS += $(IMAGES_OUTPUTDIR)/jmods/$(MODULE).jmod
+TARGETS += $(JMODS_DIR)/$(MODULE).jmod
################################################################################
--- a/make/ExplodedImageOptimize.gmk Wed Nov 09 15:20:30 2016 +0300
+++ b/make/ExplodedImageOptimize.gmk Wed Nov 09 10:04:43 2016 -0800
@@ -39,6 +39,7 @@
$(PACKAGES_ATTRIBUTE_TARGET): $(ALL_MODULEINFO_CLASSES) $(BUILD_JIGSAW_CLASSES)
$(call LogInfo, Optimizing the exploded image)
$(TOOL_ADD_PACKAGES_ATTRIBUTE) $(JDK_OUTPUTDIR)
+ $(TOUCH) $@
TARGETS := $(PACKAGES_ATTRIBUTE_TARGET)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/make/GenerateLinkOptData.gmk Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,88 @@
+#
+# Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation. Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+################################################################################
+# Generate classlist
+################################################################################
+
+default: all
+
+include $(SPEC)
+include MakeBase.gmk
+include JarArchive.gmk
+
+################################################################################
+# Create a jar with our generator class. Using a jar is intentional since it
+# will load more classes
+
+$(eval $(call SetupJarArchive, CLASSLIST_JAR, \
+ SRCS := $(BUILDTOOLS_OUTPUTDIR)/jdk_tools_classes, \
+ INCLUDES := build/tools/classlist, \
+ JAR := $(SUPPORT_OUTPUTDIR)/classlist.jar, \
+))
+
+TARGETS += $(CLASSLIST_JAR)
+
+################################################################################
+
+LINK_OPT_DIR := $(SUPPORT_OUTPUTDIR)/link_opt
+CLASSLIST_FILE := $(LINK_OPT_DIR)/classlist
+JLI_TRACE_FILE := $(LINK_OPT_DIR)/jli_trace.out
+
+# If an external buildjdk has been supplied, we don't build a separate interim
+# image, so just use the external build jdk instead.
+ifeq ($(EXTERNAL_BUILDJDK), true)
+ INTERIM_IMAGE_DIR := $(BUILD_JDK)
+endif
+
+$(CLASSLIST_FILE): $(INTERIM_IMAGE_DIR)/bin/java$(EXE_SUFFIX) $(CLASSLIST_JAR)
+ $(call MakeDir, $(LINK_OPT_DIR))
+ $(call LogInfo, Generating $(patsubst $(OUTPUT_ROOT)/%, %, $@))
+ $(call LogInfo, Generating $(patsubst $(OUTPUT_ROOT)/%, %, $(JLI_TRACE_FILE)))
+ $(FIXPATH) $(INTERIM_IMAGE_DIR)/bin/java -XX:DumpLoadedClassList=$@ \
+ -Djava.lang.invoke.MethodHandle.TRACE_RESOLVE=true \
+ -cp $(SUPPORT_OUTPUTDIR)/classlist.jar \
+ build.tools.classlist.HelloClasslist \
+ $(LOG_DEBUG) 2>&1 > $(JLI_TRACE_FILE)
+
+# The jli trace is created by the same recipe as classlist. By declaring these
+# dependencies, make will correctly rebuild both jli trace and classlist
+# incrementally using the single recpie above.
+$(CLASSLIST_FILE): $(JLI_TRACE_FILE)
+$(JLI_TRACE_FILE): $(INTERIM_IMAGE_DIR)/bin/java$(EXE_SUFFIX) $(CLASSLIST_JAR)
+
+TARGETS += $(CLASSLIST_FILE) $(JLI_TRACE_FILE)
+
+# Copy the classlist file into java.base libs
+$(eval $(call SetupCopyFiles, COPY_CLASSLIST, \
+ FILES := $(CLASSLIST_FILE), \
+ DEST := $(SUPPORT_OUTPUTDIR)/modules_libs/java.base, \
+))
+
+TARGETS += $(COPY_CLASSLIST)
+
+################################################################################
+
+all: $(TARGETS)
--- a/make/Images.gmk Wed Nov 09 15:20:30 2016 +0300
+++ b/make/Images.gmk Wed Nov 09 10:04:43 2016 -0800
@@ -113,8 +113,8 @@
JLINK_ORDER_RESOURCES := **module-info.class
JLINK_JLI_CLASSES :=
ifeq ($(ENABLE_GENERATE_CLASSLIST), true)
- JLINK_ORDER_RESOURCES += @$(SUPPORT_OUTPUTDIR)/classlist/classlist
- JLINK_JLI_CLASSES := --generate-jli-classes=@$(SUPPORT_OUTPUTDIR)/classlist/jli_trace.out
+ JLINK_ORDER_RESOURCES += @$(SUPPORT_OUTPUTDIR)/link_opt/classlist
+ JLINK_JLI_CLASSES := --generate-jli-classes=@$(SUPPORT_OUTPUTDIR)/link_opt/jli_trace.out
endif
JLINK_ORDER_RESOURCES += \
/java.base/java/** \
@@ -142,7 +142,7 @@
$(ECHO) Creating jdk jimage
$(RM) -r $(JDK_IMAGE_DIR)
$(JLINK_TOOL) --add-modules $(JDK_MODULES_LIST) \
- $(JLINK_JDK_EXTRA_OPTS) \
+ $(JLINK_JDK_EXTRA_OPTS) \
--output $(JDK_IMAGE_DIR)
$(TOUCH) $@
@@ -152,7 +152,7 @@
$(RM) -r $(JRE_IMAGE_DIR)
$(JLINK_TOOL) --add-modules $(JRE_MODULES_LIST) \
$(JLINK_JRE_EXTRA_OPTS) \
- --output $(JRE_IMAGE_DIR)
+ --output $(JRE_IMAGE_DIR)
$(TOUCH) $@
JRE_COMPACT1_IMAGE_DIR := $(JRE_IMAGE_DIR)-compact1
@@ -360,34 +360,15 @@
JDK_TARGETS += $(JDK_IMAGE_DIR)/src.zip
################################################################################
-# classlist
-
-ifeq ($(ENABLE_GENERATE_CLASSLIST), true)
- $(eval $(call SetupCopyFiles, JDK_COPY_CLASSLIST, \
- FILES := $(SUPPORT_OUTPUTDIR)/classlist/classlist, \
- DEST := $(JDK_IMAGE_DIR)/lib, \
- ))
-
- JDK_TARGETS += $(JDK_COPY_CLASSLIST)
-
- $(eval $(call SetupCopyFiles, JRE_COPY_CLASSLIST, \
- FILES := $(SUPPORT_OUTPUTDIR)/classlist/classlist, \
- DEST := $(JRE_IMAGE_DIR)/lib, \
- ))
-
- JRE_TARGETS += $(JRE_COPY_CLASSLIST)
-endif
-
-################################################################################
# /demo dir
# Avoid doing the expensive find unless called with "jdk" as target.
ifneq ($(filter jdk, $(MAKECMDGOALS)), )
DEMO_FILES := \
$(if $(wildcard $(SUPPORT_OUTPUTDIR)/demos/image), \
- $(call DoubleDollar, $(call DoubleDollar, \
+ $(call DoubleDollar, \
$(shell $(FIND) $(SUPPORT_OUTPUTDIR)/demos/image \
- -type f -a ! \( -name "_the*" -o -name "javac_state" \) ))) \
+ -type f -a ! \( -name "_the*" -o -name "javac_state" \) )) \
)
ifeq ($(ZIP_EXTERNAL_DEBUG_SYMBOLS), true)
--- a/make/InterimImage.gmk Wed Nov 09 15:20:30 2016 +0300
+++ b/make/InterimImage.gmk Wed Nov 09 10:04:43 2016 -0800
@@ -36,15 +36,15 @@
INTERIM_MODULES_LIST := $(call CommaList, $(INTERIM_IMAGE_MODULES))
-JMODS := $(patsubst %, $(IMAGES_OUTPUTDIR)/jmods/%.jmod, $(INTERIM_IMAGE_MODULES))
+JMODS := $(patsubst %, $(INTERIM_JMODS_DIR)/%.jmod, $(INTERIM_IMAGE_MODULES))
JLINK_TOOL := $(JLINK) \
- --module-path $(IMAGES_OUTPUTDIR)/jmods \
+ --module-path $(INTERIM_JMODS_DIR) \
--endian $(OPENJDK_BUILD_CPU_ENDIAN)
$(INTERIM_IMAGE_DIR)/$(JIMAGE_TARGET_FILE): $(JMODS) \
$(call DependOnVariable, INTERIM_MODULES_LIST)
- $(ECHO) Creating interim jimage
+ $(call LogWarn, Creating interim jimage)
$(RM) -r $(INTERIM_IMAGE_DIR)
$(JLINK_TOOL) \
--output $(INTERIM_IMAGE_DIR) \
--- a/make/Javadoc.gmk Wed Nov 09 15:20:30 2016 +0300
+++ b/make/Javadoc.gmk Wed Nov 09 10:04:43 2016 -0800
@@ -22,140 +22,16 @@
# questions.
#
+default: all
+
include $(SPEC)
include MakeBase.gmk
-#################################################################
-#
-# CORE_PKGS environment variable has been moved to the following file
-#
-include CORE_PKGS.gmk
-#
-# Load environment variables for API package names that are not part of
-# the Java SE platform
-#
-include NON_CORE_PKGS.gmk
-
-
-.SUFFIXES: # Delete the default suffixes
-.SUFFIXES: .java
-
-#
-# Definitions for directories
-#
-
-DOCSDIR := $(DOCS_IMAGE_DIR)
-DOCSTMPDIR = $(SUPPORT_OUTPUTDIR)/docs
-
-HOTSPOT_DOCS_IMPORT_PATH=$(HOTSPOT_OUTPUTDIR)/docs
-
-JAVADOC_CMD = $(JAVA) \
- -Djava.awt.headless=true \
- $(NEW_JAVADOC)
-
-JAVADOC_CMD_SMALL = $(JAVA_SMALL) \
- -Djava.awt.headless=true \
- $(NEW_JAVADOC)
-
-# Copyright year for beginning of Java and some of the apis
-# (Needed when creating the javadocs)
-FIRST_COPYRIGHT_YEAR = 1993
-DOMAPI_FIRST_COPYRIGHT_YEAR = 2005
-MIRROR_FIRST_COPYRIGHT_YEAR = 2004
-DOCLETAPI_FIRST_COPYRIGHT_YEAR = 1993
-TAGLETAPI_FIRST_COPYRIGHT_YEAR = 1993
-JDI_FIRST_COPYRIGHT_YEAR = 1999
-JAAS_FIRST_COPYRIGHT_YEAR = 1998
-JGSS_FIRST_COPYRIGHT_YEAR = 2000
-SMARTCARDIO_FIRST_COPYRIGHT_YEAR = 2005
-HTTPSERVER_FIRST_COPYRIGHT_YEAR = 2005
-MGMT_FIRST_COPYRIGHT_YEAR = 2003
-ATTACH_FIRST_COPYRIGHT_YEAR = 2005
-JCONSOLE_FIRST_COPYRIGHT_YEAR = 2006
-SCTPAPI_FIRST_COPYRIGHT_YEAR = 2009
-TRACING_FIRST_COPYRIGHT_YEAR = 2008
-JSHELLAPI_FIRST_COPYRIGHT_YEAR = 2015
-TREEAPI_FIRST_COPYRIGHT_YEAR = 2005
-NASHORNAPI_FIRST_COPYRIGHT_YEAR = 2014
-DYNALINKAPI_FIRST_COPYRIGHT_YEAR = 2015
-JNLP_FIRST_COPYRIGHT_YEAR = 1998
-PLUGIN2_FIRST_COPYRIGHT_YEAR = 2007
-JDKNET_FIRST_COPYRIGHT_YEAR = 2014
-JACCESSAPI_FIRST_COPYRIGHT_YEAR = 2002
-JSOBJECT_FIRST_COPYRIGHT_YEAR = 1993
-
-# Oracle name
-FULL_COMPANY_NAME = Oracle and/or its affiliates
-
-# Copyright address
-COMPANY_ADDRESS = 500 Oracle Parkway<br>Redwood Shores, CA 94065 USA.
-
-# The trademark symbol
-TRADEMARK = ™
-
-# Common copyright lines used
-# The word "Copyright" might optionally be a link to the file cpyr.html.
-# The first year of copyright may vary or not be available.
-# The address to the company might be optional.
-COMMA:= ,
-EMPTY:=
-SPACE:=$(EMPTY) $(EMPTY)
-COPYRIGHT_SYMBOL = &\#x00a9;
-# Macro to construct the copyright line
-# (The GNU make 3.78.1 "if" conditional is broken, fixed in GNU make 3.81)
-define CopyrightLine # optionalurl optionalfirstyear optionaladdress
-$(if $(strip $1),<a href="$(strip $1)">Copyright</a>,Copyright) \
-$(COPYRIGHT_SYMBOL) $(if $2,$2${COMMA},) $(COPYRIGHT_YEAR),\
-$(FULL_COMPANY_NAME). $3 All rights reserved.
-endef
-
-# Url to root of documents
-DOCSDIR_URL = {@docroot}/$(GET2DOCSDIR)
-
-# Url to copyright html file
-COPYRIGHT_URL = $(DOCSDIR_URL)/legal/cpyr.html
-
-# Url to bug filing site
-BUG_SUBMIT_URL = http://bugreport.java.com/bugreport/
-
-# Common line for how to submit a bug or rfe
-BUG_SUBMIT_LINE = <a href="$(BUG_SUBMIT_URL)">Submit a bug or feature</a>
-
-# Url to devdocs page
-DOCS_BASE_URL = http://docs.oracle.com/javase/$(VERSION_SPECIFICATION)/docs
-DEV_DOCS_URL = $(DOCS_BASE_URL)/index.html
-
-# Common Java trademark line
-JAVA_TRADEMARK_LINE = Java is a trademark or registered trademark of \
-$(FULL_COMPANY_NAME) in the US and other countries.
-
-#################################################################
-# Macros:
-
+################################################################################
# List of all possible directories for javadoc to look for sources
-# NOTE: Quotes are required around sourcepath argument only on Windows.
-# Otherwise, you get "No packages or classes specified." due
-# to $(PATH_SEP) being interpreted as an end of
-# command (newline or shell ; character)
-ALL_SOURCE_DIRS := $(wildcard \
- $(SUPPORT_OUTPUTDIR)/gensrc/j* \
- $(if $(IMPORT_MODULES_SRC), $(IMPORT_MODULES_SRC)/*) \
- $(JDK_TOPDIR)/src/*/$(OPENJDK_TARGET_OS)/classes \
- $(JDK_TOPDIR)/src/*/$(OPENJDK_TARGET_OS_TYPE)/classes \
- $(JDK_TOPDIR)/src/*/share/classes \
- $(HOTSPOT_TOPDIR)/src/*/share/classes \
- $(LANGTOOLS_TOPDIR)/src/*/share/classes \
- $(NASHORN_TOPDIR)/src/*/share/classes \
- $(CORBA_TOPDIR)/src/*/share/classes \
- $(JAXP_TOPDIR)/src/*/share/classes \
- $(JAXWS_TOPDIR)/src/*/share/classes \
- $(SUPPORT_OUTPUTDIR)/rmic/j* \
- $(JDK_TOPDIR)/src/*/share/doc/stub \
- ) \
- #
-
-ALL_MODULE_SOURCE_DIRS := \
+# Allow custom to overwrite.
+JAVADOC_SOURCE_DIRS = \
$(SUPPORT_OUTPUTDIR)/gensrc/* \
$(if $(IMPORT_MODULES_SRC), $(IMPORT_MODULES_SRC)/*) \
$(JDK_TOPDIR)/src/*/$(OPENJDK_TARGET_OS)/classes \
@@ -171,181 +47,56 @@
$(JDK_TOPDIR)/src/*/share/doc/stub \
#
-
-# List with classpath separator between them
-EMPTY:=
-SPACE:= $(EMPTY) $(EMPTY)
-RELEASEDOCS_SOURCEPATH = \
- $(subst $(SPACE),$(PATH_SEP),$(strip $(ALL_SOURCE_DIRS)))
-
-RELEASEDOCS_MODULESOURCEPATH = \
- $(subst $(SPACE),$(PATH_SEP),$(strip $(ALL_MODULE_SOURCE_DIRS)))
-
-define prep-target
- $(MKDIR) -p $(@D)
- $(RM) $@
-endef
-
-# Prep for javadoc creation, assumes $@ is an index.html file
-define prep-javadoc
- @if [ -f "$@" -a "$?" != "" ] ; then \
- $(ECHO) "# Dependencies have changed: $?"; \
- fi
- $(RM) -r $(@D)
- $(MKDIR) -p $(@D)
-endef
-
-$(eval $(call FillCacheFind, $(ALL_SOURCE_DIRS)))
-define PackageDependencies
- $(call CacheFind, $(wildcard $(foreach p, $(subst .,/,$1), $(addsuffix /$p, $(ALL_SOURCE_DIRS)))))
-endef
-
-# Given a list of packages, add packages that exist to $@, print summary
-define PackageFilter # packages
- @if [ "$1" != "" ] ; then \
- for p in $1 ; do \
- pd=`$(ECHO) $${p} | $(SED) -e 's@[.]@/@g'`; \
- found="false"; \
- for cp in $(ALL_SOURCE_DIRS) ; do \
- if [ -d $${cp}/$${pd} ] ; then \
- $(ECHO) "$${p}" >> $@; \
- found="true"; \
- break; \
- fi; \
- done; \
- if [ "$${found}" = "false" ] ; then \
- $(ECHO) "WARNING: Package not found: $${p}"; \
- fi; \
- done; \
- fi
-endef
-
-# Print out a summary of the javadoc command about to be run
-define JavadocSummary # optionsfile packagesfile
- @$(ECHO) "# Running javadoc for $(patsubst $(OUTPUT_ROOT)/%,%,$@)" $(LOG_WARN)
- @($(ECHO) "# Options (`$(BASENAME) $1`):"; $(SED) -e 's@^@# @' $1) $(LOG_DEBUG)
- @($(ECHO) "# Packages (`$(BASENAME) $2`):";$(SED) -e 's@^@# @' $2) $(LOG_DEBUG)
-endef
-
-#
-# Different api directories created from root directory
-#
-COREAPI_DOCSDIR = $(DOCSDIR)/api
-JDK_API_DOCSDIR = $(DOCSDIR)/jdk/api
-JRE_API_DOCSDIR = $(DOCSDIR)/jre/api
-PLATFORM_DOCSDIR = $(DOCSDIR)/platform
-
-JAVADOC_ARCHIVE_NAME := jdk-$(VERSION_STRING)-docs.zip
-JAVADOC_ARCHIVE_ASSEMBLY_DIR := $(DOCSTMPDIR)/zip-docs
-JAVADOC_ARCHIVE_DIR := $(OUTPUT_ROOT)/bundles
-JAVADOC_ARCHIVE := $(JAVADOC_ARCHIVE_DIR)/$(JAVADOC_ARCHIVE_NAME)
+# Should we use -Xdocrootparent? Allow custom to overwrite.
+DOCROOTPARENT_FLAG = TRUE
# The core api index file is the target for the core api javadocs rule
# and needs to be defined early so that all other javadoc rules may
# depend on it.
-COREAPI_INDEX_FILE = $(COREAPI_DOCSDIR)/index.html
-
-# The non-core api javadocs need to be able to access the root of the core
-# api directory, so for jdk/api or jre/api to get to the core api/
-# directory we would use this:
-JDKJRE2COREAPI = ../../api
-
-# Common bottom argument
-define CommonBottom # year
-<font size="-1"><br> $(call CopyrightLine,,$1,)</font>
-endef
-
-# Common trademark bottom argument (Not sure why this is used sometimes)
-define CommonTrademarkBottom # year
-<font size="-1">\
-$(BUG_SUBMIT_LINE)<br>$(JAVA_TRADEMARK_LINE)<br>\
-$(call CopyrightLine,,$1,$(COMPANY_ADDRESS))\
-</font>
-endef
+CORE_INDEX_FILE := $(JAVADOC_OUTPUTDIR)/api/index.html
-# Common echo of option
-define OptionOnly # opt
- if [ "$(strip $1)" != "" ] ; then \
- $(PRINTF) "%s\n" "$(strip $1)"; \
- fi
-endef
-
-define OptionPair # opt arg
- $(PRINTF) "%s '%s'\n" "$(strip $1)" '$(strip $2)'
-endef
+# Symbols
+TRADEMARK := ™
+COPYRIGHT_SYMBOL := &$(HASH)x00a9;
+COPYRIGHT_TEXT := Copyright
+ALL_RIGHTS_RESERVED := All rights reserved.
-define OptionTrip # opt arg arg
- $(PRINTF) "%s '%s' '%s'\n" "$(strip $1)" '$(strip $2)' '$(strip $3)'
-endef
+# URLs
+JAVADOC_BASE_URL := http://docs.oracle.com/javase/$(VERSION_SPECIFICATION)/docs
+BUG_SUBMIT_URL := http://bugreport.java.com/bugreport/
-# Core api bottom argument (with special sauce)
-COREAPI_BOTTOM = <font size="-1"> $(BUG_SUBMIT_LINE)\
-<br>For further API reference and developer documentation, \
-see <a href="$(DEV_DOCS_URL)" target="_blank">Java SE Documentation</a>. \
-That documentation contains more detailed, developer-targeted descriptions, \
-with conceptual overviews, definitions of terms, workarounds, \
-and working code examples.<br>\
-$(call CopyrightLine,$(COPYRIGHT_URL),$(FIRST_COPYRIGHT_YEAR),)\
-</font>
-
-# Common javadoc options used by all bundles
+################################################################################
+# Text snippets
-# This flag may be overridden from a custom makefile
-DOCROOTPARENT_FLAG = -Xdocrootparent $(DOCS_BASE_URL)
+FULL_COMPANY_NAME := Oracle and/or its affiliates
+COMPANY_ADDRESS := 500 Oracle Parkway<br>Redwood Shores, CA 94065 USA.
+BUG_SUBMIT_LINE := <a href="$(BUG_SUBMIT_URL)">Submit a bug or feature</a>
+JAVA_TRADEMARK_LINE := Java is a trademark or registered trademark of \
+ $(FULL_COMPANY_NAME) in the US and other countries.
-define COMMON_JAVADOCFLAGS
- $(call OptionOnly,-XDignore.symbol.file=true) ; \
- $(call OptionOnly,-quiet) ; \
- $(call OptionOnly,-use) ; \
- $(call OptionOnly,-keywords) ; \
- $(call OptionOnly,$(DOCROOTPARENT_FLAG))
-endef
-
-# Common javadoc tags used by all bundles
-
-# Java language specification cite
-TAG_JLS = jls:a:See <cite> \
-The Java™ Language Specification</cite>:
-
-# Java virtual machine specification cite
-TAG_JVMS = jvms:a:See <cite> \
-The Java™ Virtual Machine Specification</cite>:
+COMMON_BOTTOM_ADDRESS := $(COMPANY_ADDRESS)
+COMMON_BOTTOM_TEXT := $(BUG_SUBMIT_LINE)<br>$(JAVA_TRADEMARK_LINE)
-# In order to get a specific ordering it's necessary to specify the total
-# ordering of tags as the tags are otherwise ordered in order of definition.
-define COMMON_JAVADOCTAGS
- $(call OptionPair,-tag,beaninfo:X) ; \
- $(call OptionPair,-tag,revised:X) ; \
- $(call OptionPair,-tag,since.unbundled:X) ; \
- $(call OptionPair,-tag,spec:X) ; \
- $(call OptionPair,-tag,specdefault:X) ; \
- $(call OptionPair,-tag,Note:X) ; \
- $(call OptionPair,-tag,ToDo:X) ; \
- $(call OptionPair,-tag,apiNote:a:API Note:) ; \
- $(call OptionPair,-tag,implSpec:a:Implementation Requirements:) ; \
- $(call OptionPair,-tag,implNote:a:Implementation Note:) ; \
- $(call OptionPair,-tag,param) ; \
- $(call OptionPair,-tag,return) ; \
- $(call OptionPair,-tag,throws) ; \
- $(call OptionPair,-tag,since) ; \
- $(call OptionPair,-tag,version) ; \
- $(call OptionPair,-tag,serialData) ; \
- $(call OptionPair,-tag,factory) ; \
- $(call OptionPair,-tag,see) ; \
- $(call OptionPair,-tag,$(TAG_JVMS)) ; \
- $(call OptionPair,-tag,$(TAG_JLS))
-endef
+CORE_BOTTOM_COPYRIGHT_URL := {@docroot}/../legal/cpyr.html
+CORE_BOTTOM_TEXT := $(BUG_SUBMIT_LINE)\
+<br>For further API reference and developer documentation, \
+see <a href="$(JAVADOC_BASE_URL)/index.html" target="_blank">Java SE \
+Documentation</a>. That documentation contains more detailed, \
+developer-targeted descriptions, with conceptual overviews, definitions of \
+terms, workarounds, and working code examples.
-
-
-# Assume we need a draft format when the version string is not a GA version.
-ifeq ($(VERSION_IS_GA), false)
+ifeq ($(VERSION_IS_GA), true)
+ DRAFT_HEADER :=
+ DRAFT_BOTTOM :=
+ DRAFT_WINTITLE :=
+ CORE_TOP_EARLYACCESS :=
+else
+ # We need a draft format when not building the GA version.
DRAFT_HEADER := <br><strong>DRAFT $(VERSION_STRING)</strong>
DRAFT_BOTTOM := <br><strong>DRAFT $(VERSION_STRING)</strong>
DRAFT_WINTITLE := $(VERSION_BUILD)
- # Early access top text (not used in FCS releases)
- COREAPI_TOP_EARLYACCESS := \
-<div style="background-color: \#EEEEEE"> \
+ CORE_TOP_EARLYACCESS := \
+<div style="background-color: $$(HASH)EEEEEE"> \
<div style="padding: 6px; margin-top: 2px; margin-bottom: 6px; \
margin-left: 6px; margin-right: 6px; text-align: justify; \
font-size: 80%; font-family: Helvetica, Arial, sans-serif; \
@@ -355,1384 +106,932 @@
The information is being made available to you solely for purpose of \
evaluation. \
</div> </div>
-else
- DRAFT_HEADER :=
- DRAFT_BOTTOM :=
- DRAFT_WINTITLE :=
- COREAPI_TOP_EARLYACCESS :=
endif
-#################################################################
+################################################################################
+# Support functions for SetupJavadocGeneration
-#
-# Load custom Javadoc rules
-#
-
-$(eval $(call IncludeCustomExtension, , Javadoc.gmk))
+# Print an option line to the target file
+# Arguments:
+# arg 1: the option name
+# arg 2-3: optional arguments to the option
+define AddOption
+ $(PRINTF) "%s$(if $(strip $2), '%s',)$(if $(strip $3), '%s',)\n" \
+ "$(strip $1)"$(if $(strip $2), '$(strip $2)',)$(if $(strip $3), \
+ '$(strip $3)',) >> $@
+endef
-#################################################################
+# This function goes to great pains to exactly mimic the old behavior
+# in all details, including whitespace.
+# Note that COPYRIGHT_YEAR is the current year (from spec.gmk)
+# Arguments:
+# arg 1: first copyright year
+# arg 2: copyright url (optional)
+# arg 3: company address (optional)
+# arg 4: free-form text snippet (optional)
+define GenerateBottom
+ <font size="-1">$(if $(strip $4), $(strip $4))<br> $(if \
+ $(strip $2),<a href="$(strip $2)">$(COPYRIGHT_TEXT)</a>,$(COPYRIGHT_TEXT)) \
+ $(COPYRIGHT_SYMBOL) $(strip $1), $(COPYRIGHT_YEAR), \
+ $(FULL_COMPANY_NAME). $(strip $3) \
+ $(ALL_RIGHTS_RESERVED)$(if $(strip $4), )</font>
+endef
-#
-# Default target is same as docs target, create core api and all others it can
+# Speed up finding by filling cache
+$(eval $(call FillCacheFind, $(wildcard $(JAVADOC_SOURCE_DIRS))))
+
+# Prevent # from expanding
+EscapeHash = $(subst $(HASH),{hash},$(strip $1))
+
+################################################################################
+# Setup make rules for running javadoc.
#
-
-all: docs
-docs: coredocs otherdocs
-
+# Parameter 1 is the name of the rule. This name is used as variable prefix,
+# and the targets generated are listed in a variable by that name. Note that
+# the index.html file will work as a "touch file" for all the magnitude of
+# files that are generated by javadoc.
#
-# Optional target which bundles all generated javadocs into a zip archive.
-# The dependency on docs is handled in Main.gmk.
-#
-
-zip-docs: $(JAVADOC_ARCHIVE)
-
-#############################################################
+# Remaining parameters are named arguments. These include:
+# MODULES - Modules to include
+# PACKAGES - Packages to include
+# PACKAGE_FILTER - Filter for packages
+# IS_CORE - Set to TRUE for the Core API package which needs special treatment
+# API_ROOT - Where to base the documentation (jre or jdk)
+# DEST_DIR - A directory relative to the API root
+# OVERVIEW - Path to a html overview file
+# TITLE - Default title to use for the more specific versions below
+# WINDOW_TITLE - Title to use in -windowtitle. Computed from TITLE if empty.
+# HEADER_TITLE - Title to use in -header. Computed from TITLE if empty.
+# DOC_TITLE - Title to use in -doctitle. Computed from TITLE if empty.
+# FIRST_COPYRIGHT_YEAR - First year this bundle was introduced
+# DOCLINT - Doclint level. Defaults to "all".
+# DOCLINT_PACKAGES - Optional -Xdoclint/package value
+# ENCODING - Change character encoding (defaults to 'ascii')
+# SPLIT_INDEX - Enable -splitIndex
+# BREAKITERATOR - Enable -breakiterator
+# NODEPRECATEDLIST - Enable nodeprecatedlist
+# NOINDEX - Enable -noindex and -nonavbar
+# BOTTOM_COPYRIGHT_URL - Copyright URL to use in -bottom
+# BOTTOM_ADDRESS - Company address to use in -bottom
+# BOTTOM_TEXT - Extra text to use in -bottom
+# EXTRA_TOP - Additional -top data
#
-# coredocs
-#
-COREAPI_DOCTITLE = Java$(TRADEMARK) Platform, Standard Edition \
-$(VERSION_SPECIFICATION)<br>API Specification
-COREAPI_WINDOWTITLE = Java Platform SE $(VERSION_SPECIFICATION)
-COREAPI_HEADER = \
-<strong>Java$(TRADEMARK) Platform<br>Standard Ed. $(VERSION_SPECIFICATION)</strong>
+SetupJavadocGeneration = $(NamedParamsMacroTemplate)
+define SetupJavadocGenerationBody
+ ifeq ($$($1_IS_CORE), TRUE)
+ $1_JAVA := $$(JAVA)
+ $1_OUTPUT_DIRNAME := api
+ else
+ $1_JAVA := $$(JAVA_SMALL)
+ $1_OUTPUT_DIRNAME := $$($1_API_ROOT)/api/$$($1_DEST_DIR)
+
+ ifeq ($$($1_RELATIVE_CORE_DIR),)
+ # Compute a relative path to core root.
+ # The non-core api javadocs need to be able to access the root of the core
+ # api directory, so for jdk/api or jre/api to get to the core api/
+ # directory we would use this
+ # NOTE: Need to be able to override for broken old code in JShell
+ $1_RELATIVE_CORE_DIR := $$(strip $$(subst $$(call DirToDotDot, \
+ $$(JAVADOC_OUTPUTDIR))/,, $$(call DirToDotDot, \
+ $$(JAVADOC_OUTPUTDIR)/$$($1_OUTPUT_DIRNAME))))
+ endif
+
+ $1_DEPS += $(CORE_INDEX_FILE)
+ endif
-# Overview file for core apis
-COREAPI_OVERVIEW = $(JDK_TOPDIR)/src/java.base/share/classes/overview-core.html
+ ifneq ($$($1_OVERVIEW), )
+ $1_DEPS += $$($1_OVERVIEW)
+ endif
+
+ ifeq ($$($1_ENCODING), )
+ $1_ENCODING := ascii
+ endif
+
+ ifeq ($$($1_DOCLINT), )
+ $1_DOCLINT := all
+ endif
+
+ ifeq ($$($1_DOC_TITLE), )
+ $1_DOC_TITLE := $$($1_TITLE)
+ endif
+
+ ifeq ($$($1_WINDOW_TITLE), )
+ $1_WINDOW_TITLE := $$(strip $$(subst $$(TRADEMARK),, $$($1_TITLE)))
+ endif
+
+ ifeq ($$($1_HEADER_TITLE), )
+ $1_HEADER_TITLE := $$(strip $$(subst $$(TRADEMARK),, $$($1_TITLE)))
+ endif
+ $1_HEADER := <strong>$$($1_HEADER_TITLE)</strong>
-# The options and packages files
-COREAPI_OPTIONS_FILE = $(DOCSTMPDIR)/coredocs.options
-COREAPI_PACKAGES_FILE = $(DOCSTMPDIR)/coredocs.packages
+ $1_BOTTOM := $$(call GenerateBottom, $$($1_FIRST_COPYRIGHT_YEAR), \
+ $$($1_BOTTOM_COPYRIGHT_URL), $$($1_BOTTOM_ADDRESS), $$($1_BOTTOM_TEXT))
-# The modules required to be documented
-COREAPI_MODULES = java.se.ee
+ # The index.html, options, and packages files
+ $1_INDEX_FILE := $$(JAVADOC_OUTPUTDIR)/$$($1_OUTPUT_DIRNAME)/index.html
+ $1_OPTIONS_FILE := $$(SUPPORT_OUTPUTDIR)/docs/$1.options
+ $1_PACKAGES_FILE := $$(SUPPORT_OUTPUTDIR)/docs/$1.packages
-coredocs: $(COREAPI_INDEX_FILE)
+ $1_PACKAGES_VARDEPS := $$($1_PACKAGES) $$($1_PACKAGES_SINGLE_CLASS)
+ $1_PACKAGES_VARDEPS_FILE := $$(call DependOnVariable, $1_PACKAGES_VARDEPS, \
+ $$($1_PACKAGES_FILE).vardeps)
-# Set relative location to core api document root
-$(COREAPI_INDEX_FILE): GET2DOCSDIR=..
+ # Rule for creating a file with the package names in it
+ $$($1_PACKAGES_FILE): $$($1_PACKAGES_VARDEPS_FILE)
+ $$(call LogInfo, Creating Javadoc package file for $1)
+ $$(call MakeDir, $$(@D))
+ ifeq ($$($1_PACKAGES_SINGLE_CLASS), )
+ $$(ECHO) $$($1_PACKAGES) | $$(TR) ' ' '\n' > $$@
+ else
+ # NOTE: This is for backwards compatibility for taglet
+ $$(ECHO) $$($1_PACKAGES_SINGLE_CLASS) > $$@
+ endif
-# Run javadoc if the index file is out of date or missing
-$(COREAPI_INDEX_FILE): $(COREAPI_OPTIONS_FILE) $(COREAPI_PACKAGES_FILE)
- $(prep-javadoc)
- $(call JavadocSummary,$(COREAPI_OPTIONS_FILE),$(COREAPI_PACKAGES_FILE))
- $(JAVADOC_CMD) -d $(@D) \
- @$(COREAPI_OPTIONS_FILE) @$(COREAPI_PACKAGES_FILE)
+ # NOTE: Not including $$($1_EXTRA_TOP) due to $$(HASH)
+ $1_OPTIONS_VARDEPS := $$(call EscapeHash, \
+ $$($DOCROOTPARENT_FLAG) $$(JAVADOC_BASE_URL) $$($1_NO_COMMON_TAGS) \
+ $$($1_DOCLINT) $$($1_DOCLINT_PACKAGES) $$(JAVADOC_SOURCE_DIRS) \
+ $$($1_MODULES) $$($1_ENCODING) $$($1_NODEPRECATEDLIST) \
+ $$($1_BREAKITERATOR) $$($1_SPLIT_INDEX) $$($1_OVERVIEW) \
+ $$($1_DOC_TITLE) $$($1_WINDOW_TITLE) $$(DRAFT_WINTITLE) \
+ $$($1_HEADER) $$(DRAFT_HEADER) $$($1_NOINDEX) $$($1_EXTRA_TOP_2) \
+ $$($1_BOTTOM) $$(DRAFT_BOTTOM)) $$($1_PACKAGE_FILTER) $$($1_RELATIVE_CORE_DIR) \
+ $$(JAVADOC_OUTPUTDIR) \
+ )
+ $1_OPTIONS_VARDEPS_FILE := $$(call DependOnVariable, $1_OPTIONS_VARDEPS, \
+ $$($1_OPTIONS_FILE).vardeps)
-# Create file with javadoc options in it
-$(COREAPI_OPTIONS_FILE): $(COREAPI_OVERVIEW)
- $(prep-target)
- @($(call COMMON_JAVADOCFLAGS) ; \
- $(call COMMON_JAVADOCTAGS) ; \
- $(call OptionOnly,-Xdoclint:reference) ; \
- $(call OptionOnly,-Xdoclint/package:-org.omg.*$(COMMA)jdk.internal.logging.*) ; \
- $(call OptionPair,--system,none) ; \
- $(call OptionPair,--module-source-path,$(RELEASEDOCS_MODULESOURCEPATH)) ; \
- $(call OptionPair,--add-modules,$(COREAPI_MODULES)) ; \
- $(call OptionPair,-encoding,ISO-8859-1) ; \
- $(call OptionOnly,-splitIndex) ; \
- $(call OptionPair,-overview,$(COREAPI_OVERVIEW)) ; \
- $(call OptionPair,-doctitle,$(COREAPI_DOCTITLE)) ; \
- $(call OptionPair,-windowtitle,$(COREAPI_WINDOWTITLE) $(DRAFT_WINTITLE)) ; \
- $(call OptionPair,-header,$(COREAPI_HEADER)$(DRAFT_HEADER)) ; \
- $(call OptionPair,-bottom,$(COREAPI_BOTTOM)$(DRAFT_BOTTOM)) ; \
- ) >> $@
- ifdef COREAPI_TOP_EARLYACCESS
- @$(call OptionPair,-top,$(COREAPI_TOP_EARLYACCESS)) >> $@
+ # Rule for creating a file with javadoc options in it
+ $$($1_OPTIONS_FILE): $$($1_OPTIONS_VARDEPS_FILE)
+ $$(call LogInfo, Creating Javadoc options file for $1)
+ $$(call MakeDir, $$(@D))
+ $$(RM) $$@
+ $$(call AddOption, -XDignore.symbol.file=true)
+ ifneq ($$(LOG_LEVEL), trace)
+ $$(call AddOption, -quiet)
+ endif
+ $$(call AddOption, -use)
+ $$(call AddOption, -keywords)
+ ifneq ($$($DOCROOTPARENT_FLAG), )
+ # NOTE: Argument to -Xdocrootparent is not quoted to keep backwards compatibility.
+ $$(call AddOption, -Xdocrootparent $(JAVADOC_BASE_URL))
+ endif
+ ifneq ($$($1_NO_COMMON_TAGS), TRUE)
+ # In order to get a specific ordering it's necessary to specify the total
+ # ordering of tags as the tags are otherwise ordered in order of definition.
+ $$(call AddOption, -tag, beaninfo:X)
+ $$(call AddOption, -tag, revised:X)
+ $$(call AddOption, -tag, since.unbundled:X)
+ $$(call AddOption, -tag, spec:X)
+ $$(call AddOption, -tag, specdefault:X)
+ $$(call AddOption, -tag, Note:X)
+ $$(call AddOption, -tag, ToDo:X)
+ $$(call AddOption, -tag, apiNote:a:API Note:)
+ $$(call AddOption, -tag, implSpec:a:Implementation Requirements:)
+ $$(call AddOption, -tag, implNote:a:Implementation Note:)
+ $$(call AddOption, -tag, param)
+ $$(call AddOption, -tag, return)
+ $$(call AddOption, -tag, throws)
+ $$(call AddOption, -tag, since)
+ $$(call AddOption, -tag, version)
+ $$(call AddOption, -tag, serialData)
+ $$(call AddOption, -tag, factory)
+ $$(call AddOption, -tag, see)
+ $$(call AddOption, -tag, \
+ jvms:a:See <cite> The Java™ Virtual Machine Specification</cite>:)
+ $$(call AddOption, -tag, \
+ jls:a:See <cite> The Java™ Language Specification</cite>:)
+ endif
+ $$(call AddOption, -Xdoclint:$$($1_DOCLINT))
+ ifneq ($$($1_DOCLINT_PACKAGES), )
+ $$(call AddOption, -Xdoclint/package:$$(call CommaList, $$($1_DOCLINT_PACKAGES)))
+ endif
+ $$(call AddOption, --system, none)
+ $$(call AddOption, --module-source-path, $$(subst ",, $$(call PathList, $$(JAVADOC_SOURCE_DIRS))))
+ $$(call AddOption, --add-modules, $$(call CommaList, $$($1_MODULES)))
+ $$(call AddOption, -encoding, $$($1_ENCODING))
+ ifneq ($$($1_NODEPRECATEDLIST), )
+ $$(call AddOption, -nodeprecatedlist)
+ endif
+ ifneq ($$($1_BREAKITERATOR), )
+ $$(call AddOption, -breakiterator)
+ endif
+ ifneq ($$($1_SPLIT_INDEX), )
+ $$(call AddOption, -splitIndex)
+ endif
+ ifneq ($$($1_OVERVIEW), )
+ $$(call AddOption, -overview, $$($1_OVERVIEW))
+ endif
+ $$(call AddOption, -doctitle, $$($1_DOC_TITLE))
+ $$(call AddOption, -windowtitle, $$($1_WINDOW_TITLE) $$(DRAFT_WINTITLE))
+ $$(call AddOption, -header, $$($1_HEADER)$$(DRAFT_HEADER))
+ ifneq ($$($1_NOINDEX), )
+ $$(call AddOption, -nonavbar)
+ $$(call AddOption, -noindex)
+ endif
+ ifneq ($$($1_EXTRA_TOP_2), )
+ $$(call AddOption, -top,$$($1_EXTRA_TOP_2))
+ endif
+ $$(call AddOption, -bottom, $$($1_BOTTOM)$$(DRAFT_BOTTOM))
+ ifneq ($$($1_PACKAGE_FILTER), )
+ $$(call AddOption, -group, Packages, $$($1_PACKAGE_FILTER))
+ endif
+ ifneq ($$($1_RELATIVE_CORE_DIR), )
+ $$(call AddOption, -linkoffline, $$($1_RELATIVE_CORE_DIR)/api, $$(JAVADOC_OUTPUTDIR)/api/)
+ endif
+ ifneq ($$($1_EXTRA_TOP), )
+ $$(call AddOption, -top, $$($1_EXTRA_TOP))
endif
-# Create a file with the package names in it
-$(COREAPI_PACKAGES_FILE): $(call PackageDependencies,$(CORE_PKGS))
- $(prep-target)
- $(call PackageFilter,$(CORE_PKGS))
-
-#############################################################
-#
-# docletapidocs
-#
-
-ALL_OTHER_TARGETS += docletapidocs
-
-DOCLETAPI_DOCDIR := $(JDK_API_DOCSDIR)/javadoc/doclet
-DOCLETAPI2COREAPI := ../../$(JDKJRE2COREAPI)
-DOCLETAPI_DOCTITLE := Doclet API
-DOCLETAPI_WINDOWTITLE := Doclet API
-DOCLETAPI_HEADER := <strong>Doclet API</strong>
-DOCLETAPI_BOTTOM := $(call CommonTrademarkBottom,$(DOCLETAPI_FIRST_COPYRIGHT_YEAR))
-DOCLETAPI_GROUPNAME := Packages
-DOCLETAPI_REGEXP := jdk.javadoc.doclet*
-# DOCLETAPI_PKGS is located in NON_CORE_PKGS.gmk
-
-# The index.html, options, and packages files
-DOCLETAPI_INDEX_FILE = $(DOCLETAPI_DOCDIR)/index.html
-DOCLETAPI_OPTIONS_FILE = $(DOCSTMPDIR)/docletapi.options
-DOCLETAPI_PACKAGES_FILE = $(DOCSTMPDIR)/docletapi.packages
-
-# The modules required to be documented
-DOCLETAPI_MODULES = jdk.javadoc
-
-docletapidocs: $(DOCLETAPI_INDEX_FILE)
-
-# Set relative location to core api document root
-$(DOCLETAPI_INDEX_FILE): GET2DOCSDIR=$(DOCLETAPI2COREAPI)/..
+ $1_PACKAGE_DEPS := $$(call CacheFind, $$(wildcard $$(foreach p, \
+ $$(subst .,/,$$(strip $$($1_PACKAGES))), \
+ $$(addsuffix /$$p, $$(wildcard $$(JAVADOC_SOURCE_DIRS))))))
-# Run javadoc if the index file is out of date or missing
-$(DOCLETAPI_INDEX_FILE): $(DOCLETAPI_OPTIONS_FILE) $(DOCLETAPI_PACKAGES_FILE) $(COREAPI_INDEX_FILE)
- $(prep-javadoc)
- $(call JavadocSummary,$(DOCLETAPI_OPTIONS_FILE),$(DOCLETAPI_PACKAGES_FILE))
- $(JAVADOC_CMD_SMALL) -d $(@D) \
- @$(DOCLETAPI_OPTIONS_FILE) @$(DOCLETAPI_PACKAGES_FILE)
+ # Rule for actually running javadoc
+ $$($1_INDEX_FILE): $$($1_OPTIONS_FILE) $$($1_PACKAGES_FILE) \
+ $$($1_PACKAGE_DEPS) $$($1_DEPS)
+ $$(call LogWarn, Generating Javadoc for $$($1_OUTPUT_DIRNAME))
+ $$(call MakeDir, $$(@D))
+ ifneq ($$(findstring $$(LOG_LEVEL), debug trace),)
+ $$(ECHO) "Contents of $$($1_OPTIONS_FILE):" `$$(CAT) $$($1_OPTIONS_FILE)`
+ $$(ECHO) "Contents of $$($1_PACKAGES_FILE):" `$$(CAT) $$($1_PACKAGES_FILE)`
+ endif
+ $$(call ExecuteWithLog, $$(SUPPORT_OUTPUTDIR)/docs/$1.javadoc, \
+ $$($1_JAVA) -Djava.awt.headless=true $(NEW_JAVADOC) -d $$(@D) \
+ @$$($1_OPTIONS_FILE) @$$($1_PACKAGES_FILE))
+ $$(TOUCH) $$($1_INDEX_FILE)
-# Create file with javadoc options in it
-$(DOCLETAPI_OPTIONS_FILE):
- $(prep-target)
- @($(call COMMON_JAVADOCFLAGS) ; \
- $(call COMMON_JAVADOCTAGS) ; \
- $(call OptionOnly,-Xdoclint:all) ; \
- $(call OptionPair,--system,none) ; \
- $(call OptionPair,--module-source-path,$(RELEASEDOCS_MODULESOURCEPATH)) ; \
- $(call OptionPair,--add-modules,$(DOCLETAPI_MODULES)) ; \
- $(call OptionPair,-encoding,ascii) ; \
- $(call OptionOnly,-breakiterator) ; \
- $(call OptionPair,-doctitle,$(DOCLETAPI_DOCTITLE)) ; \
- $(call OptionPair,-windowtitle,$(DOCLETAPI_WINDOWTITLE) $(DRAFT_WINTITLE)); \
- $(call OptionPair,-header,$(DOCLETAPI_HEADER)$(DRAFT_HEADER)) ; \
- $(call OptionPair,-bottom,$(DOCLETAPI_BOTTOM)$(DRAFT_BOTTOM)) ; \
- $(call OptionTrip,-group,$(DOCLETAPI_GROUPNAME),$(DOCLETAPI_REGEXP)); \
- $(call OptionTrip,-linkoffline,$(DOCLETAPI2COREAPI),$(COREAPI_DOCSDIR)/); \
- ) >> $@
+ # The output returned will be the index.html file
+ $1 := $$($1_INDEX_FILE)
+endef
-# Create a file with the package names in it
-$(DOCLETAPI_PACKAGES_FILE): $(call PackageDependencies,$(DOCLETAPI_PKGS))
- $(prep-target)
- $(call PackageFilter,$(DOCLETAPI_PKGS))
-
-#############################################################
-#
-# old docletapidocs
-#
-
-ALL_OTHER_TARGETS += olddocletapidocs
+################################################################################
-OLD_DOCLET_DIR := $(JDK_API_DOCSDIR)/javadoc/old
-OLD_DOCLETAPI_DOCDIR := $(OLD_DOCLET_DIR)/doclet
-OLD_DOCLETAPI2COREAPI := ../../../$(JDKJRE2COREAPI)
-OLD_DOCLETAPI_DOCTITLE := Doclet API
-OLD_DOCLETAPI_WINDOWTITLE := Doclet API
-OLD_DOCLETAPI_HEADER := <strong>Doclet API</strong>
-OLD_DOCLETAPI_BOTTOM := $(call CommonTrademarkBottom,$(DOCLETAPI_FIRST_COPYRIGHT_YEAR))
-OLD_DOCLETAPI_GROUPNAME := Packages
-OLD_DOCLETAPI_REGEXP := com.sun.javadoc
-# OLD_DOCLETAPI_PKGS is located in NON_CORE_PKGS.gmk
-
-# The index.html, options, and packages files
-OLD_DOCLETAPI_INDEX_FILE = $(OLD_DOCLETAPI_DOCDIR)/index.html
-OLD_DOCLETAPI_OPTIONS_FILE = $(DOCSTMPDIR)/old-docletapi.options
-OLD_DOCLETAPI_PACKAGES_FILE = $(DOCSTMPDIR)/old-docletapi.packages
-
-# The modules required to be documented
-OLD_DOCLETAPI_MODULES = jdk.javadoc
-
-olddocletapidocs: $(OLD_DOCLETAPI_INDEX_FILE)
-
-# Set relative location to core api document root
-$(OLD_DOCLETAPI_INDEX_FILE): GET2DOCSDIR=$(OLD_DOCLETAPI2COREAPI)/..
-
-# Run javadoc if the index file is out of date or missing
-$(OLD_DOCLETAPI_INDEX_FILE): $(OLD_DOCLETAPI_OPTIONS_FILE) $(OLD_DOCLETAPI_PACKAGES_FILE) $(COREAPI_INDEX_FILE)
- $(prep-javadoc)
- $(call JavadocSummary,$(OLD_DOCLETAPI_OPTIONS_FILE),$(OLD_DOCLETAPI_PACKAGES_FILE))
- $(JAVADOC_CMD_SMALL) -d $(@D) \
- @$(OLD_DOCLETAPI_OPTIONS_FILE) @$(OLD_DOCLETAPI_PACKAGES_FILE)
+CORE_PACKAGES := \
+ java.applet \
+ java.awt \
+ java.awt.color \
+ java.awt.datatransfer \
+ java.awt.desktop \
+ java.awt.dnd \
+ java.awt.event \
+ java.awt.font \
+ java.awt.geom \
+ java.awt.im \
+ java.awt.im.spi \
+ java.awt.image \
+ java.awt.image.renderable \
+ java.awt.print \
+ java.beans \
+ java.beans.beancontext \
+ java.io \
+ java.lang \
+ java.lang.annotation \
+ java.lang.instrument \
+ java.lang.invoke \
+ java.lang.management \
+ java.lang.module \
+ java.lang.ref \
+ java.lang.reflect \
+ java.math \
+ java.net \
+ java.net.http \
+ java.net.spi \
+ java.nio \
+ java.nio.channels \
+ java.nio.channels.spi \
+ java.nio.charset \
+ java.nio.charset.spi \
+ java.nio.file \
+ java.nio.file.attribute \
+ java.nio.file.spi \
+ java.rmi \
+ java.rmi.activation \
+ java.rmi.dgc \
+ java.rmi.registry \
+ java.rmi.server \
+ java.security \
+ java.security.acl \
+ java.security.cert \
+ java.security.interfaces \
+ java.security.spec \
+ java.sql \
+ java.text \
+ java.text.spi \
+ java.time \
+ java.time.chrono \
+ java.time.format \
+ java.time.temporal \
+ java.time.zone \
+ java.util \
+ java.util.concurrent \
+ java.util.concurrent.atomic \
+ java.util.concurrent.locks \
+ java.util.function \
+ java.util.jar \
+ java.util.logging \
+ java.util.prefs \
+ java.util.regex \
+ java.util.spi \
+ java.util.stream \
+ java.util.zip \
+ javax.accessibility \
+ javax.activation \
+ javax.activity \
+ javax.annotation \
+ javax.annotation.processing \
+ javax.crypto \
+ javax.crypto.interfaces \
+ javax.crypto.spec \
+ javax.imageio \
+ javax.imageio.event \
+ javax.imageio.metadata \
+ javax.imageio.plugins.jpeg \
+ javax.imageio.plugins.bmp \
+ javax.imageio.plugins.tiff \
+ javax.imageio.spi \
+ javax.imageio.stream \
+ javax.jws \
+ javax.jws.soap \
+ javax.lang.model \
+ javax.lang.model.element \
+ javax.lang.model.type \
+ javax.lang.model.util \
+ javax.management \
+ javax.management.loading \
+ javax.management.monitor \
+ javax.management.relation \
+ javax.management.openmbean \
+ javax.management.timer \
+ javax.management.modelmbean \
+ javax.management.remote \
+ javax.management.remote.rmi \
+ javax.naming \
+ javax.naming.directory \
+ javax.naming.event \
+ javax.naming.ldap \
+ javax.naming.spi \
+ javax.net \
+ javax.net.ssl \
+ javax.print \
+ javax.print.attribute \
+ javax.print.attribute.standard \
+ javax.print.event \
+ javax.rmi \
+ javax.rmi.CORBA \
+ javax.rmi.ssl \
+ javax.script \
+ javax.security.auth \
+ javax.security.auth.callback \
+ javax.security.auth.kerberos \
+ javax.security.auth.login \
+ javax.security.auth.spi \
+ javax.security.auth.x500 \
+ javax.security.cert \
+ javax.security.sasl \
+ javax.sound.sampled \
+ javax.sound.sampled.spi \
+ javax.sound.midi \
+ javax.sound.midi.spi \
+ javax.sql \
+ javax.sql.rowset \
+ javax.sql.rowset.serial \
+ javax.sql.rowset.spi \
+ javax.swing \
+ javax.swing.border \
+ javax.swing.colorchooser \
+ javax.swing.filechooser \
+ javax.swing.event \
+ javax.swing.table \
+ javax.swing.text \
+ javax.swing.text.html \
+ javax.swing.text.html.parser \
+ javax.swing.text.rtf \
+ javax.swing.tree \
+ javax.swing.undo \
+ javax.swing.plaf \
+ javax.swing.plaf.basic \
+ javax.swing.plaf.metal \
+ javax.swing.plaf.multi \
+ javax.swing.plaf.nimbus \
+ javax.swing.plaf.synth \
+ javax.tools \
+ javax.transaction \
+ javax.transaction.xa \
+ javax.xml.catalog \
+ javax.xml.parsers \
+ javax.xml.bind \
+ javax.xml.bind.annotation \
+ javax.xml.bind.annotation.adapters \
+ javax.xml.bind.attachment \
+ javax.xml.bind.helpers \
+ javax.xml.bind.util \
+ javax.xml.soap \
+ javax.xml.ws \
+ javax.xml.ws.handler \
+ javax.xml.ws.handler.soap \
+ javax.xml.ws.http \
+ javax.xml.ws.soap \
+ javax.xml.ws.spi \
+ javax.xml.ws.spi.http \
+ javax.xml.ws.wsaddressing \
+ javax.xml.transform \
+ javax.xml.transform.sax \
+ javax.xml.transform.dom \
+ javax.xml.transform.stax \
+ javax.xml.transform.stream \
+ javax.xml \
+ javax.xml.crypto \
+ javax.xml.crypto.dom \
+ javax.xml.crypto.dsig \
+ javax.xml.crypto.dsig.dom \
+ javax.xml.crypto.dsig.keyinfo \
+ javax.xml.crypto.dsig.spec \
+ javax.xml.datatype \
+ javax.xml.validation \
+ javax.xml.namespace \
+ javax.xml.xpath \
+ javax.xml.stream \
+ javax.xml.stream.events \
+ javax.xml.stream.util \
+ org.ietf.jgss \
+ org.omg.CORBA \
+ org.omg.CORBA.DynAnyPackage \
+ org.omg.CORBA.ORBPackage \
+ org.omg.CORBA.TypeCodePackage \
+ org.omg.stub.java.rmi \
+ org.omg.CORBA.portable \
+ org.omg.CORBA_2_3 \
+ org.omg.CORBA_2_3.portable \
+ org.omg.CosNaming \
+ org.omg.CosNaming.NamingContextExtPackage \
+ org.omg.CosNaming.NamingContextPackage \
+ org.omg.SendingContext \
+ org.omg.PortableServer \
+ org.omg.PortableServer.CurrentPackage \
+ org.omg.PortableServer.POAPackage \
+ org.omg.PortableServer.POAManagerPackage \
+ org.omg.PortableServer.ServantLocatorPackage \
+ org.omg.PortableServer.portable \
+ org.omg.PortableInterceptor \
+ org.omg.PortableInterceptor.ORBInitInfoPackage \
+ org.omg.Messaging \
+ org.omg.IOP \
+ org.omg.IOP.CodecFactoryPackage \
+ org.omg.IOP.CodecPackage \
+ org.omg.Dynamic \
+ org.omg.DynamicAny \
+ org.omg.DynamicAny.DynAnyPackage \
+ org.omg.DynamicAny.DynAnyFactoryPackage \
+ org.w3c.dom \
+ org.w3c.dom.events \
+ org.w3c.dom.bootstrap \
+ org.w3c.dom.ls \
+ org.w3c.dom.ranges \
+ org.w3c.dom.traversal \
+ org.w3c.dom.views \
+ org.xml.sax \
+ org.xml.sax.ext \
+ org.xml.sax.helpers
-# Create file with javadoc options in it
-$(OLD_DOCLETAPI_OPTIONS_FILE):
- $(prep-target)
- @($(call COMMON_JAVADOCFLAGS) ; \
- $(call COMMON_JAVADOCTAGS) ; \
- $(call OptionOnly,-Xdoclint:all) ; \
- $(call OptionPair,--system,none) ; \
- $(call OptionPair,--module-source-path,$(RELEASEDOCS_MODULESOURCEPATH)) ; \
- $(call OptionPair,--add-modules,$(OLD_DOCLETAPI_MODULES)) ; \
- $(call OptionPair,-encoding,ascii) ; \
- $(call OptionOnly,-breakiterator) ; \
- $(call OptionPair,-doctitle,$(OLD_DOCLETAPI_DOCTITLE)) ; \
- $(call OptionPair,-windowtitle,$(OLD_DOCLETAPI_WINDOWTITLE) $(DRAFT_WINTITLE)); \
- $(call OptionPair,-header,$(OLD_DOCLETAPI_HEADER)$(DRAFT_HEADER)) ; \
- $(call OptionPair,-bottom,$(OLD_DOCLETAPI_BOTTOM)$(DRAFT_BOTTOM)) ; \
- $(call OptionTrip,-group,$(OLD_DOCLETAPI_GROUPNAME),$(OLD_DOCLETAPI_REGEXP)); \
- $(call OptionTrip,-linkoffline,$(OLD_DOCLETAPI2COREAPI),$(COREAPI_DOCSDIR)/); \
- ) >> $@
+$(eval $(call SetupJavadocGeneration, coredocs, \
+ MODULES := java.se.ee, \
+ PACKAGES := $(CORE_PACKAGES), \
+ IS_CORE := TRUE, \
+ OVERVIEW := $(JDK_TOPDIR)/src/java.base/share/classes/overview-core.html, \
+ WINDOW_TITLE := Java Platform SE $(VERSION_SPECIFICATION), \
+ HEADER_TITLE := Java$(TRADEMARK) Platform<br>Standard Ed. $(VERSION_SPECIFICATION), \
+ DOC_TITLE := Java$(TRADEMARK) Platform$(COMMA) Standard Edition \
+ $(VERSION_SPECIFICATION)<br>API Specification, \
+ FIRST_COPYRIGHT_YEAR := 1993, \
+ DOCLINT := reference, \
+ DOCLINT_PACKAGES := -org.omg.* jdk.internal.logging.*, \
+ ENCODING := ISO-8859-1, \
+ SPLIT_INDEX := TRUE, \
+ BOTTOM_COPYRIGHT_URL := $(CORE_BOTTOM_COPYRIGHT_URL), \
+ BOTTOM_TEXT := $(CORE_BOTTOM_TEXT), \
+ EXTRA_TOP := $(CORE_TOP_EARLYACCESS), \
+))
-# Create a file with the package names in it
-$(OLD_DOCLETAPI_PACKAGES_FILE): $(call PackageDependencies,$(OLD_DOCLETAPI_PKGS))
- $(prep-target)
- $(call PackageFilter,$(OLD_DOCLETAPI_PKGS))
+TARGETS += $(coredocs)
+
+################################################################################
+
+$(eval $(call SetupJavadocGeneration, docletapi, \
+ MODULES := jdk.javadoc, \
+ PACKAGES := \
+ jdk.javadoc.doclet \
+ jdk.javadoc.doclet.taglet \
+ jdk.javadoc.doclets, \
+ PACKAGE_FILTER := jdk.javadoc.doclet*, \
+ API_ROOT := jdk, \
+ DEST_DIR := javadoc/doclet, \
+ TITLE := Doclet API, \
+ FIRST_COPYRIGHT_YEAR := 1993, \
+ BREAKITERATOR := TRUE, \
+ BOTTOM_ADDRESS := $(COMMON_BOTTOM_ADDRESS), \
+ BOTTOM_TEXT := $(COMMON_BOTTOM_TEXT), \
+))
-#############################################################
-#
-# tagletapidocs
-#
+TARGETS += $(docletapi)
+
+################################################################################
-ALL_OTHER_TARGETS += tagletapidocs
-TAGLETAPI_DOCDIR := $(OLD_DOCLET_DIR)/taglet
-TAGLETAPI2COREAPI := ../../../$(JDKJRE2COREAPI)
-TAGLETAPI_DOCTITLE := Taglet API
-TAGLETAPI_WINDOWTITLE := Taglet API
-TAGLETAPI_HEADER := <strong>Taglet API</strong>
-TAGLETAPI_BOTTOM := $(call CommonTrademarkBottom,$(TAGLETAPI_FIRST_COPYRIGHT_YEAR))
-# TAGLETAPI_FILE is located in NON_CORE_PKGS.gmk
+$(eval $(call SetupJavadocGeneration, old-docletapi, \
+ MODULES := jdk.javadoc, \
+ PACKAGES := com.sun.javadoc, \
+ PACKAGE_FILTER := com.sun.javadoc, \
+ API_ROOT := jdk, \
+ DEST_DIR := javadoc/old/doclet, \
+ TITLE := Doclet API, \
+ FIRST_COPYRIGHT_YEAR := 1993, \
+ BREAKITERATOR := TRUE, \
+ BOTTOM_ADDRESS := $(COMMON_BOTTOM_ADDRESS), \
+ BOTTOM_TEXT := $(COMMON_BOTTOM_TEXT), \
+))
+
+TARGETS += $(old-docletapi)
-# The index.html, options, and packages files
-TAGLETAPI_INDEX_FILE = $(TAGLETAPI_DOCDIR)/index.html
-TAGLETAPI_OPTIONS_FILE = $(DOCSTMPDIR)/tagletapi.options
-TAGLETAPI_PACKAGES_FILE = $(DOCSTMPDIR)/tagletapi.packages
+################################################################################
-# The modules required to be documented
-TAGLETAPI_MODULES = jdk.javadoc
+# Specify a single class instead of a package
+TAGLET_PACKAGE_SINGLE_CLASS := com/sun/tools/doclets/Taglet.java
+TAGLET_PACKAGE_DIR := $(LANGTOOLS_TOPDIR)/src/jdk.javadoc/share/classes
-tagletapidocs: $(TAGLETAPI_INDEX_FILE)
-
-# Run javadoc if the index file is out of date or missing
-$(TAGLETAPI_INDEX_FILE): $(TAGLETAPI_OPTIONS_FILE) $(TAGLETAPI_PACKAGES_FILE) $(COREAPI_INDEX_FILE)
- $(prep-javadoc)
- $(call JavadocSummary,$(TAGLETAPI_OPTIONS_FILE),$(TAGLETAPI_PACKAGES_FILE))
- $(JAVADOC_CMD_SMALL) -d $(@D) \
- @$(TAGLETAPI_OPTIONS_FILE) @$(TAGLETAPI_PACKAGES_FILE)
+$(eval $(call SetupJavadocGeneration, tagletapi, \
+ MODULES := jdk.javadoc, \
+ PACKAGES := com.sun.tools.doclets, \
+ PACKAGES_SINGLE_CLASS := $(TAGLET_PACKAGE_DIR)/$(TAGLET_PACKAGE_SINGLE_CLASS), \
+ API_ROOT := jdk, \
+ DEST_DIR := javadoc/old/taglet, \
+ TITLE := Taglet API, \
+ FIRST_COPYRIGHT_YEAR := 1993, \
+ BREAKITERATOR := TRUE, \
+ NOINDEX := TRUE, \
+ BOTTOM_ADDRESS := $(COMMON_BOTTOM_ADDRESS), \
+ BOTTOM_TEXT := $(COMMON_BOTTOM_TEXT), \
+))
-# Create file with javadoc options in it
-$(TAGLETAPI_OPTIONS_FILE):
- $(prep-target)
- @($(call COMMON_JAVADOCFLAGS) ; \
- $(call COMMON_JAVADOCTAGS) ; \
- $(call OptionOnly,-Xdoclint:all) ; \
- $(call OptionPair,--system,none) ; \
- $(call OptionPair,--module-source-path,$(RELEASEDOCS_MODULESOURCEPATH)) ; \
- $(call OptionPair,--add-modules,$(TAGLETAPI_MODULES)) ; \
- $(call OptionPair,-encoding,ascii) ; \
- $(call OptionOnly,-breakiterator) ; \
- $(call OptionPair,-doctitle,$(TAGLETAPI_DOCTITLE)) ; \
- $(call OptionPair,-windowtitle,$(TAGLETAPI_WINDOWTITLE) $(DRAFT_WINTITLE)); \
- $(call OptionPair,-header,$(TAGLETAPI_HEADER)$(DRAFT_HEADER)) ; \
- $(call OptionOnly,-nonavbar) ; \
- $(call OptionOnly,-noindex) ; \
- $(call OptionPair,-bottom,$(TAGLETAPI_BOTTOM)$(DRAFT_BOTTOM)) ; \
- $(call OptionTrip,-linkoffline,$(TAGLETAPI2COREAPI),$(COREAPI_DOCSDIR)/); \
- ) >> $@
+TARGETS += $(tagletapi)
+
+################################################################################
+
+$(eval $(call SetupJavadocGeneration, domapi, \
+ MODULES := \
+ java.xml \
+ jdk.xml.dom, \
+ PACKAGES := \
+ org.w3c.dom \
+ org.w3c.dom.bootstrap \
+ org.w3c.dom.ls \
+ org.w3c.dom.ranges \
+ org.w3c.dom.traversal \
+ org.w3c.dom.html \
+ org.w3c.dom.stylesheets \
+ org.w3c.dom.css \
+ org.w3c.dom.events \
+ org.w3c.dom.views, \
+ PACKAGE_FILTER := org.w3c.dom*, \
+ API_ROOT := jre, \
+ DEST_DIR := plugin/dom, \
+ TITLE := Common DOM API, \
+ FIRST_COPYRIGHT_YEAR := 2005, \
+ DOCLINT := none, \
+ SPLIT_INDEX := TRUE, \
+ BOTTOM_ADDRESS := $(COMMON_BOTTOM_ADDRESS), \
+ BOTTOM_TEXT := $(COMMON_BOTTOM_TEXT), \
+))
+
+TARGETS += $(domapi)
+
+################################################################################
-# Create a file with the package names in it
-$(TAGLETAPI_PACKAGES_FILE): $(call PackageDependencies,$(TAGLETAPI_PKGS))
- $(prep-target)
- @($(ECHO) "$(LANGTOOLS_TOPDIR)/src/jdk.javadoc/share/classes/$(TAGLETAPI_FILE)" ) > $@
+$(eval $(call SetupJavadocGeneration, jdi, \
+ MODULES := jdk.jdi, \
+ PACKAGES := \
+ com.sun.jdi \
+ com.sun.jdi.event \
+ com.sun.jdi.request \
+ com.sun.jdi.connect \
+ com.sun.jdi.connect.spi, \
+ API_ROOT := jdk, \
+ DEST_DIR := jpda/jdi, \
+ OVERVIEW := $(JDK_TOPDIR)/src/jdk.jdi/share/classes/jdi-overview.html, \
+ TITLE := Java$(TRADEMARK) Debug Interface, \
+ FIRST_COPYRIGHT_YEAR := 1999, \
+ DOCLINT := none, \
+))
-#############################################################
-#
-# domapidocs
-#
+TARGETS += $(jdi)
-ALL_OTHER_TARGETS += domapidocs
+################################################################################
-DOMAPI_DOCDIR := $(JRE_API_DOCSDIR)/plugin/dom
-DOMAPI2COREAPI := ../../$(JDKJRE2COREAPI)
-DOMAPI_DOCTITLE := Common DOM API
-DOMAPI_WINDOWTITLE := Common DOM API
-DOMAPI_HEADER := <strong>Common DOM API</strong>
-DOMAPI_BOTTOM := $(call CommonTrademarkBottom,$(DOMAPI_FIRST_COPYRIGHT_YEAR))
-DOMAPI_GROUPNAME := Packages
-DOMAPI_REGEXP := org.w3c.dom*
-# DOMAPI_PKGS is located in NON_CORE_PKGS.gmk
+$(eval $(call SetupJavadocGeneration, jaas, \
+ MODULES := jdk.security.auth, \
+ PACKAGES := \
+ com.sun.security.auth \
+ com.sun.security.auth.callback \
+ com.sun.security.auth.login \
+ com.sun.security.auth.module, \
+ API_ROOT := jre, \
+ DEST_DIR := security/jaas/spec, \
+ OVERVIEW := $(JDK_TOPDIR)/src/jdk.security.auth/share/classes/jaas-overview.html, \
+ TITLE := Java$(TRADEMARK) Authentication and Authorization Service, \
+ FIRST_COPYRIGHT_YEAR := 1998, \
+ DOCLINT := none, \
+))
+
+TARGETS += $(jaas)
+
+################################################################################
-# The index.html, options, and packages files
-DOMAPI_INDEX_FILE = $(DOMAPI_DOCDIR)/index.html
-DOMAPI_OPTIONS_FILE = $(DOCSTMPDIR)/domapi.options
-DOMAPI_PACKAGES_FILE = $(DOCSTMPDIR)/domapi.packages
+$(eval $(call SetupJavadocGeneration, jgss, \
+ MODULES := jdk.security.jgss, \
+ PACKAGES := com.sun.security.jgss, \
+ API_ROOT := jre, \
+ DEST_DIR := security/jgss/spec, \
+ OVERVIEW := $(JDK_TOPDIR)/src/java.security.jgss/share/classes/jgss-overview.html, \
+ TITLE := Java$(TRADEMARK) GSS-API Utilities, \
+ FIRST_COPYRIGHT_YEAR := 2000, \
+ DOCLINT := none, \
+ NODEPRECATEDLIST := TRUE, \
+))
-# The modules required to be documented
-DOMAPI_MODULES = java.xml,jdk.xml.dom
+TARGETS += $(jgss)
-domapidocs: $(DOMAPI_INDEX_FILE)
+################################################################################
-# Set relative location to core api document root
-$(DOMAPI_INDEX_FILE): GET2DOCSDIR=$(DOMAPI2COREAPI)/..
+$(eval $(call SetupJavadocGeneration, smartcardio, \
+ MODULES := java.smartcardio, \
+ PACKAGES := javax.smartcardio, \
+ API_ROOT := jre, \
+ DEST_DIR := security/smartcardio/spec, \
+ TITLE := Java$(TRADEMARK) Smart Card I/O, \
+ FIRST_COPYRIGHT_YEAR := 2005, \
+ DOCLINT := none, \
+ NODEPRECATEDLIST := TRUE, \
+))
+
+TARGETS += $(smartcardio)
+
+################################################################################
-# Run javadoc if the index file is out of date or missing
-$(DOMAPI_INDEX_FILE): $(DOMAPI_OPTIONS_FILE) $(DOMAPI_PACKAGES_FILE) $(COREAPI_INDEX_FILE)
- $(prep-javadoc)
- $(call JavadocSummary,$(DOMAPI_OPTIONS_FILE),$(DOMAPI_PACKAGES_FILE))
- $(JAVADOC_CMD_SMALL) -d $(@D) \
- @$(DOMAPI_OPTIONS_FILE) @$(DOMAPI_PACKAGES_FILE)
+$(eval $(call SetupJavadocGeneration, httpserver, \
+ MODULES := jdk.httpserver, \
+ PACKAGES := \
+ com.sun.net.httpserver \
+ com.sun.net.httpserver.spi, \
+ API_ROOT := jre, \
+ DEST_DIR := net/httpserver/spec, \
+ TITLE := Java$(TRADEMARK) HTTP Server, \
+ FIRST_COPYRIGHT_YEAR := 2005, \
+ DOCLINT := none, \
+ NODEPRECATEDLIST := TRUE, \
+))
+
+TARGETS += $(httpserver)
-# Create file with javadoc options in it
-$(DOMAPI_OPTIONS_FILE):
- $(prep-target)
- @($(call COMMON_JAVADOCFLAGS) ; \
- $(call COMMON_JAVADOCTAGS) ; \
- $(call OptionOnly,-Xdoclint:none) ; \
- $(call OptionPair,--system,none) ; \
- $(call OptionPair,--module-source-path,$(RELEASEDOCS_MODULESOURCEPATH)) ; \
- $(call OptionPair,--add-modules,$(DOMAPI_MODULES)) ; \
- $(call OptionPair,-encoding,ascii) ; \
- $(call OptionOnly,-splitIndex) ; \
- $(call OptionPair,-doctitle,$(DOMAPI_DOCTITLE)) ; \
- $(call OptionPair,-windowtitle,$(DOMAPI_WINDOWTITLE) $(DRAFT_WINTITLE)); \
- $(call OptionPair,-header,$(DOMAPI_HEADER)$(DRAFT_HEADER)) ; \
- $(call OptionPair,-bottom,$(DOMAPI_BOTTOM)$(DRAFT_BOTTOM)) ; \
- $(call OptionTrip,-group,$(DOMAPI_GROUPNAME),$(DOMAPI_REGEXP)); \
- $(call OptionTrip,-linkoffline,$(DOMAPI2COREAPI),$(COREAPI_DOCSDIR)/); \
- ) >> $@
+################################################################################
+
+$(eval $(call SetupJavadocGeneration, jsobject, \
+ MODULES := jdk.jsobject, \
+ PACKAGES := netscape.javascript, \
+ API_ROOT := jre, \
+ DEST_DIR := plugin/jsobject, \
+ FIRST_COPYRIGHT_YEAR := 1993, \
+ TITLE := Java$(TRADEMARK) JSObject Doc, \
+ DOCLINT := none, \
+ NODEPRECATEDLIST := TRUE, \
+))
+
+TARGETS += $(jsobject)
+
+################################################################################
-# Create a file with the package names in it
-$(DOMAPI_PACKAGES_FILE): $(call PackageDependencies,$(DOMAPI_PKGS))
- $(prep-target)
- $(call PackageFilter,$(DOMAPI_PKGS))
+$(eval $(call SetupJavadocGeneration, mgmt, \
+ MODULES := jdk.management, \
+ PACKAGES := com.sun.management, \
+ API_ROOT := jre, \
+ DEST_DIR := management/extension, \
+ OVERVIEW := $(JDK_TOPDIR)/src/java.management/share/classes/mgmt-overview.html, \
+ TITLE := Monitoring and Management Interface for the Java$(TRADEMARK) Platform, \
+ FIRST_COPYRIGHT_YEAR := 2003, \
+ DOCLINT := none, \
+ NODEPRECATEDLIST := TRUE, \
+))
+
+TARGETS += $(mgmt)
+
+################################################################################
+
+$(eval $(call SetupJavadocGeneration, attach, \
+ MODULES := jdk.attach, \
+ PACKAGES := \
+ com.sun.tools.attach \
+ com.sun.tools.attach.spi, \
+ API_ROOT := jdk, \
+ DEST_DIR := attach/spec, \
+ TITLE := Attach API, \
+ FIRST_COPYRIGHT_YEAR := 2005, \
+ DOCLINT := none, \
+ NODEPRECATEDLIST := TRUE, \
+))
-#############################################################
-#
-# jpdadocs
-#
+TARGETS += $(attach)
+
+################################################################################
-ALL_OTHER_TARGETS += jpdadocs
+$(eval $(call SetupJavadocGeneration, jconsole, \
+ MODULES := jdk.jconsole, \
+ PACKAGES := com.sun.tools.jconsole, \
+ API_ROOT := jdk, \
+ DEST_DIR := jconsole/spec, \
+ TITLE := JConsole API, \
+ FIRST_COPYRIGHT_YEAR := 2006, \
+ DOCLINT := none, \
+ NODEPRECATEDLIST := TRUE, \
+))
+
+TARGETS += $(jconsole)
-jpdadocs: jdidocs jdwpdocs jvmtidocs
+################################################################################
-#############################################################
-#
-# jdidocs
-#
-
-ALL_OTHER_TARGETS += jdidocs
+# NOTE: Need to override RELATIVE_CORE_DIR to be bug compatible with old code.
+$(eval $(call SetupJavadocGeneration, jshellapi, \
+ MODULES := jdk.jshell, \
+ PACKAGES := \
+ jdk.jshell \
+ jdk.jshell.spi \
+ jdk.jshell.execution, \
+ API_ROOT := jdk, \
+ DEST_DIR := jshell, \
+ RELATIVE_CORE_DIR := ../../../.., \
+ OVERVIEW := $(LANGTOOLS_TOPDIR)/src/jdk.jshell/share/classes/jdk/jshell/overview.html, \
+ TITLE := JShell API, \
+ HEADER_TITLE := JSHELL API, \
+ FIRST_COPYRIGHT_YEAR := 2015, \
+))
-JDI_DOCDIR := $(JDK_API_DOCSDIR)/jpda/jdi
-JDI2COREAPI := ../../$(JDKJRE2COREAPI)
-JDI_DOCTITLE := Java$(TRADEMARK) Debug Interface
-JDI_WINDOWTITLE := Java Debug Interface
-JDI_HEADER := <strong>Java Debug Interface</strong>
-JDI_BOTTOM := $(call CommonBottom,$(JDI_FIRST_COPYRIGHT_YEAR))
-JDI_OVERVIEW := $(JDK_TOPDIR)/src/jdk.jdi/share/classes/jdi-overview.html
-# JDI_PKGS is located in NON_CORE_PKGS.gmk
+TARGETS += $(jshellapi)
+
+################################################################################
-# The index.html, options, and packages files
-JDI_INDEX_FILE = $(JDI_DOCDIR)/index.html
-JDI_OPTIONS_FILE = $(DOCSTMPDIR)/jdi.options
-JDI_PACKAGES_FILE = $(DOCSTMPDIR)/jdi.packages
+$(eval $(call SetupJavadocGeneration, treeapi, \
+ MODULES := jdk.compiler, \
+ PACKAGES := \
+ com.sun.source.doctree \
+ com.sun.source.tree \
+ com.sun.source.util, \
+ PACKAGE_FILTER := com.sun.source.*, \
+ API_ROOT := jdk, \
+ DEST_DIR := javac/tree, \
+ TITLE := Compiler Tree API, \
+ FIRST_COPYRIGHT_YEAR := 2005, \
+))
-# The modules required to be documented
-JDI_MODULES = jdk.jdi
+TARGETS += $(treeapi)
-jdidocs: $(JDI_INDEX_FILE)
+################################################################################
-# Set relative location to core api document root
-$(JDI_INDEX_FILE): GET2DOCSDIR=$(JDI2COREAPI)/..
+$(eval $(call SetupJavadocGeneration, nashornapi, \
+ MODULES := jdk.scripting.nashorn, \
+ PACKAGES := \
+ jdk.nashorn.api.scripting \
+ jdk.nashorn.api.tree, \
+ PACKAGE_FILTER := jdk.nashorn.api.*, \
+ API_ROOT := jdk, \
+ DEST_DIR := nashorn, \
+ TITLE := Nashorn API, \
+ FIRST_COPYRIGHT_YEAR := 2014, \
+))
-# Run javadoc if the index file is out of date or missing
-$(JDI_INDEX_FILE): $(JDI_OPTIONS_FILE) $(JDI_PACKAGES_FILE) $(COREAPI_INDEX_FILE)
- $(prep-javadoc)
- $(call JavadocSummary,$(JDI_OPTIONS_FILE),$(JDI_PACKAGES_FILE))
- $(JAVADOC_CMD_SMALL) -d $(@D) \
- @$(JDI_OPTIONS_FILE) @$(JDI_PACKAGES_FILE)
+TARGETS += $(nashornapi)
+
+################################################################################
-# Create file with javadoc options in it
-$(JDI_OPTIONS_FILE): $(JDI_OVERVIEW)
- $(prep-target)
- @($(call COMMON_JAVADOCFLAGS) ; \
- $(call COMMON_JAVADOCTAGS) ; \
- $(call OptionOnly,-Xdoclint:none) ; \
- $(call OptionPair,--system,none) ; \
- $(call OptionPair,--module-source-path,$(RELEASEDOCS_MODULESOURCEPATH)) ; \
- $(call OptionPair,--add-modules,$(JDI_MODULES)) ; \
- $(call OptionPair,-encoding,ascii) ; \
- $(call OptionPair,-overview,$(JDI_OVERVIEW)) ; \
- $(call OptionPair,-doctitle,$(JDI_DOCTITLE)) ; \
- $(call OptionPair,-windowtitle,$(JDI_WINDOWTITLE) $(DRAFT_WINTITLE)); \
- $(call OptionPair,-header,$(JDI_HEADER)$(DRAFT_HEADER)) ; \
- $(call OptionPair,-bottom,$(JDI_BOTTOM)$(DRAFT_BOTTOM)) ; \
- $(call OptionTrip,-linkoffline,$(JDI2COREAPI),$(COREAPI_DOCSDIR)/); \
- ) >> $@
+$(eval $(call SetupJavadocGeneration, dynalinkapi, \
+ MODULES := jdk.dynalink, \
+ PACKAGES := \
+ jdk.dynalink \
+ jdk.dynalink.beans \
+ jdk.dynalink.linker \
+ jdk.dynalink.linker.support \
+ jdk.dynalink.support, \
+ API_ROOT := jdk, \
+ DEST_DIR := dynalink, \
+ TITLE := Dynalink API, \
+ FIRST_COPYRIGHT_YEAR := 2015, \
+))
+
+TARGETS += $(dynalinkapi)
+
+################################################################################
+
+$(eval $(call SetupJavadocGeneration, sctp, \
+ MODULES := jdk.sctp, \
+ PACKAGES := com.sun.nio.sctp, \
+ API_ROOT := jre, \
+ DEST_DIR := nio/sctp/spec, \
+ TITLE := SCTP API, \
+ FIRST_COPYRIGHT_YEAR := 2009, \
+ DOCLINT := none, \
+ NODEPRECATEDLIST := TRUE, \
+))
+
+TARGETS += $(sctp)
+
+################################################################################
+
+$(eval $(call SetupJavadocGeneration, jaccess, \
+ MODULES := jdk.accessibility, \
+ PACKAGES := com.sun.java.accessibility.util, \
+ API_ROOT := jre, \
+ DEST_DIR := accessibility/jaccess/spec, \
+ TITLE := JACCESS API, \
+ FIRST_COPYRIGHT_YEAR := 2002, \
+ NODEPRECATEDLIST := TRUE, \
+))
+
+TARGETS += $(jaccess)
-# Create a file with the package names in it
-$(JDI_PACKAGES_FILE): $(call PackageDependencies,$(JDI_PKGS))
- $(prep-target)
- $(call PackageFilter,$(JDI_PKGS))
+################################################################################
-#############################################################
-#
-# jdwpdocs
-#
+$(eval $(call SetupJavadocGeneration, jdknet, \
+ MODULES := jdk.net, \
+ PACKAGES := jdk.net, \
+ API_ROOT := jre, \
+ DEST_DIR := net/socketoptions/spec, \
+ TITLE := jdk.net API, \
+ FIRST_COPYRIGHT_YEAR := 2014, \
+ DOCLINT := none, \
+ NODEPRECATEDLIST := TRUE, \
+))
-ALL_OTHER_TARGETS += jdwpdocs
+TARGETS += $(jdknet)
+
+################################################################################
-JDWP_DOCDIR = $(PLATFORM_DOCSDIR)/jpda/jdwp
+# TODO: Need to decide when the plugin API is ready to publish as experimental API.
+# This target is temporarily added for internal use for now.
+$(eval $(call SetupJavadocGeneration, jlinkplugins, \
+ MODULES := jdk.jlink, \
+ PACKAGES := jdk.tools.jlink.plugin, \
+ API_ROOT := jdk, \
+ DEST_DIR := jlink, \
+ TITLE := JLink Plugin API - EXPERIMENTAL, \
+ FIRST_COPYRIGHT_YEAR := 2015, \
+ DOCLINT := none, \
+ NODEPRECATEDLIST := TRUE, \
+))
+
+TARGETS += $(jlinkplugins)
-jdwpdocs: $(JDWP_DOCDIR)/jdwp-protocol.html
-$(JDWP_DOCDIR)/jdwp-protocol.html : $(SUPPORT_OUTPUTDIR)/gensrc/jdk.jdi/jdwp-protocol.html
- $(MKDIR) -p $(@D)
- $(RM) $@
- $(CP) $< $@
+################################################################################
+# Copy JDWP html file
+
+JDWP_HTML := $(SUPPORT_OUTPUTDIR)/gensrc/jdk.jdi/jdwp-protocol.html
-#############################################################
-#
-# jvmtidocs
-#
+$(eval $(call SetupCopyFiles, COPY_JDWP_HTML, \
+ FILES := $(JDWP_HTML), \
+ DEST := $(JAVADOC_OUTPUTDIR)/platform/jpda/jdwp, \
+))
-JVMTI_DOCDIR := $(PLATFORM_DOCSDIR)/jvmti
+COPY_TARGETS += $(COPY_JDWP_HTML)
+
+################################################################################
+# Copy JVMTI html file
+
# Pick jvmti.html from any jvm variant, they are all the same.
JVMTI_HTML := $(firstword \
$(wildcard $(HOTSPOT_OUTPUTDIR)/variant-*/gensrc/jvmtifiles/jvmti.html))
$(eval $(call SetupCopyFiles, COPY_JVMTI_HTML, \
FILES := $(JVMTI_HTML), \
- DEST := $(PLATFORM_DOCSDIR)/jvmti, \
+ DEST := $(JAVADOC_OUTPUTDIR)/platform/jvmti, \
))
-jvmtidocs: $(COPY_JVMTI_HTML)
-
-#############################################################
-#
-# jaasdocs
-#
-
-ALL_OTHER_TARGETS += jaasdocs
-
-JAAS_DOCDIR := $(JRE_API_DOCSDIR)/security/jaas/spec
-JAAS2COREAPI := ../../../$(JDKJRE2COREAPI)
-JAAS_DOCTITLE := Java$(TRADEMARK) Authentication and Authorization Service
-JAAS_WINDOWTITLE := Java Authentication and Authorization Service
-JAAS_HEADER := <strong>Java Authentication and Authorization Service</strong>
-JAAS_BOTTOM := $(call CommonBottom,$(JAAS_FIRST_COPYRIGHT_YEAR))
-# JAAS_PKGS is located in NON_CORE_PKGS.gmk
-JAAS_OVERVIEW := $(JDK_TOPDIR)/src/jdk.security.auth/share/classes/jaas-overview.html
-
-# The index.html, options, and packages files
-JAAS_INDEX_FILE = $(JAAS_DOCDIR)/index.html
-JAAS_OPTIONS_FILE = $(DOCSTMPDIR)/jaas.options
-JAAS_PACKAGES_FILE = $(DOCSTMPDIR)/jaas.packages
-
-# The modules required to be documented
-JAAS_MODULES = jdk.security.auth
-
-jaasdocs: $(JAAS_INDEX_FILE)
-
-# Set relative location to core api document root
-$(JAAS_INDEX_FILE): GET2DOCSDIR=$(JAAS2COREAPI)/..
-
-# Run javadoc if the index file is out of date or missing
-$(JAAS_INDEX_FILE): $(JAAS_OPTIONS_FILE) $(JAAS_PACKAGES_FILE) $(COREAPI_INDEX_FILE)
- $(prep-javadoc)
- $(call JavadocSummary,$(JAAS_OPTIONS_FILE),$(JAAS_PACKAGES_FILE))
- $(JAVADOC_CMD_SMALL) -d $(@D) \
- @$(JAAS_OPTIONS_FILE) @$(JAAS_PACKAGES_FILE)
-
-# Create file with javadoc options in it
-$(JAAS_OPTIONS_FILE): $(JAAS_OVERVIEW)
- $(prep-target)
- @($(call COMMON_JAVADOCFLAGS) ; \
- $(call COMMON_JAVADOCTAGS) ; \
- $(call OptionOnly,-Xdoclint:none) ; \
- $(call OptionPair,--system,none) ; \
- $(call OptionPair,--module-source-path,$(RELEASEDOCS_MODULESOURCEPATH)) ; \
- $(call OptionPair,--add-modules,$(JAAS_MODULES)) ; \
- $(call OptionPair,-encoding,ascii) ; \
- $(call OptionPair,-overview,$(JAAS_OVERVIEW)) ; \
- $(call OptionPair,-doctitle,$(JAAS_DOCTITLE)) ; \
- $(call OptionPair,-windowtitle,$(JAAS_WINDOWTITLE) $(DRAFT_WINTITLE)); \
- $(call OptionPair,-header,$(JAAS_HEADER)$(DRAFT_HEADER)) ; \
- $(call OptionPair,-bottom,$(JAAS_BOTTOM)$(DRAFT_BOTTOM)) ; \
- $(call OptionTrip,-linkoffline,$(JAAS2COREAPI),$(COREAPI_DOCSDIR)/); \
- ) >> $@
-
-# Create a file with the package names in it
-$(JAAS_PACKAGES_FILE): $(call PackageDependencies,$(JAAS_PKGS))
- $(prep-target)
- $(call PackageFilter,$(JAAS_PKGS))
-
-#############################################################
-#
-# jgssdocs
-#
-
-ALL_OTHER_TARGETS += jgssdocs
-
-JGSS_DOCDIR := $(JRE_API_DOCSDIR)/security/jgss/spec
-JGSS2COREAPI := ../../../$(JDKJRE2COREAPI)
-JGSS_DOCTITLE := Java$(TRADEMARK) GSS-API Utilities
-JGSS_WINDOWTITLE := Java GSS-API Utilities
-JGSS_HEADER := <strong>Java GSS-API Utilities</strong>
-JGSS_BOTTOM := $(call CommonBottom,$(JGSS_FIRST_COPYRIGHT_YEAR))
-JGSS_OVERVIEW := $(JDK_TOPDIR)/src/java.security.jgss/share/classes/jgss-overview.html
-# JGSS_PKGS is located in NON_CORE_PKGS.gmk
-
-# The index.html, options, and packages files
-JGSS_INDEX_FILE = $(JGSS_DOCDIR)/index.html
-JGSS_OPTIONS_FILE = $(DOCSTMPDIR)/jgss.options
-JGSS_PACKAGES_FILE = $(DOCSTMPDIR)/jgss.packages
-
-# The modules required to be documented
-JGSS_MODULES = jdk.security.jgss
-
-jgssdocs: $(JGSS_INDEX_FILE)
-
-# Set relative location to core api document root
-$(JGSS_INDEX_FILE): GET2DOCSDIR=$(JGSS2COREAPI)/..
-
-# Run javadoc if the index file is out of date or missing
-$(JGSS_INDEX_FILE): $(JGSS_OPTIONS_FILE) $(JGSS_PACKAGES_FILE) $(COREAPI_INDEX_FILE)
- $(prep-javadoc)
- $(call JavadocSummary,$(JGSS_OPTIONS_FILE),$(JGSS_PACKAGES_FILE))
- $(JAVADOC_CMD_SMALL) -d $(@D) \
- @$(JGSS_OPTIONS_FILE) @$(JGSS_PACKAGES_FILE)
-
-# Create file with javadoc options in it
-$(JGSS_OPTIONS_FILE): $(JGSS_OVERVIEW)
- $(prep-target)
- @($(call COMMON_JAVADOCFLAGS) ; \
- $(call COMMON_JAVADOCTAGS) ; \
- $(call OptionOnly,-Xdoclint:none) ; \
- $(call OptionPair,--system,none) ; \
- $(call OptionPair,--module-source-path,$(RELEASEDOCS_MODULESOURCEPATH)) ; \
- $(call OptionPair,--add-modules,$(JGSS_MODULES)) ; \
- $(call OptionPair,-encoding,ascii) ; \
- $(call OptionOnly,-nodeprecatedlist) ; \
- $(call OptionPair,-overview,$(JGSS_OVERVIEW)) ; \
- $(call OptionPair,-doctitle,$(JGSS_DOCTITLE)) ; \
- $(call OptionPair,-windowtitle,$(JGSS_WINDOWTITLE) $(DRAFT_WINTITLE)); \
- $(call OptionPair,-header,$(JGSS_HEADER)$(DRAFT_HEADER)) ; \
- $(call OptionPair,-bottom,$(JGSS_BOTTOM)$(DRAFT_BOTTOM)) ; \
- $(call OptionTrip,-linkoffline,$(JGSS2COREAPI),$(COREAPI_DOCSDIR)/); \
- ) >> $@
-
-# Create a file with the package names in it
-$(JGSS_PACKAGES_FILE): $(call PackageDependencies,$(JGSS_PKGS))
- $(prep-target)
- $(call PackageFilter,$(JGSS_PKGS))
-
-#############################################################
-#
-# smartcardiodocs
-#
-
-ALL_OTHER_TARGETS += smartcardiodocs
-
-SMARTCARDIO_DOCDIR := $(JRE_API_DOCSDIR)/security/smartcardio/spec
-SMARTCARDIO2COREAPI := ../../../$(JDKJRE2COREAPI)
-SMARTCARDIO_DOCTITLE := Java$(TRADEMARK) Smart Card I/O
-SMARTCARDIO_WINDOWTITLE := Java Smart Card I/O
-SMARTCARDIO_HEADER := <strong>Java Smart Card I/O</strong>
-SMARTCARDIO_BOTTOM := $(call CommonBottom,$(SMARTCARDIO_FIRST_COPYRIGHT_YEAR))
-# SMARTCARDIO_PKGS is located in NON_CORE_PKGS.gmk
-
-# The index.html, options, and packages files
-SMARTCARDIO_INDEX_FILE = $(SMARTCARDIO_DOCDIR)/index.html
-SMARTCARDIO_OPTIONS_FILE = $(DOCSTMPDIR)/smartcardio.options
-SMARTCARDIO_PACKAGES_FILE = $(DOCSTMPDIR)/smartcardio.packages
-
-# The modules required to be documented
-SMARTCARDIO_MODULES = java.smartcardio
-
-smartcardiodocs: $(SMARTCARDIO_INDEX_FILE)
-
-# Set relative location to core api document root
-$(SMARTCARDIO_INDEX_FILE): GET2DOCSDIR=$(SMARTCARDIO2COREAPI)/..
-
-# Run javadoc if the index file is out of date or missing
-$(SMARTCARDIO_INDEX_FILE): $(SMARTCARDIO_OPTIONS_FILE) $(SMARTCARDIO_PACKAGES_FILE) $(COREAPI_INDEX_FILE)
- $(prep-javadoc)
- $(call JavadocSummary,$(SMARTCARDIO_OPTIONS_FILE),$(SMARTCARDIO_PACKAGES_FILE))
- $(JAVADOC_CMD_SMALL) -d $(@D) \
- @$(SMARTCARDIO_OPTIONS_FILE) @$(SMARTCARDIO_PACKAGES_FILE)
-
-# Create file with javadoc options in it
-$(SMARTCARDIO_OPTIONS_FILE):
- $(prep-target)
- @($(call COMMON_JAVADOCFLAGS) ; \
- $(call COMMON_JAVADOCTAGS) ; \
- $(call OptionOnly,-Xdoclint:none) ; \
- $(call OptionPair,--system,none) ; \
- $(call OptionPair,--module-source-path,$(RELEASEDOCS_MODULESOURCEPATH)) ; \
- $(call OptionPair,--add-modules,$(SMARTCARDIO_MODULES)) ; \
- $(call OptionPair,-encoding,ascii) ; \
- $(call OptionOnly,-nodeprecatedlist) ; \
- $(call OptionPair,-doctitle,$(SMARTCARDIO_DOCTITLE)) ; \
- $(call OptionPair,-windowtitle,$(SMARTCARDIO_WINDOWTITLE) $(DRAFT_WINTITLE)); \
- $(call OptionPair,-header,$(SMARTCARDIO_HEADER)$(DRAFT_HEADER)); \
- $(call OptionPair,-bottom,$(SMARTCARDIO_BOTTOM)$(DRAFT_BOTTOM)); \
- $(call OptionTrip,-linkoffline,$(SMARTCARDIO2COREAPI),$(COREAPI_DOCSDIR)/); \
- ) >> $@
-
-# Create a file with the package names in it
-$(SMARTCARDIO_PACKAGES_FILE): $(call PackageDependencies,$(SMARTCARDIO_PKGS))
- $(prep-target)
- $(call PackageFilter,$(SMARTCARDIO_PKGS))
-
-#############################################################
-#
-# httpserverdocs
-#
-
-ALL_OTHER_TARGETS += httpserverdocs
-
-HTTPSERVER_DOCDIR := $(JRE_API_DOCSDIR)/net/httpserver/spec
-HTTPSERVER2COREAPI := ../../../$(JDKJRE2COREAPI)
-HTTPSERVER_DOCTITLE := Java$(TRADEMARK) HTTP Server
-HTTPSERVER_WINDOWTITLE := Java HTTP Server
-HTTPSERVER_HEADER := <strong>Java HTTP Server</strong>
-HTTPSERVER_BOTTOM := $(call CommonBottom,$(HTTPSERVER_FIRST_COPYRIGHT_YEAR))
-# HTTPSERVER_PKGS is located in NON_CORE_PKGS.gmk
-
-HTTPSERVER_INDEX_HTML = $(HTTPSERVER_DOCDIR)/index.html
-HTTPSERVER_OPTIONS_FILE = $(DOCSTMPDIR)/httpserver.options
-HTTPSERVER_PACKAGES_FILE = $(DOCSTMPDIR)/httpserver.packages
-
-# The modules required to be documented
-HTTPSERVER_MODULES = jdk.httpserver
-
-httpserverdocs: $(HTTPSERVER_INDEX_HTML)
-
-# Set relative location to core api document root
-$(HTTPSERVER_INDEX_HTML): GET2DOCSDIR=$(HTTPSERVER2COREAPI)/..
-
-# Run javadoc if the index file is out of date or missing
-$(HTTPSERVER_INDEX_HTML): $(HTTPSERVER_OPTIONS_FILE) $(HTTPSERVER_PACKAGES_FILE) $(COREAPI_INDEX_FILE)
- $(prep-javadoc)
- $(call JavadocSummary,$(HTTPSERVER_OPTIONS_FILE),$(HTTPSERVER_PACKAGES_FILE))
- $(JAVADOC_CMD_SMALL) -d $(@D) \
- @$(HTTPSERVER_OPTIONS_FILE) @$(HTTPSERVER_PACKAGES_FILE)
-
-# Create file with javadoc options in it
-$(HTTPSERVER_OPTIONS_FILE):
- $(prep-target)
- @($(call COMMON_JAVADOCFLAGS) ; \
- $(call COMMON_JAVADOCTAGS) ; \
- $(call OptionOnly,-Xdoclint:none) ; \
- $(call OptionPair,--system,none) ; \
- $(call OptionPair,--module-source-path,$(RELEASEDOCS_MODULESOURCEPATH)) ; \
- $(call OptionPair,--add-modules,$(HTTPSERVER_MODULES)) ; \
- $(call OptionPair,-encoding,ascii) ; \
- $(call OptionOnly,-nodeprecatedlist) ; \
- $(call OptionPair,-doctitle,$(HTTPSERVER_DOCTITLE)) ; \
- $(call OptionPair,-windowtitle,$(HTTPSERVER_WINDOWTITLE) $(DRAFT_WINTITLE)); \
- $(call OptionPair,-header,$(HTTPSERVER_HEADER)$(DRAFT_HEADER)); \
- $(call OptionPair,-bottom,$(HTTPSERVER_BOTTOM)$(DRAFT_BOTTOM)); \
- $(call OptionTrip,-linkoffline,$(HTTPSERVER2COREAPI),$(COREAPI_DOCSDIR)/); \
- ) >> $@
-
-# Create a file with the package names in it
-$(HTTPSERVER_PACKAGES_FILE): $(call PackageDependencies,$(HTTPSERVER_PKGS))
- $(prep-target)
- $(call PackageFilter,$(HTTPSERVER_PKGS))
-
-#############################################################
-#
-# jsobjectdocs
-#
-
-ALL_OTHER_TARGETS += jsobjectdocs
-
-JSOBJECT_DOCDIR := $(JRE_API_DOCSDIR)/plugin/jsobject
-JSOBJECT2COREAPI := ../../$(JDKJRE2COREAPI)
-JSOBJECT_DOCTITLE := Java$(TRADEMARK) JSObject Doc
-JSOBJECT_WINDOWTITLE := Java JSObject Doc
-JSOBJECT_HEADER := <strong>Java JSObject Doc</strong>
-JSOBJECT_BOTTOM := $(call CommonBottom,$(JSOBJECT_FIRST_COPYRIGHT_YEAR))
-# JSOBJECT_PKGS is located in NON_CORE_PKGS.gmk
-
-JSOBJECT_INDEX_HTML = $(JSOBJECT_DOCDIR)/index.html
-JSOBJECT_OPTIONS_FILE = $(DOCSTMPDIR)/jsobject.options
-JSOBJECT_PACKAGES_FILE = $(DOCSTMPDIR)/jsobject.packages
-
-# The modules required to be documented
-JSOBJECT_MODULES = jdk.jsobject
-
-jsobjectdocs: $(JSOBJECT_INDEX_HTML)
-
-# Set relative location to core api document root
-$(JSOBJECT_INDEX_HTML): GET2DOCSDIR=$(JSOBJECT2COREAPI)/..
-
-# Run javadoc if the index file is out of date or missing
-$(JSOBJECT_INDEX_HTML): $(JSOBJECT_OPTIONS_FILE) $(JSOBJECT_PACKAGES_FILE) $(COREAPI_INDEX_FILE)
- $(prep-javadoc)
- $(call JavadocSummary,$(JSOBJECT_OPTIONS_FILE),$(JSOBJECT_PACKAGES_FILE))
- $(JAVADOC_CMD_SMALL) -d $(@D) \
- @$(JSOBJECT_OPTIONS_FILE) @$(JSOBJECT_PACKAGES_FILE)
-
-# Create file with javadoc options in it
-$(JSOBJECT_OPTIONS_FILE):
- $(prep-target)
- @($(call COMMON_JAVADOCFLAGS) ; \
- $(call COMMON_JAVADOCTAGS) ; \
- $(call OptionOnly,-Xdoclint:none) ; \
- $(call OptionPair,--system,none) ; \
- $(call OptionPair,--module-source-path,$(RELEASEDOCS_MODULESOURCEPATH)) ; \
- $(call OptionPair,--add-modules,$(JSOBJECT_MODULES)) ; \
- $(call OptionPair,-encoding,ascii) ; \
- $(call OptionOnly,-nodeprecatedlist) ; \
- $(call OptionPair,-doctitle,$(JSOBJECT_DOCTITLE)) ; \
- $(call OptionPair,-windowtitle,$(JSOBJECT_WINDOWTITLE) $(DRAFT_WINTITLE)); \
- $(call OptionPair,-header,$(JSOBJECT_HEADER)$(DRAFT_HEADER)); \
- $(call OptionPair,-bottom,$(JSOBJECT_BOTTOM)$(DRAFT_BOTTOM)); \
- $(call OptionTrip,-linkoffline,$(JSOBJECT2COREAPI),$(COREAPI_DOCSDIR)/); \
- ) >> $@
-
-# Create a file with the package names in it
-$(JSOBJECT_PACKAGES_FILE): $(call PackageDependencies,$(JSOBJECT_PKGS))
- $(prep-target)
- $(call PackageFilter,$(JSOBJECT_PKGS))
-
-
-#############################################################
-#
-# mgmtdocs
-#
-
-ALL_OTHER_TARGETS += mgmtdocs
-
-MGMT_DOCDIR := $(JRE_API_DOCSDIR)/management/extension
-MGMT2COREAPI := ../../$(JDKJRE2COREAPI)
-MGMT_DOCTITLE := Monitoring and Management Interface for the Java$(TRADEMARK) Platform
-MGMT_WINDOWTITLE := Monitoring and Management Interface for the Java Platform
-MGMT_HEADER := <strong>Monitoring and Management Interface for the Java Platform</strong>
-MGMT_BOTTOM := $(call CommonBottom,$(MGMT_FIRST_COPYRIGHT_YEAR))
-MGMT_OVERVIEW := $(JDK_TOPDIR)/src/java.management/share/classes/mgmt-overview.html
-# MGMT_PKGS is located in NON_CORE_PKGS.gmk
-
-# The index.html, options, and packages files
-MGMT_INDEX_FILE = $(MGMT_DOCDIR)/index.html
-MGMT_OPTIONS_FILE = $(DOCSTMPDIR)/mgmt.options
-MGMT_PACKAGES_FILE = $(DOCSTMPDIR)/mgmt.packages
-
-# The modules required to be documented
-MGMT_MODULES = jdk.management
-
-mgmtdocs: $(MGMT_INDEX_FILE)
-
-# Set relative location to core api document root
-$(MGMT_INDEX_FILE): GET2DOCSDIR=$(MGMT2COREAPI)/..
-
-# Run javadoc if the index file is out of date or missing
-$(MGMT_INDEX_FILE): $(MGMT_OPTIONS_FILE) $(MGMT_PACKAGES_FILE) $(COREAPI_INDEX_FILE)
- $(prep-javadoc)
- $(call JavadocSummary,$(MGMT_OPTIONS_FILE),$(MGMT_PACKAGES_FILE))
- $(JAVADOC_CMD_SMALL) -d $(@D) \
- @$(MGMT_OPTIONS_FILE) @$(MGMT_PACKAGES_FILE)
-
-# Create file with javadoc options in it
-$(MGMT_OPTIONS_FILE): $(MGMT_OVERVIEW)
- $(prep-target)
- @($(call COMMON_JAVADOCFLAGS) ; \
- $(call COMMON_JAVADOCTAGS) ; \
- $(call OptionOnly,-Xdoclint:none) ; \
- $(call OptionPair,--system,none) ; \
- $(call OptionPair,--module-source-path,$(RELEASEDOCS_MODULESOURCEPATH)) ; \
- $(call OptionPair,--add-modules,$(MGMT_MODULES)) ; \
- $(call OptionPair,-encoding,ascii) ; \
- $(call OptionOnly,-nodeprecatedlist) ; \
- $(call OptionPair,-overview,$(MGMT_OVERVIEW)) ; \
- $(call OptionPair,-doctitle,$(MGMT_DOCTITLE)) ; \
- $(call OptionPair,-windowtitle,$(MGMT_WINDOWTITLE) $(DRAFT_WINTITLE)); \
- $(call OptionPair,-header,$(MGMT_HEADER)$(DRAFT_HEADER)) ; \
- $(call OptionPair,-bottom,$(MGMT_BOTTOM)$(DRAFT_BOTTOM)) ; \
- $(call OptionTrip,-linkoffline,$(MGMT2COREAPI),$(COREAPI_DOCSDIR)/); \
- ) >> $@
-
-# Create a file with the package names in it
-$(MGMT_PACKAGES_FILE): $(call PackageDependencies,$(MGMT_PKGS))
- $(prep-target)
- $(call PackageFilter,$(MGMT_PKGS))
-
-#############################################################
-#
-# attachdocs
-#
-
-ALL_OTHER_TARGETS += attachdocs
-
-ATTACH_DOCDIR := $(JDK_API_DOCSDIR)/attach/spec
-ATTACH2COREAPI := ../../$(JDKJRE2COREAPI)
-ATTACH_DOCTITLE := Attach API
-ATTACH_WINDOWTITLE := Attach API
-ATTACH_HEADER := <strong>Attach API</strong>
-ATTACH_BOTTOM := $(call CommonBottom,$(ATTACH_FIRST_COPYRIGHT_YEAR))
-# ATTACH_PKGS is located in NON_CORE_PKGS.gmk
-
-ATTACH_INDEX_HTML = $(ATTACH_DOCDIR)/index.html
-ATTACH_OPTIONS_FILE = $(DOCSTMPDIR)/attach.options
-ATTACH_PACKAGES_FILE = $(DOCSTMPDIR)/attach.packages
-
-# The modules required to be documented
-ATTACH_MODULES = jdk.attach
-
-attachdocs: $(ATTACH_INDEX_HTML)
-
-# Set relative location to core api document root
-$(ATTACH_INDEX_HTML): GET2DOCSDIR=$(ATTACH2COREAPI)/..
-
-# Run javadoc if the index file is out of date or missing
-$(ATTACH_INDEX_HTML): $(ATTACH_OPTIONS_FILE) $(ATTACH_PACKAGES_FILE) $(COREAPI_INDEX_FILE)
- $(prep-javadoc)
- $(call JavadocSummary,$(ATTACH_OPTIONS_FILE),$(ATTACH_PACKAGES_FILE))
- $(JAVADOC_CMD_SMALL) -d $(@D) \
- @$(ATTACH_OPTIONS_FILE) @$(ATTACH_PACKAGES_FILE)
-
-# Create file with javadoc options in it
-$(ATTACH_OPTIONS_FILE):
- $(prep-target)
- @($(call COMMON_JAVADOCFLAGS) ; \
- $(call COMMON_JAVADOCTAGS) ; \
- $(call OptionOnly,-Xdoclint:none) ; \
- $(call OptionPair,--system,none) ; \
- $(call OptionPair,--module-source-path,$(RELEASEDOCS_MODULESOURCEPATH)) ; \
- $(call OptionPair,--add-modules,$(ATTACH_MODULES)) ; \
- $(call OptionPair,-encoding,ascii) ; \
- $(call OptionOnly,-nodeprecatedlist) ; \
- $(call OptionPair,-doctitle,$(ATTACH_DOCTITLE)) ; \
- $(call OptionPair,-windowtitle,$(ATTACH_WINDOWTITLE) $(DRAFT_WINTITLE)); \
- $(call OptionPair,-header,$(ATTACH_HEADER)$(DRAFT_HEADER)) ; \
- $(call OptionPair,-bottom,$(ATTACH_BOTTOM)$(DRAFT_BOTTOM)) ; \
- $(call OptionTrip,-linkoffline,$(ATTACH2COREAPI),$(COREAPI_DOCSDIR)/); \
- ) >> $@
-
-# Create a file with the package names in it
-$(ATTACH_PACKAGES_FILE): $(call PackageDependencies,$(ATTACH_PKGS))
- $(prep-target)
- $(call PackageFilter,$(ATTACH_PKGS))
-
-#############################################################
-#
-# jconsoledocs
-#
-
-ALL_OTHER_TARGETS += jconsoledocs
-
-JCONSOLE_DOCDIR := $(JDK_API_DOCSDIR)/jconsole/spec
-JCONSOLE2COREAPI := ../../$(JDKJRE2COREAPI)
-JCONSOLE_DOCTITLE := JConsole API
-JCONSOLE_WINDOWTITLE := JConsole API
-JCONSOLE_HEADER := <strong>JConsole API</strong>
-JCONSOLE_BOTTOM := $(call CommonBottom,$(JCONSOLE_FIRST_COPYRIGHT_YEAR))
-# JCONSOLE_PKGS is located in NON_CORE_PKGS.gmk
-
-JCONSOLE_INDEX_HTML = $(JCONSOLE_DOCDIR)/index.html
-JCONSOLE_OPTIONS_FILE = $(DOCSTMPDIR)/jconsole.options
-JCONSOLE_PACKAGES_FILE = $(DOCSTMPDIR)/jconsole.packages
-
-# The modules required to be documented
-JCONSOLE_MODULES = jdk.jconsole
-
-jconsoledocs: $(JCONSOLE_INDEX_HTML)
-
-# Set relative location to core api document root
-$(JCONSOLE_INDEX_HTML): GET2DOCSDIR=$(JCONSOLE2COREAPI)/..
-
-# Run javadoc if the index file is out of date or missing
-$(JCONSOLE_INDEX_HTML): $(JCONSOLE_OPTIONS_FILE) $(JCONSOLE_PACKAGES_FILE) $(COREAPI_INDEX_FILE)
- $(prep-javadoc)
- $(call JavadocSummary,$(JCONSOLE_OPTIONS_FILE),$(JCONSOLE_PACKAGES_FILE))
- $(JAVADOC_CMD_SMALL) -d $(@D) \
- @$(JCONSOLE_OPTIONS_FILE) @$(JCONSOLE_PACKAGES_FILE)
-
-# Create file with javadoc options in it
-$(JCONSOLE_OPTIONS_FILE):
- $(prep-target)
- @($(call COMMON_JAVADOCFLAGS) ; \
- $(call COMMON_JAVADOCTAGS) ; \
- $(call OptionOnly,-Xdoclint:none) ; \
- $(call OptionPair,--system,none) ; \
- $(call OptionPair,--module-source-path,$(RELEASEDOCS_MODULESOURCEPATH)) ; \
- $(call OptionPair,--add-modules,$(JCONSOLE_MODULES)) ; \
- $(call OptionPair,-encoding,ascii) ; \
- $(call OptionOnly,-nodeprecatedlist) ; \
- $(call OptionPair,-doctitle,$(JCONSOLE_DOCTITLE)) ; \
- $(call OptionPair,-windowtitle,$(JCONSOLE_WINDOWTITLE) $(DRAFT_WINTITLE)); \
- $(call OptionPair,-header,$(JCONSOLE_HEADER)$(DRAFT_HEADER)) ; \
- $(call OptionPair,-bottom,$(JCONSOLE_BOTTOM)$(DRAFT_BOTTOM)) ; \
- $(call OptionTrip,-linkoffline,$(JCONSOLE2COREAPI),$(COREAPI_DOCSDIR)/); \
- ) >> $@
-
-# Create a file with the package names in it
-$(JCONSOLE_PACKAGES_FILE): $(call PackageDependencies,$(JCONSOLE_PKGS))
- $(prep-target)
- $(call PackageFilter,$(JCONSOLE_PKGS))
+COPY_TARGETS += $(COPY_JVMTI_HTML)
-#############################################################
-#
-# jshellapidocs
-#
-
-ALL_OTHER_TARGETS += jshellapidocs
-
-JSHELLAPI_DOCDIR := $(JDK_API_DOCSDIR)/jshell
-JSHELLAPI2COREAPI := ../../$(JDKJRE2COREAPI)
-JSHELLAPI_DOCTITLE := JShell API
-JSHELLAPI_WINDOWTITLE := JShell API
-JSHELLAPI_HEADER := <strong>JSHELL API</strong>
-JSHELLAPI_BOTTOM := $(call CommonBottom,$(JSHELLAPI_FIRST_COPYRIGHT_YEAR))
-JSHELLAPI_OVERVIEW := $(LANGTOOLS_TOPDIR)/src/jdk.jshell/share/classes/jdk/jshell/overview.html
-# JSHELLAPI_PKGS is located in NON_CORE_PKGS.gmk
-
-JSHELLAPI_INDEX_HTML = $(JSHELLAPI_DOCDIR)/index.html
-JSHELLAPI_OPTIONS_FILE = $(DOCSTMPDIR)/jshellapi.options
-JSHELLAPI_PACKAGES_FILE = $(DOCSTMPDIR)/jshellapi.packages
-
-# The modules required to be documented
-JSHELLAPI_MODULES = jdk.jshell
-
-jshellapidocs: $(JSHELLAPI_INDEX_HTML)
-
-# Set relative location to core api document root
-$(JSHELLAPI_INDEX_HTML): GET2DOCSDIR=$(JSHELLAPI2COREAPI)/..
-
-# Run javadoc if the index file is out of date or missing
-$(JSHELLAPI_INDEX_HTML): $(JSHELLAPI_OPTIONS_FILE) $(JSHELLAPI_PACKAGES_FILE) $(COREAPI_INDEX_FILE)
- $(prep-javadoc)
- $(call JavadocSummary,$(JSHELLAPI_OPTIONS_FILE),$(JSHELLAPI_PACKAGES_FILE))
- $(JAVADOC_CMD_SMALL) -d $(@D) \
- @$(JSHELLAPI_OPTIONS_FILE) @$(JSHELLAPI_PACKAGES_FILE)
-
-# Create file with javadoc options in it
-$(JSHELLAPI_OPTIONS_FILE):
- $(prep-target)
- @($(call COMMON_JAVADOCFLAGS) ; \
- $(call COMMON_JAVADOCTAGS) ; \
- $(call OptionOnly,-Xdoclint:all) ; \
- $(call OptionPair,--system,none) ; \
- $(call OptionPair,--module-source-path,$(RELEASEDOCS_MODULESOURCEPATH)) ; \
- $(call OptionPair,--add-modules,$(JSHELLAPI_MODULES)) ; \
- $(call OptionPair,-encoding,ascii) ; \
- $(call OptionPair,-overview,$(JSHELLAPI_OVERVIEW)) ; \
- $(call OptionPair,-doctitle,$(JSHELLAPI_DOCTITLE)) ; \
- $(call OptionPair,-windowtitle,$(JSHELLAPI_WINDOWTITLE) $(DRAFT_WINTITLE)); \
- $(call OptionPair,-header,$(JSHELLAPI_HEADER)$(DRAFT_HEADER)) ; \
- $(call OptionPair,-bottom,$(JSHELLAPI_BOTTOM)$(DRAFT_BOTTOM)) ; \
- $(call OptionTrip,-linkoffline,$(JSHELLAPI2COREAPI),$(COREAPI_DOCSDIR)/); \
- ) >> $@
-
-# Create a file with the package names in it
-$(JSHELLAPI_PACKAGES_FILE): $(call PackageDependencies,$(JSHELLAPI_PKGS))
- $(prep-target)
- $(call PackageFilter,$(JSHELLAPI_PKGS))
-
-#############################################################
-#
-# treeapidocs
-#
-
-ALL_OTHER_TARGETS += treeapidocs
-
-TREEAPI_DOCDIR := $(JDK_API_DOCSDIR)/javac/tree
-TREEAPI2COREAPI := ../../$(JDKJRE2COREAPI)
-TREEAPI_DOCTITLE := Compiler Tree API
-TREEAPI_WINDOWTITLE := Compiler Tree API
-TREEAPI_HEADER := <strong>Compiler Tree API</strong>
-TREEAPI_BOTTOM := $(call CommonBottom,$(TREEAPI_FIRST_COPYRIGHT_YEAR))
-TREEAPI_GROUPNAME := Packages
-TREEAPI_REGEXP := com.sun.source.*
-# TREEAPI_PKGS is located in NON_CORE_PKGS.gmk
-
-TREEAPI_INDEX_HTML = $(TREEAPI_DOCDIR)/index.html
-TREEAPI_OPTIONS_FILE = $(DOCSTMPDIR)/treeapi.options
-TREEAPI_PACKAGES_FILE = $(DOCSTMPDIR)/treeapi.packages
-
-# The modules required to be documented
-TREEAPI_MODULES = jdk.compiler
-
-treeapidocs: $(TREEAPI_INDEX_HTML)
-
-# Set relative location to core api document root
-$(TREEAPI_INDEX_HTML): GET2DOCSDIR=$(TREEAPI2COREAPI)/..
-
-# Run javadoc if the index file is out of date or missing
-$(TREEAPI_INDEX_HTML): $(TREEAPI_OPTIONS_FILE) $(TREEAPI_PACKAGES_FILE) $(COREAPI_INDEX_FILE)
- $(prep-javadoc)
- $(call JavadocSummary,$(TREEAPI_OPTIONS_FILE),$(TREEAPI_PACKAGES_FILE))
- $(JAVADOC_CMD_SMALL) -d $(@D) \
- @$(TREEAPI_OPTIONS_FILE) @$(TREEAPI_PACKAGES_FILE)
-
-# Create file with javadoc options in it
-$(TREEAPI_OPTIONS_FILE):
- $(prep-target)
- @($(call COMMON_JAVADOCFLAGS) ; \
- $(call COMMON_JAVADOCTAGS) ; \
- $(call OptionOnly,-Xdoclint:all) ; \
- $(call OptionPair,--system,none) ; \
- $(call OptionPair,--module-source-path,$(RELEASEDOCS_MODULESOURCEPATH)) ; \
- $(call OptionPair,--add-modules,$(TREEAPI_MODULES)) ; \
- $(call OptionPair,-encoding,ascii) ; \
- $(call OptionPair,-doctitle,$(TREEAPI_DOCTITLE)) ; \
- $(call OptionPair,-windowtitle,$(TREEAPI_WINDOWTITLE) $(DRAFT_WINTITLE)); \
- $(call OptionPair,-header,$(TREEAPI_HEADER)$(DRAFT_HEADER)) ; \
- $(call OptionPair,-bottom,$(TREEAPI_BOTTOM)$(DRAFT_BOTTOM)) ; \
- $(call OptionTrip,-group,$(TREEAPI_GROUPNAME),$(TREEAPI_REGEXP)); \
- $(call OptionTrip,-linkoffline,$(TREEAPI2COREAPI),$(COREAPI_DOCSDIR)/); \
- ) >> $@
-
-# Create a file with the package names in it
-$(TREEAPI_PACKAGES_FILE): $(call PackageDependencies,$(TREEAPI_PKGS))
- $(prep-target)
- $(call PackageFilter,$(TREEAPI_PKGS))
-
-#############################################################
-#
-# nashornapidocs
-#
-
-ALL_OTHER_TARGETS += nashornapidocs
-
-NASHORNAPI_DOCDIR := $(JDK_API_DOCSDIR)/nashorn
-NASHORNAPI2COREAPI := ../$(JDKJRE2COREAPI)
-NASHORNAPI_DOCTITLE := Nashorn API
-NASHORNAPI_WINDOWTITLE := Nashorn API
-NASHORNAPI_HEADER := <strong>Nashorn API</strong>
-NASHORNAPI_BOTTOM := $(call CommonBottom,$(NASHORNAPI_FIRST_COPYRIGHT_YEAR))
-NASHORNAPI_GROUPNAME := Packages
-NASHORNAPI_REGEXP := jdk.nashorn.api.*
-# NASHORNAPI_PKGS is located in NON_CORE_PKGS.gmk
-
-NASHORNAPI_INDEX_HTML = $(NASHORNAPI_DOCDIR)/index.html
-NASHORNAPI_OPTIONS_FILE = $(DOCSTMPDIR)/nashornapi.options
-NASHORNAPI_PACKAGES_FILE = $(DOCSTMPDIR)/nashornapi.packages
-
-# The modules required to be documented
-NASHORNAPI_MODULES = jdk.scripting.nashorn
-
-nashornapidocs: $(NASHORNAPI_INDEX_HTML)
-
-# Set relative location to core api document root
-$(NASHORNAPI_INDEX_HTML): GET2DOCSDIR=$(NASHORNAPI2COREAPI)/..
-
-# Run javadoc if the index file is out of date or missing
-$(NASHORNAPI_INDEX_HTML): $(NASHORNAPI_OPTIONS_FILE) $(NASHORNAPI_PACKAGES_FILE) $(COREAPI_INDEX_FILE)
- $(prep-javadoc)
- $(call JavadocSummary,$(NASHORNAPI_OPTIONS_FILE),$(NASHORNAPI_PACKAGES_FILE))
- $(JAVADOC_CMD_SMALL) -d $(@D) \
- @$(NASHORNAPI_OPTIONS_FILE) @$(NASHORNAPI_PACKAGES_FILE)
-
-# Create file with javadoc options in it
-$(NASHORNAPI_OPTIONS_FILE):
- $(prep-target)
- @($(call COMMON_JAVADOCFLAGS) ; \
- $(call COMMON_JAVADOCTAGS) ; \
- $(call OptionOnly,-Xdoclint:all) ; \
- $(call OptionPair,--system,none) ; \
- $(call OptionPair,--module-source-path,$(RELEASEDOCS_MODULESOURCEPATH)) ; \
- $(call OptionPair,--add-modules,$(NASHORNAPI_MODULES)) ; \
- $(call OptionPair,-encoding,ascii) ; \
- $(call OptionPair,-doctitle,$(NASHORNAPI_DOCTITLE)) ; \
- $(call OptionPair,-windowtitle,$(NASHORNAPI_WINDOWTITLE) $(DRAFT_WINTITLE)); \
- $(call OptionPair,-header,$(NASHORNAPI_HEADER)$(DRAFT_HEADER)) ; \
- $(call OptionPair,-bottom,$(NASHORNAPI_BOTTOM)$(DRAFT_BOTTOM)) ; \
- $(call OptionTrip,-group,$(NASHORNAPI_GROUPNAME),$(NASHORNAPI_REGEXP)); \
- $(call OptionTrip,-linkoffline,$(NASHORNAPI2COREAPI),$(COREAPI_DOCSDIR)/); \
- ) >> $@
-
-# Create a file with the package names in it
-$(NASHORNAPI_PACKAGES_FILE): $(call PackageDependencies,$(NASHORNAPI_PKGS))
- $(prep-target)
- $(call PackageFilter,$(NASHORNAPI_PKGS))
-
-#############################################################
-#
-# dynalinkapidocs
-#
-
-ALL_OTHER_TARGETS += dynalinkapidocs
-
-DYNALINKAPI_DOCDIR := $(JDK_API_DOCSDIR)/dynalink
-DYNALINKAPI2COREAPI := ../$(JDKJRE2COREAPI)
-DYNALINKAPI_DOCTITLE := Dynalink API
-DYNALINKAPI_WINDOWTITLE := Dynalink API
-DYNALINKAPI_HEADER := <strong>Dynalink API</strong>
-DYNALINKAPI_BOTTOM := $(call CommonBottom,$(DYNALINKAPI_FIRST_COPYRIGHT_YEAR))
-DYNALINKAPI_GROUPNAME := Packages
-DYNALINKAPI_REGEXP := jdk.dynalink.*
-# DYNALINKAPI_PKGS is located in NON_CORE_PKGS.gmk
-
-DYNALINKAPI_INDEX_HTML = $(DYNALINKAPI_DOCDIR)/index.html
-DYNALINKAPI_OPTIONS_FILE = $(DOCSTMPDIR)/dynalinkapi.options
-DYNALINKAPI_PACKAGES_FILE = $(DOCSTMPDIR)/dynalinkapi.packages
-
-# The modules required to be documented
-DYNALINKAPI_MODULES = jdk.dynalink
-
-dynalinkapidocs: $(DYNALINKAPI_INDEX_HTML)
-
-# Set relative location to core api document root
-$(DYNALINKAPI_INDEX_HTML): GET2DOCSDIR=$(DYNALINKAPI2COREAPI)/..
-
-# Run javadoc if the index file is out of date or missing
-$(DYNALINKAPI_INDEX_HTML): $(DYNALINKAPI_OPTIONS_FILE) $(DYNALINKAPI_PACKAGES_FILE) $(COREAPI_INDEX_FILE)
- $(prep-javadoc)
- $(call JavadocSummary,$(DYNALINKAPI_OPTIONS_FILE),$(DYNALINKAPI_PACKAGES_FILE))
- $(JAVADOC_CMD_SMALL) -d $(@D) \
- @$(DYNALINKAPI_OPTIONS_FILE) @$(DYNALINKAPI_PACKAGES_FILE)
-
-# Create file with javadoc options in it
-$(DYNALINKAPI_OPTIONS_FILE):
- $(prep-target)
- @($(call COMMON_JAVADOCFLAGS) ; \
- $(call COMMON_JAVADOCTAGS) ; \
- $(call OptionOnly,-Xdoclint:all) ; \
- $(call OptionPair,--system,none) ; \
- $(call OptionPair,--module-source-path,$(RELEASEDOCS_MODULESOURCEPATH)) ; \
- $(call OptionPair,--add-modules,$(DYNALINKAPI_MODULES)) ; \
- $(call OptionPair,-encoding,ascii) ; \
- $(call OptionPair,-doctitle,$(DYNALINKAPI_DOCTITLE)) ; \
- $(call OptionPair,-windowtitle,$(DYNALINKAPI_WINDOWTITLE) $(DRAFT_WINTITLE)); \
- $(call OptionPair,-header,$(DYNALINKAPI_HEADER)$(DRAFT_HEADER)) ; \
- $(call OptionPair,-bottom,$(DYNALINKAPI_BOTTOM)$(DRAFT_BOTTOM)) ; \
- $(call OptionTrip,-linkoffline,$(DYNALINKAPI2COREAPI),$(COREAPI_DOCSDIR)/); \
- ) >> $@
-
-# Create a file with the package names in it
-$(DYNALINKAPI_PACKAGES_FILE): $(call PackageDependencies,$(DYNALINKAPI_PKGS))
- $(prep-target)
- $(call PackageFilter,$(DYNALINKAPI_PKGS))
+################################################################################
+# Optional target which bundles all generated javadocs into a zip archive.
+# The dependency on docs is handled in Main.gmk.
-#############################################################
-#
-# sctpdocs
-#
-
-ALL_OTHER_TARGETS += sctpdocs
-
-SCTPAPI_DOCDIR := $(JRE_API_DOCSDIR)/nio/sctp/spec
-SCTPAPI2COREAPI := ../../../$(JDKJRE2COREAPI)
-SCTPAPI_DOCTITLE := SCTP API
-SCTPAPI_WINDOWTITLE := SCTP API
-SCTPAPI_HEADER := <strong>SCTP API</strong>
-SCTPAPI_BOTTOM := $(call CommonBottom,$(SCTPAPI_FIRST_COPYRIGHT_YEAR))
-# SCTPAPI_PKGS is located in NON_CORE_PKGS.gmk
-
-SCTPAPI_INDEX_HTML = $(SCTPAPI_DOCDIR)/index.html
-SCTPAPI_OPTIONS_FILE = $(DOCSTMPDIR)/sctp.options
-SCTPAPI_PACKAGES_FILE = $(DOCSTMPDIR)/sctp.packages
-
-# The modules required to be documented
-SCTPAPI_MODULES = jdk.sctp
-
-sctpdocs: $(SCTPAPI_INDEX_HTML)
-
-# Set relative location to core api document root
-$(SCTPAPI_INDEX_HTML): GET2DOCSDIR=$(SCTPAPI2COREAPI)/..
-
-# Run javadoc if the index file is out of date or missing
-$(SCTPAPI_INDEX_HTML): $(SCTPAPI_OPTIONS_FILE) $(SCTPAPI_PACKAGES_FILE) $(COREAPI_INDEX_FILE)
- $(prep-javadoc)
- $(call JavadocSummary,$(SCTPAPI_OPTIONS_FILE),$(SCTPAPI_PACKAGES_FILE))
- $(JAVADOC_CMD_SMALL) -d $(@D) \
- @$(SCTPAPI_OPTIONS_FILE) @$(SCTPAPI_PACKAGES_FILE)
-
-# Create file with javadoc options in it
-$(SCTPAPI_OPTIONS_FILE):
- $(prep-target)
- @($(call COMMON_JAVADOCFLAGS) ; \
- $(call COMMON_JAVADOCTAGS) ; \
- $(call OptionOnly,-Xdoclint:none) ; \
- $(call OptionPair,--system,none) ; \
- $(call OptionPair,--module-source-path,$(RELEASEDOCS_MODULESOURCEPATH)) ; \
- $(call OptionPair,--add-modules,$(SCTPAPI_MODULES)) ; \
- $(call OptionPair,-encoding,ascii) ; \
- $(call OptionOnly,-nodeprecatedlist) ; \
- $(call OptionPair,-doctitle,$(SCTPAPI_DOCTITLE)) ; \
- $(call OptionPair,-windowtitle,$(SCTPAPI_WINDOWTITLE) $(DRAFT_WINTITLE)); \
- $(call OptionPair,-header,$(SCTPAPI_HEADER)$(DRAFT_HEADER)) ; \
- $(call OptionPair,-bottom,$(SCTPAPI_BOTTOM)$(DRAFT_BOTTOM)) ; \
- $(call OptionTrip,-linkoffline,$(SCTPAPI2COREAPI),$(COREAPI_DOCSDIR)/); \
- ) >> $@
-
-# Create a file with the package names in it
-$(SCTPAPI_PACKAGES_FILE): $(call PackageDependencies,$(SCTPAPI_PKGS))
- $(prep-target)
- $(call PackageFilter,$(SCTPAPI_PKGS))
-
-#############################################################
-#
-# jaccessdocs - Java Accessibility Utilities
-#
-
-ALL_OTHER_TARGETS += jaccessdocs
-
-JACCESSAPI_DOCDIR := $(JRE_API_DOCSDIR)/accessibility/jaccess/spec
-JACCESSAPI2COREAPI := ../../../$(JDKJRE2COREAPI)
-JACCESSAPI_DOCTITLE := JACCESS API
-JACCESSAPI_WINDOWTITLE := JACCESS API
-JACCESSAPI_HEADER := <strong>JACCESS API</strong>
-JACCESSAPI_BOTTOM := $(call CommonBottom,$(JACCESSAPI_FIRST_COPYRIGHT_YEAR))
-# JACCESSAPI_PKGS is located in NON_CORE_PKGS.gmk
-
-JACCESSAPI_INDEX_HTML = $(JACCESSAPI_DOCDIR)/index.html
-JACCESSAPI_OPTIONS_FILE = $(DOCSTMPDIR)/jaccess.options
-JACCESSAPI_PACKAGES_FILE = $(DOCSTMPDIR)/jaccess.packages
-
-# The modules required to be documented
-JACCESSAPI_MODULES = jdk.accessibility
-
-jaccessdocs: $(JACCESSAPI_INDEX_HTML)
-
-# Set relative location to core api document root
-$(JACCESSAPI_INDEX_HTML): GET2DOCSDIR=$(JACCESSAPI2COREAPI)/..
-
-# Run javadoc if the index file is out of date or missing
-$(JACCESSAPI_INDEX_HTML): $(JACCESSAPI_OPTIONS_FILE) $(JACCESSAPI_PACKAGES_FILE) $(COREAPI_INDEX_FILE)
- $(prep-javadoc)
- $(call JavadocSummary,$(JACCESSAPI_OPTIONS_FILE),$(JACCESSAPI_PACKAGES_FILE))
- $(JAVADOC_CMD_SMALL) -d $(@D) \
- @$(JACCESSAPI_OPTIONS_FILE) @$(JACCESSAPI_PACKAGES_FILE)
-
-# Create file with javadoc options in it
-$(JACCESSAPI_OPTIONS_FILE):
- $(prep-target)
- @($(call COMMON_JAVADOCFLAGS) ; \
- $(call COMMON_JAVADOCTAGS) ; \
- $(call OptionOnly,-Xdoclint:all) ; \
- $(call OptionPair,--system,none) ; \
- $(call OptionPair,--module-source-path,$(RELEASEDOCS_MODULESOURCEPATH)) ; \
- $(call OptionPair,--add-modules,$(JACCESSAPI_MODULES)) ; \
- $(call OptionPair,-encoding,ascii) ; \
- $(call OptionOnly,-nodeprecatedlist) ; \
- $(call OptionPair,-doctitle,$(JACCESSAPI_DOCTITLE)) ; \
- $(call OptionPair,-windowtitle,$(JACCESSAPI_WINDOWTITLE) $(DRAFT_WINTITLE)); \
- $(call OptionPair,-header,$(JACCESSAPI_HEADER)$(DRAFT_HEADER)) ; \
- $(call OptionPair,-bottom,$(JACCESSAPI_BOTTOM)$(DRAFT_BOTTOM)) ; \
- $(call OptionTrip,-linkoffline,$(JACCESSAPI2COREAPI),$(COREAPI_DOCSDIR)/); \
- ) >> $@
-
-# Create a file with the package names in it
-$(JACCESSAPI_PACKAGES_FILE): $(call PackageDependencies,$(JACCESSAPI_PKGS))
- $(prep-target)
- $(call PackageFilter,$(JACCESSAPI_PKGS))
-
-#############################################################
-#
-# jdk.net docs
-#
-
-ALL_OTHER_TARGETS += jdknetdocs
-
-JDKNET_DOCDIR := $(JRE_API_DOCSDIR)/net/socketoptions/spec
-JDKNET2COREAPI := ../../../$(JDKJRE2COREAPI)
-JDKNET_DOCTITLE := jdk.net API
-JDKNET_WINDOWTITLE := jdk.net API
-JDKNET_HEADER := <strong>jdk.net API</strong>
-JDKNET_BOTTOM := $(call CommonBottom,$(JDKNET_FIRST_COPYRIGHT_YEAR))
-JDKNET_PKGS := jdk.net
-
-JDKNET_INDEX_HTML = $(JDKNET_DOCDIR)/index.html
-JDKNET_OPTIONS_FILE = $(DOCSTMPDIR)/jdknet.options
-JDKNET_PACKAGES_FILE = $(DOCSTMPDIR)/jdknet.packages
-
-# The modules required to be documented
-JDKNET_MODULES = jdk.net
-
-jdknetdocs: $(JDKNET_INDEX_HTML)
-
-# Set relative location to core api document root
-$(JDKNET_INDEX_HTML): GET2DOCSDIR=$(JDKNET2COREAPI)/..
-
-# Run javadoc if the index file is out of date or missing
-$(JDKNET_INDEX_HTML): $(JDKNET_OPTIONS_FILE) $(JDKNET_PACKAGES_FILE) $(COREAPI_INDEX_FILE)
- $(prep-javadoc)
- $(call JavadocSummary,$(JDKNET_OPTIONS_FILE),$(JDKNET_PACKAGES_FILE))
- $(JAVADOC_CMD_SMALL) -d $(@D) \
- @$(JDKNET_OPTIONS_FILE) @$(JDKNET_PACKAGES_FILE)
-
-# Create file with javadoc options in it
-$(JDKNET_OPTIONS_FILE):
- $(prep-target)
- @($(call COMMON_JAVADOCFLAGS) ; \
- $(call COMMON_JAVADOCTAGS) ; \
- $(call OptionOnly,-Xdoclint:none) ; \
- $(call OptionPair,--system,none) ; \
- $(call OptionPair,--module-source-path,$(RELEASEDOCS_MODULESOURCEPATH)) ; \
- $(call OptionPair,--add-modules,$(JDKNET_MODULES)) ; \
- $(call OptionPair,-encoding,ascii) ; \
- $(call OptionOnly,-nodeprecatedlist) ; \
- $(call OptionPair,-doctitle,$(JDKNET_DOCTITLE)) ; \
- $(call OptionPair,-windowtitle,$(JDKNET_WINDOWTITLE) $(DRAFT_WINTITLE)); \
- $(call OptionPair,-header,$(JDKNET_HEADER)$(DRAFT_HEADER)); \
- $(call OptionPair,-bottom,$(JDKNET_BOTTOM)$(DRAFT_BOTTOM)); \
- $(call OptionTrip,-linkoffline,$(JDKNET2COREAPI),$(COREAPI_DOCSDIR)/); \
- ) >> $@
-
-# Create a file with the package names in it
-$(JDKNET_PACKAGES_FILE): $(call PackageDependencies,$(JDKNET_PKGS))
- $(prep-target)
- $(call PackageFilter,$(JDKNET_PKGS))
-
-#############################################################
-#
-# jlink plugin API docs
-#
-# TODO: Need to decide when the plugin API is ready to publish as experimental API.
-# This target is temporarily added for internal use for now.
-#
-
-ALL_OTHER_TARGETS += jlinkdocs
-
-JLINK_PLUGIN_FIRST_COPYRIGHT_YEAR = 2015
-JLINK_PLUGIN_DOCDIR := $(JDK_API_DOCSDIR)/jlink
-JLINK_PLUGIN2COREAPI := ../$(JDKJRE2COREAPI)
-JLINK_PLUGIN_DOCTITLE := JLink Plugin API - EXPERIMENTAL
-JLINK_PLUGIN_WINDOWTITLE := JLink Plugin API - EXPERIMENTAL
-JLINK_PLUGIN_HEADER := <strong>JLink Plugin API - EXPERIMENTAL</strong>
-JLINK_PLUGIN_BOTTOM := $(call CommonBottom,$(JLINK_PLUGIN_FIRST_COPYRIGHT_YEAR))
-JLINK_PLUGIN_PKGS = jdk.tools.jlink.plugin
-
-JLINK_PLUGIN_INDEX_HTML = $(JLINK_PLUGIN_DOCDIR)/index.html
-JLINK_PLUGIN_OPTIONS_FILE = $(DOCSTMPDIR)/jlinkplugins.options
-JLINK_PLUGIN_PACKAGES_FILE = $(DOCSTMPDIR)/jlinkplugins.packages
-
-# The modules required to be documented
-JLINK_PLUGIN_MODULES = jdk.jlink
-
-jlinkdocs: $(JLINK_PLUGIN_INDEX_HTML)
-
-# Set relative location to core api document root
-$(JLINK_PLUGIN_INDEX_HTML): GET2DOCSDIR=$(JLINK_PLUGIN2COREAPI)/..
-
-# Run javadoc if the index file is out of date or missing
-$(JLINK_PLUGIN_INDEX_HTML): $(JLINK_PLUGIN_OPTIONS_FILE) $(JLINK_PLUGIN_PACKAGES_FILE) $(COREAPI_INDEX_FILE)
- $(prep-javadoc)
- $(call JavadocSummary,$(JLINK_PLUGIN_OPTIONS_FILE),$(JLINK_PLUGIN_PACKAGES_FILE))
- $(JAVADOC_CMD_SMALL) -d $(@D) \
- @$(JLINK_PLUGIN_OPTIONS_FILE) @$(JLINK_PLUGIN_PACKAGES_FILE)
-
-# Create file with javadoc options in it
-$(JLINK_PLUGIN_OPTIONS_FILE):
- $(prep-target)
- @($(call COMMON_JAVADOCFLAGS) ; \
- $(call COMMON_JAVADOCTAGS) ; \
- $(call OptionOnly,-Xdoclint:none) ; \
- $(call OptionPair,--system,none) ; \
- $(call OptionPair,--module-source-path,$(RELEASEDOCS_MODULESOURCEPATH)) ; \
- $(call OptionPair,--add-modules,$(JLINK_PLUGIN_MODULES)) ; \
- $(call OptionPair,-encoding,ascii) ; \
- $(call OptionOnly,-nodeprecatedlist) ; \
- $(call OptionPair,-doctitle,$(JLINK_PLUGIN_DOCTITLE)) ; \
- $(call OptionPair,-windowtitle,$(JLINK_PLUGIN_WINDOWTITLE) $(DRAFT_WINTITLE)); \
- $(call OptionPair,-header,$(JLINK_PLUGIN_HEADER)$(DRAFT_HEADER)); \
- $(call OptionPair,-bottom,$(JLINK_PLUGIN_BOTTOM)$(DRAFT_BOTTOM)); \
- $(call OptionTrip,-linkoffline,$(JLINK_PLUGIN2COREAPI),$(COREAPI_DOCSDIR)/); \
- ) >> $@
-
-# Create a file with the package names in it
-$(JLINK_PLUGIN_PACKAGES_FILE): $(call PackageDependencies,$(JLINK_PLUGIN_PKGS))
- $(prep-target)
- $(call PackageFilter,$(JLINK_PLUGIN_PKGS))
-
-
-otherdocs: $(ALL_OTHER_TARGETS)
-
-#
# Add the core docs as prerequisite to the archive to trigger a rebuild
# if the core docs were rebuilt. Ideally any doc rebuild should trigger
# this, but the way prerequisites are currently setup in this file, that
# is hard to achieve.
-#
-$(JAVADOC_ARCHIVE): $(COREAPI_INDEX_FILE)
+JAVADOC_ARCHIVE_NAME := jdk-$(VERSION_STRING)-docs.zip
+JAVADOC_ARCHIVE_ASSEMBLY_DIR := $(SUPPORT_OUTPUTDIR)/docs/zip-docs
+JAVADOC_ARCHIVE_DIR := $(OUTPUT_ROOT)/bundles
+JAVADOC_ARCHIVE := $(JAVADOC_ARCHIVE_DIR)/$(JAVADOC_ARCHIVE_NAME)
+
+$(JAVADOC_ARCHIVE): $(CORE_INDEX_FILE)
$(call LogInfo, Compressing javadoc to single $(JAVADOC_ARCHIVE_NAME))
$(MKDIR) -p $(JAVADOC_ARCHIVE_DIR)
$(RM) -r $(JAVADOC_ARCHIVE_ASSEMBLY_DIR)
$(MKDIR) -p $(JAVADOC_ARCHIVE_ASSEMBLY_DIR)
- all_roots=`$(FIND) $(DOCSDIR) | $(GREP) index.html | grep -v old/doclet`; \
+ all_roots=`$(FIND) $(JAVADOC_OUTPUTDIR) | $(GREP) index.html | grep -v old/doclet`; \
pushd $(JAVADOC_ARCHIVE_ASSEMBLY_DIR); \
for index_file in $${all_roots} ; do \
target_dir=`dirname $${index_file}`; \
@@ -1742,10 +1041,21 @@
$(ZIP) -q -r $(JAVADOC_ARCHIVE) * ; \
popd ;
-#############################################################
-.PHONY: all docs coredocs otherdocs \
- $(ALL_OTHER_TARGETS) zip-docs
+ZIP_TARGETS += $(JAVADOC_ARCHIVE)
+
+################################################################################
+
+# Hook to include the corresponding custom file, if present.
+$(eval $(call IncludeCustomExtension, , Javadoc.gmk))
################################################################################
-$(eval $(call IncludeCustomExtension, , Javadoc-post.gmk))
+docs-javadoc: $(TARGETS)
+
+docs-copy: $(COPY_TARGETS)
+
+docs-zip: $(ZIP_TARGETS)
+
+all: docs-javadoc docs-copy docs-zip
+
+.PHONY: default all docs-javadoc docs-copy docs-zip
--- a/make/Main.gmk Wed Nov 09 15:20:30 2016 +0300
+++ b/make/Main.gmk Wed Nov 09 10:04:43 2016 -0800
@@ -341,15 +341,15 @@
# Docs targets
docs-javadoc:
- +($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Javadoc.gmk docs)
+ +($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Javadoc.gmk docs-javadoc)
-docs-jvmtidoc:
- +($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Javadoc.gmk jvmtidocs)
+docs-copy:
+ +($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Javadoc.gmk docs-copy)
-zip-docs:
- +($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Javadoc.gmk zip-docs)
+docs-zip:
+ +($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Javadoc.gmk docs-zip)
-ALL_TARGETS += docs-javadoc docs-jvmtidoc zip-docs
+ALL_TARGETS += docs-javadoc docs-copy docs-zip
################################################################################
# Cross compilation support
@@ -376,15 +376,29 @@
# The interim-image is a small jlinked image that is used to generate artifacts
# at build time for use when linking the real images.
+INTERIM_JMOD_TARGETS := $(addsuffix -interim-jmod, $(INTERIM_IMAGE_MODULES))
+
+define DeclareInterimJmodRecipe
+ $1-interim-jmod:
+ +($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f CreateJmods.gmk \
+ MODULE=$1 \
+ JMODS_DIR=$(INTERIM_JMODS_DIR) \
+ JMODS_TEMPDIR=$(INTERIM_JMODS_DIR)/temp \
+ INTERIM_JMOD=true \
+ )
+endef
+
+$(foreach m, $(INTERIM_IMAGE_MODULES), $(eval $(call DeclareInterimJmodRecipe,$m)))
+
interim-image:
+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f InterimImage.gmk)
ifeq ($(ENABLE_GENERATE_CLASSLIST), true)
- generate-classlist:
- +($(CD) $(JDK_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f GenerateClasslist.gmk)
+ generate-link-opt-data:
+ +($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f GenerateLinkOptData.gmk)
endif
-ALL_TARGETS += interim-image generate-classlist
+ALL_TARGETS += $(INTERIM_JMOD_TARGETS) interim-image generate-link-opt-data
################################################################################
# Build tests
@@ -607,13 +621,15 @@
# When creating a BUILDJDK, the java compilation has already been done by the
# normal build and copied in.
ifneq ($(CREATING_BUILDJDK), true)
- $(foreach m, $(JAVA_MODULES), $(eval $m-jmod: $m-java))
+ $(foreach m, $(JAVA_MODULES), $(eval $m_JMOD_DEPS += $m-java))
endif
- $(foreach m, $(GENDATA_MODULES), $(eval $m-jmod: $m-gendata))
- $(foreach m, $(RMIC_MODULES), $(eval $m-jmod: $m-rmic))
- $(foreach m, $(LIBS_MODULES), $(eval $m-jmod: $m-libs))
- $(foreach m, $(LAUNCHER_MODULES), $(eval $m-jmod: $m-launchers))
- $(foreach m, $(COPY_MODULES), $(eval $m-jmod: $m-copy))
+ $(foreach m, $(GENDATA_MODULES), $(eval $m_JMOD_DEPS += $m-gendata))
+ $(foreach m, $(RMIC_MODULES), $(eval $m_JMOD_DEPS += $m-rmic))
+ $(foreach m, $(LIBS_MODULES), $(eval $m_JMOD_DEPS += $m-libs))
+ $(foreach m, $(LAUNCHER_MODULES), $(eval $m_JMOD_DEPS += $m-launchers))
+ $(foreach m, $(COPY_MODULES), $(eval $m_JMOD_DEPS += $m-copy))
+ $(foreach m, $(ALL_MODULES), $(eval $m-jmod: $($(m)_JMOD_DEPS)))
+ $(foreach m, $(INTERIM_IMAGE_MODULES), $(eval $m-interim-jmod: $($(m)_JMOD_DEPS)))
# Jmods cannot be created until we have the jmod tool ready to run. During
# a normal build we run it from the exploded image, but when cross compiling
@@ -636,12 +652,13 @@
buildtools-modules: create-buildjdk
else
# While actually creating the buildjdk, the default deps applies.
- $(JMOD_TARGETS): $(DEFAULT_JMOD_DEPS)
+ $(JMOD_TARGETS) $(INTERIM_JMOD_TARGETS): $(DEFAULT_JMOD_DEPS)
endif
else
# The normal non cross compilation case uses the default deps.
# To avoid races with the optimize target, that also needs to happen first.
- $(JMOD_TARGETS): $(DEFAULT_JMOD_DEPS) exploded-image-optimize
+ $(JMOD_TARGETS) $(INTERIM_JMOD_TARGETS): $(DEFAULT_JMOD_DEPS) \
+ exploded-image-optimize
endif
zip-security: java.base-java java.security.jgss-java java.security.jgss-libs \
@@ -654,16 +671,17 @@
ifeq ($(ENABLE_GENERATE_CLASSLIST), true)
ifeq ($(CREATE_BUILDJDK), true)
# If creating a buildjdk, the interim image needs to be based on that.
- generate-classlist: create-buildjdk
+ generate-link-opt-data: create-buildjdk
else ifeq ($(EXTERNAL_BUILDJDK), false)
# If an external buildjdk has been provided, we skip generating an
# interim-image and just use the external buildjdk for generating
# classlist.
- generate-classlist: interim-image
+ generate-link-opt-data: interim-image
endif
- generate-classlist: buildtools-jdk
+ generate-link-opt-data: buildtools-jdk
- jdk-image jre-image: generate-classlist
+ # The generated classlist needs to go into java.base-jmod.
+ java.base-jmod jdk-image jre-image: generate-link-opt-data
endif
jdk-image: jmods zip-source source-tips demos samples jrtfs-jar
@@ -683,9 +701,10 @@
docs-javadoc: $(GENSRC_TARGETS) rmic
- docs-jvmtidoc: hotspot
+ # The gensrc step for jdk.jdi creates an html file that is used by docs-copy.
+ docs-copy: hotspot jdk.jdi-gensrc
- zip-docs: docs-javadoc docs-jvmtidoc
+ docs-zip: docs-javadoc docs-copy
test: jdk-image test-image
@@ -694,7 +713,7 @@
create-buildjdk-interim-image: create-buildjdk-copy
- interim-image: $(addsuffix -jmod, $(INTERIM_IMAGE_MODULES))
+ interim-image: $(INTERIM_JMOD_TARGETS)
test-make: clean-test-make
@@ -812,7 +831,7 @@
endif
# This target builds the documentation image
-docs-image: docs-javadoc docs-jvmtidoc
+docs-image: docs-javadoc docs-copy
# This target builds the test image
test-image: prepare-test-image test-image-hotspot-jtreg-native \
@@ -860,7 +879,7 @@
CLEAN_SUPPORT_DIR_TARGETS := $(addprefix clean-, $(CLEAN_SUPPORT_DIRS))
CLEAN_TESTS += hotspot-jtreg-native jdk-jtreg-native lib
CLEAN_TEST_TARGETS += $(addprefix clean-test-, $(CLEAN_TESTS))
-CLEAN_PHASES := gensrc java native include docs
+CLEAN_PHASES := gensrc java native include
CLEAN_PHASE_TARGETS := $(addprefix clean-, $(CLEAN_PHASES))
CLEAN_MODULE_TARGETS := $(addprefix clean-, $(ALL_MODULES))
# Construct targets of the form clean-$module-$phase
@@ -872,6 +891,9 @@
($(CD) $(OUTPUT_ROOT) && $(RM) -r build*.log*)
$(ECHO) Cleaned all build artifacts.
+clean-docs:
+ $(call CleanDocs)
+
$(CLEAN_DIR_TARGETS):
$(call CleanDir,$(patsubst clean-%, %, $@))
@@ -911,7 +933,7 @@
)
$(ECHO) Cleaned everything, you will have to re-run configure.
-ALL_TARGETS += clean dist-clean $(CLEAN_DIR_TARGETS) $(CLEAN_SUPPORT_DIR_TARGETS) \
+ALL_TARGETS += clean clean-docs dist-clean $(CLEAN_DIR_TARGETS) $(CLEAN_SUPPORT_DIR_TARGETS) \
$(CLEAN_TEST_TARGETS) $(CLEAN_PHASE_TARGETS) $(CLEAN_MODULE_TARGETS) \
$(CLEAN_MODULE_PHASE_TARGETS)
--- a/make/MainSupport.gmk Wed Nov 09 15:20:30 2016 +0300
+++ b/make/MainSupport.gmk Wed Nov 09 10:04:43 2016 -0800
@@ -41,6 +41,15 @@
JOBS=$(JOBS) $1) || true
endef
+define CleanDocs
+ @$(PRINTF) "Cleaning docs ..."
+ @$(PRINTF) "\n" $(LOG_DEBUG)
+ $(RM) -r $(SUPPORT_OUTPUTDIR)/docs
+ $(RM) -r $(SUPPORT_OUTPUTDIR)/javadoc
+ $(RM) -r $(IMAGES_OUTPUTDIR)/docs
+ @$(PRINTF) " done\n"
+endef
+
# Cleans the dir given as $1
define CleanDir
@$(PRINTF) "Cleaning $(strip $1) build artifacts ..."
@@ -99,15 +108,6 @@
@$(PRINTF) " done\n"
endef
-define Clean-docs
- @$(PRINTF) "Cleaning docs ..."
- @$(PRINTF) "\n" $(LOG_DEBUG)
- $(RM) -r $(SUPPORT_OUTPUTDIR)/docs
- $(RM) -r $(IMAGES_OUTPUTDIR)/docs
- $(RM) $(OUTPUT_ROOT)/bundles/jdk-*-docs.zip
- @$(PRINTF) " done\n"
-endef
-
define CleanModule
$(call Clean-gensrc, $1)
$(call Clean-java, $1)
--- a/make/ZipSource.gmk Wed Nov 09 15:20:30 2016 +0300
+++ b/make/ZipSource.gmk Wed Nov 09 10:04:43 2016 -0800
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -28,61 +28,68 @@
include $(SPEC)
include MakeBase.gmk
include JavaCompilation.gmk
+include Modules.gmk
+
+SRC_ZIP_WORK_DIR := $(SUPPORT_OUTPUTDIR)/src
# Hook to include the corresponding custom file, if present.
$(eval $(call IncludeCustomExtension, , ZipSource.gmk))
################################################################################
+# Create the directory structure for src.zip using symlinks.
+# <module>/<package>/<file>.java
-# Use ?= to enable override in custom makefile
-SRC_ZIP_INCLUDES ?= \
- com \
- java \
- javax \
- jdk \
- org \
- sun \
- #
+# Find extra source dirs for a module that are not part of normal compilation
+# but should be included in src.zip.
+# $1: Module to find dirs for
+ExtraSrcDirs = \
+ $(wildcard $(SUPPORT_OUTPUTDIR)/rmic/$(strip $1))
-SRC_ZIP_EXCLUDES ?=
+ALL_MODULES := $(FindAllModules)
-SRC_ZIP_SRCS += $(wildcard \
- $(JDK_TOPDIR)/src/*/share/classes \
- $(JDK_TOPDIR)/src/*/$(OPENJDK_TARGET_OS)/classes \
- $(JDK_TOPDIR)/src/*/$(OPENJDK_TARGET_OS_API_DIR)/classes \
- $(LANGTOOLS_TOPDIR)/src/*/share/classes \
- $(CORBA_TOPDIR)/src/*/share/classes \
- $(JAXP_TOPDIR)/src/*/share/classes \
- $(JAXWS_TOPDIR)/src/*/share/classes \
- $(SUPPORT_OUTPUTDIR)/gensrc/j* \
- $(SUPPORT_OUTPUTDIR)/rmic/j* \
+# Generate the src dirs in the first make invocation and then call this makefile
+# again to create src.zip.
+$(foreach m, $(ALL_MODULES), \
+ $(foreach d, $(call FindModuleSrcDirs, $m) $(call ExtraSrcDirs, $m), \
+ $(eval $d_TARGET := $(SRC_ZIP_WORK_DIR)/$(patsubst $(TOPDIR)/%,%,$d)/$m) \
+ $(if $(SRC_GENERATED), , \
+ $(eval $$($d_TARGET): $d ; \
+ $$(if $(filter $(TOPDIR)/%, $d), $$(link-file-relative), $$(link-file-absolute)) \
+ ) \
) \
- #
+ $(eval SRC_ZIP_SRCS += $$($d_TARGET)) \
+ $(eval SRC_ZIP_SRCS_$m += $$($d_TARGET)) \
+ ) \
+)
+
+TARGETS += $(SRC_ZIP_SRCS)
-# Need to copy launcher src files into desired directory structure
-# before zipping the sources.
-$(eval $(call SetupCopyFiles,COPY_LAUNCHER_SRC, \
- SRC := $(JDK_TOPDIR)/src/java.base, \
- DEST := $(SUPPORT_OUTPUTDIR)/src/launcher, \
- FLATTEN := true, \
- FILES := $(wildcard \
- $(JDK_TOPDIR)/src/java.base/share/native/launcher/* \
- $(JDK_TOPDIR)/src/java.base/share/native/libjli/* \
- $(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_API_DIR)/native/libjli/java_md*)))
+################################################################################
+# Only evaluate the creation of src.zip in a sub make call when the symlinked
+# src directory structure has been generated.
+ifeq ($(SRC_GENERATED), true)
+ $(eval $(call SetupZipArchive, BUILD_SRC_ZIP, \
+ SRC := $(dir $(SRC_ZIP_SRCS)), \
+ INCLUDES := $(SRC_ZIP_INCLUDES), \
+ INCLUDE_FILES := $(SRC_ZIP_INCLUDE_FILES), \
+ EXCLUDES := $(SRC_ZIP_EXCLUDES), \
+ EXCLUDE_FILES := $(SRC_ZIP_EXCLUDE_FILES), \
+ SUFFIXES := .java, \
+ ZIP := $(SUPPORT_OUTPUTDIR)/src.zip, \
+ ))
-# This dir needs to exist before macro is evaluated to avoid warning from find.
-$(call MakeDir, $(SUPPORT_OUTPUTDIR)/src)
-$(eval $(call SetupZipArchive,BUILD_SRC_ZIP, \
- SRC := $(SRC_ZIP_SRCS) $(SUPPORT_OUTPUTDIR)/src, \
- INCLUDES := $(SRC_ZIP_INCLUDES) launcher, \
- EXCLUDES := $(SRC_ZIP_EXCLUDES), \
- EXCLUDE_FILES := $(SRC_ZIP_EXCLUDE_FILES), \
- SUFFIXES := .java .c .h, \
- ZIP := $(SUPPORT_OUTPUTDIR)/src.zip, \
- EXTRA_DEPS := $(COPY_LAUNCHER_SRC)))
+ do-zip: $(BUILD_SRC_ZIP)
+
+ .PHONY: do-zip
+endif
+
+zip: $(SRC_ZIP_SRCS)
+ +$(MAKE) $(MAKE_ARGS) -f ZipSource.gmk do-zip SRC_GENERATED=true
+
+TARGETS += zip
################################################################################
-all: $(BUILD_SRC_ZIP)
+all: $(TARGETS)
-.PHONY: default all
+.PHONY: default all zip
--- a/make/common/MakeBase.gmk Wed Nov 09 15:20:30 2016 +0300
+++ b/make/common/MakeBase.gmk Wed Nov 09 10:04:43 2016 -0800
@@ -454,7 +454,7 @@
Too many named arguments to macro, please update MAX_PARAMS in MakeBase.gmk))
# Iterate over 2 3 4... and evaluate the named parameters with $1_ as prefix
$(foreach i,$(PARAM_SEQUENCE), $(if $(strip $($i)),\
- $(strip $1)_$(strip $($i)))$(NEWLINE))
+ $(strip $1)_$(strip $(call DoubleDollar, $($i))))$(NEWLINE))
# Debug print all named parameter names and values
$(if $(findstring $(LOG_LEVEL),debug trace), \
$(info $0 $(strip $1) $(foreach i,$(PARAM_SEQUENCE), \
@@ -575,25 +575,21 @@
$($(strip $1)_dotdots)/$($(strip $1)_suffix)
################################################################################
-# link-file-* works similarly to install file but creates a symlink instead on
-# platforms that support it. There are two versions, either creating a relative
-# or an absolute link.
-ifeq ($(OPENJDK_BUILD_OS), windows)
- link-file-absolute = $(install-file)
- link-file-relative = $(install-file)
-else
- define link-file-relative
+# link-file-* works similarly to install-file but creates a symlink instead.
+# There are two versions, either creating a relative or an absolute link. Be
+# careful when using this on Windows since the symlink created is only valid in
+# the unix emulation environment.
+define link-file-relative
$(call MakeDir, $(@D))
$(RM) $@
$(LN) -s $(call RelativePath, $<, $(@D)) $@
- endef
+endef
- define link-file-absolute
+define link-file-absolute
$(call MakeDir, $(@D))
$(RM) $@
$(LN) -s $< $@
- endef
-endif
+endef
################################################################################
# Filter out duplicate sub strings while preserving order. Keeps the first occurance.
--- a/make/common/Modules.gmk Wed Nov 09 15:20:30 2016 +0300
+++ b/make/common/Modules.gmk Wed Nov 09 10:04:43 2016 -0800
@@ -108,6 +108,7 @@
jdk.charsets \
jdk.crypto.ec \
jdk.crypto.pkcs11 \
+ jdk.desktop \
jdk.dynalink \
jdk.jsobject \
jdk.localedata \
@@ -177,6 +178,16 @@
$(patsubst %,%/$(strip $1)/$(sub)/module-info.java, $(TOP_SRC_DIRS))) \
$(patsubst %,%/$(strip $1)/module-info.java, $(IMPORT_MODULES_SRC)))
+# Find module-info.java files in the specific source dir
+# Param 1 - Src dir to find module-info.java files in
+FindModuleInfosForSrcDir = \
+ $(wildcard \
+ $(foreach sub, $(SRC_SUBDIRS), \
+ $(patsubst %,%/*/$(sub)/module-info.java, $(strip $1)) \
+ ) \
+ $(patsubst %,%/*/module-info.java, $(strip $1)) \
+ )
+
# Extract the module names from the paths of module-info.java files. The
# position of the module directory differs depending on if this is an imported
# src dir or not.
@@ -192,6 +203,13 @@
$(sort $(filter-out $(MODULES_FILTER), \
$(call GetModuleNameFromModuleInfo, $(MODULE_INFOS))))
+# Find all modules in a specific src dir
+# Param 1 - Src dir to find modules in
+FindModulesForSrcDir = \
+ $(sort $(filter-out $(MODULES_FILTER), \
+ $(call GetModuleNameFromModuleInfo, $(call FindModuleInfosForSrcDir, $1)) \
+ ))
+
FindImportedModules = \
$(filter-out $(MODULES_FILTER), \
$(if $(IMPORT_MODULES_CLASSES), $(notdir $(wildcard $(IMPORT_MODULES_CLASSES)/*))))
--- a/make/common/NativeCompilation.gmk Wed Nov 09 15:20:30 2016 +0300
+++ b/make/common/NativeCompilation.gmk Wed Nov 09 10:04:43 2016 -0800
@@ -746,9 +746,10 @@
# This is a rough heuristic and may not always print accurate information.
$$($1_BUILD_INFO): $$($1_SRCS) $$($1_COMPILE_VARDEPS_FILE)
ifeq ($$(wildcard $$($1_TARGET)),)
- $(ECHO) 'Creating $$($1_BASENAME) from $$(words $$(filter-out %.vardeps, $$?)) file(s)'
+ $(ECHO) 'Creating $$(subst $$(BUILD_OUTPUT)/,,$$($1_TARGET)) from $$(words \
+ $$(filter-out %.vardeps, $$?)) file(s)'
else
- $(ECHO) $$(strip 'Updating $$($1_BASENAME)' \
+ $(ECHO) $$(strip 'Updating $$(subst $$(BUILD_OUTPUT)/,,$$($1_TARGET))' \
$$(if $$(filter-out %.vardeps, $$?), \
'due to $$(words $$(filter-out %.vardeps, $$?)) file(s)', \
$$(if $$(filter %.vardeps, $$?), 'due to makefile changes')))
--- a/make/common/ZipArchive.gmk Wed Nov 09 15:20:30 2016 +0300
+++ b/make/common/ZipArchive.gmk Wed Nov 09 10:04:43 2016 -0800
@@ -73,6 +73,11 @@
else
$1_ZIP_INCLUDES := $$(addprefix -i$(SPACE)$(DQUOTE),$$(addsuffix /*$(DQUOTE),$$($1_INCLUDES)))
endif
+ else
+ ifneq ($$($1_SUFFIXES),)
+ $1_ZIP_INCLUDES := $$(foreach s,$$($1_SUFFIXES), \
+ $$(addprefix -i$(SPACE)$(DQUOTE),*$$s$(DQUOTE)))
+ endif
endif
ifneq ($$($1_INCLUDE_FILES),)
$1_ZIP_INCLUDES += $$(addprefix -i$(SPACE),$$($1_INCLUDE_FILES))
--- a/nashorn/.hgtags Wed Nov 09 15:20:30 2016 +0300
+++ b/nashorn/.hgtags Wed Nov 09 10:04:43 2016 -0800
@@ -375,3 +375,5 @@
e3b11296395b39bfeb3364f26c2ef77fa652e300 jdk-9+139
785843878cf78d50cc2959ea2c5a4202bbe885b4 jdk-9+140
a46b7d3867957a868a6cc8ee66c05079b883733a jdk-9+141
+d3f5d7311a1aec3152b17d75046d5d298245a0b4 jdk-9+142
+b4e57ead3fae4939b70dd345d1f6744a1dedfa21 jdk-9+143
--- a/nashorn/samples/dynalink/ArrayStreamLinkerExporter.java Wed Nov 09 15:20:30 2016 +0300
+++ b/nashorn/samples/dynalink/ArrayStreamLinkerExporter.java Wed Nov 09 10:04:43 2016 -0800
@@ -38,9 +38,10 @@
import java.util.stream.LongStream;
import java.util.stream.Stream;
import jdk.dynalink.CallSiteDescriptor;
-import jdk.dynalink.CompositeOperation;
import jdk.dynalink.NamedOperation;
+import jdk.dynalink.NamespaceOperation;
import jdk.dynalink.Operation;
+import jdk.dynalink.StandardNamespace;
import jdk.dynalink.StandardOperation;
import jdk.dynalink.linker.GuardedInvocation;
import jdk.dynalink.linker.GuardingDynamicLinker;
@@ -104,9 +105,9 @@
final CallSiteDescriptor desc = request.getCallSiteDescriptor();
final Operation op = desc.getOperation();
final Object name = NamedOperation.getName(op);
- final boolean getProp = CompositeOperation.contains(
+ final boolean getProp = NamespaceOperation.contains(
NamedOperation.getBaseOperation(op),
- StandardOperation.GET_PROPERTY);
+ StandardOperation.GET, StandardNamespace.PROPERTY);
if (getProp && "stream".equals(name)) {
return new GuardedInvocation(ARRAY_TO_STREAM,
Guards.isOfClass(self.getClass(), GUARD_TYPE));
--- a/nashorn/samples/dynalink/BufferIndexingLinkerExporter.java Wed Nov 09 15:20:30 2016 +0300
+++ b/nashorn/samples/dynalink/BufferIndexingLinkerExporter.java Wed Nov 09 10:04:43 2016 -0800
@@ -29,6 +29,11 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import static jdk.dynalink.StandardNamespace.ELEMENT;
+import static jdk.dynalink.StandardNamespace.PROPERTY;
+import static jdk.dynalink.StandardOperation.GET;
+import static jdk.dynalink.StandardOperation.SET;
+
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodType;
import java.nio.Buffer;
@@ -42,10 +47,10 @@
import java.util.ArrayList;
import java.util.List;
import jdk.dynalink.CallSiteDescriptor;
-import jdk.dynalink.CompositeOperation;
import jdk.dynalink.NamedOperation;
+import jdk.dynalink.NamespaceOperation;
import jdk.dynalink.Operation;
-import jdk.dynalink.StandardOperation;
+import jdk.dynalink.StandardNamespace;
import jdk.dynalink.linker.GuardedInvocation;
import jdk.dynalink.linker.GuardingDynamicLinker;
import jdk.dynalink.linker.GuardingDynamicLinkerExporter;
@@ -135,23 +140,6 @@
IS_DOUBLEBUFFER = Guards.isInstance(DoubleBuffer.class, GUARD_TYPE);
}
- // locate the first standard operation from the call descriptor
- private static StandardOperation getFirstStandardOperation(final CallSiteDescriptor desc) {
- final Operation base = NamedOperation.getBaseOperation(desc.getOperation());
- if (base instanceof StandardOperation) {
- return (StandardOperation)base;
- } else if (base instanceof CompositeOperation) {
- final CompositeOperation cop = (CompositeOperation)base;
- for(int i = 0; i < cop.getOperationCount(); ++i) {
- final Operation op = cop.getOperation(i);
- if (op instanceof StandardOperation) {
- return (StandardOperation)op;
- }
- }
- }
- return null;
- }
-
@Override
public List<GuardingDynamicLinker> get() {
final ArrayList<GuardingDynamicLinker> linkers = new ArrayList<>();
@@ -170,22 +158,25 @@
}
final CallSiteDescriptor desc = request.getCallSiteDescriptor();
- final StandardOperation op = getFirstStandardOperation(desc);
- if (op == null) {
+ final Operation namedOp = desc.getOperation();
+ final Operation namespaceOp = NamedOperation.getBaseOperation(namedOp);
+ final Operation op = NamespaceOperation.getBaseOperation(namespaceOp);
+ final StandardNamespace ns = StandardNamespace.findFirst(namespaceOp);
+ if (ns == null) {
return null;
}
- switch (op) {
- case GET_ELEMENT:
+ if (op == GET) {
+ if (ns == ELEMENT) {
return linkGetElement(self);
- case SET_ELEMENT:
- return linkSetElement(self);
- case GET_PROPERTY: {
+ } else if (ns == PROPERTY) {
final Object name = NamedOperation.getName(desc.getOperation());
if ("length".equals(name)) {
return linkLength();
}
}
+ } else if (op == SET && ns == ELEMENT) {
+ return linkSetElement(self);
}
return null;
--- a/nashorn/samples/dynalink/DOMLinkerExporter.java Wed Nov 09 15:20:30 2016 +0300
+++ b/nashorn/samples/dynalink/DOMLinkerExporter.java Wed Nov 09 10:04:43 2016 -0800
@@ -35,9 +35,10 @@
import java.util.ArrayList;
import java.util.List;
import jdk.dynalink.CallSiteDescriptor;
-import jdk.dynalink.CompositeOperation;
import jdk.dynalink.NamedOperation;
+import jdk.dynalink.NamespaceOperation;
import jdk.dynalink.Operation;
+import jdk.dynalink.StandardNamespace;
import jdk.dynalink.StandardOperation;
import jdk.dynalink.linker.GuardedInvocation;
import jdk.dynalink.linker.GuardingDynamicLinker;
@@ -132,9 +133,9 @@
final CallSiteDescriptor desc = request.getCallSiteDescriptor();
final Operation op = desc.getOperation();
final Object name = NamedOperation.getName(op);
- final boolean getProp = CompositeOperation.contains(
+ final boolean getProp = NamespaceOperation.contains(
NamedOperation.getBaseOperation(op),
- StandardOperation.GET_PROPERTY);
+ StandardOperation.GET, StandardNamespace.PROPERTY);
if (getProp && name instanceof String) {
final String nameStr = (String)name;
--- a/nashorn/samples/dynalink/MissingMethodLinkerExporter.java Wed Nov 09 15:20:30 2016 +0300
+++ b/nashorn/samples/dynalink/MissingMethodLinkerExporter.java Wed Nov 09 10:04:43 2016 -0800
@@ -35,9 +35,10 @@
import java.util.ArrayList;
import java.util.List;
import jdk.dynalink.CallSiteDescriptor;
-import jdk.dynalink.CompositeOperation;
import jdk.dynalink.NamedOperation;
+import jdk.dynalink.NamespaceOperation;
import jdk.dynalink.Operation;
+import jdk.dynalink.StandardNamespace;
import jdk.dynalink.StandardOperation;
import jdk.dynalink.beans.BeansLinker;
import jdk.dynalink.linker.GuardedInvocation;
@@ -99,23 +100,6 @@
"getName", MethodType.methodType(String.class));
}
- // locate the first standard operation from the call descriptor
- private static StandardOperation getFirstStandardOperation(final CallSiteDescriptor desc) {
- final Operation base = NamedOperation.getBaseOperation(desc.getOperation());
- if (base instanceof StandardOperation) {
- return (StandardOperation)base;
- } else if (base instanceof CompositeOperation) {
- final CompositeOperation cop = (CompositeOperation)base;
- for(int i = 0; i < cop.getOperationCount(); ++i) {
- final Operation op = cop.getOperation(i);
- if (op instanceof StandardOperation) {
- return (StandardOperation)op;
- }
- }
- }
- return null;
- }
-
@Override
public List<GuardingDynamicLinker> get() {
final ArrayList<GuardingDynamicLinker> linkers = new ArrayList<>();
@@ -140,8 +124,12 @@
// we return that method object. If not, we return a MissingMethod object.
if (self instanceof MissingMethodHandler) {
// Check if this is a named GET_METHOD first.
- final boolean isGetMethod = getFirstStandardOperation(desc) == StandardOperation.GET_METHOD;
- final Object name = NamedOperation.getName(desc.getOperation());
+ final Operation namedOp = desc.getOperation();
+ final Operation namespaceOp = NamedOperation.getBaseOperation(namedOp);
+ final Operation op = NamespaceOperation.getBaseOperation(namespaceOp);
+
+ final boolean isGetMethod = op == StandardOperation.GET && StandardNamespace.findFirst(namespaceOp) == StandardNamespace.METHOD;
+ final Object name = NamedOperation.getName(namedOp);
if (isGetMethod && name instanceof String) {
final GuardingDynamicLinker javaLinker = beansLinker.getLinkerForClass(self.getClass());
GuardedInvocation inv;
@@ -166,7 +154,7 @@
} else if (self instanceof MissingMethod) {
// This is step (2). We call MissingMethodHandler.doesNotUnderstand here
// Check if this is this a CALL first.
- final boolean isCall = getFirstStandardOperation(desc) == StandardOperation.CALL;
+ final boolean isCall = NamedOperation.getBaseOperation(desc.getOperation()) == StandardOperation.CALL;
if (isCall) {
MethodHandle mh = DOES_NOT_UNDERSTAND;
--- a/nashorn/samples/dynalink/UnderscoreNameLinkerExporter.java Wed Nov 09 15:20:30 2016 +0300
+++ b/nashorn/samples/dynalink/UnderscoreNameLinkerExporter.java Wed Nov 09 10:04:43 2016 -0800
@@ -34,9 +34,10 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import jdk.dynalink.CallSiteDescriptor;
-import jdk.dynalink.CompositeOperation;
import jdk.dynalink.NamedOperation;
+import jdk.dynalink.NamespaceOperation;
import jdk.dynalink.Operation;
+import jdk.dynalink.StandardNamespace;
import jdk.dynalink.StandardOperation;
import jdk.dynalink.linker.GuardedInvocation;
import jdk.dynalink.linker.GuardingDynamicLinker;
@@ -68,23 +69,6 @@
return buf.toString();
}
- // locate the first standard operation from the call descriptor
- private static StandardOperation getFirstStandardOperation(final CallSiteDescriptor desc) {
- final Operation base = NamedOperation.getBaseOperation(desc.getOperation());
- if (base instanceof StandardOperation) {
- return (StandardOperation)base;
- } else if (base instanceof CompositeOperation) {
- final CompositeOperation cop = (CompositeOperation)base;
- for(int i = 0; i < cop.getOperationCount(); ++i) {
- final Operation op = cop.getOperation(i);
- if (op instanceof StandardOperation) {
- return (StandardOperation)op;
- }
- }
- }
- return null;
- }
-
@Override
public List<GuardingDynamicLinker> get() {
final ArrayList<GuardingDynamicLinker> linkers = new ArrayList<>();
@@ -92,12 +76,14 @@
@Override
public GuardedInvocation getGuardedInvocation(final LinkRequest request,
final LinkerServices linkerServices) throws Exception {
- final Object self = request.getReceiver();
final CallSiteDescriptor desc = request.getCallSiteDescriptor();
final Operation op = desc.getOperation();
final Object name = NamedOperation.getName(op);
+ final Operation namespaceOp = NamedOperation.getBaseOperation(op);
// is this a named GET_METHOD?
- final boolean isGetMethod = getFirstStandardOperation(desc) == StandardOperation.GET_METHOD;
+ final boolean isGetMethod =
+ NamespaceOperation.getBaseOperation(namespaceOp) == StandardOperation.GET
+ && StandardNamespace.findFirst(namespaceOp) == StandardNamespace.METHOD;
if (isGetMethod && name instanceof String) {
final String str = (String)name;
if (str.indexOf('_') == -1) {
@@ -106,13 +92,9 @@
final String nameStr = translateToCamelCase(str);
// create a new call descriptor to use translated name
- final CallSiteDescriptor newDesc = new CallSiteDescriptor(
- desc.getLookup(),
- new NamedOperation(NamedOperation.getBaseOperation(op), nameStr),
- desc.getMethodType());
+ final CallSiteDescriptor newDesc = desc.changeOperation(((NamedOperation)op).changeName(nameStr));
// create a new Link request to link the call site with translated name
- final LinkRequest newRequest = new SimpleLinkRequest(newDesc,
- request.isCallSiteUnstable(), request.getArguments());
+ final LinkRequest newRequest = request.replaceArguments(newDesc, request.getArguments());
// return guarded invocation linking the translated request
return linkerServices.getGuardedInvocation(newRequest);
}
--- a/nashorn/samples/dynalink/underscore_linker.js Wed Nov 09 15:20:30 2016 +0300
+++ b/nashorn/samples/dynalink/underscore_linker.js Wed Nov 09 10:04:43 2016 -0800
@@ -46,5 +46,6 @@
// but make sure classpath points to the pluggable linker jar!
`jjs -cp underscore_linker.jar underscore.js`
+print($ERR)
print($OUT)
--- a/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/CallSiteDescriptor.java Wed Nov 09 15:20:30 2016 +0300
+++ b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/CallSiteDescriptor.java Wed Nov 09 10:04:43 2016 -0800
@@ -83,9 +83,11 @@
package jdk.dynalink;
+import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodHandles.Lookup;
import java.lang.invoke.MethodType;
import java.util.Objects;
+import java.util.function.Supplier;
/**
* Call site descriptors contain all the information necessary for linking a
@@ -148,44 +150,82 @@
}
/**
- * Creates a new call site descriptor from this descriptor, which is
- * identical to this, except it changes the method type. Invokes
- * {@link #changeMethodTypeInternal(MethodType)} and checks that it returns
- * a descriptor of the same class as this descriptor.
+ * Finds or creates a call site descriptor that only differs in its
+ * method type from this descriptor.
+ * Invokes {@link #changeMethodTypeInternal(MethodType)}.
*
* @param newMethodType the new method type
- * @return a new call site descriptor, with the method type changed.
- * @throws RuntimeException if {@link #changeMethodTypeInternal(MethodType)}
- * returned a descriptor of different class than this object.
- * @throws NullPointerException if {@link #changeMethodTypeInternal(MethodType)}
- * returned null.
+ * @return a call site descriptor with changed method type.
+ * @throws NullPointerException if {@code newMethodType} is null.
*/
public final CallSiteDescriptor changeMethodType(final MethodType newMethodType) {
- final CallSiteDescriptor changed = Objects.requireNonNull(
- changeMethodTypeInternal(newMethodType),
- "changeMethodTypeInternal() must not return null.");
+ final CallSiteDescriptor changed = changeMethodTypeInternal(newMethodType);
- if (getClass() != changed.getClass()) {
- throw new RuntimeException(
- "changeMethodTypeInternal() must return an object of the same class it is invoked on.");
+ if (getClass() != CallSiteDescriptor.class) {
+ assertChangeInvariants(changed, "changeMethodTypeInternal");
+ alwaysAssert(operation == changed.operation, () -> "changeMethodTypeInternal must not change the descriptor's operation");
+ alwaysAssert(newMethodType == changed.methodType, () -> "changeMethodTypeInternal didn't set the correct new method type");
}
-
return changed;
}
/**
- * Creates a new call site descriptor from this descriptor, which is
- * identical to this, except it changes the method type. Subclasses must
- * override this method to return an object of their exact class.
+ * Finds or creates a call site descriptor that only differs in its
+ * method type from this descriptor. Subclasses must override this method
+ * to return an object of their exact class. If an overridden method changes
+ * something other than the method type in the descriptor (its class, lookup,
+ * or operation), or returns null, an {@code AssertionError} will be thrown
+ * from {@link #changeMethodType(MethodType)}.
*
* @param newMethodType the new method type
- * @return a new call site descriptor, with the method type changed.
+ * @return a call site descriptor with the changed method type.
*/
protected CallSiteDescriptor changeMethodTypeInternal(final MethodType newMethodType) {
return new CallSiteDescriptor(getLookupPrivileged(), operation, newMethodType);
}
/**
+ * Finds or creates a call site descriptor that only differs in its
+ * operation from this descriptor.
+ * Invokes {@link #changeOperationInternal(Operation)}.
+ *
+ * @param newOperation the new operation
+ * @return a call site descriptor with the changed operation.
+ * @throws NullPointerException if {@code newOperation} is null.
+ * @throws SecurityException if the descriptor's lookup isn't the
+ * {@link MethodHandles#publicLookup()}, and a security manager is present,
+ * and a check for {@code RuntimePermission("dynalink.getLookup")} fails.
+ * This is necessary as changing the operation in the call site descriptor
+ * allows fabrication of descriptors for arbitrary operations with the lookup.
+ */
+ public final CallSiteDescriptor changeOperation(final Operation newOperation) {
+ getLookup(); // force security check
+ final CallSiteDescriptor changed = changeOperationInternal(newOperation);
+
+ if (getClass() != CallSiteDescriptor.class) {
+ assertChangeInvariants(changed, "changeOperationInternal");
+ alwaysAssert(methodType == changed.methodType, () -> "changeOperationInternal must not change the descriptor's method type");
+ alwaysAssert(newOperation == changed.operation, () -> "changeOperationInternal didn't set the correct new operation");
+ }
+ return changed;
+ }
+
+ /**
+ * Finds or creates a call site descriptor that only differs in its
+ * operation from this descriptor. Subclasses must override this method
+ * to return an object of their exact class. If an overridden method changes
+ * something other than the operation in the descriptor (its class, lookup,
+ * or method type), or returns null, an {@code AssertionError} will be thrown
+ * from {@link #changeOperation(Operation)}.
+ *
+ * @param newOperation the new operation
+ * @return a call site descriptor with the changed operation.
+ */
+ protected CallSiteDescriptor changeOperationInternal(final Operation newOperation) {
+ return new CallSiteDescriptor(getLookupPrivileged(), newOperation, methodType);
+ }
+
+ /**
* Returns true if this call site descriptor is equal to the passed object.
* It is considered equal if the other object is of the exact same class,
* their operations and method types are equal, and their lookups have the
@@ -255,4 +295,16 @@
final StringBuilder b = new StringBuilder(o.length() + mt.length() + 1 + l.length());
return b.append(o).append(mt).append('@').append(l).toString();
}
+
+ private void assertChangeInvariants(final CallSiteDescriptor changed, final String caller) {
+ alwaysAssert(changed != null, () -> caller + " must not return null.");
+ alwaysAssert(getClass() == changed.getClass(), () -> caller + " must not change the descriptor's class");
+ alwaysAssert(lookupsEqual(getLookupPrivileged(), changed.getLookupPrivileged()), () -> caller + " must not change the descriptor's lookup");
+ }
+
+ private static void alwaysAssert(final boolean cond, final Supplier<String> errorMessage) {
+ if (!cond) {
+ throw new AssertionError(errorMessage.get());
+ }
+ }
}
--- a/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/CompositeOperation.java Wed Nov 09 15:20:30 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,297 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * This file is available under and governed by the GNU General Public
- * License version 2 only, as published by the Free Software Foundation.
- * However, the following notice accompanied the original version of this
- * file, and Oracle licenses the original version of this file under the BSD
- * license:
- */
-/*
- Copyright 2015 Attila Szegedi
-
- Licensed under both the Apache License, Version 2.0 (the "Apache License")
- and the BSD License (the "BSD License"), with licensee being free to
- choose either of the two at their discretion.
-
- You may not use this file except in compliance with either the Apache
- License or the BSD License.
-
- If you choose to use this file in compliance with the Apache License, the
- following notice applies to you:
-
- You may obtain a copy of the Apache License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied. See the License for the specific language governing
- permissions and limitations under the License.
-
- If you choose to use this file in compliance with the BSD License, the
- following notice applies to you:
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are
- met:
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- * Neither the name of the copyright holder nor the names of
- contributors may be used to endorse or promote products derived from
- this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER
- BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-package jdk.dynalink;
-
-import java.util.Arrays;
-import java.util.Objects;
-
-/**
- * Describes an operation that is composed of at least two other operations. The
- * component operations are treated as alternatives to each other in order of
- * preference. The semantics of the composite operation is "first successful".
- * That is, a composite of {@code GET_PROPERTY|GET_ELEMENT:color} should be
- * interpreted as <i>get the property named "color" on the object, but if the
- * property does not exist, then get the collection element named "color"
- * instead</i>.
- * <p>
- * Composite operations are helpful in implementation of languages that
- * don't distinguish between one or more of the property, method, and element
- * namespaces, or when expressing operations against objects that can be
- * considered both ordinary objects and collections, e.g. Java
- * {@link java.util.Map} objects. A composite operation
- * {@code GET_PROPERTY|GET_ELEMENT:empty} against a Java map will always match
- * the {@link java.util.Map#isEmpty()} property, but
- * {@code GET_ELEMENT|GET_PROPERTY:empty} will actually match a map element with
- * key {@code "empty"} if the map contains that key, and only fall back to the
- * {@code isEmpty()} property getter if the map does not contain the key. If
- * the source language mandates this semantics, it can be easily achieved using
- * composite operations.
- * <p>
- * Even if the language itself doesn't distinguish between some of the
- * namespaces, it can be helpful to map different syntaxes to different
- * compositions. E.g. the source expression {@code obj.color} could map to
- * {@code GET_PROPERTY|GET_ELEMENT|GET_METHOD:color}, but a different source
- * expression that looks like collection element access {@code obj[key]} could
- * be expressed instead as {@code GET_ELEMENT|GET_PROPERTY|GET_METHOD}.
- * Finally, if the retrieved value is subsequently called, then it makes sense
- * to bring {@code GET_METHOD} to the front of the list: the getter part of the
- * source expression {@code obj.color()} should be
- * {@code GET_METHOD|GET_PROPERTY|GET_ELEMENT:color} and the one for
- * {@code obj[key]()} should be {@code GET_METHOD|GET_ELEMENT|GET_PROPERTY}.
- * <p>
- * The elements of a composite operation can not be composites or named
- * operations, but rather simple operations such are elements of
- * {@link StandardOperation}. A composite operation itself can serve as the base
- * operation of a named operation, though; a typical way to construct e.g. the
- * {@code GET_ELEMENT|GET_PROPERTY:empty} from above would be:
- * <pre>
- * Operation getElementOrPropertyEmpty = new NamedOperation(
- * new CompositeOperation(
- * StandardOperation.GET_ELEMENT,
- * StandardOperation.GET_PROPERTY),
- * "empty");
- * </pre>
- * <p>
- * Not all compositions make sense. Typically, any combination in any order of
- * standard getter operations {@code GET_PROPERTY}, {@code GET_ELEMENT}, and
- * {@code GET_METHOD} make sense, as do combinations of {@code SET_PROPERTY} and
- * {@code SET_ELEMENT}; other standard operations should not be combined. The
- * constructor will allow any combination of operations, though.
- */
-public final class CompositeOperation implements Operation {
- private final Operation[] operations;
-
- /**
- * Constructs a new composite operation.
- * @param operations the components for this composite operation. The passed
- * array will be cloned.
- * @throws IllegalArgumentException if less than two components are
- * specified, or any component is itself a {@link CompositeOperation} or a
- * {@link NamedOperation}.
- * @throws NullPointerException if either the operations array or any of its
- * elements are {@code null}.
- */
- public CompositeOperation(final Operation... operations) {
- Objects.requireNonNull(operations, "operations array is null");
- if (operations.length < 2) {
- throw new IllegalArgumentException("Must have at least two operations");
- }
- final Operation[] clonedOps = operations.clone();
- for(int i = 0; i < clonedOps.length; ++i) {
- final Operation op = clonedOps[i];
- if (op == null) {
- throw new NullPointerException("operations[" + i + "] is null");
- } else if (op instanceof NamedOperation) {
- throw new IllegalArgumentException("operations[" + i + "] is a NamedOperation");
- } else if (op instanceof CompositeOperation) {
- throw new IllegalArgumentException("operations[" + i + "] is a CompositeOperation");
- }
- }
- this.operations = clonedOps;
- }
-
- /**
- * Returns the component operations in this composite operation. The
- * returned array is a copy and changes to it don't have effect on this
- * object.
- * @return the component operations in this composite operation.
- */
- public Operation[] getOperations() {
- return operations.clone();
- }
-
- /**
- * Returns the number of component operations in this composite operation.
- * @return the number of component operations in this composite operation.
- */
- public int getOperationCount() {
- return operations.length;
- }
-
- /**
- * Returns the i-th component operation in this composite operation.
- * @param i the operation index
- * @return the i-th component operation in this composite operation.
- * @throws IndexOutOfBoundsException if the index is out of range.
- */
- public Operation getOperation(final int i) {
- try {
- return operations[i];
- } catch (final ArrayIndexOutOfBoundsException e) {
- throw new IndexOutOfBoundsException(Integer.toString(i));
- }
- }
-
- /**
- * Returns true if this composite operation contains an operation equal to
- * the specified operation.
- * @param operation the operation being searched for. Must not be null.
- * @return true if the if this composite operation contains an operation
- * equal to the specified operation.
- */
- public boolean contains(final Operation operation) {
- Objects.requireNonNull(operation);
- for(final Operation component: operations) {
- if (component.equals(operation)) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Returns true if the other object is also a composite operation and their
- * component operations are equal.
- * @param obj the object to compare to
- * @return true if this object is equal to the other one, false otherwise.
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj instanceof CompositeOperation) {
- return Arrays.equals(operations, ((CompositeOperation)obj).operations);
- }
- return false;
- }
-
- /**
- * Returns the hash code of this composite operation. Defined to be equal
- * to {@code java.util.Arrays.hashCode(operations)}.
- */
- @Override
- public int hashCode() {
- return Arrays.hashCode(operations);
- };
-
- /**
- * Returns the string representation of this composite operation. Defined to
- * be the {@code toString} of its component operations, each separated by
- * the vertical line character (e.g. {@code "GET_PROPERTY|GET_ELEMENT"}).
- * @return the string representation of this composite operation.
- */
- @Override
- public String toString() {
- final StringBuilder b = new StringBuilder();
- b.append(operations[0]);
- for(int i = 1; i < operations.length; ++i) {
- b.append('|').append(operations[i]);
- }
- return b.toString();
- }
-
- /**
- * Returns the components of the passed operation if it is a composite
- * operation, otherwise returns an array containing the operation itself.
- * This allows for returning an array of component even if it is not known
- * whether the operation is itself a composite (treating a non-composite
- * operation as if it were a single-element composite of itself).
- * @param op the operation whose components are retrieved.
- * @return if the passed operation is a composite operation, returns its
- * {@link #getOperations()}, otherwise returns the operation itself.
- */
- public static Operation[] getOperations(final Operation op) {
- return op instanceof CompositeOperation
- ? ((CompositeOperation)op).operations.clone()
- : new Operation[] { op };
- }
-
- /**
- * Returns true if the specified potentially composite operation is a
- * {@link CompositeOperation} and contains an operation equal to the
- * specified operation. If {@code composite} is not a
- * {@link CompositeOperation}, then the two operations are compared for
- * equality.
- * @param composite the potentially composite operation. Must not be null.
- * @param operation the operation being searched for. Must not be null.
- * @return true if the if the passed operation is a
- * {@link CompositeOperation} and contains a component operation equal to
- * the specified operation, or if it is not a {@link CompositeOperation} and
- * is equal to {@code operation}.
- */
- public static boolean contains(final Operation composite, final Operation operation) {
- if (composite instanceof CompositeOperation) {
- return ((CompositeOperation)composite).contains(operation);
- }
- return composite.equals(Objects.requireNonNull(operation));
- }
-}
--- a/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/NamedOperation.java Wed Nov 09 15:20:30 2016 +0300
+++ b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/NamedOperation.java Wed Nov 09 10:04:43 2016 -0800
@@ -88,15 +88,47 @@
/**
* Operation that associates a name with another operation. Typically used with
* operations that normally take a name or an index to bind them to a fixed
- * name. E.g. {@code new NamedOperation(StandardOperation.GET_PROPERTY, "color")}
+ * name. E.g.
+ * <pre>
+ * new NamedOperation(
+ * new NamespaceOperation(
+ * StandardOperation.GET,
+ * StandardNamespace.PROPERTY),
+ * "color")
+ * </pre>
* will be a named operation for getting the property named "color" on the
* object it is applied to, and
- * {@code new NamedOperation(StandardOperation.GET_ELEMENT, 3)} will be a named
- * operation for getting the element at index 3 from the collection it is
- * applied to. In these cases, the expected signature of the call site for the
+ * <pre>
+ * new NamedOperation(
+ * new NamespaceOperation(
+ * StandardOperation.GET,
+ * StandardNamespace.ELEMENT),
+ * 3)
+ * </pre>
+ * will be a named operation for getting the element at index 3 from the collection
+ * it is applied to ("name" in this context is akin to "address" and encompasses both
+ * textual names, numeric indices, or any other kinds of addressing that linkers can
+ * understand). In these cases, the expected signature of the call site for the
* operation will change to no longer include the name parameter. Specifically,
* the documentation for all {@link StandardOperation} members describes how
* they are affected by being incorporated into a named operation.
+ * <p>While {@code NamedOperation} can be constructed directly, it is often convenient
+ * to use the {@link Operation#named(Object)} factory method instead, e.g.:
+ * <pre>
+ * StandardOperation.GET
+ * .withNamespace(StandardNamespace.ELEMENT),
+ * .named(3)
+ * )
+ * </pre>
+ * <p>
+ * Even though {@code NamedOperation} is most often used with {@link NamespaceOperation} as
+ * its base, it can have other operations as its base too (except another named operation).
+ * Specifically, {@link StandardOperation#CALL} as well as {@link StandardOperation#NEW} can
+ * both be used with {@code NamedOperation} directly. The contract for these operations is such
+ * that when they are used as named operations, their name is only used for diagnostic messages,
+ * usually containing the textual representation of the source expression that retrieved the
+ * callee, e.g. {@code StandardOperation.CALL.named("window.open")}.
+ * </p>
*/
public final class NamedOperation implements Operation {
private final Operation baseOperation;
@@ -116,7 +148,7 @@
*/
public NamedOperation(final Operation baseOperation, final Object name) {
if (baseOperation instanceof NamedOperation) {
- throw new IllegalArgumentException("baseOperation is a named operation");
+ throw new IllegalArgumentException("baseOperation is a NamedOperation");
}
this.baseOperation = Objects.requireNonNull(baseOperation, "baseOperation is null");
this.name = Objects.requireNonNull(name, "name is null");
@@ -139,6 +171,16 @@
}
/**
+ * Finds or creates a named operation that differs from this one only in the name.
+ * @param newName the new name to replace the old name with.
+ * @return a named operation with the changed name.
+ * @throws NullPointerException if the name is null.
+ */
+ public final NamedOperation changeName(final String newName) {
+ return new NamedOperation(baseOperation, newName);
+ }
+
+ /**
* Compares this named operation to another object. Returns true if the
* other object is also a named operation, and both their base operations
* and name are equal.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/Namespace.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * This file is available under and governed by the GNU General Public
+ * License version 2 only, as published by the Free Software Foundation.
+ * However, the following notice accompanied the original version of this
+ * file, and Oracle licenses the original version of this file under the BSD
+ * license:
+ */
+/*
+ Copyright 2016 Attila Szegedi
+
+ Licensed under both the Apache License, Version 2.0 (the "Apache License")
+ and the BSD License (the "BSD License"), with licensee being free to
+ choose either of the two at their discretion.
+
+ You may not use this file except in compliance with either the Apache
+ License or the BSD License.
+
+ If you choose to use this file in compliance with the Apache License, the
+ following notice applies to you:
+
+ You may obtain a copy of the Apache License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ If you choose to use this file in compliance with the BSD License, the
+ following notice applies to you:
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of the copyright holder nor the names of
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER
+ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+package jdk.dynalink;
+
+/**
+ * An object that describes a namespace that is the target of a dynamic operation
+ * on an object. Every object can have one or more namespaces. Dynalink defines a
+ * set of standard namespaces with the {@link StandardNamespace} enum. Operations
+ * that need to specify a namespace they operate on can be expressed using
+ * {@link NamespaceOperation}.
+ */
+public interface Namespace {
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/NamespaceOperation.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,331 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * This file is available under and governed by the GNU General Public
+ * License version 2 only, as published by the Free Software Foundation.
+ * However, the following notice accompanied the original version of this
+ * file, and Oracle licenses the original version of this file under the BSD
+ * license:
+ */
+/*
+ Copyright 2016 Attila Szegedi
+
+ Licensed under both the Apache License, Version 2.0 (the "Apache License")
+ and the BSD License (the "BSD License"), with licensee being free to
+ choose either of the two at their discretion.
+
+ You may not use this file except in compliance with either the Apache
+ License or the BSD License.
+
+ If you choose to use this file in compliance with the Apache License, the
+ following notice applies to you:
+
+ You may obtain a copy of the Apache License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ If you choose to use this file in compliance with the BSD License, the
+ following notice applies to you:
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of the copyright holder nor the names of
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER
+ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+package jdk.dynalink;
+
+import java.util.Arrays;
+import java.util.Objects;
+
+/**
+ * Describes an operation that operates on at least one {@link Namespace} of
+ * an object. E.g. a property getter would be described as
+ * <pre>
+ * Operation propertyGetter = new NamespaceOperation(
+ * StandardOperation.GET,
+ * StandardNamespace.PROPERTY);
+ * </pre>
+ * They are often combined with {@link NamedOperation}, e.g. to express a
+ * property getter for a property named "color", you would construct:
+ * <pre>
+ * Operation colorPropertyGetter = new NamedOperation(
+ * new NamespaceOperation(
+ * StandardOperation.GET,
+ * StandardNamespace.PROPERTY),
+ * "color");
+ * </pre>
+ * <p>While {@code NamespaceOperation} can be constructed directly, it is often convenient
+ * to use the {@link Operation#withNamespace(Namespace)} and {@link Operation#withNamespaces(Namespace...)} factory
+ * methods instead, e.g.:
+ * <pre>
+ * Operation getElementOrPropertyEmpty =
+ * StandardOperation.GET
+ * .withNamespace(StandardNamespace.PROPERTY)
+ * .named("color");
+ * </pre>
+ * <h3>Operations on multiple namespaces</h3>
+ * If multiple namespaces are specified, the namespaces are treated as
+ * alternatives to each other in order of preference. The semantics of
+ * such operation is "first applicable".
+ * That is, a composite of {@code GET:PROPERTY|ELEMENT:color} should be
+ * interpreted as <i>get the property named "color" on the object, but if the
+ * property does not exist, then get the collection element named "color"
+ * instead</i>.
+ * <p>
+ * Operations with multiple namespaces are helpful in implementation of languages that
+ * don't distinguish between one or more of the namespaces, or when expressing operations
+ * against objects that can be considered both ordinary objects and collections, e.g. Java
+ * {@link java.util.Map} objects. A {@code GET:PROPERTY|ELEMENT:empty} operation
+ * against a Java map will always match
+ * the {@link java.util.Map#isEmpty()} property, but
+ * {@code GET:ELEMENT|PROPERTY:empty} will actually match a map element with
+ * key {@code "empty"} if the map contains that key, and only fall back to the
+ * {@code isEmpty()} property getter if the map does not contain the key. If
+ * the source language mandates this semantics, it can be easily achieved using
+ * operations on multiple namespaces.
+ * <p>
+ * Even if the language itself doesn't distinguish between some of the
+ * namespaces, it can be helpful to map different syntaxes to different namespace orderings.
+ * E.g. the source expression {@code obj.color} could map to
+ * {@code GET:PROPERTY|ELEMENT|METHOD:color}, but a different source
+ * expression that looks like collection element access {@code obj[key]} could
+ * be expressed instead as {@code GET:ELEMENT|PROPERTY|METHOD} in order to favor the
+ * element semantics. Finally, if the retrieved value is subsequently called, then it makes sense
+ * to bring {@code METHOD} to the front of the namespace list: the getter part of the
+ * source expression {@code obj.color()} could be
+ * {@code GET:METHOD|PROPERTY|ELEMENT:color} and the one for
+ * {@code obj[key]()} could be {@code GET:METHOD|ELEMENT|PROPERTY}.
+ * <p>
+ * The base operation of a namespace operation can not itself be a namespace or named
+ * operation, but rather one of simple operations such are elements of
+ * {@link StandardOperation}. A namespace operation itself can serve as the base
+ * operation of a named operation, though; a typical way to construct e.g. the
+ * {@code GET:ELEMENT|PROPERTY:empty} from above would be:
+ * <pre>
+ * Operation getElementOrPropertyEmpty = StandardOperation.GET
+ * .withNamespaces(
+ * StandardNamespace.ELEMENT,
+ * StandardNamespace.PROPERTY)
+ * .named("empty");
+ * </pre>
+ */
+public final class NamespaceOperation implements Operation {
+ private final Operation baseOperation;
+ private final Namespace[] namespaces;
+
+ /**
+ * Constructs a new namespace operation.
+ * @param baseOperation the base operation that operates on one or more namespaces.
+ * @param namespaces one or more namespaces this operation operates on.
+ * @throws IllegalArgumentException if less than one namespace is
+ * specified, or the base operation is itself a {@link NamespaceOperation} or a
+ * {@link NamedOperation}.
+ * @throws NullPointerException if either the {@code namespaces} array or any of its
+ * elements are {@code null}, or if {@code baseOperation} is {@code null}.
+ */
+ public NamespaceOperation(final Operation baseOperation, final Namespace... namespaces) {
+ this.baseOperation = Objects.requireNonNull(baseOperation, "baseOperation is null");
+ if (baseOperation instanceof NamedOperation) {
+ throw new IllegalArgumentException("baseOperation is a NamedOperation");
+ } else if (baseOperation instanceof NamespaceOperation) {
+ throw new IllegalArgumentException("baseOperation is a NamespaceOperation");
+ }
+
+ this.namespaces = Objects.requireNonNull(namespaces, "namespaces array is null").clone();
+ if (namespaces.length < 1) {
+ throw new IllegalArgumentException("Must specify at least one namespace");
+ }
+ for(int i = 0; i < namespaces.length; ++i) {
+ final int fi = i;
+ Objects.requireNonNull(namespaces[i], () -> "operations[" + fi + "] is null");
+ }
+ }
+
+ /**
+ * Returns the base operation of this named operation.
+ * @return the base operation of this named operation.
+ */
+ public Operation getBaseOperation() {
+ return baseOperation;
+ }
+
+ /**
+ * Returns the namespaces in this namespace operation. The returned
+ * array is a copy and changes to it don't have effect on this
+ * object.
+ * @return the namespaces in this namespace operation.
+ */
+ public Namespace[] getNamespaces() {
+ return namespaces.clone();
+ }
+
+ /**
+ * Returns the number of namespaces in this namespace operation.
+ * @return the number of namespaces in this namespace operation.
+ */
+ public int getNamespaceCount() {
+ return namespaces.length;
+ }
+
+ /**
+ * Returns the i-th namespace in this namespace operation.
+ * @param i the namespace index
+ * @return the i-th namespace in this namespace operation.
+ * @throws IndexOutOfBoundsException if the index is out of range.
+ */
+ public Namespace getNamespace(final int i) {
+ try {
+ return namespaces[i];
+ } catch (final ArrayIndexOutOfBoundsException e) {
+ throw new IndexOutOfBoundsException(Integer.toString(i));
+ }
+ }
+
+ /**
+ * Returns true if this namespace operation contains a namespace equal to
+ * the specified namespace.
+ * @param namespace the namespace being searched for. Must not be null.
+ * @return true if the if this namespace operation contains a namespace
+ * equal to the specified namespace.
+ */
+ public boolean contains(final Namespace namespace) {
+ Objects.requireNonNull(namespace);
+ for(final Namespace component: namespaces) {
+ if (component.equals(namespace)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Returns true if the other object is also a namespace operation and their
+ * base operation and namespaces are equal.
+ * @param obj the object to compare to
+ * @return true if this object is equal to the other one, false otherwise.
+ */
+ @Override
+ public boolean equals(final Object obj) {
+ if (obj instanceof NamespaceOperation) {
+ final NamespaceOperation other = (NamespaceOperation)obj;
+ return baseOperation.equals(other.baseOperation) && Arrays.equals(namespaces, other.namespaces);
+ }
+ return false;
+ }
+
+ /**
+ * Returns the hash code of this namespace operation. Defined to be equal
+ * to {@code baseOperation.hashCode() + 31 * Arrays.hashCode(namespaces)}.
+ */
+ @Override
+ public int hashCode() {
+ return baseOperation.hashCode() + 31 * Arrays.hashCode(namespaces);
+ };
+
+ /**
+ * Returns the string representation of this namespace operation. Defined to
+ * be the {@code toString} of its base operation, followed by a colon character,
+ * followed with the list of its namespaces separated with the vertical line
+ * character (e.g. {@code "GET:PROPERTY|ELEMENT"}).
+ * @return the string representation of this namespace operation.
+ */
+ @Override
+ public String toString() {
+ final StringBuilder b = new StringBuilder();
+ b.append(baseOperation).append(':');
+ b.append(namespaces[0]);
+ for(int i = 1; i < namespaces.length; ++i) {
+ b.append('|').append(namespaces[i]);
+ }
+ return b.toString();
+ }
+
+ /**
+ * If the passed operation is a namespace operation, returns its
+ * {@link #getBaseOperation()}, otherwise returns the operation as is.
+ * @param op the operation
+ * @return the base operation of the passed operation.
+ */
+ public static Operation getBaseOperation(final Operation op) {
+ return op instanceof NamespaceOperation ? ((NamespaceOperation )op).getBaseOperation() : op;
+ }
+
+ /**
+ * If the passed operation is a namespace operation, returns its
+ * {@link #getNamespaces()}, otherwise returns an empty array.
+ * @param op the operation
+ * @return the namespaces of the passed operation.
+ */
+ public static Namespace[] getNamespaces(final Operation op) {
+ return op instanceof NamespaceOperation ? ((NamespaceOperation)op).getNamespaces() : new Namespace[0];
+ }
+
+ /**
+ * Returns true if the specified operation is a {@link NamespaceOperation}
+ * and its base operation is equal to the specified operation, and it
+ * contains the specified namespace. If it is not a {@link NamespaceOperation},
+ * then it returns false.
+ * @param op the operation. Must not be null.
+ * @param baseOperation the base operation being searched for. Must not be null.
+ * @param namespace the namespace being searched for. Must not be null.
+ * @return true if the if the passed operation is a {@link NamespaceOperation},
+ * its base operation equals the searched base operation, and contains a namespace
+ * equal to the searched namespace.
+ */
+ public static boolean contains(final Operation op, final Operation baseOperation, final Namespace namespace) {
+ if (op instanceof NamespaceOperation) {
+ final NamespaceOperation no = (NamespaceOperation)op;
+ return no.baseOperation.equals(baseOperation) && no.contains(namespace);
+ }
+ return false;
+ }
+}
--- a/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/Operation.java Wed Nov 09 15:20:30 2016 +0300
+++ b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/Operation.java Wed Nov 09 10:04:43 2016 -0800
@@ -86,14 +86,51 @@
/**
* An object that describes a dynamic operation. Dynalink defines a set of
* standard operations with the {@link StandardOperation} class, as well as a
- * way to attach a fixed name to an operation using {@link NamedOperation} and
- * to express a set of alternative operations using {@link CompositeOperation}.
+ * way to express the target {@link Namespace namespace(s)} of an operation
+ * on an object using {@link NamespaceOperation} and finally a way to attach
+ * a fixed target name to an operation using {@link NamedOperation}.
* When presenting examples in this documentation, we will refer to standard
- * operations using their name (e.g. {@code GET_PROPERTY}), to composite
- * operations by separating their components with the vertical line character
- * (e.g. {@code GET_PROPERTY|GET_ELEMENT}), and finally to named operations by
- * separating the base operation and the name with the colon character (e.g.
- * {@code GET_PROPERTY|GET_ELEMENT:color}).
+ * operations using their name (e.g. {@code GET}), to namespace operations
+ * by separating their base operation with a colon from their namespace
+ * (e.g. {@code GET:PROPERTY}), or in case of multiple namespaces we will
+ * further separate those with the vertical line character (e.g.
+ * {@code GET:PROPERTY|ELEMENT}), and finally we will refer to named operations
+ * by separating the base operation and the name with the colon character (e.g.
+ * {@code GET:PROPERTY|ELEMENT:color}).
*/
public interface Operation {
+ /**
+ * Returns a {@link NamespaceOperation} using this operation as its base.
+ * @param namespace the namespace that is the target of the namespace operation.
+ * @return a {@link NamespaceOperation} with this operation as its base and the specified
+ * namespace as its target.
+ * @throws IllegalArgumentException if this operation is already a namespace operation or a named operation.
+ * @throws NullPointerException if {@code namespace} is null.
+ */
+ default NamespaceOperation withNamespace(final Namespace namespace) {
+ return withNamespaces(namespace);
+ }
+
+ /**
+ * Returns a {@link NamespaceOperation} using this operation as its base.
+ * @param namespaces the namespaces that are the target of the namespace operation.
+ * @return a {@link NamespaceOperation} with this operation as its base and the specified
+ * namespaces as its targets.
+ * @throws IllegalArgumentException if this operation is already a namespace operation or a named operation.
+ * @throws NullPointerException if {@code namespace} or any of its elements is null.
+ */
+ default NamespaceOperation withNamespaces(final Namespace... namespaces) {
+ return new NamespaceOperation(this, namespaces);
+ }
+
+ /**
+ * Returns a {@link NamedOperation} using this operation as its base.
+ * @param name the name that is the target of the named operation.
+ * @return a {@link NamedOperation} with this operation as its base and the specified name.
+ * @throws IllegalArgumentException if this operation is already a named operation.
+ * @throws NullPointerException if {@code name} is null.
+ */
+ default NamedOperation named(final Object name) {
+ return new NamedOperation(this, name);
+ }
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/StandardNamespace.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,130 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * This file is available under and governed by the GNU General Public
+ * License version 2 only, as published by the Free Software Foundation.
+ * However, the following notice accompanied the original version of this
+ * file, and Oracle licenses the original version of this file under the BSD
+ * license:
+ */
+/*
+ Copyright 2016 Attila Szegedi
+
+ Licensed under both the Apache License, Version 2.0 (the "Apache License")
+ and the BSD License (the "BSD License"), with licensee being free to
+ choose either of the two at their discretion.
+
+ You may not use this file except in compliance with either the Apache
+ License or the BSD License.
+
+ If you choose to use this file in compliance with the Apache License, the
+ following notice applies to you:
+
+ You may obtain a copy of the Apache License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ If you choose to use this file in compliance with the BSD License, the
+ following notice applies to you:
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of the copyright holder nor the names of
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER
+ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+package jdk.dynalink;
+
+/**
+ * An enumeration of standard namespaces defined by Dynalink.
+ */
+public enum StandardNamespace implements Namespace {
+ /**
+ * Standard namespace for properties of an object.
+ */
+ PROPERTY,
+ /**
+ * Standard namespace for elements of a collection object.
+ */
+ ELEMENT,
+ /**
+ * Standard namespace for methods of an object. The method objects retrieved
+ * through a {@link StandardOperation#GET} on this namespace can be (and where
+ * object semantics allows they should be) unbound, that is: not bound to the
+ * object they were retrieved through. When they are used with
+ * {@link StandardOperation#CALL} an explicit "this" receiver argument is always
+ * passed to them. Of course bound methods can be returned if the object semantics
+ * requires them and such methods are free to ignore the receiver passed in the
+ * {@code CALL} operation or even raise an error when it is different from the one
+ * the method is bound to, or exhibit any other behavior their semantics requires
+ * in such case.
+ */
+ METHOD;
+
+ /**
+ * If the passed in operation is a {@link NamespaceOperation}, or a
+ * {@link NamedOperation} wrapping a {@link NamespaceOperation}, then it
+ * returns the first (if any) {@link StandardNamespace} in its namespace
+ * list. If the passed operation is not a namespace operation (optionally
+ * wrapped in a named operation), or if it doesn't have any standard
+ * namespaces in it, returns {@code null}.
+ * @param op the operation
+ * @return the first standard namespace in the operation's namespace list
+ */
+ public static StandardNamespace findFirst(final Operation op) {
+ for(final Namespace ns: NamespaceOperation.getNamespaces(NamedOperation.getBaseOperation(op))) {
+ if (ns instanceof StandardNamespace) {
+ return (StandardNamespace)ns;
+ }
+ }
+ return null;
+ }
+}
--- a/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/StandardOperation.java Wed Nov 09 15:20:30 2016 +0300
+++ b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/StandardOperation.java Wed Nov 09 10:04:43 2016 -0800
@@ -84,79 +84,40 @@
package jdk.dynalink;
/**
- * Defines the standard dynamic operations. Getter and setter operations defined
- * in this enumeration can be composed into a {@link CompositeOperation}, and
- * {@link NamedOperation} can be used to bind the name parameter of operations
- * that take one, in which case it disappears from the type signature.
+ * Defines the standard dynamic operations. The operations {@link #GET} and {@link #SET} must
+ * be used as part of a {@link NamespaceOperation}. {@link NamedOperation} can then be further used on these
+ * {@link NamespaceOperation}s to bind the name parameter of {@link #GET} and {@link #SET} operations, in which case it
+ * disappears from their type signature.
+ * {@link NamedOperation} can also be used to decorate {@link #CALL} and {@link #NEW} operations with a
+ * diagnostic name, and as such it does not affect their type signature.
*/
public enum StandardOperation implements Operation {
/**
- * Get the value of a property defined on an object. Call sites with this
+ * Get the value from a namespace defined on an object. Call sites with this
* operation should have a signature of
- * <tt>(receiver, propertyName)→value</tt> or
+ * <tt>(receiver, name)→value</tt> or
* <tt>(receiver)→value</tt> when used with {@link NamedOperation}, with
* all parameters and return type being of any type (either primitive or
- * reference).
+ * reference). This operation must always be used as part of a {@link NamespaceOperation}.
*/
- GET_PROPERTY,
- /**
- * Set the value of a property defined on an object. Call sites with this
- * operation should have a signature of
- * <tt>(receiver, propertyName, value)→void</tt> or
- * <tt>(receiver, value)→void</tt> when used with {@link NamedOperation},
- * with all parameters and return type being of any type (either primitive
- * or reference).
- */
- SET_PROPERTY,
+ GET,
/**
- * Get the value of an element of a collection. Call sites with this
+ * Set the value in a namespace defined on an object. Call sites with this
* operation should have a signature of
- * <tt>(receiver, index)→value</tt> or
- * <tt>(receiver)→value</tt> when used with {@link NamedOperation}, with
- * all parameters and return type being of any type (either primitive or
- * reference).
- */
- GET_ELEMENT,
- /**
- * Set the value of an element of a collection. Call sites with this
- * operation should have a signature of
- * <tt>(receiver, index, value)→void</tt> or
+ * <tt>(receiver, name, value)→void</tt> or
* <tt>(receiver, value)→void</tt> when used with {@link NamedOperation},
* with all parameters and return type being of any type (either primitive
- * or reference).
+ * or reference). This operation must always be used as part of a {@link NamespaceOperation}.
*/
- SET_ELEMENT,
- /**
- * Get the length of an array or size of a collection. Call sites with
- * this operation should have a signature of <tt>(receiver)→value</tt>,
- * with all parameters and return type being of any type (either primitive
- * or reference).
- */
- GET_LENGTH,
+ SET,
/**
- * Gets an object representing a method defined on an object. Call sites
- * with this operation should have a signature of
- * <tt>(receiver, methodName)→value</tt>, or
- * <tt>(receiver)→value</tt> when used with {@link NamedOperation}
- * with all parameters and return type being of any type (either primitive
- * or reference).
- */
- GET_METHOD,
- /**
- * Calls a method defined on an object. Call sites with this
- * operation should have a signature of
- * <tt>(receiver, methodName, arguments...)→value</tt> or
- * <tt>(receiver, arguments...)→value</tt> when used with {@link NamedOperation},
- * with all parameters and return type being of any type (either primitive
- * or reference).
- */
- CALL_METHOD,
- /**
- * Calls a callable object. Call sites with this operation should have a
- * signature of <tt>(receiver, arguments...)→value</tt>, with all
- * parameters and return type being of any type (either primitive or
- * reference). Typically, if the callable is a method of an object, the
- * first argument will act as the "this" value passed to the called method.
+ * Call a callable object. Call sites with this operation should have a
+ * signature of <tt>(callable, receiver, arguments...)→value</tt>,
+ * with all parameters and return type being of any type (either primitive or
+ * reference). Typically, the callables are presumed to be methods of an object, so
+ * an explicit receiver value is always passed to the callable before the arguments.
+ * If a callable has no concept of a receiver, it is free to ignore the value of the
+ * receiver argument.
* The <tt>CALL</tt> operation is allowed to be used with a
* {@link NamedOperation} even though it does not take a name. Using it with
* a named operation won't affect its signature; the name is solely meant to
@@ -164,8 +125,8 @@
*/
CALL,
/**
- * Calls a constructor object. Call sites with this operation should have a
- * signature of <tt>(receiver, arguments...)→value</tt>, with all
+ * Call a constructor object. Call sites with this operation should have a
+ * signature of <tt>(constructor, arguments...)→value</tt>, with all
* parameters and return type being of any type (either primitive or
* reference). The <tt>NEW</tt> operation is allowed to be used with a
* {@link NamedOperation} even though it does not take a name. Using it with
--- a/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/AbstractJavaLinker.java Wed Nov 09 15:20:30 2016 +0300
+++ b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/AbstractJavaLinker.java Wed Nov 09 10:04:43 2016 -0800
@@ -99,9 +99,11 @@
import java.util.Map;
import java.util.Set;
import jdk.dynalink.CallSiteDescriptor;
-import jdk.dynalink.CompositeOperation;
import jdk.dynalink.NamedOperation;
+import jdk.dynalink.Namespace;
+import jdk.dynalink.NamespaceOperation;
import jdk.dynalink.Operation;
+import jdk.dynalink.StandardNamespace;
import jdk.dynalink.StandardOperation;
import jdk.dynalink.beans.GuardedInvocationComponent.ValidationType;
import jdk.dynalink.internal.InternalTypeUtilities;
@@ -360,22 +362,6 @@
directLinkerServices = linkerServices;
}
- // Handle NamedOperation(CALL_METHOD, name) separately
- final Operation operation = callSiteDescriptor.getOperation();
- if (operation instanceof NamedOperation) {
- final NamedOperation namedOperation = (NamedOperation)operation;
- if (namedOperation.getBaseOperation() == StandardOperation.CALL_METHOD) {
- final GuardedInvocation inv =
- createGuardedDynamicMethodInvocation(callSiteDescriptor,
- directLinkerServices, namedOperation.getName().toString(), methods);
- if (inv == null) {
- return createNoSuchMemberHandler(missingMemberHandlerFactory,
- request, directLinkerServices).getGuardedInvocation();
- }
- return inv;
- }
- }
-
final GuardedInvocationComponent gic = getGuardedInvocationComponent(
new ComponentLinkRequest(request, directLinkerServices,
missingMemberHandlerFactory));
@@ -386,7 +372,8 @@
final LinkRequest linkRequest;
final LinkerServices linkerServices;
final MissingMemberHandlerFactory missingMemberHandlerFactory;
- final List<Operation> operations;
+ final Operation baseOperation;
+ final List<Namespace> namespaces;
final Object name;
ComponentLinkRequest(final LinkRequest linkRequest,
@@ -395,21 +382,22 @@
this.linkRequest = linkRequest;
this.linkerServices = linkerServices;
this.missingMemberHandlerFactory = missingMemberHandlerFactory;
- final Operation operation = linkRequest.getCallSiteDescriptor().getOperation();
- this.operations = Arrays.asList(
- CompositeOperation.getOperations(
- NamedOperation.getBaseOperation(operation)));
- this.name = NamedOperation.getName(operation);
+ final Operation namedOp = linkRequest.getCallSiteDescriptor().getOperation();
+ this.name = NamedOperation.getName(namedOp);
+ final Operation namespaceOp = NamedOperation.getBaseOperation(namedOp);
+ this.baseOperation = NamespaceOperation.getBaseOperation(namespaceOp);
+ this.namespaces = Arrays.asList(NamespaceOperation.getNamespaces(namespaceOp));
}
private ComponentLinkRequest(final LinkRequest linkRequest,
final LinkerServices linkerServices,
final MissingMemberHandlerFactory missingMemberHandlerFactory,
- final List<Operation> operations, final Object name) {
+ final Operation baseOperation, final List<Namespace> namespaces, final Object name) {
this.linkRequest = linkRequest;
this.linkerServices = linkerServices;
this.missingMemberHandlerFactory = missingMemberHandlerFactory;
- this.operations = operations;
+ this.baseOperation = baseOperation;
+ this.namespaces = namespaces;
this.name = name;
}
@@ -417,29 +405,33 @@
return linkRequest.getCallSiteDescriptor();
}
- ComponentLinkRequest popOperations() {
+ ComponentLinkRequest popNamespace() {
return new ComponentLinkRequest(linkRequest, linkerServices,
- missingMemberHandlerFactory,
- operations.subList(1, operations.size()), name);
+ missingMemberHandlerFactory, baseOperation,
+ namespaces.subList(1, namespaces.size()), name);
}
}
protected GuardedInvocationComponent getGuardedInvocationComponent(final ComponentLinkRequest req)
throws Exception {
- final Operation op = req.operations.get(0);
- if (op instanceof StandardOperation) {
- switch((StandardOperation)op) {
- case GET_PROPERTY: return getPropertyGetter(req.popOperations());
- case SET_PROPERTY: return getPropertySetter(req.popOperations());
- case GET_METHOD: return getMethodGetter(req.popOperations());
- default:
+ if (!req.namespaces.isEmpty()) {
+ final Namespace ns = req.namespaces.get(0);
+ final Operation op = req.baseOperation;
+ if (op == StandardOperation.GET) {
+ if (ns == StandardNamespace.PROPERTY) {
+ return getPropertyGetter(req.popNamespace());
+ } else if (ns == StandardNamespace.METHOD) {
+ return getMethodGetter(req.popNamespace());
+ }
+ } else if (op == StandardOperation.SET && ns == StandardNamespace.PROPERTY) {
+ return getPropertySetter(req.popNamespace());
}
}
return null;
}
GuardedInvocationComponent getNextComponent(final ComponentLinkRequest req) throws Exception {
- if (req.operations.isEmpty()) {
+ if (req.namespaces.isEmpty()) {
return createNoSuchMemberHandler(req.missingMemberHandlerFactory,
req.linkRequest, req.linkerServices);
}
@@ -447,7 +439,7 @@
if (gic != null) {
return gic;
}
- return getNextComponent(req.popOperations());
+ return getNextComponent(req.popNamespace());
}
private GuardedInvocationComponent createNoSuchMemberHandler(
@@ -626,8 +618,7 @@
if(gi != null) {
return new GuardedInvocationComponent(gi, clazz, ValidationType.EXACT_CLASS);
}
- // If we don't have a property setter with this name, always fall back to the next operation in the
- // composite (if any)
+ // If we don't have a property setter with this name, always fall back to the next namespace (if any).
return getNextComponent(req);
}
@@ -808,8 +799,8 @@
// We have no such method, always delegate to the next component
return getNextComponent(req);
}
- // No delegation to the next component of the composite operation; if we have a method with that name,
- // we'll always return it at this point.
+ // No delegation to the next namespace; if we have a method with that name, we'll always return it at
+ // this point.
final MethodType type = getMethodGetterType(req);
return getClassGuardedInvocationComponent(req.linkerServices.asType(MethodHandles.dropArguments(
MethodHandles.constant(Object.class, method), 0, type.parameterType(0)), type), type);
@@ -880,7 +871,7 @@
@SuppressWarnings("unused")
// This method is marked to return Object instead of DynamicMethod as it's used as a linking component and we don't
// want to make the DynamicMethod type observable externally (e.g. as the return type of a MethodHandle returned for
- // GET_METHOD linking).
+ // GET:METHOD linking).
private Object getDynamicMethod(final Object name) {
return getDynamicMethod(String.valueOf(name), methods);
}
--- a/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/BeanLinker.java Wed Nov 09 15:20:30 2016 +0300
+++ b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/BeanLinker.java Wed Nov 09 10:04:43 2016 -0800
@@ -92,7 +92,9 @@
import java.util.List;
import java.util.Map;
import jdk.dynalink.CallSiteDescriptor;
+import jdk.dynalink.Namespace;
import jdk.dynalink.Operation;
+import jdk.dynalink.StandardNamespace;
import jdk.dynalink.StandardOperation;
import jdk.dynalink.beans.GuardedInvocationComponent.ValidationType;
import jdk.dynalink.linker.GuardedInvocation;
@@ -112,10 +114,11 @@
if(clazz.isArray()) {
// Some languages won't have a notion of manipulating collections. Exposing "length" on arrays as an
// explicit property is beneficial for them.
- // REVISIT: is it maybe a code smell that StandardOperation.GET_LENGTH is not needed?
setPropertyGetter("length", MethodHandles.arrayLength(clazz), ValidationType.EXACT_CLASS);
- } else if(List.class.isAssignableFrom(clazz)) {
+ } else if(Collection.class.isAssignableFrom(clazz)) {
setPropertyGetter("length", GET_COLLECTION_LENGTH, ValidationType.INSTANCE_OF);
+ } else if(Map.class.isAssignableFrom(clazz)) {
+ setPropertyGetter("length", GET_MAP_LENGTH, ValidationType.INSTANCE_OF);
}
}
@@ -135,14 +138,14 @@
if(superGic != null) {
return superGic;
}
- if (!req.operations.isEmpty()) {
- final Operation op = req.operations.get(0);
- if (op instanceof StandardOperation) {
- switch ((StandardOperation)op) {
- case GET_ELEMENT: return getElementGetter(req.popOperations());
- case SET_ELEMENT: return getElementSetter(req.popOperations());
- case GET_LENGTH: return getLengthGetter(req.getDescriptor());
- default:
+ if (!req.namespaces.isEmpty()) {
+ final Operation op = req.baseOperation;
+ final Namespace ns = req.namespaces.get(0);
+ if (ns == StandardNamespace.ELEMENT) {
+ if (op == StandardOperation.GET) {
+ return getElementGetter(req.popNamespace());
+ } else if (op == StandardOperation.SET) {
+ return getElementSetter(req.popNamespace());
}
}
}
@@ -524,38 +527,6 @@
private static final MethodHandle GET_MAP_LENGTH = Lookup.PUBLIC.findVirtual(Map.class, "size",
MethodType.methodType(int.class));
- private static final MethodHandle COLLECTION_GUARD = Guards.getInstanceOfGuard(Collection.class);
-
- private GuardedInvocationComponent getLengthGetter(final CallSiteDescriptor callSiteDescriptor) {
- assertParameterCount(callSiteDescriptor, 1);
- final MethodType callSiteType = callSiteDescriptor.getMethodType();
- final Class<?> declaredType = callSiteType.parameterType(0);
- // If declared type of receiver at the call site is already an array, collection, or map, bind without guard.
- // Thing is, it'd be quite stupid of a call site creator to go though invokedynamic when it knows in advance
- // they're dealing with an array, collection, or map, but hey...
- if(declaredType.isArray()) {
- return new GuardedInvocationComponent(MethodHandles.arrayLength(declaredType).asType(callSiteType));
- } else if(Collection.class.isAssignableFrom(declaredType)) {
- return new GuardedInvocationComponent(GET_COLLECTION_LENGTH.asType(callSiteType));
- } else if(Map.class.isAssignableFrom(declaredType)) {
- return new GuardedInvocationComponent(GET_MAP_LENGTH.asType(callSiteType));
- }
-
- // Otherwise, create a binding based on the actual type of the argument with an appropriate guard.
- if(clazz.isArray()) {
- return new GuardedInvocationComponent(MethodHandles.arrayLength(clazz).asType(callSiteType),
- Guards.isArray(0, callSiteType), ValidationType.EXACT_CLASS);
- } if(Collection.class.isAssignableFrom(clazz)) {
- return new GuardedInvocationComponent(GET_COLLECTION_LENGTH.asType(callSiteType), Guards.asType(
- COLLECTION_GUARD, callSiteType), Collection.class, ValidationType.INSTANCE_OF);
- } if(Map.class.isAssignableFrom(clazz)) {
- return new GuardedInvocationComponent(GET_MAP_LENGTH.asType(callSiteType), Guards.asType(MAP_GUARD,
- callSiteType), Map.class, ValidationType.INSTANCE_OF);
- }
- // Can't retrieve length for objects that are neither arrays, nor collections, nor maps.
- return null;
- }
-
private static void assertParameterCount(final CallSiteDescriptor descriptor, final int paramCount) {
if(descriptor.getMethodType().parameterCount() != paramCount) {
throw new BootstrapMethodError(descriptor.getOperation() + " must have exactly " + paramCount + " parameters.");
--- a/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/BeansLinker.java Wed Nov 09 15:20:30 2016 +0300
+++ b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/BeansLinker.java Wed Nov 09 10:04:43 2016 -0800
@@ -87,6 +87,7 @@
import java.util.Collections;
import java.util.Set;
import jdk.dynalink.DynamicLinkerFactory;
+import jdk.dynalink.StandardNamespace;
import jdk.dynalink.StandardOperation;
import jdk.dynalink.linker.GuardedInvocation;
import jdk.dynalink.linker.GuardingDynamicLinker;
@@ -102,21 +103,18 @@
* <ul>
* <li>expose all public methods of form {@code setXxx()}, {@code getXxx()},
* and {@code isXxx()} as property setters and getters for
- * {@link StandardOperation#SET_PROPERTY} and {@link StandardOperation#GET_PROPERTY}
- * operations;</li>
- * <li>expose all public methods for invocation through
- * {@link StandardOperation#CALL_METHOD} operation;</li>
+ * {@link StandardOperation#SET} and {@link StandardOperation#GET} operations in the
+ * {@link StandardNamespace#PROPERTY} namespace;</li>
* <li>expose all public methods for retrieval for
- * {@link StandardOperation#GET_METHOD} operation; the methods thus retrieved
- * can then be invoked using {@link StandardOperation#CALL}.</li>
+ * {@link StandardOperation#GET} operation in the {@link StandardNamespace#METHOD} namespace;
+ * the methods thus retrieved can then be invoked using {@link StandardOperation#CALL}.</li>
* <li>expose all public fields as properties, unless there are getters or
* setters for the properties of the same name;</li>
- * <li>expose {@link StandardOperation#GET_LENGTH},
- * {@link StandardOperation#GET_ELEMENT} and {@link StandardOperation#SET_ELEMENT}
- * on native Java arrays, as well as {@link java.util.List} and
- * {@link java.util.Map} objects; ({@link StandardOperation#GET_LENGTH} works on
- * any {@link java.util.Collection});</li>
- * <li>expose a virtual property named {@code length} on Java arrays;</li>
+ * <li> expose elements of native Java arrays, {@link java.util.List} and {@link java.util.Map} objects as
+ * {@link StandardOperation#GET} and {@link StandardOperation#SET} operations in the
+ * {@link StandardNamespace#ELEMENT} namespace;</li>
+ * <li>expose a virtual property named {@code length} on Java arrays, {@link java.util.Collection} and
+ * {@link java.util.Map} objects;</li>
* <li>expose {@link StandardOperation#NEW} on instances of {@link StaticClass}
* as calls to constructors, including those static class objects that represent
* Java arrays (their constructors take a single {@code int} parameter
@@ -130,10 +128,10 @@
* <p><strong>Overloaded method resolution</strong> is performed automatically
* for property setters, methods, and constructors. Additionally, manual
* overloaded method selection is supported by having a call site specify a name
- * for a method that contains an explicit signature, i.e.
- * {@code NamedMethod(GET_METHOD, "parseInt(String,int)")}. You can use
- * non-qualified class names in such signatures regardless of those classes'
- * packages, they will match any class with the same non-qualified name. You
+ * for a method that contains an explicit signature, e.g.
+ * {@code StandardOperation.GET.withNamespace(METHOD).named("parseInt(String,int)")}
+ * You can use non-qualified class names in such signatures regardless of those
+ * classes' packages, they will match any class with the same non-qualified name. You
* only have to use a fully qualified class name in case non-qualified class
* names would cause selection ambiguity (that is extremely rare). Overloaded
* resolution for constructors is not automatic as there is no logical place to
@@ -235,7 +233,7 @@
/**
* Returns true if the object is a Java dynamic method (e.g., one
- * obtained through a {@code GET_METHOD} operation on a Java object or
+ * obtained through a {@code GET:METHOD} operation on a Java object or
* {@link StaticClass} or through
* {@link #getConstructorMethod(Class, String)}.
*
--- a/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/DynamicMethodLinker.java Wed Nov 09 15:20:30 2016 +0300
+++ b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/DynamicMethodLinker.java Wed Nov 09 10:04:43 2016 -0800
@@ -88,6 +88,7 @@
import jdk.dynalink.CallSiteDescriptor;
import jdk.dynalink.NamedOperation;
import jdk.dynalink.Operation;
+import jdk.dynalink.StandardNamespace;
import jdk.dynalink.StandardOperation;
import jdk.dynalink.linker.GuardedInvocation;
import jdk.dynalink.linker.LinkRequest;
@@ -98,7 +99,8 @@
/**
* Simple linker that implements the {@link StandardOperation#CALL} operation
* for {@link DynamicMethod} objects - the objects returned by
- * {@link StandardOperation#GET_METHOD} through {@link AbstractJavaLinker}.
+ * {@link StandardOperation#GET} on {@link StandardNamespace#METHOD} namespace through
+ * {@link AbstractJavaLinker}.
*/
class DynamicMethodLinker implements TypeBasedGuardingDynamicLinker {
@Override
--- a/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/GuardedInvocationComponent.java Wed Nov 09 15:20:30 2016 +0300
+++ b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/GuardedInvocationComponent.java Wed Nov 09 10:04:43 2016 -0800
@@ -87,7 +87,7 @@
import jdk.dynalink.linker.GuardedInvocation;
/**
- * Represents one component for a GuardedInvocation of a potentially composite operation of an
+ * Represents one component for a GuardedInvocation of a potentially multi-namespace operation of an
* {@link AbstractJavaLinker}. In addition to holding a guarded invocation, it holds semantic information about its
* guard. All guards produced in the AbstractJavaLinker are either "Class.isInstance()" or "getClass() == clazz"
* expressions. This allows choosing the most restrictive guard as the guard for the composition of two components.
--- a/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/StaticClass.java Wed Nov 09 15:20:30 2016 +0300
+++ b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/StaticClass.java Wed Nov 09 10:04:43 2016 -0800
@@ -92,7 +92,7 @@
* methods, properties, and fields), as well as construction of instances using
* {@link StandardOperation#NEW} operation. In Dynalink, {@link Class} objects
* are not treated specially and act as ordinary Java objects; you can use e.g.
- * {@code NamedOperation(GET_PROPERTY, "superclass")} as a property getter to
+ * {@code GET:PROPERTY:superclass} as a property getter to
* invoke {@code clazz.getSuperclass()}. On the other hand, you can not use
* {@code Class} objects to access static members of a class, nor to create new
* instances of the class using {@code NEW}. This is consistent with how
--- a/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/StaticClassLinker.java Wed Nov 09 15:20:30 2016 +0300
+++ b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/StaticClassLinker.java Wed Nov 09 10:04:43 2016 -0800
@@ -91,7 +91,7 @@
import java.util.Set;
import jdk.dynalink.CallSiteDescriptor;
import jdk.dynalink.NamedOperation;
-import jdk.dynalink.Operation;
+import jdk.dynalink.StandardNamespace;
import jdk.dynalink.StandardOperation;
import jdk.dynalink.beans.GuardedInvocationComponent.ValidationType;
import jdk.dynalink.linker.GuardedInvocation;
@@ -168,17 +168,12 @@
if (superGic != null) {
return superGic;
}
- if (!req.operations.isEmpty()) {
- final Operation op = req.operations.get(0);
- if (op instanceof StandardOperation) {
- switch ((StandardOperation)op) {
- case GET_ELEMENT:
- case SET_ELEMENT:
- // StaticClass doesn't behave as a collection
- return getNextComponent(req.popOperations());
- default:
- }
- }
+ if (!req.namespaces.isEmpty()
+ && req.namespaces.get(0) == StandardNamespace.ELEMENT
+ && (req.baseOperation == StandardOperation.GET || req.baseOperation == StandardOperation.SET))
+ {
+ // StaticClass doesn't behave as a collection
+ return getNextComponent(req.popNamespace());
}
return null;
}
--- a/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/package-info.java Wed Nov 09 15:20:30 2016 +0300
+++ b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/package-info.java Wed Nov 09 10:04:43 2016 -0800
@@ -129,7 +129,7 @@
* bytecode would look something like this:
* <pre>
* aload 2 // load "obj" on stack
- * invokedynamic "GET_PROPERTY:color"(Object)Object // invoke property getter on object of unknown type
+ * invokedynamic "GET:PROPERTY:color"(Object)Object // invoke property getter on object of unknown type
* astore 3 // store the return value into local variable "color"
* </pre>
* In order to link the {@code invokedynamic} instruction, we need a bootstrap
@@ -175,9 +175,9 @@
* dynamic operations. It does not prescribe how would you encode the operations
* in your call site, though. That is why in the above example the
* {@code parseOperation} function is left empty, and you would be expected to
- * provide the code to parse the string {@code "GET_PROPERTY:color"}
+ * provide the code to parse the string {@code "GET:PROPERTY:color"}
* in the call site's name into a named property getter operation object as
- * {@code new NamedOperation(StandardOperation.GET_PROPERTY), "color")}.
+ * {@code StandardOperation.GET.withNamespace(StandardNamespace.PROPERTY).named("color")}.
* </ul>
* <p>What can you already do with the above setup? {@code DynamicLinkerFactory}
* by default creates a {@code DynamicLinker} that can link Java objects with the
@@ -231,18 +231,20 @@
* Dynalink defines several standard operations in its
* {@link jdk.dynalink.StandardOperation} class. The linker for Java
* objects can link all of these operations, and you are encouraged to at
- * minimum support and use these operations in your language too. To associate
- * a fixed name with an operation, you can use
- * {@link jdk.dynalink.NamedOperation} as in the above example where
- * {@code StandardOperation.GET_PROPERTY} was combined with the name
- * {@code "color"} in a {@code NamedOperation} to form a property getter for the
- * property named "color".
- * <h2>Composite operations</h2>
+ * minimum support and use these operations in your language too. The
+ * standard operations {@code GET} and {@code SET} need to be combined with
+ * at least one {@link jdk.dynalink.Namespace} to be useful, e.g. to express a
+ * property getter, you'd use {@code StandardOperation.GET.withNamespace(StandardNamespace.PROPERTY)}.
+ * Dynalink defines three standard namespaces in the {@link jdk.dynalink.StandardNamespace} class.
+ * To associate a fixed name with an operation, you can use
+ * {@link jdk.dynalink.NamedOperation} as in the previous example:
+ * {@code StandardOperation.GET.withNamespace(StandardNamespace.PROPERTY).named("color")}
+ * expresses a getter for the property named "color".
+ * <h2>Operations on multiple namespaces</h2>
* Some languages might not have separate namespaces on objects for
* properties, elements, and methods, and a source language construct might
- * address two or three of them. Dynalink supports specifying composite
- * operations for this purpose using the
- * {@link jdk.dynalink.CompositeOperation} class.
+ * address several of them at once. Dynalink supports specifying multiple
+ * {@link jdk.dynalink.Namespace} objects with {@link jdk.dynalink.NamespaceOperation}.
* <h2>Language-specific linkers</h2>
* Languages that define their own object model different than the JVM
* class-based model and/or use their own type conversions will need to create
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/AssignSymbols.java Wed Nov 09 15:20:30 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/AssignSymbols.java Wed Nov 09 10:04:43 2016 -0800
@@ -343,7 +343,7 @@
symbol = null;
} else if (symbol.isParam()) {
// Duplicate parameter. Null return will force an error.
- throw new AssertionError("duplicate parameter");
+ throwParserException(ECMAErrors.getMessage("syntax.error.duplicate.parameter", name), origin);
}
} else if (isVar) {
if (isBlockScope) {
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/Lower.java Wed Nov 09 15:20:30 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/Lower.java Wed Nov 09 10:04:43 2016 -0800
@@ -45,6 +45,7 @@
import jdk.nashorn.internal.ir.CallNode;
import jdk.nashorn.internal.ir.CaseNode;
import jdk.nashorn.internal.ir.CatchNode;
+import jdk.nashorn.internal.ir.ClassNode;
import jdk.nashorn.internal.ir.ContinueNode;
import jdk.nashorn.internal.ir.DebuggerNode;
import jdk.nashorn.internal.ir.EmptyNode;
@@ -60,9 +61,11 @@
import jdk.nashorn.internal.ir.LabelNode;
import jdk.nashorn.internal.ir.LexicalContext;
import jdk.nashorn.internal.ir.LiteralNode;
+import jdk.nashorn.internal.ir.LiteralNode.ArrayLiteralNode;
import jdk.nashorn.internal.ir.LiteralNode.PrimitiveLiteralNode;
import jdk.nashorn.internal.ir.LoopNode;
import jdk.nashorn.internal.ir.Node;
+import jdk.nashorn.internal.ir.ObjectNode;
import jdk.nashorn.internal.ir.ReturnNode;
import jdk.nashorn.internal.ir.RuntimeNode;
import jdk.nashorn.internal.ir.Statement;
@@ -70,6 +73,7 @@
import jdk.nashorn.internal.ir.Symbol;
import jdk.nashorn.internal.ir.ThrowNode;
import jdk.nashorn.internal.ir.TryNode;
+import jdk.nashorn.internal.ir.UnaryNode;
import jdk.nashorn.internal.ir.VarNode;
import jdk.nashorn.internal.ir.WhileNode;
import jdk.nashorn.internal.ir.WithNode;
@@ -78,6 +82,8 @@
import jdk.nashorn.internal.parser.Token;
import jdk.nashorn.internal.parser.TokenType;
import jdk.nashorn.internal.runtime.Context;
+import jdk.nashorn.internal.runtime.ECMAErrors;
+import jdk.nashorn.internal.runtime.ErrorManager;
import jdk.nashorn.internal.runtime.JSType;
import jdk.nashorn.internal.runtime.Source;
import jdk.nashorn.internal.runtime.logging.DebugLogger;
@@ -98,6 +104,7 @@
private final DebugLogger log;
private final boolean es6;
+ private final Source source;
// Conservative pattern to test if element names consist of characters valid for identifiers.
// This matches any non-zero length alphanumeric string including _ and $ and not starting with a digit.
@@ -146,6 +153,7 @@
this.log = initLogger(compiler.getContext());
this.es6 = compiler.getScriptEnvironment()._es6;
+ this.source = compiler.getSource();
}
@Override
@@ -241,6 +249,10 @@
}
}
+ if (es6 && expressionStatement.destructuringDeclarationType() != null) {
+ throwNotImplementedYet("es6.destructuring", expressionStatement);
+ }
+
return addStatement(node);
}
@@ -250,6 +262,14 @@
}
@Override
+ public boolean enterForNode(final ForNode forNode) {
+ if (es6 && (forNode.getInit() instanceof ObjectNode || forNode.getInit() instanceof ArrayLiteralNode)) {
+ throwNotImplementedYet("es6.destructuring", forNode);
+ }
+ return super.enterForNode(forNode);
+ }
+
+ @Override
public Node leaveForNode(final ForNode forNode) {
ForNode newForNode = forNode;
@@ -270,6 +290,37 @@
}
@Override
+ public boolean enterFunctionNode(final FunctionNode functionNode) {
+ if (es6) {
+ if (functionNode.getKind() == FunctionNode.Kind.MODULE) {
+ throwNotImplementedYet("es6.module", functionNode);
+ }
+
+ if (functionNode.getKind() == FunctionNode.Kind.GENERATOR) {
+ throwNotImplementedYet("es6.generator", functionNode);
+ }
+ if (functionNode.usesSuper()) {
+ throwNotImplementedYet("es6.super", functionNode);
+ }
+
+ final int numParams = functionNode.getNumOfParams();
+ if (numParams > 0) {
+ final IdentNode lastParam = functionNode.getParameter(numParams - 1);
+ if (lastParam.isRestParameter()) {
+ throwNotImplementedYet("es6.rest.param", lastParam);
+ }
+ }
+ for (final IdentNode param : functionNode.getParameters()) {
+ if (param.isDestructuredParameter()) {
+ throwNotImplementedYet("es6.destructuring", functionNode);
+ }
+ }
+ }
+
+ return super.enterFunctionNode(functionNode);
+ }
+
+ @Override
public Node leaveFunctionNode(final FunctionNode functionNode) {
log.info("END FunctionNode: ", functionNode.getName());
return functionNode;
@@ -578,6 +629,29 @@
}
@Override
+ public boolean enterUnaryNode(final UnaryNode unaryNode) {
+ if (es6) {
+ if (unaryNode.isTokenType(TokenType.YIELD) ||
+ unaryNode.isTokenType(TokenType.YIELD_STAR)) {
+ throwNotImplementedYet("es6.yield", unaryNode);
+ } else if (unaryNode.isTokenType(TokenType.SPREAD_ARGUMENT) ||
+ unaryNode.isTokenType(TokenType.SPREAD_ARRAY)) {
+ throwNotImplementedYet("es6.spread", unaryNode);
+ }
+ }
+
+ return super.enterUnaryNode(unaryNode);
+ }
+
+ @Override
+ public boolean enterASSIGN(BinaryNode binaryNode) {
+ if (es6 && (binaryNode.lhs() instanceof ObjectNode || binaryNode.lhs() instanceof ArrayLiteralNode)) {
+ throwNotImplementedYet("es6.destructuring", binaryNode);
+ }
+ return super.enterASSIGN(binaryNode);
+ }
+
+ @Override
public Node leaveVarNode(final VarNode varNode) {
addStatement(varNode);
if (varNode.getFlag(VarNode.IS_LAST_FUNCTION_DECLARATION)
@@ -608,6 +682,12 @@
return addStatement(withNode);
}
+ @Override
+ public boolean enterClassNode(final ClassNode classNode) {
+ throwNotImplementedYet("es6.class", classNode);
+ return super.enterClassNode(classNode);
+ }
+
/**
* Given a function node that is a callee in a CallNode, replace it with
* the appropriate marker function. This is used by {@link CodeGenerator}
@@ -766,4 +846,13 @@
}
return false;
}
+
+ private void throwNotImplementedYet(final String msgId, final Node node) {
+ final long token = node.getToken();
+ final int line = source.getLine(node.getStart());
+ final int column = source.getColumn(node.getStart());
+ final String message = ECMAErrors.getMessage("unimplemented." + msgId);
+ final String formatted = ErrorManager.format(message, source, line, column, token);
+ throw new RuntimeException(formatted);
+ }
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/visitor/NodeOperatorVisitor.java Wed Nov 09 15:20:30 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/visitor/NodeOperatorVisitor.java Wed Nov 09 10:04:43 2016 -0800
@@ -45,7 +45,7 @@
}
@Override
- public final boolean enterUnaryNode(final UnaryNode unaryNode) {
+ public boolean enterUnaryNode(final UnaryNode unaryNode) {
switch (unaryNode.tokenType()) {
case ADD:
return enterADD(unaryNode);
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/Global.java Wed Nov 09 15:20:30 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/Global.java Wed Nov 09 10:04:43 2016 -0800
@@ -48,7 +48,6 @@
import javax.script.ScriptContext;
import javax.script.ScriptEngine;
import jdk.dynalink.CallSiteDescriptor;
-import jdk.dynalink.StandardOperation;
import jdk.dynalink.linker.GuardedInvocation;
import jdk.dynalink.linker.LinkRequest;
import jdk.nashorn.api.scripting.ClassFilter;
@@ -2449,17 +2448,17 @@
}
@Override
- public GuardedInvocation findGetMethod(final CallSiteDescriptor desc, final LinkRequest request, final StandardOperation operation) {
+ public GuardedInvocation findGetMethod(final CallSiteDescriptor desc, final LinkRequest request) {
final String name = NashornCallSiteDescriptor.getOperand(desc);
final boolean isScope = NashornCallSiteDescriptor.isScope(desc);
if (lexicalScope != null && isScope && !NashornCallSiteDescriptor.isApplyToCall(desc)) {
if (lexicalScope.hasOwnProperty(name)) {
- return lexicalScope.findGetMethod(desc, request, operation);
+ return lexicalScope.findGetMethod(desc, request);
}
}
- final GuardedInvocation invocation = super.findGetMethod(desc, request, operation);
+ final GuardedInvocation invocation = super.findGetMethod(desc, request);
// We want to avoid adding our generic lexical scope switchpoint to global constant invocations,
// because those are invalidated per-key in the addBoundProperties method above.
@@ -3061,8 +3060,8 @@
}
@Override
- protected GuardedInvocation findGetMethod(final CallSiteDescriptor desc, final LinkRequest request, final StandardOperation operation) {
- return filterInvocation(super.findGetMethod(desc, request, operation));
+ protected GuardedInvocation findGetMethod(final CallSiteDescriptor desc, final LinkRequest request) {
+ return filterInvocation(super.findGetMethod(desc, request));
}
@Override
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeJSAdapter.java Wed Nov 09 15:20:30 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeJSAdapter.java Wed Nov 09 10:04:43 2016 -0800
@@ -37,7 +37,6 @@
import java.util.Iterator;
import java.util.List;
import jdk.dynalink.CallSiteDescriptor;
-import jdk.dynalink.StandardOperation;
import jdk.dynalink.linker.GuardedInvocation;
import jdk.dynalink.linker.LinkRequest;
import jdk.nashorn.internal.lookup.Lookup;
@@ -365,7 +364,7 @@
Object obj;
if (func instanceof ScriptFunction) {
- obj = ScriptRuntime.apply((ScriptFunction)func, adaptee);
+ obj = ScriptRuntime.apply((ScriptFunction)func, this);
} else {
obj = new NativeArray(0);
}
@@ -473,11 +472,11 @@
}
@Override
- protected GuardedInvocation findGetMethod(final CallSiteDescriptor desc, final LinkRequest request, final StandardOperation operation) {
+ protected GuardedInvocation findGetMethod(final CallSiteDescriptor desc, final LinkRequest request) {
final String name = NashornCallSiteDescriptor.getOperand(desc);
if (overrides && super.hasOwnProperty(name)) {
try {
- final GuardedInvocation inv = super.findGetMethod(desc, request, operation);
+ final GuardedInvocation inv = super.findGetMethod(desc, request);
if (inv != null) {
return inv;
}
@@ -486,11 +485,9 @@
}
}
- switch(operation) {
- case GET_PROPERTY:
- case GET_ELEMENT:
+ if (!NashornCallSiteDescriptor.isMethodFirstOperation(desc)) {
return findHook(desc, __get__);
- case GET_METHOD:
+ } else {
final FindProperty find = adaptee.findProperty(__call__, true);
if (find != null) {
final Object value = find.getObjectValue();
@@ -505,11 +502,7 @@
}
}
throw typeError("no.such.function", name, ScriptRuntime.safeToString(this));
- default:
- break;
}
-
- throw new AssertionError("should not reach here");
}
@Override
@@ -544,7 +537,7 @@
private Object callAdaptee(final Object retValue, final String name, final Object... args) {
final Object func = adaptee.get(name);
if (func instanceof ScriptFunction) {
- return ScriptRuntime.apply((ScriptFunction)func, adaptee, args);
+ return ScriptRuntime.apply((ScriptFunction)func, this, args);
}
return retValue;
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeObject.java Wed Nov 09 15:20:30 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeObject.java Wed Nov 09 10:04:43 2016 -0800
@@ -25,6 +25,10 @@
package jdk.nashorn.internal.objects;
+import static jdk.dynalink.StandardNamespace.METHOD;
+import static jdk.dynalink.StandardNamespace.PROPERTY;
+import static jdk.dynalink.StandardOperation.GET;
+import static jdk.dynalink.StandardOperation.SET;
import static jdk.nashorn.internal.lookup.Lookup.MH;
import static jdk.nashorn.internal.runtime.ECMAErrors.typeError;
import static jdk.nashorn.internal.runtime.ScriptRuntime.UNDEFINED;
@@ -40,9 +44,7 @@
import java.util.Set;
import java.util.concurrent.Callable;
import jdk.dynalink.CallSiteDescriptor;
-import jdk.dynalink.NamedOperation;
import jdk.dynalink.Operation;
-import jdk.dynalink.StandardOperation;
import jdk.dynalink.beans.BeansLinker;
import jdk.dynalink.beans.StaticClass;
import jdk.dynalink.linker.GuardedInvocation;
@@ -97,6 +99,10 @@
});
}
+ private static final Operation GET_METHOD = GET.withNamespace(METHOD);
+ private static final Operation GET_PROPERTY = GET.withNamespace(PROPERTY);
+ private static final Operation SET_PROPERTY = SET.withNamespace(PROPERTY);
+
@SuppressWarnings("unused")
private static ScriptObject get__proto__(final Object self) {
// See ES6 draft spec: B.2.2.1.1 get Object.prototype.__proto__
@@ -782,7 +788,7 @@
for(final String methodName: methodNames) {
final MethodHandle method;
try {
- method = getBeanOperation(linker, StandardOperation.GET_METHOD, methodName, getterType, source);
+ method = getBeanOperation(linker, GET_METHOD, methodName, getterType, source);
} catch(final IllegalAccessError e) {
// Presumably, this was a caller sensitive method. Ignore it and carry on.
continue;
@@ -794,7 +800,7 @@
MethodHandle getter;
if(readablePropertyNames.contains(propertyName)) {
try {
- getter = getBeanOperation(linker, StandardOperation.GET_PROPERTY, propertyName, getterType, source);
+ getter = getBeanOperation(linker, GET_PROPERTY, propertyName, getterType, source);
} catch(final IllegalAccessError e) {
// Presumably, this was a caller sensitive method. Ignore it and carry on.
getter = Lookup.EMPTY_GETTER;
@@ -806,7 +812,7 @@
MethodHandle setter;
if(isWritable) {
try {
- setter = getBeanOperation(linker, StandardOperation.SET_PROPERTY, propertyName, setterType, source);
+ setter = getBeanOperation(linker, SET_PROPERTY, propertyName, setterType, source);
} catch(final IllegalAccessError e) {
// Presumably, this was a caller sensitive method. Ignore it and carry on.
setter = Lookup.EMPTY_SETTER;
@@ -836,11 +842,11 @@
}
}
- private static MethodHandle getBeanOperation(final GuardingDynamicLinker linker, final StandardOperation operation,
+ private static MethodHandle getBeanOperation(final GuardingDynamicLinker linker, final Operation operation,
final String name, final MethodType methodType, final Object source) {
final GuardedInvocation inv;
try {
- inv = NashornBeansLinker.getGuardedInvocation(linker, createLinkRequest(new NamedOperation(operation, name), methodType, source), Bootstrap.getLinkerServices());
+ inv = NashornBeansLinker.getGuardedInvocation(linker, createLinkRequest(operation.named(name), methodType, source), Bootstrap.getLinkerServices());
assert passesGuard(source, inv.getGuard());
} catch(RuntimeException|Error e) {
throw e;
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeString.java Wed Nov 09 15:20:30 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeString.java Wed Nov 09 10:04:43 2016 -0800
@@ -42,7 +42,6 @@
import java.util.Locale;
import java.util.Set;
import jdk.dynalink.CallSiteDescriptor;
-import jdk.dynalink.StandardOperation;
import jdk.dynalink.linker.GuardedInvocation;
import jdk.dynalink.linker.LinkRequest;
import jdk.nashorn.internal.lookup.MethodHandleFactory.LookupException;
@@ -127,15 +126,15 @@
// This is to support length as method call as well.
@Override
- protected GuardedInvocation findGetMethod(final CallSiteDescriptor desc, final LinkRequest request, final StandardOperation operation) {
+ protected GuardedInvocation findGetMethod(final CallSiteDescriptor desc, final LinkRequest request) {
final String name = NashornCallSiteDescriptor.getOperand(desc);
// if str.length(), then let the bean linker handle it
- if ("length".equals(name) && operation == StandardOperation.GET_METHOD) {
+ if ("length".equals(name) && NashornCallSiteDescriptor.isMethodFirstOperation(desc)) {
return null;
}
- return super.findGetMethod(desc, request, operation);
+ return super.findGetMethod(desc, request);
}
// This is to provide array-like access to string characters without creating a NativeString wrapper.
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/Parser.java Wed Nov 09 15:20:30 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/Parser.java Wed Nov 09 10:04:43 2016 -0800
@@ -1962,6 +1962,18 @@
switch (type) {
case SEMICOLON:
// for (init; test; modify)
+ if (varDeclList != null) {
+ assert init == null;
+ init = varDeclList.init;
+ // late check for missing assignment, now we know it's a for (init; test; modify) loop
+ if (varDeclList.missingAssignment != null) {
+ if (varDeclList.missingAssignment instanceof IdentNode) {
+ throw error(AbstractParser.message("missing.const.assignment", ((IdentNode)varDeclList.missingAssignment).getName()));
+ } else {
+ throw error(AbstractParser.message("missing.destructuring.assignment"), varDeclList.missingAssignment.getToken());
+ }
+ }
+ }
// for each (init; test; modify) is invalid
if ((flags & ForNode.IS_FOR_EACH) != 0) {
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptObject.java Wed Nov 09 15:20:30 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptObject.java Wed Nov 09 10:04:43 2016 -0800
@@ -67,7 +67,6 @@
import java.util.concurrent.atomic.LongAdder;
import jdk.dynalink.CallSiteDescriptor;
import jdk.dynalink.NamedOperation;
-import jdk.dynalink.StandardOperation;
import jdk.dynalink.linker.GuardedInvocation;
import jdk.dynalink.linker.LinkRequest;
import jdk.nashorn.internal.codegen.CompilerConstants.Call;
@@ -1858,23 +1857,16 @@
* @return GuardedInvocation for the callsite
*/
public GuardedInvocation lookup(final CallSiteDescriptor desc, final LinkRequest request) {
- // NOTE: we support GET_ELEMENT and SET_ELEMENT as JavaScript doesn't distinguish items from properties. Nashorn itself
- // emits "GET_PROPERTY|GET_ELEMENT|GET_METHOD:identifier" for "<expr>.<identifier>" and "GET_ELEMENT|GET_PROPERTY|GET_METHOD" for "<expr>[<expr>]", but we are
+ // NOTE: we support GET:ELEMENT and SET:ELEMENT as JavaScript doesn't distinguish items from properties. Nashorn itself
+ // emits "GET:PROPERTY|ELEMENT|METHOD:identifier" for "<expr>.<identifier>" and "GET:ELEMENT|PROPERTY|METHOD" for "<expr>[<expr>]", but we are
// more flexible here and dispatch not on operation name (getProp vs. getElem), but rather on whether the
// operation has an associated name or not.
- final StandardOperation op = NashornCallSiteDescriptor.getFirstStandardOperation(desc);
- if (op == null) {
- return null;
- }
- switch (op) {
- case GET_PROPERTY:
- case GET_ELEMENT:
- case GET_METHOD:
+ switch (NashornCallSiteDescriptor.getStandardOperation(desc)) {
+ case GET:
return desc.getOperation() instanceof NamedOperation
- ? findGetMethod(desc, request, op)
+ ? findGetMethod(desc, request)
: findGetIndexMethod(desc, request);
- case SET_PROPERTY:
- case SET_ELEMENT:
+ case SET:
return desc.getOperation() instanceof NamedOperation
? findSetMethod(desc, request)
: findSetIndexMethod(desc, request);
@@ -1883,8 +1875,8 @@
case NEW:
return findNewMethod(desc, request);
default:
+ return null;
}
- return null;
}
/**
@@ -1952,11 +1944,10 @@
*
* @param desc the call site descriptor
* @param request the link request
- * @param operation operation for get: getProp, getMethod, getElem etc
*
* @return GuardedInvocation to be invoked at call site.
*/
- protected GuardedInvocation findGetMethod(final CallSiteDescriptor desc, final LinkRequest request, final StandardOperation operation) {
+ protected GuardedInvocation findGetMethod(final CallSiteDescriptor desc, final LinkRequest request) {
final boolean explicitInstanceOfCheck = explicitInstanceOfCheck(desc, request);
String name = NashornCallSiteDescriptor.getOperand(desc);
@@ -1967,21 +1958,17 @@
}
if (request.isCallSiteUnstable() || hasWithScope()) {
- return findMegaMorphicGetMethod(desc, name, operation == StandardOperation.GET_METHOD);
+ return findMegaMorphicGetMethod(desc, name, NashornCallSiteDescriptor.isMethodFirstOperation(desc));
}
final FindProperty find = findProperty(name, true, NashornCallSiteDescriptor.isScope(desc), this);
MethodHandle mh;
if (find == null) {
- switch (operation) {
- case GET_ELEMENT: // getElem only gets here if element name is constant, so treat it like a property access
- case GET_PROPERTY:
+ if (!NashornCallSiteDescriptor.isMethodFirstOperation(desc)) {
return noSuchProperty(desc, request);
- case GET_METHOD:
+ } else {
return noSuchMethod(desc, request);
- default:
- throw new AssertionError(operation); // never invoked with any other operation
}
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/Undefined.java Wed Nov 09 15:20:30 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/Undefined.java Wed Nov 09 10:04:43 2016 -0800
@@ -32,7 +32,6 @@
import java.lang.invoke.MethodHandles;
import jdk.dynalink.CallSiteDescriptor;
import jdk.dynalink.NamedOperation;
-import jdk.dynalink.StandardOperation;
import jdk.dynalink.linker.GuardedInvocation;
import jdk.dynalink.linker.support.Guards;
import jdk.nashorn.internal.runtime.linker.NashornCallSiteDescriptor;
@@ -93,29 +92,22 @@
* @return GuardedInvocation to be invoked at call site.
*/
public static GuardedInvocation lookup(final CallSiteDescriptor desc) {
- final StandardOperation op = NashornCallSiteDescriptor.getFirstStandardOperation(desc);
- if (op == null) {
- return null;
- }
- switch (op) {
+ switch (NashornCallSiteDescriptor.getStandardOperation(desc)) {
case CALL:
case NEW:
final String name = NashornCallSiteDescriptor.getOperand(desc);
final String msg = name != null? "not.a.function" : "cant.call.undefined";
throw typeError(msg, name);
- case GET_PROPERTY:
- case GET_ELEMENT:
- case GET_METHOD:
- // NOTE: we support GET_ELEMENT and SET_ELEMENT as JavaScript doesn't distinguish items from properties. Nashorn itself
- // emits "GET_PROPERTY|GET_ELEMENT|GET_METHOD:identifier" for "<expr>.<identifier>" and "GET_ELEMENT|GET_PROPERTY|GET_METHOD" for "<expr>[<expr>]", but we are
+ case GET:
+ // NOTE: we support GET:ELEMENT and SET:ELEMENT as JavaScript doesn't distinguish items from properties. Nashorn itself
+ // emits "GET:PROPERTY|ELEMENT|METHOD:identifier" for "<expr>.<identifier>" and "GET:ELEMENT|PROPERTY|METHOD" for "<expr>[<expr>]", but we are
// more flexible here and dispatch not on operation name (getProp vs. getElem), but rather on whether the
// operation has an associated name or not.
if (!(desc.getOperation() instanceof NamedOperation)) {
return findGetIndexMethod(desc);
}
return findGetMethod(desc);
- case SET_PROPERTY:
- case SET_ELEMENT:
+ case SET:
if (!(desc.getOperation() instanceof NamedOperation)) {
return findSetIndexMethod(desc);
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/WithObject.java Wed Nov 09 15:20:30 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/WithObject.java Wed Nov 09 10:04:43 2016 -0800
@@ -97,9 +97,6 @@
return super.lookup(desc, request);
}
- // With scopes can never be observed outside of Nashorn code, so all call sites that can address it will of
- // necessity have a Nashorn descriptor - it is safe to cast.
- final NashornCallSiteDescriptor ndesc = (NashornCallSiteDescriptor)desc;
GuardedInvocation link = null;
final Operation op = desc.getOperation();
@@ -111,7 +108,7 @@
if (find != null) {
link = expression.lookup(desc, request);
if (link != null) {
- return fixExpressionCallSite(ndesc, link);
+ return fixExpressionCallSite(desc, link);
}
}
@@ -126,39 +123,30 @@
// __noSuchProperty__ and __noSuchMethod__ in expression
final String fallBack;
- final StandardOperation firstOp = ndesc.getFirstOperation();
- switch (firstOp) {
- case GET_METHOD:
- fallBack = NO_SUCH_METHOD_NAME;
- break;
- case GET_PROPERTY:
- case GET_ELEMENT:
- fallBack = NO_SUCH_PROPERTY_NAME;
- break;
- default:
+ final Operation firstOp = NashornCallSiteDescriptor.getBaseOperation(desc);
+ if (firstOp == StandardOperation.GET) {
+ if (NashornCallSiteDescriptor.isMethodFirstOperation(desc)) {
+ fallBack = NO_SUCH_METHOD_NAME;
+ } else {
+ fallBack = NO_SUCH_PROPERTY_NAME;
+ }
+ } else {
fallBack = null;
- break;
}
if (fallBack != null) {
find = expression.findProperty(fallBack, true);
if (find != null) {
- switch (firstOp) {
- case GET_METHOD:
+ if (NO_SUCH_METHOD_NAME.equals(fallBack)) {
link = expression.noSuchMethod(desc, request);
- break;
- case GET_PROPERTY:
- case GET_ELEMENT:
+ } else if (NO_SUCH_PROPERTY_NAME.equals(fallBack)) {
link = expression.noSuchProperty(desc, request);
- break;
- default:
- break;
}
}
}
if (link != null) {
- return fixExpressionCallSite(ndesc, link);
+ return fixExpressionCallSite(desc, link);
}
// still not found, may be scope can handle with it's own
@@ -245,10 +233,10 @@
return link.asType(newInvType);
}
- private static GuardedInvocation fixExpressionCallSite(final NashornCallSiteDescriptor desc, final GuardedInvocation link) {
+ private static GuardedInvocation fixExpressionCallSite(final CallSiteDescriptor desc, final GuardedInvocation link) {
// If it's not a getMethod, just add an expression filter that converts WithObject in "this" position to its
// expression.
- if (desc.getFirstOperation() != StandardOperation.GET_METHOD) {
+ if (NashornCallSiteDescriptor.getBaseOperation(desc) != StandardOperation.GET || !NashornCallSiteDescriptor.isMethodFirstOperation(desc)) {
return fixReceiverType(link, WITHEXPRESSIONFILTER).filterArguments(0, WITHEXPRESSIONFILTER);
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/BrowserJSObjectLinker.java Wed Nov 09 15:20:30 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/BrowserJSObjectLinker.java Wed Nov 09 10:04:43 2016 -0800
@@ -35,7 +35,6 @@
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import jdk.dynalink.CallSiteDescriptor;
-import jdk.dynalink.StandardOperation;
import jdk.dynalink.linker.GuardedInvocation;
import jdk.dynalink.linker.LinkRequest;
import jdk.dynalink.linker.LinkerServices;
@@ -91,24 +90,17 @@
inv = null;
}
- final StandardOperation op = NashornCallSiteDescriptor.getFirstStandardOperation(desc);
- if (op == null) {
- return inv;
- }
final String name = NashornCallSiteDescriptor.getOperand(desc);
- switch (op) {
- case GET_PROPERTY:
- case GET_ELEMENT:
- case GET_METHOD:
+ switch (NashornCallSiteDescriptor.getStandardOperation(desc)) {
+ case GET:
return name != null ? findGetMethod(name, inv) : findGetIndexMethod(inv);
- case SET_PROPERTY:
- case SET_ELEMENT:
+ case SET:
return name != null ? findSetMethod(name, inv) : findSetIndexMethod();
case CALL:
return findCallMethod(desc);
default:
+ return null;
}
- return null;
}
private static GuardedInvocation findGetMethod(final String name, final GuardedInvocation inv) {
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/JSObjectLinker.java Wed Nov 09 15:20:30 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/JSObjectLinker.java Wed Nov 09 10:04:43 2016 -0800
@@ -33,6 +33,7 @@
import java.util.Map;
import javax.script.Bindings;
import jdk.dynalink.CallSiteDescriptor;
+import jdk.dynalink.Operation;
import jdk.dynalink.StandardOperation;
import jdk.dynalink.linker.GuardedInvocation;
import jdk.dynalink.linker.LinkRequest;
@@ -92,29 +93,31 @@
}
private GuardedInvocation lookup(final CallSiteDescriptor desc, final LinkRequest request, final LinkerServices linkerServices) throws Exception {
- final StandardOperation op = NashornCallSiteDescriptor.getFirstStandardOperation(desc);
- if (op == null) {
- return null;
- }
- final String name = NashornCallSiteDescriptor.getOperand(desc);
- switch (op) {
- case GET_PROPERTY:
- case GET_ELEMENT:
- case GET_METHOD:
- if (name != null) {
- return findGetMethod(name);
+ final Operation op = NashornCallSiteDescriptor.getBaseOperation(desc);
+ if (op instanceof StandardOperation) {
+ final String name = NashornCallSiteDescriptor.getOperand(desc);
+ switch ((StandardOperation)op) {
+ case GET:
+ if (NashornCallSiteDescriptor.hasStandardNamespace(desc)) {
+ if (name != null) {
+ return findGetMethod(name);
+ }
+ // For indexed get, we want get GuardedInvocation beans linker and pass it.
+ // JSObjectLinker.get uses this fallback getter for explicit signature method access.
+ return findGetIndexMethod(nashornBeansLinker.getGuardedInvocation(request, linkerServices));
+ }
+ break;
+ case SET:
+ if (NashornCallSiteDescriptor.hasStandardNamespace(desc)) {
+ return name != null ? findSetMethod(name) : findSetIndexMethod();
+ }
+ break;
+ case CALL:
+ return findCallMethod(desc);
+ case NEW:
+ return findNewMethod(desc);
+ default:
}
- // For indexed get, we want get GuardedInvocation beans linker and pass it.
- // JSObjectLinker.get uses this fallback getter for explicit signature method access.
- return findGetIndexMethod(nashornBeansLinker.getGuardedInvocation(request, linkerServices));
- case SET_PROPERTY:
- case SET_ELEMENT:
- return name != null ? findSetMethod(name) : findSetIndexMethod();
- case CALL:
- return findCallMethod(desc);
- case NEW:
- return findNewMethod(desc);
- default:
}
return null;
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/JavaSuperAdapterLinker.java Wed Nov 09 15:20:30 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/JavaSuperAdapterLinker.java Wed Nov 09 10:04:43 2016 -0800
@@ -25,15 +25,15 @@
package jdk.nashorn.internal.runtime.linker;
+import static jdk.dynalink.StandardNamespace.METHOD;
+import static jdk.dynalink.StandardOperation.GET;
import static jdk.nashorn.internal.runtime.linker.JavaAdapterBytecodeGenerator.SUPER_PREFIX;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
import jdk.dynalink.CallSiteDescriptor;
-import jdk.dynalink.NamedOperation;
import jdk.dynalink.Operation;
-import jdk.dynalink.StandardOperation;
import jdk.dynalink.beans.BeansLinker;
import jdk.dynalink.linker.GuardedInvocation;
import jdk.dynalink.linker.LinkRequest;
@@ -61,6 +61,8 @@
IS_ADAPTER_OF_CLASS = lookup.findOwnStatic("isAdapterOfClass", boolean.class, Class.class, Object.class);
}
+ private static final Operation GET_METHOD = GET.withNamespace(METHOD);
+
private final BeansLinker beansLinker;
JavaSuperAdapterLinker(final BeansLinker beansLinker) {
@@ -82,8 +84,8 @@
final CallSiteDescriptor descriptor = linkRequest.getCallSiteDescriptor();
- if(!NashornCallSiteDescriptor.contains(descriptor, StandardOperation.GET_METHOD)) {
- // We only handle GET_METHOD
+ if(!NashornCallSiteDescriptor.contains(descriptor, GET, METHOD)) {
+ // We only handle GET:METHOD
return null;
}
@@ -97,8 +99,7 @@
final MethodType type = descriptor.getMethodType();
final Class<?> adapterClass = adapter.getClass();
final String name = NashornCallSiteDescriptor.getOperand(descriptor);
- final Operation newOp = name == null ? StandardOperation.GET_METHOD :
- new NamedOperation(StandardOperation.GET_METHOD, SUPER_PREFIX + name);
+ final Operation newOp = name == null ? GET_METHOD : GET_METHOD.named(SUPER_PREFIX + name);
final CallSiteDescriptor newDescriptor = new CallSiteDescriptor(
NashornCallSiteDescriptor.getLookupInternal(descriptor), newOp,
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornBeansLinker.java Wed Nov 09 15:20:30 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornBeansLinker.java Wed Nov 09 10:04:43 2016 -0800
@@ -35,7 +35,9 @@
import java.util.function.Supplier;
import jdk.dynalink.CallSiteDescriptor;
import jdk.dynalink.NamedOperation;
+import jdk.dynalink.Operation;
import jdk.dynalink.SecureLookupSupplier;
+import jdk.dynalink.StandardNamespace;
import jdk.dynalink.StandardOperation;
import jdk.dynalink.beans.BeansLinker;
import jdk.dynalink.linker.ConversionComparator.Comparison;
@@ -46,6 +48,7 @@
import jdk.dynalink.linker.MethodHandleTransformer;
import jdk.dynalink.linker.support.DefaultInternalObjectFilter;
import jdk.dynalink.linker.support.Lookup;
+import jdk.dynalink.linker.support.SimpleLinkRequest;
import jdk.nashorn.api.scripting.ScriptUtils;
import jdk.nashorn.internal.runtime.ConsString;
import jdk.nashorn.internal.runtime.Context;
@@ -68,6 +71,9 @@
// Object type arguments of Java method calls, field set and array set.
private static final boolean MIRROR_ALWAYS = Options.getBooleanProperty("nashorn.mirror.always", true);
+ private static final Operation GET_METHOD = StandardOperation.GET.withNamespace(StandardNamespace.METHOD);
+ private static final MethodType GET_METHOD_TYPE = MethodType.methodType(Object.class, Object.class);
+
private static final MethodHandle EXPORT_ARGUMENT;
private static final MethodHandle IMPORT_RESULT;
private static final MethodHandle FILTER_CONSSTRING;
@@ -114,20 +120,38 @@
// those are script functions.
final String name = getFunctionalInterfaceMethodName(self.getClass());
if (name != null) {
- final MethodType callType = desc.getMethodType();
- // drop callee (Undefined ScriptFunction) and change the request to be CALL_METHOD:<name>
- final CallSiteDescriptor newDesc = new CallSiteDescriptor(
+ // Obtain the method
+ final CallSiteDescriptor getMethodDesc = new CallSiteDescriptor(
NashornCallSiteDescriptor.getLookupInternal(desc),
- new NamedOperation(StandardOperation.CALL_METHOD, name),
- desc.getMethodType().dropParameterTypes(1, 2));
- final GuardedInvocation gi = getGuardedInvocation(beansLinker,
- linkRequest.replaceArguments(newDesc, linkRequest.getArguments()),
+ GET_METHOD.named(name), GET_METHOD_TYPE);
+ final GuardedInvocation getMethodInv = linkerServices.getGuardedInvocation(
+ new SimpleLinkRequest(getMethodDesc, false, self));
+ final Object method;
+ try {
+ method = getMethodInv.getInvocation().invokeExact(self);
+ } catch (final Exception|Error e) {
+ throw e;
+ } catch (final Throwable t) {
+ throw new RuntimeException(t);
+ }
+
+ final Object[] args = linkRequest.getArguments();
+ args[1] = args[0]; // callee (the functional object) becomes this
+ args[0] = method; // the method becomes the callee
+
+ final MethodType callType = desc.getMethodType();
+
+ final CallSiteDescriptor newDesc = desc.changeMethodType(
+ desc.getMethodType().changeParameterType(0, Object.class).changeParameterType(1, callType.parameterType(0)));
+ final GuardedInvocation gi = getGuardedInvocation(beansLinker, linkRequest.replaceArguments(newDesc, args),
new NashornBeansLinkerServices(linkerServices));
- // drop 'thiz' passed from the script.
- return gi.replaceMethods(
- MH.dropArguments(linkerServices.filterInternalObjects(gi.getInvocation()), 1, callType.parameterType(1)),
- gi.getGuard());
+ // Bind to the method, drop the original "this" and use original "callee" as this:
+ final MethodHandle inv = linkerServices.filterInternalObjects(gi
+ .getInvocation() // (method, this, args...)
+ .bindTo(method)); // (this, args...)
+ final MethodHandle calleeToThis = MH.dropArguments(inv, 1, callType.parameterType(1)); // (callee->this, <drop>, args...)
+ return gi.replaceMethods(calleeToThis, gi.getGuard());
}
}
return getGuardedInvocation(beansLinker, linkRequest, linkerServices);
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornBottomLinker.java Wed Nov 09 15:20:30 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornBottomLinker.java Wed Nov 09 10:04:43 2016 -0800
@@ -38,7 +38,6 @@
import jdk.dynalink.CallSiteDescriptor;
import jdk.dynalink.NamedOperation;
import jdk.dynalink.Operation;
-import jdk.dynalink.StandardOperation;
import jdk.dynalink.beans.BeansLinker;
import jdk.dynalink.linker.GuardedInvocation;
import jdk.dynalink.linker.GuardingDynamicLinker;
@@ -98,7 +97,7 @@
private static GuardedInvocation linkBean(final LinkRequest linkRequest) throws Exception {
final CallSiteDescriptor desc = linkRequest.getCallSiteDescriptor();
final Object self = linkRequest.getReceiver();
- switch (NashornCallSiteDescriptor.getFirstStandardOperation(desc)) {
+ switch (NashornCallSiteDescriptor.getStandardOperation(desc)) {
case NEW:
if(BeansLinker.isDynamicConstructor(self)) {
throw typeError("no.constructor.matches.args", ScriptRuntime.safeToString(self));
@@ -124,35 +123,26 @@
static MethodHandle linkMissingBeanMember(final LinkRequest linkRequest, final LinkerServices linkerServices) throws Exception {
final CallSiteDescriptor desc = linkRequest.getCallSiteDescriptor();
- final StandardOperation op = NashornCallSiteDescriptor.getFirstStandardOperation(desc);
- if (op != null) {
- final String operand = NashornCallSiteDescriptor.getOperand(desc);
- switch (op) {
- case GET_METHOD:
- case GET_PROPERTY:
- case GET_ELEMENT: {
- if (NashornCallSiteDescriptor.isOptimistic(desc)) {
- return adaptThrower(MethodHandles.insertArguments(THROW_OPTIMISTIC_UNDEFINED, 0, NashornCallSiteDescriptor.getProgramPoint(desc)), desc);
- }
- if (NashornCallSiteDescriptor.getOperand(desc) != null) {
- return getInvocation(EMPTY_PROP_GETTER, linkerServices, desc);
- }
- return getInvocation(EMPTY_ELEM_GETTER, linkerServices, desc);
+ final String operand = NashornCallSiteDescriptor.getOperand(desc);
+ switch (NashornCallSiteDescriptor.getStandardOperation(desc)) {
+ case GET:
+ if (NashornCallSiteDescriptor.isOptimistic(desc)) {
+ return adaptThrower(MethodHandles.insertArguments(THROW_OPTIMISTIC_UNDEFINED, 0, NashornCallSiteDescriptor.getProgramPoint(desc)), desc);
+ } else if (operand != null) {
+ return getInvocation(EMPTY_PROP_GETTER, linkerServices, desc);
}
- case SET_PROPERTY:
- case SET_ELEMENT:
- final boolean strict = NashornCallSiteDescriptor.isStrict(desc);
- if (strict) {
- return adaptThrower(bindOperand(THROW_STRICT_PROPERTY_SETTER, operand), desc);
- }
- if (NashornCallSiteDescriptor.getOperand(desc) != null) {
- return getInvocation(EMPTY_PROP_SETTER, linkerServices, desc);
- }
- return getInvocation(EMPTY_ELEM_SETTER, linkerServices, desc);
- default:
+ return getInvocation(EMPTY_ELEM_GETTER, linkerServices, desc);
+ case SET:
+ final boolean strict = NashornCallSiteDescriptor.isStrict(desc);
+ if (strict) {
+ return adaptThrower(bindOperand(THROW_STRICT_PROPERTY_SETTER, operand), desc);
+ } else if (operand != null) {
+ return getInvocation(EMPTY_PROP_SETTER, linkerServices, desc);
}
+ return getInvocation(EMPTY_ELEM_SETTER, linkerServices, desc);
+ default:
+ throw new AssertionError("unknown call type " + desc);
}
- throw new AssertionError("unknown call type " + desc);
}
private static MethodHandle bindOperand(final MethodHandle handle, final String operand) {
@@ -217,17 +207,13 @@
private static GuardedInvocation linkNull(final LinkRequest linkRequest) {
final CallSiteDescriptor desc = linkRequest.getCallSiteDescriptor();
- switch (NashornCallSiteDescriptor.getFirstStandardOperation(desc)) {
+ switch (NashornCallSiteDescriptor.getStandardOperation(desc)) {
case NEW:
case CALL:
throw typeError("not.a.function", "null");
- case GET_METHOD:
- throw typeError("no.such.function", getArgument(linkRequest), "null");
- case GET_PROPERTY:
- case GET_ELEMENT:
- throw typeError("cant.get.property", getArgument(linkRequest), "null");
- case SET_PROPERTY:
- case SET_ELEMENT:
+ case GET:
+ throw typeError(NashornCallSiteDescriptor.isMethodFirstOperation(desc) ? "no.such.function" : "cant.get.property", getArgument(linkRequest), "null");
+ case SET:
throw typeError("cant.set.property", getArgument(linkRequest), "null");
default:
throw new AssertionError("unknown call type " + desc);
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornCallSiteDescriptor.java Wed Nov 09 15:20:30 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornCallSiteDescriptor.java Wed Nov 09 10:04:43 2016 -0800
@@ -25,6 +25,12 @@
package jdk.nashorn.internal.runtime.linker;
+import static jdk.dynalink.StandardNamespace.ELEMENT;
+import static jdk.dynalink.StandardNamespace.METHOD;
+import static jdk.dynalink.StandardNamespace.PROPERTY;
+import static jdk.dynalink.StandardOperation.GET;
+import static jdk.dynalink.StandardOperation.SET;
+
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodHandles.Lookup;
import java.lang.invoke.MethodType;
@@ -40,10 +46,11 @@
import java.util.concurrent.ConcurrentMap;
import java.util.stream.Stream;
import jdk.dynalink.CallSiteDescriptor;
-import jdk.dynalink.CompositeOperation;
import jdk.dynalink.NamedOperation;
+import jdk.dynalink.NamespaceOperation;
import jdk.dynalink.Operation;
import jdk.dynalink.SecureLookupSupplier;
+import jdk.dynalink.StandardNamespace;
import jdk.dynalink.StandardOperation;
import jdk.nashorn.internal.ir.debug.NashornTextifier;
import jdk.nashorn.internal.runtime.AccessControlContextFactory;
@@ -78,12 +85,12 @@
// Correspond to the operation indices above.
private static final Operation[] OPERATIONS = new Operation[] {
- new CompositeOperation(StandardOperation.GET_PROPERTY, StandardOperation.GET_ELEMENT, StandardOperation.GET_METHOD),
- new CompositeOperation(StandardOperation.GET_ELEMENT, StandardOperation.GET_PROPERTY, StandardOperation.GET_METHOD),
- new CompositeOperation(StandardOperation.GET_METHOD, StandardOperation.GET_PROPERTY, StandardOperation.GET_ELEMENT),
- new CompositeOperation(StandardOperation.GET_METHOD, StandardOperation.GET_ELEMENT, StandardOperation.GET_PROPERTY),
- new CompositeOperation(StandardOperation.SET_PROPERTY, StandardOperation.SET_ELEMENT),
- new CompositeOperation(StandardOperation.SET_ELEMENT, StandardOperation.SET_PROPERTY),
+ GET.withNamespaces(PROPERTY, ELEMENT, METHOD),
+ GET.withNamespaces(ELEMENT, PROPERTY, METHOD),
+ GET.withNamespaces(METHOD, PROPERTY, ELEMENT),
+ GET.withNamespaces(METHOD, ELEMENT, PROPERTY),
+ SET.withNamespaces(PROPERTY, ELEMENT),
+ SET.withNamespaces(ELEMENT, PROPERTY),
StandardOperation.CALL,
StandardOperation.NEW
};
@@ -248,7 +255,7 @@
return existing;
}
}
- final NamedOperation newOp = new NamedOperation(baseOp, name);
+ final NamedOperation newOp = baseOp.named(name);
namedOps.put(name, new WeakReference<>(newOp));
return newOp;
}
@@ -288,16 +295,6 @@
}
/**
- * Returns the named operand in this descriptor's operation. Equivalent to
- * {@code ((NamedOperation)getOperation()).getName().toString()} for call
- * sites with a named operand. For call sites without named operands returns null.
- * @return the named operand in this descriptor's operation.
- */
- public String getOperand() {
- return getOperand(this);
- }
-
- /**
* Returns the named operand in the passed descriptor's operation.
* Equivalent to
* {@code ((NamedOperation)desc.getOperation()).getName().toString()} for
@@ -311,70 +308,63 @@
return operation instanceof NamedOperation ? ((NamedOperation)operation).getName().toString() : null;
}
+ private static StandardNamespace findFirstStandardNamespace(final CallSiteDescriptor desc) {
+ return StandardNamespace.findFirst(desc.getOperation());
+ }
+
/**
- * Returns the first operation in this call site descriptor's potentially
- * composite operation. E.g. if this call site descriptor has a composite
- * operation {@code GET_PROPERTY|GET_METHOD|GET_ELEM}, it will return
- * {@code GET_PROPERTY}. Nashorn - being a ECMAScript engine - does not
- * distinguish between property, element, and method namespace; ECMAScript
- * objects just have one single property namespace for all these, therefore
- * it is largely irrelevant what the composite operation is structured like;
- * if the first operation can't be satisfied, neither can the others. The
- * first operation is however sometimes used to slightly alter the
- * semantics; for example, a distinction between {@code GET_PROPERTY} and
- * {@code GET_METHOD} being the first operation can translate into whether
- * {@code "__noSuchProperty__"} or {@code "__noSuchMethod__"} will be
- * executed in case the property is not found. Note that if a call site
- * descriptor comes from outside of Nashorn, its class will be different,
- * and there is no guarantee about the way it composes its operations. For
- * that reason, for potentially foreign call site descriptors you should use
- * {@link #getFirstStandardOperation(CallSiteDescriptor)} instead.
- * @return the first operation in this call site descriptor. Note this will
- * always be a {@code StandardOperation} as Nashorn internally only uses
- * standard operations.
+ * Returns true if the operation of the call descriptor is operating on the method namespace first.
+ * @param desc the call descriptor in question.
+ * @return true if the operation of the call descriptor is operating on the method namespace first.
*/
- public StandardOperation getFirstOperation() {
- final Operation base = NamedOperation.getBaseOperation(getOperation());
- if (base instanceof CompositeOperation) {
- return (StandardOperation)((CompositeOperation)base).getOperation(0);
- }
- return (StandardOperation)base;
+ public static boolean isMethodFirstOperation(final CallSiteDescriptor desc) {
+ return findFirstStandardNamespace(desc) == StandardNamespace.METHOD;
+ }
+
+ /**
+ * Returns true if there's a namespace operation in the call descriptor and it is operating on at least
+ * one {@link StandardNamespace}. This method is only needed for exported linkers, since internal linkers
+ * always operate on Nashorn-generated call sites, and they always operate on standard namespaces only.
+ * @param desc the call descriptor in question.
+ * @return true if the operation of the call descriptor is operating on at least one standard namespace.
+ */
+ public static boolean hasStandardNamespace(final CallSiteDescriptor desc) {
+ return findFirstStandardNamespace(desc) != null;
}
/**
- * Returns the first standard operation in the (potentially composite)
- * operation of the passed call site descriptor.
+ * Returns the base operation in this call site descriptor after unwrapping it from both a named operation
+ * and a namespace operation.
* @param desc the call site descriptor.
- * @return Returns the first standard operation in the (potentially
- * composite) operation of the passed call site descriptor. Can return null
- * if the call site contains no standard operations.
+ * @return the base operation in this call site descriptor.
*/
- public static StandardOperation getFirstStandardOperation(final CallSiteDescriptor desc) {
- final Operation base = NamedOperation.getBaseOperation(desc.getOperation());
- if (base instanceof StandardOperation) {
- return (StandardOperation)base;
- } else if (base instanceof CompositeOperation) {
- final CompositeOperation cop = (CompositeOperation)base;
- for(int i = 0; i < cop.getOperationCount(); ++i) {
- final Operation op = cop.getOperation(i);
- if (op instanceof StandardOperation) {
- return (StandardOperation)op;
- }
- }
- }
- return null;
+ public static Operation getBaseOperation(final CallSiteDescriptor desc) {
+ return NamespaceOperation.getBaseOperation(NamedOperation.getBaseOperation(desc.getOperation()));
}
/**
- * Returns true if the passed call site descriptor's operation contains (or
- * is) the specified standard operation.
+ * Returns the standard operation that is the base operation in this call site descriptor.
+ * @param desc the call site descriptor.
+ * @return the standard operation that is the base operation in this call site descriptor.
+ * @throws ClassCastException if the base operation is not a standard operation. This method is only
+ * safe to use when the base operation is known to be a standard operation (e.g. all Nashorn call sites
+ * are such, so it's safe to use from internal linkers).
+ */
+ public static StandardOperation getStandardOperation(final CallSiteDescriptor desc) {
+ return (StandardOperation)getBaseOperation(desc);
+ }
+
+ /**
+ * Returns true if the passed call site descriptor contains the specified standard operation on the
+ * specified standard namespace.
* @param desc the call site descriptor.
* @param operation the operation whose presence is tested.
- * @return Returns true if the call site descriptor's operation contains (or
- * is) the specified standard operation.
+ * @param namespace the namespace on which the operation operates.
+ * @return Returns true if the call site descriptor contains the specified standard operation on the
+ * specified standard namespace.
*/
- public static boolean contains(final CallSiteDescriptor desc, final StandardOperation operation) {
- return CompositeOperation.contains(NamedOperation.getBaseOperation(desc.getOperation()), operation);
+ public static boolean contains(final CallSiteDescriptor desc, final StandardOperation operation, final StandardNamespace namespace) {
+ return NamespaceOperation.contains(NamedOperation.getBaseOperation(desc.getOperation()), operation, namespace);
}
/**
@@ -383,8 +373,8 @@
* @param obj object on which CALL or NEW is used
* @return error message
*/
- public String getFunctionErrorMessage(final Object obj) {
- final String funcDesc = getOperand();
+ private String getFunctionErrorMessage(final Object obj) {
+ final String funcDesc = getOperand(this);
return funcDesc != null? funcDesc : ScriptRuntime.safeToString(obj);
}
@@ -552,4 +542,9 @@
public CallSiteDescriptor changeMethodTypeInternal(final MethodType newMethodType) {
return get(getLookupPrivileged(), getOperation(), newMethodType, flags);
}
+
+ @Override
+ protected CallSiteDescriptor changeOperationInternal(final Operation newOperation) {
+ return get(getLookupPrivileged(), newOperation, getMethodType(), flags);
+ }
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/PrimitiveLookup.java Wed Nov 09 15:20:30 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/PrimitiveLookup.java Wed Nov 09 10:04:43 2016 -0800
@@ -99,10 +99,8 @@
final String name = NashornCallSiteDescriptor.getOperand(desc);
final FindProperty find = name != null ? wrappedReceiver.findProperty(name, true) : null;
- switch (NashornCallSiteDescriptor.getFirstStandardOperation(desc)) {
- case GET_PROPERTY:
- case GET_ELEMENT:
- case GET_METHOD:
+ switch (NashornCallSiteDescriptor.getStandardOperation(desc)) {
+ case GET:
//checks whether the property name is hard-coded in the call-site (i.e. a getProp vs a getElem, or setProp vs setElem)
//if it is we can make assumptions on the property: that if it is not defined on primitive wrapper itself it never will be.
//so in that case we can skip creation of primitive wrapper and start our search with the prototype.
@@ -133,8 +131,7 @@
}
}
break;
- case SET_PROPERTY:
- case SET_ELEMENT:
+ case SET:
return getPrimitiveSetter(name, guard, wrapFilter, NashornCallSiteDescriptor.isStrict(desc));
default:
break;
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/ReflectionCheckLinker.java Wed Nov 09 15:20:30 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/ReflectionCheckLinker.java Wed Nov 09 10:04:43 2016 -0800
@@ -30,6 +30,7 @@
import java.lang.reflect.Modifier;
import java.lang.reflect.Proxy;
import jdk.dynalink.CallSiteDescriptor;
+import jdk.dynalink.StandardNamespace;
import jdk.dynalink.StandardOperation;
import jdk.dynalink.linker.GuardedInvocation;
import jdk.dynalink.linker.LinkRequest;
@@ -129,9 +130,9 @@
// allow 'static' access on Class objects representing public classes of non-restricted packages
if ((self instanceof Class) && Modifier.isPublic(((Class<?>)self).getModifiers())) {
final CallSiteDescriptor desc = request.getCallSiteDescriptor();
- if ("static".equals(NashornCallSiteDescriptor.getOperand(desc)) && NashornCallSiteDescriptor.contains(desc, StandardOperation.GET_PROPERTY)) {
+ if ("static".equals(NashornCallSiteDescriptor.getOperand(desc)) && NashornCallSiteDescriptor.contains(desc, StandardOperation.GET, StandardNamespace.PROPERTY)) {
if (Context.isAccessibleClass((Class<?>)self) && !isReflectionClass((Class<?>)self)) {
- // If "GET_PROPERTY:static" passes access checks, allow access.
+ // If "GET:PROPERTY:static" passes access checks, allow access.
return;
}
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/resources/Messages.properties Wed Nov 09 15:20:30 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/resources/Messages.properties Wed Nov 09 10:04:43 2016 -0800
@@ -214,6 +214,7 @@
syntax.error.strict.cant.delete=cannot delete "{0}" in strict mode
syntax.error.redeclare.variable=Variable "{0}" has already been declared
syntax.error.unprotected.switch.declaration=Unsupported {0} declaration in unprotected switch statement
+syntax.error.duplicate.parameter=Duplicate parameter name "{0}"
io.error.cant.write=cannot write "{0}"
@@ -222,3 +223,12 @@
uri.error.bad.uri=Bad URI "{0}" near offset {1}
list.adapter.null.global=Attempted to create the adapter from outside a JavaScript execution context.
+
+unimplemented.es6.module=ES6 modules are not yet implemented
+unimplemented.es6.rest.param=ES6 function rest parameter declaration is not yet implemented
+unimplemented.es6.yield=ES6 yield and yield* are not yet implemented
+unimplemented.es6.spread=ES6 spread operator is not yet implemented
+unimplemented.es6.class=ES6 class declarations and expressions are not yet implemented
+unimplemented.es6.destructuring=ES6 destructuring is not yet implemented
+unimplemented.es6.generator=ES6 generator is not yet implemented
+unimplemented.es6.super=ES6 super keyword is not yet implemented
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/es6/class.js Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * Class declaration is not implemented
+ *
+ * @test
+ * @run
+ * @option --language=es6
+ */
+
+try {
+ eval("class Foo {}");
+} catch (e) {
+ print(String(e).replace(/\\/g, "/"))
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/es6/class.js.EXPECTED Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,3 @@
+java.lang.RuntimeException: test/script/basic/es6/class.js#33:3<eval>:1:0 ES6 class declarations and expressions are not yet implemented
+class Foo {}
+^
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/es6/destructuring.js Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * Destructuring is not implemented
+ *
+ * @test
+ * @run
+ * @option --language=es6
+ */
+
+
+function check(code) {
+ try {
+ eval(code);
+ } catch (e) {
+ print(String(e).replace(/\\/g, "/"))
+ }
+}
+
+check("var { x: y } = obj;");
+check("let { x: y } = obj;");
+check("const { x: y } = obj;");
+check("({ x: y }) = obj;");
+check("for (var { x: y } of obj) ;");
+check("for (let { x: y } of obj) ;");
+check("var { x, y } = obj;");
+check("let { x, y } = obj;");
+check("const { x, y } = obj;");
+check("({ x, y }) = obj;");
+check("for (var { x, y } of obj) ;");
+check("for (let { x, y } of obj) ;");
+check("var [a, b] = obj;");
+check("let [a, b] = obj;");
+check("const [a, b] = obj;");
+check("[a, b] = obj;");
+check("for ([a, b] of obj) ;");
+check("for (var [a, b] of obj) ;");
+check("for (let [a, b] of obj) ;");
+check("(function({ x: y }) { return x; })()");
+check("(function({ x }) { return x; })()");
+check("(function([x]) { return x; })()");
+check("for (var [[x, y, z] = [4, 5, 6]] = [7, 8, 9]; iterCount < 1; ) ;");
+check("for ([ arrow = () => {} ] of [[]]) ;");
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/es6/destructuring.js.EXPECTED Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,72 @@
+java.lang.RuntimeException: test/script/basic/es6/destructuring.js#35:6<eval>:1:4 ES6 destructuring is not yet implemented
+var { x: y } = obj;
+ ^
+java.lang.RuntimeException: test/script/basic/es6/destructuring.js#35:6<eval>:1:4 ES6 destructuring is not yet implemented
+let { x: y } = obj;
+ ^
+java.lang.RuntimeException: test/script/basic/es6/destructuring.js#35:6<eval>:1:6 ES6 destructuring is not yet implemented
+const { x: y } = obj;
+ ^
+java.lang.RuntimeException: test/script/basic/es6/destructuring.js#35:6<eval>:1:1 ES6 destructuring is not yet implemented
+({ x: y }) = obj;
+ ^
+java.lang.RuntimeException: test/script/basic/es6/destructuring.js#35:6<eval>:1:0 ES6 destructuring is not yet implemented
+for (var { x: y } of obj) ;
+^
+java.lang.RuntimeException: test/script/basic/es6/destructuring.js#35:6<eval>:1:0 ES6 destructuring is not yet implemented
+for (let { x: y } of obj) ;
+^
+java.lang.RuntimeException: test/script/basic/es6/destructuring.js#35:6<eval>:1:4 ES6 destructuring is not yet implemented
+var { x, y } = obj;
+ ^
+java.lang.RuntimeException: test/script/basic/es6/destructuring.js#35:6<eval>:1:4 ES6 destructuring is not yet implemented
+let { x, y } = obj;
+ ^
+java.lang.RuntimeException: test/script/basic/es6/destructuring.js#35:6<eval>:1:6 ES6 destructuring is not yet implemented
+const { x, y } = obj;
+ ^
+java.lang.RuntimeException: test/script/basic/es6/destructuring.js#35:6<eval>:1:1 ES6 destructuring is not yet implemented
+({ x, y }) = obj;
+ ^
+java.lang.RuntimeException: test/script/basic/es6/destructuring.js#35:6<eval>:1:0 ES6 destructuring is not yet implemented
+for (var { x, y } of obj) ;
+^
+java.lang.RuntimeException: test/script/basic/es6/destructuring.js#35:6<eval>:1:0 ES6 destructuring is not yet implemented
+for (let { x, y } of obj) ;
+^
+java.lang.RuntimeException: test/script/basic/es6/destructuring.js#35:6<eval>:1:4 ES6 destructuring is not yet implemented
+var [a, b] = obj;
+ ^
+java.lang.RuntimeException: test/script/basic/es6/destructuring.js#35:6<eval>:1:4 ES6 destructuring is not yet implemented
+let [a, b] = obj;
+ ^
+java.lang.RuntimeException: test/script/basic/es6/destructuring.js#35:6<eval>:1:6 ES6 destructuring is not yet implemented
+const [a, b] = obj;
+ ^
+java.lang.RuntimeException: test/script/basic/es6/destructuring.js#35:6<eval>:1:0 ES6 destructuring is not yet implemented
+[a, b] = obj;
+^
+java.lang.RuntimeException: test/script/basic/es6/destructuring.js#35:6<eval>:1:0 ES6 destructuring is not yet implemented
+for ([a, b] of obj) ;
+^
+java.lang.RuntimeException: test/script/basic/es6/destructuring.js#35:6<eval>:1:0 ES6 destructuring is not yet implemented
+for (var [a, b] of obj) ;
+^
+java.lang.RuntimeException: test/script/basic/es6/destructuring.js#35:6<eval>:1:0 ES6 destructuring is not yet implemented
+for (let [a, b] of obj) ;
+^
+java.lang.RuntimeException: test/script/basic/es6/destructuring.js#35:6<eval>:1:9 ES6 destructuring is not yet implemented
+(function({ x: y }) { return x; })()
+ ^
+java.lang.RuntimeException: test/script/basic/es6/destructuring.js#35:6<eval>:1:9 ES6 destructuring is not yet implemented
+(function({ x }) { return x; })()
+ ^
+java.lang.RuntimeException: test/script/basic/es6/destructuring.js#35:6<eval>:1:9 ES6 destructuring is not yet implemented
+(function([x]) { return x; })()
+ ^
+java.lang.RuntimeException: test/script/basic/es6/destructuring.js#35:6<eval>:1:9 ES6 destructuring is not yet implemented
+for (var [[x, y, z] = [4, 5, 6]] = [7, 8, 9]; iterCount < 1; ) ;
+ ^
+java.lang.RuntimeException: test/script/basic/es6/destructuring.js#35:6<eval>:1:0 ES6 destructuring is not yet implemented
+for ([ arrow = () => {} ] of [[]]) ;
+^
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/es6/generator.js Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * Generators are not implemented
+ *
+ * @test
+ * @run
+ * @option --language=es6
+ */
+
+function check(code) {
+ try {
+ eval(code);
+ } catch (e) {
+ print(String(e).replace(/\\/g, "/"))
+ }
+}
+
+check("function* func() { yield 1; }");
+check("({ * generatorMethod() { yield 1; } })");
+check("var func = function*() { yield 1; }");
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/es6/generator.js.EXPECTED Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,9 @@
+java.lang.RuntimeException: test/script/basic/es6/generator.js#34:6<eval>:1:17 ES6 generator is not yet implemented
+function* func() { yield 1; }
+ ^
+java.lang.RuntimeException: test/script/basic/es6/generator.js#34:6<eval>:1:23 ES6 generator is not yet implemented
+({ * generatorMethod() { yield 1; } })
+ ^
+java.lang.RuntimeException: test/script/basic/es6/generator.js#34:6<eval>:1:23 ES6 generator is not yet implemented
+var func = function*() { yield 1; }
+ ^
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/es6/restparam.js Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * ES6 rest params are not implemented
+ *
+ * @test
+ * @run
+ * @option --language=es6
+ */
+
+
+function check(code) {
+ try {
+ eval(code);
+ } catch (e) {
+ print(String(e).replace(/\\/g, "/"))
+ }
+}
+
+check("function func(...args) {}");
+check("function func(x, y, ...args) {}");
+check("({ meth(...args) {} })");
+check("({ meth(x, y, ...args) {} })");
+check("({ meth(x = 0, x) {} })");
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/es6/restparam.js.EXPECTED Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,15 @@
+java.lang.RuntimeException: test/script/basic/es6/restparam.js#35:6<eval>:1:17 ES6 function rest parameter declaration is not yet implemented
+function func(...args) {}
+ ^
+java.lang.RuntimeException: test/script/basic/es6/restparam.js#35:6<eval>:1:23 ES6 function rest parameter declaration is not yet implemented
+function func(x, y, ...args) {}
+ ^
+java.lang.RuntimeException: test/script/basic/es6/restparam.js#35:6<eval>:1:11 ES6 function rest parameter declaration is not yet implemented
+({ meth(...args) {} })
+ ^
+java.lang.RuntimeException: test/script/basic/es6/restparam.js#35:6<eval>:1:17 ES6 function rest parameter declaration is not yet implemented
+({ meth(x, y, ...args) {} })
+ ^
+SyntaxError: test/script/basic/es6/restparam.js#35:6<eval>:1:15 Duplicate parameter name "x"
+({ meth(x = 0, x) {} })
+ ^
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/es6/spread.js Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * ES6 spread operator is not implemented
+ *
+ * @test
+ * @run
+ * @option --language=es6
+ */
+
+function check(code) {
+ try {
+ eval(code);
+ } catch (e) {
+ print(String(e).replace(/\\/g, "/"))
+ }
+}
+
+check("var x = [...args]");
+check("var x = [1, 2, ...args]");
+check("var x = [...args, 3, 5]");
+check("var r = func(...arr)");
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/es6/spread.js.EXPECTED Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,12 @@
+java.lang.RuntimeException: test/script/basic/es6/spread.js#34:8<eval>:1:9 ES6 spread operator is not yet implemented
+var x = [...args]
+ ^
+java.lang.RuntimeException: test/script/basic/es6/spread.js#34:8<eval>:1:15 ES6 spread operator is not yet implemented
+var x = [1, 2, ...args]
+ ^
+java.lang.RuntimeException: test/script/basic/es6/spread.js#34:8<eval>:1:9 ES6 spread operator is not yet implemented
+var x = [...args, 3, 5]
+ ^
+java.lang.RuntimeException: test/script/basic/es6/spread.js#34:8<eval>:1:13 ES6 spread operator is not yet implemented
+var r = func(...arr)
+ ^
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/es6/super.js Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * ES6 super keyword is not implemented
+ *
+ * @test
+ * @run
+ * @option --language=es6
+ */
+
+function check(code) {
+ try {
+ eval(code);
+ } catch (e) {
+ print(String(e).replace(/\\/g, "/"))
+ }
+}
+
+check("({ meth() { x = super.x } })");
+check("({ meth() { x = super.x() } })");
+check("({ meth() { x = super['x'] } })");
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/es6/super.js.EXPECTED Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,9 @@
+java.lang.RuntimeException: test/script/basic/es6/super.js#34:8<eval>:1:10 ES6 super keyword is not yet implemented
+({ meth() { x = super.x } })
+ ^
+java.lang.RuntimeException: test/script/basic/es6/super.js#34:8<eval>:1:10 ES6 super keyword is not yet implemented
+({ meth() { x = super.x() } })
+ ^
+java.lang.RuntimeException: test/script/basic/es6/super.js#34:8<eval>:1:10 ES6 super keyword is not yet implemented
+({ meth() { x = super['x'] } })
+ ^
--- a/nashorn/test/script/basic/jsadapter-ids.js Wed Nov 09 15:20:30 2016 +0300
+++ b/nashorn/test/script/basic/jsadapter-ids.js Wed Nov 09 10:04:43 2016 -0800
@@ -30,6 +30,7 @@
var obj = new JSAdapter() {
__getIds__: function() {
+ Assert.assertTrue(this === obj);
print("__getIds__ called");
return [ "foo", "bar" ];
}
--- a/nashorn/test/script/basic/jsadapter.js Wed Nov 09 15:20:30 2016 +0300
+++ b/nashorn/test/script/basic/jsadapter.js Wed Nov 09 10:04:43 2016 -0800
@@ -30,39 +30,81 @@
var obj = new JSAdapter() {
__get__: function(name) {
+ Assert.assertTrue(this === obj);
print("getter called for '" + name + "'"); return name;
},
__put__: function(name, value) {
+ Assert.assertTrue(this === obj);
print("setter called for '" + name + "' with " + value);
},
__call__: function(name, arg1, arg2) {
+ Assert.assertTrue(this === obj);
print("method '" + name + "' called with " + arg1 + ", " + arg2);
},
__new__: function(arg1, arg2) {
+ Assert.assertTrue(this === obj);
print("new with " + arg1 + ", " + arg2);
},
__getKeys__: function() {
+ Assert.assertTrue(this === obj);
print("__getKeys__ called");
return [ "foo", "bar" ];
},
__getValues__: function() {
+ Assert.assertTrue(this === obj);
print("__getValues__ called");
return [ "fooval", "barval" ];
},
__has__: function(name) {
+ Assert.assertTrue(this === obj);
print("__has__ called with '" + name + "'");
return name == "js";
},
__delete__: function(name) {
+ Assert.assertTrue(this === obj);
print("__delete__ called with '" + name + "'");
return true;
+ },
+
+ __preventExtensions__ : function() {
+ Assert.assertTrue(this === obj);
+ print("__preventExtensions__ called");
+ },
+
+ __freeze__ : function() {
+ Assert.assertTrue(this === obj);
+ print("__freeze__ called");
+
+ },
+
+ __isFrozen__ : function() {
+ Assert.assertTrue(this === obj);
+ print("__isFrozen__ called");
+ return false;
+ },
+
+ __seal__ : function() {
+ Assert.assertTrue(this === obj);
+ print("__seal__ called");
+ },
+
+ __isSealed__ : function() {
+ Assert.assertTrue(this === obj);
+ print("__isSealed__ called");
+ return false;
+ },
+
+ __isExtensible__ : function() {
+ Assert.assertTrue(this === obj);
+ print("__isExtensible__ called");
+ return true;
}
};
@@ -103,3 +145,13 @@
print(obj["js"]);
obj["js"] = "javascript";
print(obj["javascript"]);
+
+// call __isExtensible__, __isSealed__, __isFrozen__
+print(Object.isExtensible(obj));
+print(Object.isSealed(obj));
+print(Object.isFrozen(obj));
+
+// call __freeze__, __seal__, __preventExtensions__
+Object.freeze(obj);
+Object.seal(obj);
+Object.preventExtensions(obj);
--- a/nashorn/test/script/basic/jsadapter.js.EXPECTED Wed Nov 09 15:20:30 2016 +0300
+++ b/nashorn/test/script/basic/jsadapter.js.EXPECTED Wed Nov 09 10:04:43 2016 -0800
@@ -20,3 +20,12 @@
setter called for 'js' with javascript
getter called for 'javascript'
javascript
+__isExtensible__ called
+true
+__isSealed__ called
+false
+__isFrozen__ called
+false
+__freeze__ called
+__seal__ called
+__preventExtensions__ called
--- a/nashorn/test/script/basic/jsadapterlink.js Wed Nov 09 15:20:30 2016 +0300
+++ b/nashorn/test/script/basic/jsadapterlink.js Wed Nov 09 10:04:43 2016 -0800
@@ -31,18 +31,21 @@
var js1 = new JSAdapter() {
__get__: function(name) {
+ Assert.assertTrue(this === js1);
return "js1->" + name;
}
};
var js2 = new JSAdapter() {
__get__: function(name) {
+ Assert.assertTrue(this === js2);
return "js2->" + name;
}
};
var js3 = new JSAdapter() {
__get__: function(name) {
+ Assert.assertTrue(this === js3);
return "js3->" + name;
}
};
--- a/nashorn/test/src/META-INF/services/jdk.dynalink.linker.GuardingDynamicLinkerExporter Wed Nov 09 15:20:30 2016 +0300
+++ b/nashorn/test/src/META-INF/services/jdk.dynalink.linker.GuardingDynamicLinkerExporter Wed Nov 09 10:04:43 2016 -0800
@@ -1,2 +1,3 @@
jdk.dynalink.test.UntrustedGuardingDynamicLinkerExporter
jdk.dynalink.test.TrustedGuardingDynamicLinkerExporter
+jdk.dynalink.test.TrustedUnderscoreNameLinkerExporter
--- a/nashorn/test/src/jdk/dynalink/beans/test/BeanLinkerTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/nashorn/test/src/jdk/dynalink/beans/test/BeanLinkerTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -24,14 +24,13 @@
*/
package jdk.dynalink.beans.test;
+import static jdk.dynalink.StandardNamespace.ELEMENT;
+import static jdk.dynalink.StandardNamespace.METHOD;
+import static jdk.dynalink.StandardNamespace.PROPERTY;
import static jdk.dynalink.StandardOperation.CALL;
-import static jdk.dynalink.StandardOperation.CALL_METHOD;
-import static jdk.dynalink.StandardOperation.GET_ELEMENT;
-import static jdk.dynalink.StandardOperation.GET_LENGTH;
-import static jdk.dynalink.StandardOperation.GET_METHOD;
-import static jdk.dynalink.StandardOperation.GET_PROPERTY;
+import static jdk.dynalink.StandardOperation.GET;
import static jdk.dynalink.StandardOperation.NEW;
-import static jdk.dynalink.StandardOperation.SET_ELEMENT;
+import static jdk.dynalink.StandardOperation.SET;
import java.lang.invoke.CallSite;
import java.lang.invoke.MethodHandle;
@@ -39,7 +38,6 @@
import java.lang.invoke.MethodType;
import java.security.AccessControlException;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.Date;
import java.util.List;
import jdk.dynalink.CallSiteDescriptor;
@@ -78,12 +76,21 @@
}
private CallSite createCallSite(final boolean publicLookup, final Operation op, final Object name, final MethodType mt) {
- return createCallSite(publicLookup, new NamedOperation(op, name), mt);
+ return createCallSite(publicLookup, op.named(name), mt);
+ }
+
+ private CallSite createGetMethodCallSite(final boolean publicLookup, final String name) {
+ return createCallSite(publicLookup, GET_METHOD, name, MethodType.methodType(Object.class, Object.class));
}
private static final MethodHandle throwArrayIndexOutOfBounds = findThrower("throwArrayIndexOutOfBounds");
private static final MethodHandle throwIndexOutOfBounds = findThrower("throwIndexOutOfBounds");
+ private static final Operation GET_PROPERTY = GET.withNamespace(PROPERTY);
+ private static final Operation GET_ELEMENT = GET.withNamespace(ELEMENT);
+ private static final Operation GET_METHOD = GET.withNamespace(METHOD);
+ private static final Operation SET_ELEMENT = SET.withNamespace(ELEMENT);
+
private static final MethodHandle findThrower(final String name) {
try {
return MethodHandles.lookup().findStatic(BeanLinkerTest.class, name,
@@ -209,26 +216,6 @@
}
@Test(dataProvider = "flags")
- public void getlengthTest(final boolean publicLookup) throws Throwable {
- final MethodType mt = MethodType.methodType(int.class, Object.class);
- final CallSite cs = createCallSite(publicLookup, GET_LENGTH, mt);
-
- final int[] arr = {23, 42};
- Assert.assertEquals((int) cs.getTarget().invoke((Object) arr), 2);
- Assert.assertEquals((int) cs.getTarget().invoke(Collections.EMPTY_LIST), 0);
-
- final List<String> list = new ArrayList<>();
- list.add("hello");
- list.add("world");
- list.add("dynalink");
- Assert.assertEquals((int) cs.getTarget().invoke(list), 3);
- list.add("nashorn");
- Assert.assertEquals((int) cs.getTarget().invoke(list), 4);
- list.clear();
- Assert.assertEquals((int) cs.getTarget().invoke(list), 0);
- }
-
- @Test(dataProvider = "flags")
public void getElementTest(final boolean publicLookup) throws Throwable {
final MethodType mt = MethodType.methodType(int.class, Object.class, int.class);
final CallSite cs = createCallSite(publicLookup, GET_ELEMENT, mt);
@@ -364,8 +351,7 @@
@Test(dataProvider = "flags")
public void instanceMethodCallTest(final boolean publicLookup) {
- final MethodType mt = MethodType.methodType(Object.class, Object.class);
- final CallSite cs = createCallSite(publicLookup, GET_METHOD, "getClass", mt);
+ final CallSite cs = createGetMethodCallSite(publicLookup, "getClass");
final MethodType mt2 = MethodType.methodType(Class.class, Object.class, Object.class);
final CallSite cs2 = createCallSite(publicLookup, CALL, mt2);
@@ -389,23 +375,8 @@
}
@Test(dataProvider = "flags")
- public void instanceMethodCallTest2(final boolean publicLookup) {
- final MethodType mt = MethodType.methodType(Class.class, Object.class);
- final CallSite cs = createCallSite(publicLookup, CALL_METHOD, "getClass", mt);
- Class clz = null;
- try {
- clz = (Class) cs.getTarget().invoke(new Date());
- } catch (final Throwable th) {
- throw new RuntimeException(th);
- }
-
- Assert.assertEquals(clz, Date.class);
- }
-
- @Test(dataProvider = "flags")
public void staticMethodCallTest(final boolean publicLookup) {
- final MethodType mt = MethodType.methodType(Object.class, StaticClass.class);
- final CallSite cs = createCallSite(publicLookup, GET_METHOD, "getProperty", mt);
+ final CallSite cs = createGetMethodCallSite(publicLookup, "getProperty");
final MethodType mt2 = MethodType.methodType(String.class, Object.class, Object.class, String.class);
final CallSite cs2 = createCallSite(publicLookup, CALL, mt2);
@@ -428,28 +399,15 @@
Assert.assertEquals(str, System.getProperty("os.name"));
}
- @Test(dataProvider = "flags")
- public void staticMethodCallTest2(final boolean publicLookup) {
- final MethodType mt = MethodType.methodType(String.class, Object.class, String.class);
- final CallSite cs = createCallSite(publicLookup, CALL_METHOD, "getProperty", mt);
-
- String str = null;
- try {
- str = (String) cs.getTarget().invoke(StaticClass.forClass(System.class), "os.name");
- } catch (final Throwable th) {
- throw new RuntimeException(th);
- }
- Assert.assertEquals(str, System.getProperty("os.name"));
- }
-
// try calling System.getenv and expect security exception
@Test(dataProvider = "flags")
public void systemGetenvTest(final boolean publicLookup) {
- final MethodType mt = MethodType.methodType(Object.class, Object.class);
- final CallSite cs = createCallSite(publicLookup, CALL_METHOD, "getenv", mt);
+ final CallSite cs1 = createGetMethodCallSite(publicLookup, "getenv");
+ final CallSite cs2 = createCallSite(publicLookup, CALL, MethodType.methodType(Object.class, Object.class, Object.class));
try {
- cs.getTarget().invoke(StaticClass.forClass(System.class));
+ final Object method = cs1.getTarget().invoke(StaticClass.forClass(System.class));
+ cs2.getTarget().invoke(method, StaticClass.forClass(System.class));
throw new RuntimeException("should not reach here in any case!");
} catch (final Throwable th) {
Assert.assertTrue(th instanceof SecurityException);
@@ -459,11 +417,12 @@
// try getting a specific sensitive System property and expect security exception
@Test(dataProvider = "flags")
public void systemGetPropertyTest(final boolean publicLookup) {
- final MethodType mt = MethodType.methodType(String.class, Object.class, String.class);
- final CallSite cs = createCallSite(publicLookup, CALL_METHOD, "getProperty", mt);
+ final CallSite cs1 = createGetMethodCallSite(publicLookup, "getProperty");
+ final CallSite cs2 = createCallSite(publicLookup, CALL, MethodType.methodType(String.class, Object.class, Object.class, String.class));
try {
- cs.getTarget().invoke(StaticClass.forClass(System.class), "java.home");
+ final Object method = cs1.getTarget().invoke(StaticClass.forClass(System.class));
+ cs2.getTarget().invoke(method, StaticClass.forClass(System.class), "java.home");
throw new RuntimeException("should not reach here in any case!");
} catch (final Throwable th) {
Assert.assertTrue(th instanceof SecurityException);
@@ -473,11 +432,12 @@
// check a @CallerSensitive API and expect appropriate access check exception
@Test(dataProvider = "flags")
public void systemLoadLibraryTest(final boolean publicLookup) {
- final MethodType mt = MethodType.methodType(void.class, Object.class, String.class);
- final CallSite cs = createCallSite(publicLookup, CALL_METHOD, "loadLibrary", mt);
+ final CallSite cs1 = createGetMethodCallSite(publicLookup, "loadLibrary");
+ final CallSite cs2 = createCallSite(publicLookup, CALL, MethodType.methodType(void.class, Object.class, Object.class, String.class));
try {
- cs.getTarget().invoke(StaticClass.forClass(System.class), "foo");
+ final Object method = cs1.getTarget().invoke(StaticClass.forClass(System.class));
+ cs2.getTarget().invoke(method, StaticClass.forClass(System.class), "foo");
throw new RuntimeException("should not reach here in any case!");
} catch (final Throwable th) {
if (publicLookup) {
--- a/nashorn/test/src/jdk/dynalink/beans/test/BeansLinkerTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/nashorn/test/src/jdk/dynalink/beans/test/BeansLinkerTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -24,12 +24,12 @@
*/
package jdk.dynalink.beans.test;
+import static jdk.dynalink.StandardNamespace.ELEMENT;
+import static jdk.dynalink.StandardNamespace.METHOD;
+import static jdk.dynalink.StandardNamespace.PROPERTY;
import static jdk.dynalink.StandardOperation.CALL;
-import static jdk.dynalink.StandardOperation.GET_ELEMENT;
-import static jdk.dynalink.StandardOperation.GET_METHOD;
-import static jdk.dynalink.StandardOperation.GET_PROPERTY;
-import static jdk.dynalink.StandardOperation.SET_ELEMENT;
-import static jdk.dynalink.StandardOperation.SET_PROPERTY;
+import static jdk.dynalink.StandardOperation.GET;
+import static jdk.dynalink.StandardOperation.SET;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
@@ -42,12 +42,11 @@
import java.util.regex.Pattern;
import java.util.stream.Stream;
import jdk.dynalink.CallSiteDescriptor;
-import jdk.dynalink.CompositeOperation;
import jdk.dynalink.DynamicLinkerFactory;
-import jdk.dynalink.NamedOperation;
+import jdk.dynalink.Namespace;
+import jdk.dynalink.NamespaceOperation;
import jdk.dynalink.NoSuchDynamicMethodException;
import jdk.dynalink.Operation;
-import jdk.dynalink.StandardOperation;
import jdk.dynalink.support.SimpleRelinkableCallSite;
import org.testng.Assert;
import org.testng.annotations.Test;
@@ -67,32 +66,32 @@
@Test
public static void testPublicFieldPropertyUnnamedGetter() {
- testGetterPermutations(GET_PROPERTY, (op) -> Assert.assertEquals(42, call(op, new Bean1(), "answer")));
+ testGetterPermutations(PROPERTY, (op) -> Assert.assertEquals(42, call(op, new Bean1(), "answer")));
}
@Test
public static void testPublicFieldPropertyNamedGetter() {
- testGetterPermutations(GET_PROPERTY, (op) -> Assert.assertEquals(42, call(named("answer", op), new Bean1())));
+ testGetterPermutations(PROPERTY, (op) -> Assert.assertEquals(42, call(op.named("answer"), new Bean1())));
}
@Test
public static void testGetterPropertyUnnamedGetter() {
- testGetterPermutations(GET_PROPERTY, (op) -> Assert.assertEquals("bean1", call(op, new Bean1(), "name")));
+ testGetterPermutations(PROPERTY, (op) -> Assert.assertEquals("bean1", call(op, new Bean1(), "name")));
}
@Test
public static void testGetterPropertyNamedGetter() {
- testGetterPermutations(GET_PROPERTY, (op) -> Assert.assertEquals("bean1", call(named("name", op), new Bean1())));
+ testGetterPermutations(PROPERTY, (op) -> Assert.assertEquals("bean1", call(op.named("name"), new Bean1())));
}
@Test
public static void testMethodUnnamedGetter() {
- testGetterPermutations(GET_METHOD, (op) -> Assert.assertEquals("bar-foo", call(call(op, new Bean1(), "someMethod"), new Bean1(), "bar")));
+ testGetterPermutations(METHOD, (op) -> Assert.assertEquals("bar-foo", call(call(op, new Bean1(), "someMethod"), new Bean1(), "bar")));
}
@Test
public static void testMethodNamedGetter() {
- testGetterPermutations(GET_METHOD, (op) -> Assert.assertEquals("bar-foo", call(call(named("someMethod", op), new Bean1()), new Bean1(), "bar")));
+ testGetterPermutations(METHOD, (op) -> Assert.assertEquals("bar-foo", call(call(op.named("someMethod"), new Bean1()), new Bean1(), "bar")));
}
private static final Map<String, String> MAP1 = new HashMap<>();
@@ -102,12 +101,12 @@
@Test
public static void testElementUnnamedGetter() {
- testGetterPermutations(GET_ELEMENT, (op) -> Assert.assertEquals("bar", call(op, MAP1, "foo")));
+ testGetterPermutations(ELEMENT, (op) -> Assert.assertEquals("bar", call(op, MAP1, "foo")));
}
@Test
public static void testElementNamedGetter() {
- testGetterPermutations(GET_ELEMENT, (op) -> Assert.assertEquals("bar", call(named("foo", op), MAP1)));
+ testGetterPermutations(ELEMENT, (op) -> Assert.assertEquals("bar", call(op.named("foo"), MAP1)));
}
public static class Bean2 {
@@ -121,7 +120,7 @@
@Test
public static void testUnnamedFieldSetter() {
- testSetterPermutations(SET_PROPERTY, (op) -> {
+ testSetterPermutations(PROPERTY, (op) -> {
final Bean2 bean2 = new Bean2();
call(op, bean2, "answer", 12);
Assert.assertEquals(bean2.answer, 12);
@@ -130,16 +129,16 @@
@Test
public static void testNamedFieldSetter() {
- testSetterPermutations(SET_PROPERTY, (op) -> {
+ testSetterPermutations(PROPERTY, (op) -> {
final Bean2 bean2 = new Bean2();
- call(named("answer", op), bean2, 14);
+ call(op.named("answer"), bean2, 14);
Assert.assertEquals(bean2.answer, 14);
});
}
@Test
public static void testUnnamedPropertySetter() {
- testSetterPermutations(SET_PROPERTY, (op) -> {
+ testSetterPermutations(PROPERTY, (op) -> {
final Bean2 bean2 = new Bean2();
call(op, bean2, "name", "boo");
Assert.assertEquals(bean2.name, "boo");
@@ -148,14 +147,14 @@
@Test
public static void testNamedPropertySetter() {
- testSetterPermutations(SET_PROPERTY, (op) -> {
+ testSetterPermutations(PROPERTY, (op) -> {
final Bean2 bean2 = new Bean2();
- call(named("name", op), bean2, "blah");
+ call(op.named("name"), bean2, "blah");
Assert.assertEquals(bean2.name, "blah");
});
}
- private static final Pattern GET_ELEMENT_THEN_PROPERTY_PATTERN = Pattern.compile(".*GET_ELEMENT.*GET_PROPERTY.*");
+ private static final Pattern GET_ELEMENT_THEN_PROPERTY_PATTERN = Pattern.compile(".*ELEMENT.*PROPERTY.*");
@Test
public static void testUnnamedElementAndPropertyGetter() {
@@ -168,10 +167,10 @@
public static void testNamedElementAndPropertyGetter() {
final Map<String, Object> map = new HashMap<>();
map.put("empty", true);
- testGetterPermutations(GET_ELEMENT_THEN_PROPERTY_PATTERN, 4, (op) -> Assert.assertEquals(true, call(named("empty", op), map)));
+ testGetterPermutations(GET_ELEMENT_THEN_PROPERTY_PATTERN, 4, (op) -> Assert.assertEquals(true, call(op.named("empty"), map)));
}
- private static final Pattern GET_PROPERTY_THEN_ELEMENT_PATTERN = Pattern.compile(".*GET_PROPERTY.*GET_ELEMENT.*");
+ private static final Pattern GET_PROPERTY_THEN_ELEMENT_PATTERN = Pattern.compile(".*PROPERTY.*ELEMENT.*");
@Test
public static void testUnnamedPropertyAndElementGetter() {
@@ -184,7 +183,7 @@
public static void testNamedPropertyAndElementGetter() {
final Map<String, Object> map = new HashMap<>();
map.put("empty", true);
- testGetterPermutations(GET_PROPERTY_THEN_ELEMENT_PATTERN, 4, (op) -> Assert.assertEquals(false, call(named("empty", op), map)));
+ testGetterPermutations(GET_PROPERTY_THEN_ELEMENT_PATTERN, 4, (op) -> Assert.assertEquals(false, call(op.named("empty"), map)));
}
public static class MapWithProperty extends HashMap<String, Object> {
@@ -200,24 +199,24 @@
final MapWithProperty map = new MapWithProperty();
map.put("name", "element");
- call(ops(SET_PROPERTY, SET_ELEMENT), map, "name", "property");
+ call(SET.withNamespaces(PROPERTY, ELEMENT), map, "name", "property");
Assert.assertEquals("property", map.name);
Assert.assertEquals("element", map.get("name"));
- call(ops(SET_ELEMENT, SET_PROPERTY), map, "name", "element2");
+ call(SET.withNamespaces(ELEMENT, PROPERTY), map, "name", "element2");
Assert.assertEquals("property", map.name);
Assert.assertEquals("element2", map.get("name"));
}
@Test
public static void testMissingMembersAtLinkTime() {
- testPermutations(GETTER_PERMUTATIONS, (op) -> expectNoSuchDynamicMethodException(()-> call(named("foo", op), new Object())));
- testPermutations(SETTER_PERMUTATIONS, (op) -> expectNoSuchDynamicMethodException(()-> call(named("foo", op), new Object(), "newValue")));
+ testPermutations(GETTER_PERMUTATIONS, (op) -> expectNoSuchDynamicMethodException(()-> call(op.named("foo"), new Object())));
+ testPermutations(SETTER_PERMUTATIONS, (op) -> expectNoSuchDynamicMethodException(()-> call(op.named("foo"), new Object(), "newValue")));
}
@Test
public static void testMissingMembersAtRunTime() {
- call(GET_ELEMENT, new ArrayList<>(), "foo");
+ call(GET.withNamespace(ELEMENT), new ArrayList<>(), "foo");
Stream.of(new HashMap(), new ArrayList(), new Object[0]).forEach((receiver) -> {
testPermutations(GETTER_PERMUTATIONS, (op) -> { System.err.println(op + " " + receiver.getClass().getName()); Assert.assertNull(call(op, receiver, "foo"));});
// No assertion for the setter; we just expect it to silently succeed
@@ -233,59 +232,59 @@
}
}
- private static Operation[] GETTER_PERMUTATIONS = new Operation[] {
- GET_PROPERTY,
- GET_METHOD,
- GET_ELEMENT,
- ops(GET_PROPERTY, GET_ELEMENT),
- ops(GET_PROPERTY, GET_METHOD),
- ops(GET_ELEMENT, GET_PROPERTY),
- ops(GET_ELEMENT, GET_METHOD),
- ops(GET_METHOD, GET_PROPERTY),
- ops(GET_METHOD, GET_ELEMENT),
- ops(GET_PROPERTY, GET_ELEMENT, GET_METHOD),
- ops(GET_PROPERTY, GET_METHOD, GET_ELEMENT),
- ops(GET_ELEMENT, GET_PROPERTY, GET_METHOD),
- ops(GET_ELEMENT, GET_METHOD, GET_PROPERTY),
- ops(GET_METHOD, GET_PROPERTY, GET_ELEMENT),
- ops(GET_METHOD, GET_ELEMENT, GET_PROPERTY),
+ private static NamespaceOperation[] GETTER_PERMUTATIONS = new NamespaceOperation[] {
+ GET.withNamespaces(PROPERTY),
+ GET.withNamespaces(METHOD),
+ GET.withNamespaces(ELEMENT),
+ GET.withNamespaces(PROPERTY, ELEMENT),
+ GET.withNamespaces(PROPERTY, METHOD),
+ GET.withNamespaces(ELEMENT, PROPERTY),
+ GET.withNamespaces(ELEMENT, METHOD),
+ GET.withNamespaces(METHOD, PROPERTY),
+ GET.withNamespaces(METHOD, ELEMENT),
+ GET.withNamespaces(PROPERTY, ELEMENT, METHOD),
+ GET.withNamespaces(PROPERTY, METHOD, ELEMENT),
+ GET.withNamespaces(ELEMENT, PROPERTY, METHOD),
+ GET.withNamespaces(ELEMENT, METHOD, PROPERTY),
+ GET.withNamespaces(METHOD, PROPERTY, ELEMENT),
+ GET.withNamespaces(METHOD, ELEMENT, PROPERTY)
};
- private static Operation[] SETTER_PERMUTATIONS = new Operation[] {
- SET_PROPERTY,
- SET_ELEMENT,
- ops(SET_PROPERTY, SET_ELEMENT),
- ops(SET_ELEMENT, SET_PROPERTY)
+ private static NamespaceOperation[] SETTER_PERMUTATIONS = new NamespaceOperation[] {
+ SET.withNamespaces(PROPERTY),
+ SET.withNamespaces(ELEMENT),
+ SET.withNamespaces(PROPERTY, ELEMENT),
+ SET.withNamespaces(ELEMENT, PROPERTY)
};
- private static void testPermutations(final Operation[] ops, final StandardOperation requiredOp, final int expectedCount, final Consumer<Operation> test) {
- testPermutationsWithFilter(ops, (op)->CompositeOperation.contains(op, requiredOp), expectedCount, test);
+ private static void testPermutations(final NamespaceOperation[] ops, final Operation requiredOp, final Namespace requiredNamespace, final int expectedCount, final Consumer<NamespaceOperation> test) {
+ testPermutationsWithFilter(ops, (op)->NamespaceOperation.contains(op, requiredOp, requiredNamespace), expectedCount, test);
}
- private static void testPermutations(final Operation[] ops, final Pattern regex, final int expectedCount, final Consumer<Operation> test) {
+ private static void testPermutations(final NamespaceOperation[] ops, final Pattern regex, final int expectedCount, final Consumer<NamespaceOperation> test) {
testPermutationsWithFilter(ops, (op)->regex.matcher(op.toString()).matches(), expectedCount, test);
}
- private static void testPermutations(final Operation[] ops, final Consumer<Operation> test) {
+ private static void testPermutations(final NamespaceOperation[] ops, final Consumer<NamespaceOperation> test) {
testPermutationsWithFilter(ops, (op)->true, ops.length, test);
}
- private static void testPermutationsWithFilter(final Operation[] ops, final Predicate<Operation> filter, final int expectedCount, final Consumer<Operation> test) {
+ private static void testPermutationsWithFilter(final NamespaceOperation[] ops, final Predicate<NamespaceOperation> filter, final int expectedCount, final Consumer<NamespaceOperation> test) {
final int[] counter = new int[1];
Stream.of(ops).filter(filter).forEach((op)-> { counter[0]++; test.accept(op); });
Assert.assertEquals(counter[0], expectedCount);
}
- private static void testGetterPermutations(final StandardOperation requiredOp, final Consumer<Operation> test) {
- testPermutations(GETTER_PERMUTATIONS, requiredOp, 11, test);
+ private static void testGetterPermutations(final Namespace requiredNamespace, final Consumer<NamespaceOperation> test) {
+ testPermutations(GETTER_PERMUTATIONS, GET, requiredNamespace, 11, test);
}
- private static void testGetterPermutations(final Pattern regex, final int expectedCount, final Consumer<Operation> test) {
+ private static void testGetterPermutations(final Pattern regex, final int expectedCount, final Consumer<NamespaceOperation> test) {
testPermutations(GETTER_PERMUTATIONS, regex, expectedCount, test);
}
- private static void testSetterPermutations(final StandardOperation requiredOp, final Consumer<Operation> test) {
- testPermutations(SETTER_PERMUTATIONS, requiredOp, 3, test);
+ private static void testSetterPermutations(final Namespace requiredNamespace, final Consumer<NamespaceOperation> test) {
+ testPermutations(SETTER_PERMUTATIONS, SET, requiredNamespace, 3, test);
}
private static Object call(final Operation op, final Object... args) {
@@ -305,14 +304,6 @@
return call(CALL, args);
}
- private static Operation named(final Object name, final Operation... ops) {
- return new NamedOperation(ops(ops), name);
- }
-
- private static Operation ops(final Operation... ops) {
- return ops.length == 1 ? ops[0] : new CompositeOperation(ops);
- }
-
private static MethodType t(final int argCount) {
return MethodType.methodType(Object.class, Collections.nCopies(argCount, Object.class));
}
--- a/nashorn/test/src/jdk/dynalink/support/test/CallSiteTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/nashorn/test/src/jdk/dynalink/support/test/CallSiteTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -25,6 +25,9 @@
package jdk.dynalink.support.test;
+import static jdk.dynalink.StandardNamespace.PROPERTY;
+import static jdk.dynalink.StandardOperation.GET;
+
import java.lang.invoke.CallSite;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
@@ -33,14 +36,15 @@
import jdk.dynalink.CallSiteDescriptor;
import jdk.dynalink.DynamicLinker;
import jdk.dynalink.DynamicLinkerFactory;
-import jdk.dynalink.NamedOperation;
-import jdk.dynalink.StandardOperation;
+import jdk.dynalink.Operation;
import jdk.dynalink.linker.GuardedInvocation;
import jdk.dynalink.support.SimpleRelinkableCallSite;
import org.testng.Assert;
import org.testng.annotations.Test;
public class CallSiteTest {
+ private static final Operation GET_PROPERTY = GET.withNamespace(PROPERTY);
+
@Test
public void testInitialize() {
final DynamicLinkerFactory factory = new DynamicLinkerFactory();
@@ -48,7 +52,7 @@
final MethodType mt = MethodType.methodType(Object.class, Object.class);
final boolean[] initializeCalled = { Boolean.FALSE };
linker.link(new SimpleRelinkableCallSite(new CallSiteDescriptor(
- MethodHandles.publicLookup(), new NamedOperation(StandardOperation.GET_PROPERTY, "DO_NOT_CARE"), mt)) {
+ MethodHandles.publicLookup(), GET_PROPERTY.named("DO_NOT_CARE"), mt)) {
@Override
public void initialize(final MethodHandle relinkAndInvoke) {
initializeCalled[0] = Boolean.TRUE;
@@ -66,7 +70,7 @@
final MethodType mt = MethodType.methodType(Object.class, Object.class);
final boolean[] relinkCalled = { Boolean.FALSE };
final CallSite cs = linker.link(new SimpleRelinkableCallSite(new CallSiteDescriptor(
- MethodHandles.publicLookup(), new NamedOperation(StandardOperation.GET_PROPERTY, "class"), mt)) {
+ MethodHandles.publicLookup(), GET_PROPERTY.named("class"), mt)) {
@Override
public void relink(final GuardedInvocation guardedInvocation, final MethodHandle relinkAndInvoke) {
relinkCalled[0] = Boolean.TRUE;
@@ -90,7 +94,7 @@
final MethodType mt = MethodType.methodType(Object.class, Object.class);
final boolean[] resetAndRelinkCalled = { Boolean.FALSE };
final CallSite cs = linker.link(new SimpleRelinkableCallSite(new CallSiteDescriptor(
- MethodHandles.publicLookup(), new NamedOperation(StandardOperation.GET_PROPERTY, "length"), mt)) {
+ MethodHandles.publicLookup(), GET_PROPERTY.named("length"), mt)) {
@Override
public void resetAndRelink(final GuardedInvocation guardedInvocation, final MethodHandle relinkAndInvoke) {
resetAndRelinkCalled[0] = Boolean.TRUE;
--- a/nashorn/test/src/jdk/dynalink/test/DynamicLinkerFactoryTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/nashorn/test/src/jdk/dynalink/test/DynamicLinkerFactoryTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -24,6 +24,9 @@
*/
package jdk.dynalink.test;
+import static jdk.dynalink.StandardNamespace.PROPERTY;
+import static jdk.dynalink.StandardOperation.GET;
+
import java.lang.invoke.CallSite;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
@@ -35,9 +38,9 @@
import jdk.dynalink.CallSiteDescriptor;
import jdk.dynalink.DynamicLinker;
import jdk.dynalink.DynamicLinkerFactory;
-import jdk.dynalink.NamedOperation;
import jdk.dynalink.NoSuchDynamicMethodException;
import jdk.dynalink.Operation;
+import jdk.dynalink.StandardNamespace;
import jdk.dynalink.StandardOperation;
import jdk.dynalink.beans.StaticClass;
import jdk.dynalink.linker.GuardedInvocation;
@@ -52,6 +55,8 @@
@SuppressWarnings("javadoc")
public class DynamicLinkerFactoryTest {
+ private static final Operation GET_PROPERTY = GET.withNamespace(PROPERTY);
+
private static DynamicLinkerFactory newDynamicLinkerFactory(final boolean resetClassLoader) {
final DynamicLinkerFactory factory = new DynamicLinkerFactory();
if (resetClassLoader) {
@@ -190,7 +195,7 @@
final MethodType mt = MethodType.methodType(Object.class, Object.class, String.class);
final DynamicLinker linker = factory.createLinker();
final CallSite cs = linker.link(new SimpleRelinkableCallSite(new CallSiteDescriptor(
- MethodHandles.publicLookup(), StandardOperation.GET_PROPERTY, mt)));
+ MethodHandles.publicLookup(), GET_PROPERTY, mt)));
Assert.assertFalse(reachedPrelinkTransformer[0]);
Assert.assertEquals(cs.getTarget().invoke(new Object(), "class"), Object.class);
Assert.assertTrue(reachedPrelinkTransformer[0]);
@@ -209,7 +214,7 @@
final MethodType mt = MethodType.methodType(Object.class, Object.class, String.class);
final DynamicLinker linker = factory.createLinker();
final CallSite cs = linker.link(new SimpleRelinkableCallSite(new CallSiteDescriptor(
- MethodHandles.publicLookup(), StandardOperation.GET_PROPERTY, mt)));
+ MethodHandles.publicLookup(), GET_PROPERTY, mt)));
Assert.assertFalse(reachedInternalObjectsFilter[0]);
Assert.assertEquals(cs.getTarget().invoke(new Object(), "class"), Object.class);
Assert.assertTrue(reachedInternalObjectsFilter[0]);
@@ -252,7 +257,7 @@
final MethodType mt = MethodType.methodType(Object.class, Object.class);
final CallSiteDescriptor testDescriptor = new CallSiteDescriptor(MethodHandles.publicLookup(),
- new NamedOperation(StandardOperation.GET_METHOD, methodName), mt);
+ GET.withNamespace(StandardNamespace.METHOD).named(methodName), mt);
final CallSite cs = linker.link(new SimpleRelinkableCallSite(testDescriptor));
TrustedGuardingDynamicLinkerExporter.enable();
@@ -274,7 +279,7 @@
final DynamicLinker linker = factory.createLinker();
final MethodType mt = MethodType.methodType(Object.class, Object.class);
- final NamedOperation op = new NamedOperation(StandardOperation.GET_PROPERTY, "foo");
+ final Operation op = GET_PROPERTY.named("foo");
final CallSite cs = linker.link(new SimpleRelinkableCallSite(new CallSiteDescriptor(
MethodHandles.publicLookup(), op, mt)));
final boolean[] reachedGetMember = new boolean[1];
@@ -306,7 +311,7 @@
// check that the nashorn exported linker can be used for ScriptObjectMirror
final ScriptEngine engine = new ScriptEngineManager().getEngineByName("nashorn");
final MethodType mt = MethodType.methodType(Object.class, Object.class);
- final NamedOperation op = new NamedOperation(StandardOperation.GET_PROPERTY, "foo");
+ final Operation op = GET_PROPERTY.named("foo");
final CallSite cs = linker.link(new SimpleRelinkableCallSite(new CallSiteDescriptor(
MethodHandles.publicLookup(), op, mt)));
Object value = null;
--- a/nashorn/test/src/jdk/dynalink/test/LinkedCallSiteLocationTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/nashorn/test/src/jdk/dynalink/test/LinkedCallSiteLocationTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -24,20 +24,21 @@
*/
package jdk.dynalink.test;
-import static jdk.dynalink.StandardOperation.CALL_METHOD;
-
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
import jdk.dynalink.CallSiteDescriptor;
import jdk.dynalink.DynamicLinker;
import jdk.dynalink.DynamicLinkerFactory;
-import jdk.dynalink.NamedOperation;
+import jdk.dynalink.Operation;
+import jdk.dynalink.StandardNamespace;
+import jdk.dynalink.StandardOperation;
import jdk.dynalink.linker.GuardingDynamicLinker;
import jdk.dynalink.support.SimpleRelinkableCallSite;
import org.testng.Assert;
import org.testng.annotations.Test;
public class LinkedCallSiteLocationTest {
+ private static final Operation GET_METHOD = StandardOperation.GET.withNamespace(StandardNamespace.METHOD);
@Test
public void testLinkedCallSiteLocation() throws Throwable {
final StackTraceElement[] lastLinked = new StackTraceElement[1];
@@ -51,7 +52,7 @@
final SimpleRelinkableCallSite callSite = new SimpleRelinkableCallSite(
new CallSiteDescriptor(
MethodHandles.lookup(),
- new NamedOperation(CALL_METHOD, "foo"),
+ GET_METHOD.named("foo"),
MethodType.methodType(void.class, Object.class)));
linker.link(callSite);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/src/jdk/dynalink/test/TrustedUnderscoreNameLinkerExporter.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * - Neither the name of Oracle nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package jdk.dynalink.test;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import jdk.dynalink.CallSiteDescriptor;
+import jdk.dynalink.NamedOperation;
+import jdk.dynalink.NamespaceOperation;
+import jdk.dynalink.Operation;
+import jdk.dynalink.StandardNamespace;
+import jdk.dynalink.StandardOperation;
+import jdk.dynalink.linker.GuardedInvocation;
+import jdk.dynalink.linker.GuardingDynamicLinker;
+import jdk.dynalink.linker.GuardingDynamicLinkerExporter;
+import jdk.dynalink.linker.LinkRequest;
+import jdk.dynalink.linker.LinkerServices;
+import jdk.dynalink.linker.support.SimpleLinkRequest;
+
+/**
+ * This is a dynalink pluggable linker (see http://openjdk.java.net/jeps/276).
+ * This linker translater underscore_separated method names to CamelCase names
+ * used in Java APIs.
+ */
+public final class TrustedUnderscoreNameLinkerExporter extends GuardingDynamicLinkerExporter {
+ private static final Pattern UNDERSCORE_NAME = Pattern.compile("_(.)");
+
+ // translate underscore_separated name as a CamelCase name
+ private static String translateToCamelCase(final String name) {
+ final Matcher m = UNDERSCORE_NAME.matcher(name);
+ final StringBuilder buf = new StringBuilder();
+ while (m.find()) {
+ m.appendReplacement(buf, m.group(1).toUpperCase());
+ }
+ m.appendTail(buf);
+ return buf.toString();
+ }
+
+ @Override
+ public List<GuardingDynamicLinker> get() {
+ final ArrayList<GuardingDynamicLinker> linkers = new ArrayList<>();
+ linkers.add(new GuardingDynamicLinker() {
+ @Override
+ public GuardedInvocation getGuardedInvocation(final LinkRequest request,
+ final LinkerServices linkerServices) throws Exception {
+ final CallSiteDescriptor desc = request.getCallSiteDescriptor();
+ final Operation op = desc.getOperation();
+ final Object name = NamedOperation.getName(op);
+ final Operation namespaceOp = NamedOperation.getBaseOperation(op);
+ // is this a named GET_METHOD?
+ final boolean isGetMethod =
+ NamespaceOperation.getBaseOperation(namespaceOp) == StandardOperation.GET
+ && StandardNamespace.findFirst(namespaceOp) == StandardNamespace.METHOD;
+ if (isGetMethod && name instanceof String) {
+ final String str = (String)name;
+ if (str.indexOf('_') == -1) {
+ return null;
+ }
+
+ final String nameStr = translateToCamelCase(str);
+ // create a new call descriptor to use translated name
+ final CallSiteDescriptor newDesc = AccessController.doPrivileged(
+ new PrivilegedAction<CallSiteDescriptor>() {
+ @Override
+ public CallSiteDescriptor run() {
+ return desc.changeOperation(((NamedOperation)op).changeName(nameStr));
+ }
+ });
+ // create a new Link request to link the call site with translated name
+ final LinkRequest newRequest = request.replaceArguments(newDesc, request.getArguments());
+ // return guarded invocation linking the translated request
+ return linkerServices.getGuardedInvocation(newRequest);
+ }
+
+ return null;
+ }
+ });
+ return linkers;
+ }
+}
--- a/nashorn/test/src/jdk/nashorn/api/javaaccess/test/ArrayConversionTest.java Wed Nov 09 15:20:30 2016 +0300
+++ b/nashorn/test/src/jdk/nashorn/api/javaaccess/test/ArrayConversionTest.java Wed Nov 09 10:04:43 2016 -0800
@@ -104,11 +104,11 @@
@Test
public void testVarArgs() throws ScriptException {
// Sole NativeArray in vararg position becomes vararg array itself
- runTest("assertVarArg_42_17", "[42, 17]");
+ runTest("assertVarArgWith42And17", "[42, 17]");
// NativeArray in vararg position becomes an argument if there are more arguments
- runTest("assertVarArg_array_17", "[42], 18");
+ runTest("assertVarArgArray7", "[42], 18");
// Only NativeArray is converted to vararg array, other objects (e.g. a function) aren't
- runTest("assertVarArg_function", "function() { return 'Hello' }");
+ runTest("assertVarArgFunction", "function() { return 'Hello' }");
}
private static void runTest(final String testMethodName, final String argument) throws ScriptException {
@@ -209,20 +209,20 @@
assertEquals(Arrays.asList("apple", "orange"), array[1]);
}
- public static void assertVarArg_42_17(final Object... args) {
+ public static void assertVarArgWith42And17(final Object... args) {
assertEquals(2, args.length);
assertEquals(42, ((Number)args[0]).intValue());
assertEquals(17, ((Number)args[1]).intValue());
}
- public static void assertVarArg_array_17(final Object... args) throws ScriptException {
+ public static void assertVarArgArray7(final Object... args) throws ScriptException {
assertEquals(2, args.length);
e.getBindings(ScriptContext.ENGINE_SCOPE).put("arr", args[0]);
assertTrue((Boolean)e.eval("arr instanceof Array && arr.length == 1 && arr[0] == 42"));
assertEquals(18, ((Number)args[1]).intValue());
}
- public static void assertVarArg_function(final Object... args) throws ScriptException {
+ public static void assertVarArgFunction(final Object... args) throws ScriptException {
assertEquals(1, args.length);
e.getBindings(ScriptContext.ENGINE_SCOPE).put("fn", args[0]);
assertEquals("Hello", e.eval("fn()"));
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/src/jdk/nashorn/api/scripting/test/JDK_8169050_Test.java Wed Nov 09 10:04:43 2016 -0800
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package jdk.nashorn.api.scripting.test;
+
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
+import javax.script.ScriptException;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+import static org.testng.Assert.*;
+
+/**
+ * @bug 8169050
+ * @summary underscore_linker.js sample fails after dynalink changes for JDK-8168005
+ */
+public class JDK_8169050_Test {
+ private ScriptEngine engine;
+
+ @BeforeClass
+ public void setupTest() {
+ engine = new ScriptEngineManager().getEngineByName("js");
+ }
+
+ @Test
+ public void testUndersoreName() throws ScriptException {
+ engine.eval("var S = java.util.stream.Stream, v = 0;");
+ // The underscore name 'for_each' exercises pluggable dynalink linker
+ engine.eval("S.of(4, 5, 9).for_each(function(x) { v += x })");
+ assertEquals(18, ((Number)engine.get("v")).intValue());
+ }
+}
--- a/test/Makefile Wed Nov 09 15:20:30 2016 +0300
+++ b/test/Makefile Wed Nov 09 10:04:43 2016 -0800
@@ -74,13 +74,14 @@
jaxp_%:
@$(NO_STOPPING)$(call SUBDIR_TEST, $(JAXP_DIR), CONCURRENCY=$(JDK_TEST_JOBS) TEST="$@" $@)
-ifeq ($(TEST_JOBS), 0)
- HOTSPOT_TEST_JOBS=1
-else
- HOTSPOT_TEST_JOBS=$(TEST_JOBS)
+SUB_MAKE_ARGS :=
+ifneq ($(TEST_JOBS), 0)
+ ifneq ($(TEST_JOBS), )
+ SUB_MAKE_ARGS += CONCURRENCY=$(TEST_JOBS)
+ endif
endif
hotspot_%:
- @$(NO_STOPPING)$(call SUBDIR_TEST, $(HOTSPOT_DIR), CONCURRENCY=$(HOTSPOT_TEST_JOBS) TEST="$@" $@)
+ @$(NO_STOPPING)$(call SUBDIR_TEST, $(HOTSPOT_DIR), $(SUB_MAKE_ARGS) TEST="$@" $@)
#
# jtreg_tests
--- a/test/make/TestJavaCompilation.gmk Wed Nov 09 15:20:30 2016 +0300
+++ b/test/make/TestJavaCompilation.gmk Wed Nov 09 10:04:43 2016 -0800
@@ -202,9 +202,9 @@
DEPENDENCIES := $(OUTPUT_DIR)/_jar3_created, \
SRCS := $(JAR3_SRC_ROOT1) $(JAR3_SRC_ROOT2), \
EXTRA_FILES := extra-file \
- dir2/file$$$$foo.dollar \
+ dir2/file$$foo.dollar \
$(JAR3_SRC_ROOT2)/extra-file-abs, \
- EXCLUDE_FILES := dir1/file1$$$$foo.class, \
+ EXCLUDE_FILES := dir1/file1$$foo.class, \
JAR := $(JAR3_FILE), \
))
--- a/test/make/TestMakeBase.gmk Wed Nov 09 15:20:30 2016 +0300
+++ b/test/make/TestMakeBase.gmk Wed Nov 09 10:04:43 2016 -0800
@@ -209,9 +209,9 @@
test ! -e $(VARDEP_FLAG_FILE)
#
# Test including some problematic characters
- $(MAKE) -f $(THIS_FILE) VARDEP_TEST_VAR='value4 \$$$$ORIGIN' $(VARDEP_TARGET_FILE)
+ $(MAKE) -f $(THIS_FILE) VARDEP_TEST_VAR='value4 \$$ORIGIN' $(VARDEP_TARGET_FILE)
$(RM) $(VARDEP_FLAG_FILE)
- $(MAKE) -f $(THIS_FILE) VARDEP_TEST_VAR='value4 \$$$$ORIGIN' $(VARDEP_TARGET_FILE)
+ $(MAKE) -f $(THIS_FILE) VARDEP_TEST_VAR='value4 \$$ORIGIN' $(VARDEP_TARGET_FILE)
test ! -e $(VARDEP_FLAG_FILE)
# Test specifying a specific value file to store variable in