--- a/.hgtags Fri Oct 14 19:12:37 2016 +0300
+++ b/.hgtags Fri Oct 14 11:11:19 2016 -0700
@@ -381,3 +381,4 @@
1b4b5d01aa11edf24b6fadbe3d2f3e411e3b02cd jdk-9+136
9cb87c88ed851c0575b8ead753ea238ed5b544e9 jdk-9+137
d273dfe9a126d3bffe92072547fef2cd1361b0eb jdk-9+138
+65477538bec32963dc41153d89c4417eb46c45fc jdk-9+139
--- a/.hgtags-top-repo Fri Oct 14 19:12:37 2016 +0300
+++ b/.hgtags-top-repo Fri Oct 14 11:11:19 2016 -0700
@@ -381,3 +381,4 @@
3ec350f5f32af249b59620d7e37b54bdcd77b233 jdk-9+136
d7f519b004254b19e384131d9f0d0e40e31a0fd3 jdk-9+137
67c4388142bdf58aec8fefa4475faaa8a5d7380c jdk-9+138
+7dcf453eacae79ee86a6bcc75fd0b546fc99b48a jdk-9+139
--- a/ASSEMBLY_EXCEPTION Fri Oct 14 19:12:37 2016 +0300
+++ b/ASSEMBLY_EXCEPTION Fri Oct 14 11:11:19 2016 -0700
@@ -1,27 +1,27 @@
OPENJDK ASSEMBLY EXCEPTION
-The OpenJDK source code made available by Sun at openjdk.java.net and
-openjdk.dev.java.net ("OpenJDK Code") is distributed under the terms of the
-GNU General Public License <http://www.gnu.org/copyleft/gpl.html> version 2
+The OpenJDK source code made available by Oracle America, Inc. (Oracle) at
+openjdk.java.net ("OpenJDK Code") is distributed under the terms of the GNU
+General Public License <http://www.gnu.org/copyleft/gpl.html> version 2
only ("GPL2"), with the following clarification and special exception.
Linking this OpenJDK Code statically or dynamically with other code
is making a combined work based on this library. Thus, the terms
and conditions of GPL2 cover the whole combination.
- As a special exception, Sun gives you permission to link this
- OpenJDK Code with certain code licensed by Sun as indicated at
+ As a special exception, Oracle gives you permission to link this
+ OpenJDK Code with certain code licensed by Oracle as indicated at
http://openjdk.java.net/legal/exception-modules-2007-05-08.html
("Designated Exception Modules") to produce an executable,
regardless of the license terms of the Designated Exception Modules,
and to copy and distribute the resulting executable under GPL2,
provided that the Designated Exception Modules continue to be
- governed by the licenses under which they were offered by Sun.
+ governed by the licenses under which they were offered by Oracle.
-As such, it allows licensees and sublicensees of Sun's GPL2 OpenJDK Code to
-build an executable that includes those portions of necessary code that Sun
-could not provide under GPL2 (or that Sun has provided under GPL2 with the
-Classpath exception). If you modify or add to the OpenJDK code, that new
-GPL2 code may still be combined with Designated Exception Modules if the
-new code is made subject to this exception by its copyright holder.
+As such, it allows licensees and sublicensees of Oracle's GPL2 OpenJDK Code
+to build an executable that includes those portions of necessary code that
+Oracle could not provide under GPL2 (or that Oracle has provided under GPL2
+with the Classpath exception). If you modify or add to the OpenJDK code,
+that new GPL2 code may still be combined with Designated Exception Modules
+if the new code is made subject to this exception by its copyright holder.
--- a/common/bin/compare.sh Fri Oct 14 19:12:37 2016 +0300
+++ b/common/bin/compare.sh Fri Oct 14 11:11:19 2016 -0700
@@ -654,10 +654,10 @@
OTHER_DIZ_FILE="$OTHER/support/native/java.base/java_objs/java.diz"
elif [ "$NAME" = "jimage.exe" ] \
&& [ -f "$OTHER/support/native/jdk.jlink/jimage_objs/jimage.diz" ]; then
- OTHER_DIZ_FILE="$OTHER/support/native/jdk.jlink/jimage_objs/jimage.diz"
+ OTHER_DIZ_FILE="$OTHER/support/modules_cmds/jdk.jlink/jimage.diz"
elif [ "$NAME" = "javacpl.exe" ] \
&& [ -f "$OTHER/support/native/jdk.plugin/javacpl/javacpl.diz" ]; then
- OTHER_DIZ_FILE="$OTHER/support/native/jdk.plugin/javacpl/javacpl.diz"
+ OTHER_DIZ_FILE="$OTHER/support/modules_cmds/jdk.deploy.controlpanel/javacpl.diz"
elif [ -f "${OTHER_FILE_BASE}.diz" ]; then
OTHER_DIZ_FILE=${OTHER_FILE_BASE}.diz
else
@@ -686,10 +686,10 @@
THIS_DIZ_FILE="$THIS/support/native/java.base/java_objs/java.diz"
elif [ "$NAME" = "jimage.exe" ] \
&& [ -f "$THIS/support/native/jdk.jlink/jimage_objs/jimage.diz" ]; then
- THIS_DIZ_FILE="$THIS/support/native/jdk.jlink/jimage_objs/jimage.diz"
+ THIS_DIZ_FILE="$THIS/support/modules_cmds/jdk.jlink/jimage.diz"
elif [ "$NAME" = "javacpl.exe" ] \
&& [ -f "$THIS/support/native/jdk.plugin/javacpl/javacpl.diz" ]; then
- THIS_DIZ_FILE="$THIS/support/native/jdk.plugin/javacpl/javacpl.diz"
+ THIS_DIZ_FILE="$THIS/support/modules_cmds/jdk.deploy.controlpanel/javacpl.diz"
elif [ -f "${THIS_FILE_BASE}.diz" ]; then
THIS_DIZ_FILE=${THIS_FILE/.dll/}.diz
else
--- a/corba/.hgtags Fri Oct 14 19:12:37 2016 +0300
+++ b/corba/.hgtags Fri Oct 14 11:11:19 2016 -0700
@@ -381,3 +381,4 @@
aa053a3faf266c12b4fd5272da431a3e08e4a3e3 jdk-9+136
258cf18fa7fc59359b874f8743b7168dc48baf73 jdk-9+137
27bb44be32076861a0951bcefb07a1d92509a4b6 jdk-9+138
+8c9da7fc5b07c606afd571c7012441b77dda83b2 jdk-9+139
--- a/corba/ASSEMBLY_EXCEPTION Fri Oct 14 19:12:37 2016 +0300
+++ b/corba/ASSEMBLY_EXCEPTION Fri Oct 14 11:11:19 2016 -0700
@@ -1,27 +1,27 @@
OPENJDK ASSEMBLY EXCEPTION
-The OpenJDK source code made available by Sun at openjdk.java.net and
-openjdk.dev.java.net ("OpenJDK Code") is distributed under the terms of the
-GNU General Public License <http://www.gnu.org/copyleft/gpl.html> version 2
+The OpenJDK source code made available by Oracle America, Inc. (Oracle) at
+openjdk.java.net ("OpenJDK Code") is distributed under the terms of the GNU
+General Public License <http://www.gnu.org/copyleft/gpl.html> version 2
only ("GPL2"), with the following clarification and special exception.
Linking this OpenJDK Code statically or dynamically with other code
is making a combined work based on this library. Thus, the terms
and conditions of GPL2 cover the whole combination.
- As a special exception, Sun gives you permission to link this
- OpenJDK Code with certain code licensed by Sun as indicated at
+ As a special exception, Oracle gives you permission to link this
+ OpenJDK Code with certain code licensed by Oracle as indicated at
http://openjdk.java.net/legal/exception-modules-2007-05-08.html
("Designated Exception Modules") to produce an executable,
regardless of the license terms of the Designated Exception Modules,
and to copy and distribute the resulting executable under GPL2,
provided that the Designated Exception Modules continue to be
- governed by the licenses under which they were offered by Sun.
+ governed by the licenses under which they were offered by Oracle.
-As such, it allows licensees and sublicensees of Sun's GPL2 OpenJDK Code to
-build an executable that includes those portions of necessary code that Sun
-could not provide under GPL2 (or that Sun has provided under GPL2 with the
-Classpath exception). If you modify or add to the OpenJDK code, that new
-GPL2 code may still be combined with Designated Exception Modules if the
-new code is made subject to this exception by its copyright holder.
+As such, it allows licensees and sublicensees of Oracle's GPL2 OpenJDK Code
+to build an executable that includes those portions of necessary code that
+Oracle could not provide under GPL2 (or that Oracle has provided under GPL2
+with the Classpath exception). If you modify or add to the OpenJDK code,
+that new GPL2 code may still be combined with Designated Exception Modules
+if the new code is made subject to this exception by its copyright holder.
--- a/hotspot/.hgtags Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/.hgtags Fri Oct 14 11:11:19 2016 -0700
@@ -541,3 +541,4 @@
a20da289f646ee44440695b81abc0548330e4ca7 jdk-9+136
dfcbf839e299e7e2bba1da69bdb347617ea4c7e8 jdk-9+137
fc0956308c7a586267c5dd35dff74f773aa9c3eb jdk-9+138
+08492e67bf3226784dab3bf9ae967382ddbc1af5 jdk-9+139
--- a/hotspot/ASSEMBLY_EXCEPTION Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/ASSEMBLY_EXCEPTION Fri Oct 14 11:11:19 2016 -0700
@@ -1,9 +1,9 @@
OPENJDK ASSEMBLY EXCEPTION
-The OpenJDK source code made available by Oracle at openjdk.java.net and
-openjdk.dev.java.net ("OpenJDK Code") is distributed under the terms of the
-GNU General Public License <http://www.gnu.org/copyleft/gpl.html> version 2
+The OpenJDK source code made available by Oracle America, Inc. (Oracle) at
+openjdk.java.net ("OpenJDK Code") is distributed under the terms of the GNU
+General Public License <http://www.gnu.org/copyleft/gpl.html> version 2
only ("GPL2"), with the following clarification and special exception.
Linking this OpenJDK Code statically or dynamically with other code
@@ -19,9 +19,9 @@
provided that the Designated Exception Modules continue to be
governed by the licenses under which they were offered by Oracle.
-As such, it allows licensees and sublicensees of Oracle's GPL2 OpenJDK Code to
-build an executable that includes those portions of necessary code that Oracle
-could not provide under GPL2 (or that Oracle has provided under GPL2 with the
-Classpath exception). If you modify or add to the OpenJDK code, that new
-GPL2 code may still be combined with Designated Exception Modules if the
-new code is made subject to this exception by its copyright holder.
+As such, it allows licensees and sublicensees of Oracle's GPL2 OpenJDK Code
+to build an executable that includes those portions of necessary code that
+Oracle could not provide under GPL2 (or that Oracle has provided under GPL2
+with the Classpath exception). If you modify or add to the OpenJDK code,
+that new GPL2 code may still be combined with Designated Exception Modules
+if the new code is made subject to this exception by its copyright holder.
--- a/hotspot/make/BuildHotspot.gmk Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/make/BuildHotspot.gmk Fri Oct 14 11:11:19 2016 -0700
@@ -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
@@ -45,10 +45,7 @@
jsig:
+$(MAKE) -f lib/CompileLibjsig.gmk
-dist: $(VARIANT_TARGETS) jsig
- +$(MAKE) -f Dist.gmk
-
-all: dist
+all: $(VARIANT_TARGETS) jsig
.PHONY: $(VARIANT_TARGETS) $(VARIANT_GENSRC_TARGETS) $(VARIANT_LIBS_TARGETS) \
- jsig dist all
+ jsig all
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/make/CopyToExplodedJdk.gmk Fri Oct 14 11:11:19 2016 -0700
@@ -0,0 +1,55 @@
+#
+# 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.
+#
+
+# Copy all built libraries into exploded jdk
+LIB_TARGETS := $(filter $(LIB_OUTPUTDIR)/%, $(TARGETS))
+ifeq ($(OPENJDK_TARGET_OS), windows)
+ $(eval $(call SetupCopyFiles, COPY_LIBS_BIN, \
+ SRC := $(SUPPORT_OUTPUTDIR)/modules_libs/java.base, \
+ DEST := $(JDK_OUTPUTDIR)/bin, \
+ FILES := $(filter-out %.lib, $(LIB_TARGETS)), \
+ ))
+
+ $(eval $(call SetupCopyFiles, COPY_LIBS_LIB, \
+ SRC := $(SUPPORT_OUTPUTDIR)/modules_libs/java.base, \
+ DEST := $(JDK_OUTPUTDIR)/lib, \
+ FILES := $(filter %.lib, $(LIB_TARGETS))))
+
+ TARGETS += $(COPY_LIBS_BIN) $(COPY_LIBS_LIB)
+else
+ $(eval $(call SetupCopyFiles, COPY_LIBS, \
+ SRC := $(SUPPORT_OUTPUTDIR)/modules_libs/java.base, \
+ DEST := $(JDK_OUTPUTDIR)/lib, \
+ FILES := $(filter %$(SHARED_LIBRARY_SUFFIX), $(LIB_TARGETS)), \
+ ))
+ $(eval $(call SetupCopyFiles, LINK_LIBS, \
+ SRC := $(SUPPORT_OUTPUTDIR)/modules_libs/java.base, \
+ DEST := $(JDK_OUTPUTDIR)/lib, \
+ FILES := $(filter-out %$(SHARED_LIBRARY_SUFFIX), $(LIB_TARGETS)), \
+ MACRO := link-file-relative, \
+ ))
+
+ TARGETS += $(COPY_LIBS) $(LINK_LIBS)
+endif
--- a/hotspot/make/Dist.gmk Fri Oct 14 19:12:37 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,223 +0,0 @@
-#
-# 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. Oracle designates this
-# particular file as subject to the "Classpath" exception as provided
-# by Oracle in the LICENSE file that accompanied this code.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-################################################################################
-# Copy the generated output into well-defined places in the dist directory.
-
-# This must be the first rule
-default: all
-
-include $(SPEC)
-include MakeBase.gmk
-
-$(eval $(call IncludeCustomExtension, hotspot, Dist.gmk))
-
-DIST_OUTPUTDIR := $(HOTSPOT_OUTPUTDIR)/dist
-
-# Unfortunately, all platforms have different target subdirs.
-ifeq ($(OPENJDK_TARGET_OS), windows)
- LIB_SUBDIR := bin
-else ifeq ($(OPENJDK_TARGET_OS), macosx)
- LIB_SUBDIR := lib
-else
- LIB_SUBDIR := lib$(OPENJDK_TARGET_CPU_LIBDIR)
-endif
-
-################################################################################
-# Setup make rules to copy a native library and associated data.
-#
-# 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.
-#
-# Remaining parameters are named arguments. These include:
-# NAME -- The base name of the native library (e.g. 'jvm')
-# VARIANT -- The variant to copy from
-# VARIANT_TARGET_DIR -- The variant target sub dir, with trailing slash, optional
-SetupDistLibFile = $(NamedParamsMacroTemplate)
-define SetupDistLibFileBody
- ifneq ($$($1_VARIANT), )
- $1_SRC_DIR := $$(HOTSPOT_OUTPUTDIR)/variant-$$($1_VARIANT)/lib$$($1_NAME)
- else
- $1_SRC_DIR := $$(HOTSPOT_OUTPUTDIR)/lib$$($1_NAME)
- endif
- $1_LIB_NAME := $(LIBRARY_PREFIX)$$($1_NAME)
- $1_TARGET_DIR := $$(DIST_OUTPUTDIR)/$$(LIB_SUBDIR)/$$($1_VARIANT_TARGET_DIR)
-
- # Copy the the native library.
- $$(eval $$(call SetupCopyFiles, $1_COPY_LIB, \
- DEST := $$($1_TARGET_DIR), \
- FILES := $$(wildcard \
- $$($1_SRC_DIR)/$$($1_LIB_NAME)$(SHARED_LIBRARY_SUFFIX)), \
- ))
-
- TARGETS += $$($1_COPY_LIB)
-
- # Copy related data (debug symbols, static-build symbols file etc)
- $$(eval $$(call SetupCopyFiles, $1_COPY_FILES, \
- DEST := $$($1_TARGET_DIR), \
- FILES := $$(wildcard \
- $$(addprefix $$($1_SRC_DIR)/$$($1_LIB_NAME), \
- .diz .debuginfo .pdb .map .symbols)), \
- ))
-
- TARGETS += $$($1_COPY_FILES)
-
- ifeq ($(OPENJDK_TARGET_OS), macosx)
- # Debug symbols on macosx is a directory, not a single file, per library.
- $1_DSYM_SRC := $$($1_SRC_DIR)/$$($1_LIB_NAME)$(SHARED_LIBRARY_SUFFIX).dSYM)
- ifneq ($$(wildcard $$($1_DSYM_SRC)), )
- $$(eval $$(call SetupCopyFiles, $1_COPY_DSYM_DIR, \
- DEST := $$($1_TARGET_DIR), \
- SRC := $$($1_SRC_DIR), \
- FILES := $$(shell $(FIND) $$($1_DSYM_SRC) -type f), \
- ))
- TARGETS += $$($1_COPY_DSYM_DIR)
- endif
- endif
-endef
-
-################################################################################
-# Copy common files, which are independent on the jvm variant(s) being built.
-# For files that were generated during the build, we assume all versions of
-# these files are identical, and just pick one arbitrarily to use as source.
-
-ANY_JVM_VARIANT := $(firstword $(JVM_VARIANTS))
-JVM_VARIANT_OUTPUTDIR := $(HOTSPOT_OUTPUTDIR)/variant-$(ANY_JVM_VARIANT)
-
-### Copy platform-independent .h files
-INCLUDE_FILES_SRC_DIR := $(HOTSPOT_TOPDIR)/src/share/vm
-$(eval $(call SetupCopyFiles, COPY_INCLUDE, \
- SRC := $(INCLUDE_FILES_SRC_DIR), \
- DEST := $(DIST_OUTPUTDIR)/include, \
- FLATTEN := true, \
- FILES := $(INCLUDE_FILES_SRC_DIR)/prims/jni.h \
- $(INCLUDE_FILES_SRC_DIR)/code/jvmticmlr.h \
- $(INCLUDE_FILES_SRC_DIR)/services/jmm.h))
-
-TARGETS += $(COPY_INCLUDE)
-
-### Copy jni_md.h
-
-# This might have been defined in a custom extension
-ifeq ($(JNI_MD_H_SRC), )
- JNI_MD_H_SRC := $(HOTSPOT_TOPDIR)/src/cpu/$(HOTSPOT_TARGET_CPU_ARCH)/vm/jni_$(HOTSPOT_TARGET_CPU_ARCH).h
-endif
-
-ifeq ($(OPENJDK_TARGET_OS), macosx)
- # NOTE: This should most likely be darwin, but the old hotspot build uses bsd
- JNI_MD_SUBDIR := bsd
-else ifeq ($(OPENJDK_TARGET_OS), windows)
- JNI_MD_SUBDIR := win32
-else
- JNI_MD_SUBDIR := $(OPENJDK_TARGET_OS)
-endif
-
-# SetupCopyFiles is not used here since it's non-trivial to copy a single
-# file with a different target name.
-$(DIST_OUTPUTDIR)/include/$(JNI_MD_SUBDIR)/jni_md.h: $(JNI_MD_H_SRC)
- $(call LogInfo, Copying hotspot/dist/include/$(JNI_MD_SUBDIR)/jni_md.h)
- $(install-file)
-
-TARGETS += $(DIST_OUTPUTDIR)/include/$(JNI_MD_SUBDIR)/jni_md.h
-
-$(eval $(call SetupCopyFiles, COPY_JVMTI_H, \
- DEST := $(DIST_OUTPUTDIR)/include, \
- FLATTEN := true, \
- FILES := $(JVM_VARIANT_OUTPUTDIR)/gensrc/jvmtifiles/jvmti.h))
-
-TARGETS += $(COPY_JVMTI_H)
-
-# NOTE: In the old build, this file was not copied on Windows.
-ifneq ($(OPENJDK_TARGET_OS), windows)
- $(eval $(call SetupCopyFiles, COPY_JVMTI_HTML, \
- DEST := $(DIST_OUTPUTDIR)/docs/platform/jvmti, \
- FILES := $(JVM_VARIANT_OUTPUTDIR)/gensrc/jvmtifiles/jvmti.html))
-endif
-
-TARGETS += $(COPY_JVMTI_HTML)
-
-ifeq ($(OPENJDK_TARGET_OS), windows)
- $(eval $(call SetupCopyFiles, COPY_JVM_LIB, \
- DEST := $(DIST_OUTPUTDIR)/lib, \
- FILES :=$(JVM_VARIANT_OUTPUTDIR)/libjvm/objs/jvm.lib))
-
- TARGETS += $(COPY_JVM_LIB)
-endif
-
-# Copy libjsig, if it exists
-$(eval $(call SetupDistLibFile, DIST_jsig, \
- NAME := jsig, \
-))
-
-################################################################################
-# Copy variant-specific files
-
-# Setup make rules to copy a single variant to dist.
-# $1: The name of the variant
-define SetupDistForVariant
- ifneq ($$(filter client minimal, $1), )
- VARIANT_TARGET_DIR := $1
- else
- # Use 'server' as default target directory name for all other variants.
- VARIANT_TARGET_DIR := server
- endif
-
- $$(eval $$(call SetupDistLibFile, DIST_$(strip $1)_jvm, \
- NAME := jvm, \
- VARIANT := $1, \
- VARIANT_TARGET_DIR := $$(VARIANT_TARGET_DIR)/, \
- ))
-
- # Copy the dtrace libraries, if they exist
- $$(eval $$(call SetupDistLibFile, DIST_$(strip $1)_jvm_db, \
- NAME := jvm_db, \
- VARIANT := $1, \
- VARIANT_TARGET_DIR := $$(VARIANT_TARGET_DIR)/, \
- ))
-
- $$(eval $$(call SetupDistLibFile, DIST_$(strip $1)_jvm_dtrace, \
- NAME := jvm_dtrace, \
- VARIANT := $1, \
- VARIANT_TARGET_DIR := $$(VARIANT_TARGET_DIR)/, \
- ))
-
- # Copy the Xusage.txt file
- $$(eval $$(call SetupCopyFiles, DIST_$(strip $1)_Xusage, \
- DEST := $$(DIST_OUTPUTDIR)/$$(LIB_SUBDIR)/$(strip $1), \
- FILES := $$(HOTSPOT_OUTPUTDIR)/variant-$(strip $1)/support/misc/Xusage.txt, \
- ))
-
- TARGETS += $$(DIST_$(strip $1)_Xusage)
-endef
-
-$(foreach variant, $(JVM_VARIANTS), \
- $(eval $(call SetupDistForVariant, $(variant))) \
-)
-
-################################################################################
-
-all: $(TARGETS)
-
-.PHONY: all
--- a/hotspot/make/HotspotCommon.gmk Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/make/HotspotCommon.gmk Fri Oct 14 11:11:19 2016 -0700
@@ -33,6 +33,15 @@
DTRACE_SUPPORT_DIR := $(JVM_SUPPORT_DIR)/dtrace
+LIB_OUTPUTDIR := $(call FindLibDirForModule, java.base)
+ifneq ($(filter client minimal, $(JVM_VARIANT)), )
+ JVM_VARIANT_SUBDIR := $(JVM_VARIANT)
+else
+ # Use 'server' as default target directory name for all other variants.
+ JVM_VARIANT_SUBDIR := server
+endif
+JVM_LIB_OUTPUTDIR := $(LIB_OUTPUTDIR)/$(JVM_VARIANT_SUBDIR)
+
################################################################################
# Test if a feature is available in the present build of JVM_VARIANT. Will return
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/make/copy/Copy-java.base.gmk Fri Oct 14 11:11:19 2016 -0700
@@ -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. Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+# These include files are currently being copied from the jdk repository for
+# historical reasons. Disable copying from here until this has been cleaned up.
+# The files in hotspot differ slightly from the corresponding files in jdk.
+# See JDK-8167078.
+
+INCLUDE_DST_DIR := $(SUPPORT_OUTPUTDIR)/modules_include/$(MODULE)
+
+################################################################################
+# Copy platform-independent .h files
+$(eval $(call SetupCopyFiles, COPY_INCLUDE_FILES, \
+ SRC := $(HOTSPOT_TOPDIR)/src/share/vm, \
+ DEST := $(INCLUDE_DST_DIR), \
+ FLATTEN := true, \
+ FILES := prims/jni.h code/jvmticmlr.h \
+))
+
+#TARGETS += $(COPY_INCLUDE_FILES)
+
+################################################################################
+# Copy jni_md.h
+
+# This might have been defined in a custom extension
+JNI_MD_H_SRC ?= $(HOTSPOT_TOPDIR)/src/cpu/$(HOTSPOT_TARGET_CPU_ARCH)/vm/jni_$(HOTSPOT_TARGET_CPU_ARCH).h
+
+ifeq ($(OPENJDK_TARGET_OS), macosx)
+ # NOTE: This should most likely be darwin, but the old hotspot build uses bsd
+ JNI_MD_SUBDIR := bsd
+else ifeq ($(OPENJDK_TARGET_OS), windows)
+ JNI_MD_SUBDIR := win32
+else
+ JNI_MD_SUBDIR := $(OPENJDK_TARGET_OS)
+endif
+
+# SetupCopyFiles is not used here since it's non-trivial to copy a single
+# file with a different target name.
+$(INCLUDE_DST_DIR)/$(JNI_MD_SUBDIR)/jni_md.h: $(JNI_MD_H_SRC)
+ $(call LogInfo, Copying hotspot/dist/include/$(JNI_MD_SUBDIR)/jni_md.h)
+ $(install-file)
+
+#TARGETS += $(INCLUDE_DST_DIR)/$(JNI_MD_SUBDIR)/jni_md.h
+
+################################################################################
--- a/hotspot/make/gensrc/GenerateSources.gmk Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/make/gensrc/GenerateSources.gmk Fri Oct 14 11:11:19 2016 -0700
@@ -47,7 +47,7 @@
# The Xusage.txt file needs to have platform specific path separator
$(eval $(call SetupTextFileProcessing, CREATE_XUSAGE, \
SOURCE_FILES := $(HOTSPOT_TOPDIR)/src/share/vm/Xusage.txt, \
- OUTPUT_FILE := $(JVM_SUPPORT_DIR)/misc/Xusage.txt, \
+ OUTPUT_FILE := $(JVM_LIB_OUTPUTDIR)/Xusage.txt, \
REPLACEMENTS := separated by ;> => separated by $(PATH_SEP)> ; , \
))
--- a/hotspot/make/gensrc/GensrcJvmti.gmk Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/make/gensrc/GensrcJvmti.gmk Fri Oct 14 11:11:19 2016 -0700
@@ -67,7 +67,8 @@
$$($1_OUTPUT_DIR)/$1: $$($1_XML_FILE) $$($1_XSL_FILE) $$($1_DEPS) $$(BUILD_JVMTI_TOOLS)
$$(call LogInfo, Generating $$(@F))
$$(call MakeDir, $$(@D))
- $$(call ExecuteWithLog, $$@, $$(TOOL_JVMTI_GEN) -IN $$($1_XML_FILE) -XSL $$($1_XSL_FILE) -OUT $$@ $$($1_ARGS))
+ $$(call ExecuteWithLog, $$@, $$(TOOL_JVMTI_GEN) -IN $$($1_XML_FILE) \
+ -XSL $$($1_XSL_FILE) -OUT $$@ $$($1_ARGS))
# jvmtiGen does not return error code properly on fail.
# NOTE: We should really fix jvmtiGen.java instead.
test -f $$@
@@ -129,13 +130,28 @@
TARGETS += $(JVMTI_OUTPUTDIR)/jvmtiEnvRecommended.cpp
################################################################################
+# Disable copy of jvmti.h from hotspot until this has been cleared up. The file
+# is currently being copied from the jdk repository. See JDK-8167078.
+# 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, \
+# ))
+
+# TARGETS += $(COPY_JVMTI_H)
+#endif
+
+################################################################################
# Create trace files in gensrc/tracefiles
TRACE_OUTPUTDIR := $(JVM_VARIANT_OUTPUTDIR)/gensrc/tracefiles
TRACE_SRCDIR := $(HOTSPOT_TOPDIR)/src/share/vm/trace
-# Append directories to search (might have been set by custom extensions)
-TRACE_SEARCH_DIRS += $(TRACE_SRCDIR)
+# Append list of XSL files to search (might have been set by custom extensions)
+TRACE_XSL_FILES += $(wildcard $(TRACE_SRCDIR)/*.xsl)
TRACE_XML ?= $(TRACE_SRCDIR)/trace.xml
@@ -155,7 +171,7 @@
define SetupTraceGeneration
$$(eval $$(call SetupXslTransform, $1, \
XML_FILE := $$(TRACE_XML), \
- XSL_FILE := $$(firstword $$(wildcard $$(addsuffix /$$(basename $1).xsl, $$(TRACE_SEARCH_DIRS)))), \
+ XSL_FILE := $$(firstword $$(filter %/$$(basename $1).xsl, $$(TRACE_XSL_FILES))), \
OUTPUT_DIR := $$(TRACE_OUTPUTDIR), \
DEPS := $$(TRACE_DEPS), \
))
--- a/hotspot/make/lib/CompileDtracePostJvm.gmk Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/make/lib/CompileDtracePostJvm.gmk Fri Oct 14 11:11:19 2016 -0700
@@ -180,7 +180,7 @@
$(eval $(call SetupNativeCompilation, BUILD_LIBJVM_DTRACE, \
LIBRARY := jvm_dtrace, \
- OUTPUT_DIR := $(LIBJVM_DTRACE_OUTPUTDIR), \
+ OUTPUT_DIR := $(JVM_LIB_OUTPUTDIR), \
SRC := $(HOTSPOT_TOPDIR)/src/os/solaris/dtrace, \
INCLUDE_FILES := jvm_dtrace.c, \
CFLAGS := -m64 -G -mt -KPIC, \
@@ -197,7 +197,7 @@
# the old build.
$(eval $(call SetupNativeCompilation, BUILD_LIBJVM_DB, \
LIBRARY := jvm_db, \
- OUTPUT_DIR := $(LIBJVM_DB_OUTPUTDIR), \
+ OUTPUT_DIR := $(JVM_LIB_OUTPUTDIR), \
SRC := $(HOTSPOT_TOPDIR)/src/os/solaris/dtrace, \
INCLUDE_FILES := libjvm_db.c, \
CFLAGS := -I$(JVM_VARIANT_OUTPUTDIR)/gensrc -I$(DTRACE_SUPPORT_DIR) \
--- a/hotspot/make/lib/CompileJvm.gmk Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/make/lib/CompileJvm.gmk Fri Oct 14 11:11:19 2016 -0700
@@ -174,13 +174,6 @@
JVM_RCFLAGS += -D"HS_FILEDESC=$(HOTSPOT_VM_DISTRO) $(RC_DESC)$(JVM_VARIANT) VM"
endif
-ifeq ($(OPENJDK_TARGET_OS), macosx)
- # NOTE: The old build did not strip binaries on macosx.
- JVM_STRIP_SYMBOLS := false
-else
- JVM_STRIP_SYMBOLS := true
-endif
-
JVM_OPTIMIZATION ?= HIGHEST_JVM
################################################################################
@@ -189,7 +182,7 @@
$(eval $(call SetupNativeCompilation, BUILD_LIBJVM, \
TOOLCHAIN := TOOLCHAIN_LINK_CXX, \
LIBRARY := jvm, \
- OUTPUT_DIR := $(JVM_OUTPUTDIR), \
+ OUTPUT_DIR := $(JVM_LIB_OUTPUTDIR), \
SRC := $(JVM_SRC_DIRS), \
EXCLUDES := $(JVM_EXCLUDES), \
EXCLUDE_FILES := $(JVM_EXCLUDE_FILES), \
@@ -211,7 +204,6 @@
OBJECT_DIR := $(JVM_OUTPUTDIR)/objs, \
MAPFILE := $(JVM_MAPFILE), \
USE_MAPFILE_FOR_SYMBOLS := true, \
- STRIP_SYMBOLS := $(JVM_STRIP_SYMBOLS), \
EMBED_MANIFEST := true, \
RC_FLAGS := $(JVM_RCFLAGS), \
VERSIONINFO_RESOURCE := $(HOTSPOT_TOPDIR)/src/os/windows/vm/version.rc, \
@@ -219,6 +211,18 @@
PRECOMPILED_HEADER_EXCLUDE := $(JVM_PRECOMPILED_HEADER_EXCLUDE), \
))
+ifeq ($(OPENJDK_TARGET_OS), windows)
+ # It doesn't matter which jvm.lib file gets exported, but we need
+ # to pick just one.
+ ifeq ($(JVM_VARIANT), $(firstword $(JVM_VARIANTS)))
+ $(eval $(call SetupCopyFiles, COPY_JVM_LIB, \
+ DEST := $(LIB_OUTPUTDIR), \
+ FILES :=$(JVM_VARIANT_OUTPUTDIR)/libjvm/objs/jvm.lib, \
+ ))
+ TARGETS += $(COPY_JVM_LIB)
+ endif
+endif
+
# AIX warning explanation:
# 1500-010 : (W) WARNING in ...: Infinite loop. Program may not stop.
# There are several infinite loops in the vm, so better suppress.
--- a/hotspot/make/lib/CompileLibjsig.gmk Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/make/lib/CompileLibjsig.gmk Fri Oct 14 11:11:19 2016 -0700
@@ -34,7 +34,6 @@
ifneq ($(OPENJDK_TARGET_OS), windows)
ifeq ($(STATIC_BUILD), false)
- LIBJSIG_STRIP_SYMBOLS := true
ifeq ($(OPENJDK_TARGET_OS), linux)
LIBJSIG_CFLAGS := -fPIC -D_GNU_SOURCE -D_REENTRANT $(EXTRA_CFLAGS)
LIBJSIG_LDFLAGS := $(LDFLAGS_HASH_STYLE) $(EXTRA_CFLAGS)
@@ -72,8 +71,6 @@
else ifeq ($(OPENJDK_TARGET_OS), macosx)
LIBJSIG_CFLAGS := -m64 -D_GNU_SOURCE -pthread -mno-omit-leaf-frame-pointer -mstack-alignment=16 -fPIC
LIBJSIG_LDFLAGS := $(LDFLAGS_HASH_STYLE)
- # NOTE: This lib is not stripped on macosx in old build. Looks like a mistake.
- LIBJSIG_STRIP_SYMBOLS := false
else
$(error Unknown target OS $(OPENJDK_TARGET_OS) in CompileLibjsig.gmk)
endif
@@ -84,20 +81,71 @@
LIBJSIG_LDFLAGS += $(SHARED_LIBRARY_FLAGS)
+ LIB_OUTPUTDIR := $(call FindLibDirForModule, java.base)
+
$(eval $(call SetupNativeCompilation, BUILD_LIBJSIG, \
LIBRARY := jsig, \
EXTRA_FILES := $(LIBJSIG_SRC_FILE), \
- OUTPUT_DIR := $(LIBJSIG_OUTPUTDIR), \
+ OUTPUT_DIR := $(LIB_OUTPUTDIR), \
LANG := C, \
CFLAGS := $(LIBJSIG_CFLAGS) $(LIBJSIG_CPU_FLAGS), \
LDFLAGS := $(LIBJSIG_LDFLAGS) $(LIBJSIG_CPU_FLAGS), \
LIBS := $(LIBJSIG_LIBS), \
MAPFILE := $(LIBJSIG_MAPFILE), \
OBJECT_DIR := $(LIBJSIG_OUTPUTDIR)/objs, \
- STRIP_SYMBOLS := $(LIBJSIG_STRIP_SYMBOLS), \
))
TARGETS += $(BUILD_LIBJSIG)
+
+ ############################################################################
+ # Create symlinks in each variant sub dir
+ ifeq ($(OPENJDK_TARGET_OS), macosx)
+ DEBUG_INFO_SUFFIX := $(SHARED_LIBRARY_SUFFIX).dSYM
+ else
+ DEBUG_INFO_SUFFIX := .debuginfo
+ endif
+
+ # $1 variant subdir
+ define CreateSymlinks
+ # Always symlink from libdir/variant/libjsig.so -> ../libjsig.so and
+ # the corresponding debuginfo.
+ $(LIB_OUTPUTDIR)/$1/$(call SHARED_LIBRARY,jsig): \
+ $(LIB_OUTPUTDIR)/$(call SHARED_LIBRARY,jsig)
+ $$(call MakeDir, $$(@D))
+ $(RM) $$@
+ $(LN) -s ../$$(@F) $$@
+
+ TARGETS += $(LIB_OUTPUTDIR)/$1/$(call SHARED_LIBRARY,jsig)
+
+ ifeq ($(COPY_DEBUG_SYMBOLS), true)
+ $(LIB_OUTPUTDIR)/$1/$(LIBRARY_PREFIX)jsig$(DEBUG_INFO_SUFFIX): \
+ $(LIB_OUTPUTDIR)/$(call SHARED_LIBRARY,jsig)
+ $$(call MakeDir, $$(@D))
+ $(RM) $$@
+ $(LN) -s ../$$(@F) $$@
+
+ TARGETS += $(LIB_OUTPUTDIR)/$1/$(LIBRARY_PREFIX)jsig$(DEBUG_INFO_SUFFIX)
+
+ ifeq ($(ZIP_EXTERNAL_DEBUG_SYMBOLS), true)
+ $(LIB_OUTPUTDIR)/$1/$(LIBRARY_PREFIX)jsig.diz: \
+ $(LIB_OUTPUTDIR)/$1/$(LIBRARY_PREFIX)jsig$(DEBUG_INFO_SUFFIX)
+ $(CD) $$(@D) && $(ZIP) -q -y $$@ $$(basename $$(@F))$(DEBUG_INFO_SUFFIX)
+
+ TARGETS += $(LIB_OUTPUTDIR)/$1/$(LIBRARY_PREFIX)jsig.diz
+ endif
+ endif
+ endef
+
+ # The subdir is the same as the variant for client and minimal, for all
+ # others it's server.
+ VARIANT_SUBDIRS := $(filter client minimal, $(JVM_VARIANTS)) \
+ $(if $(filter-out client minimal, $(JVM_VARIANTS)), server)
+ $(foreach v, $(VARIANT_SUBDIRS), $(eval $(call CreateSymlinks,$v)))
+
+ ############################################################################
+
+ include CopyToExplodedJdk.gmk
+
endif
endif
--- a/hotspot/make/lib/CompileLibraries.gmk Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/make/lib/CompileLibraries.gmk Fri Oct 14 11:11:19 2016 -0700
@@ -41,6 +41,8 @@
include lib/CompileGtest.gmk
endif
+include CopyToExplodedJdk.gmk
+
all: $(TARGETS)
.PHONY: all
--- a/hotspot/make/lib/JvmOverrideFiles.gmk Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/make/lib/JvmOverrideFiles.gmk Fri Oct 14 11:11:19 2016 -0700
@@ -31,6 +31,7 @@
ifeq ($(TOOLCHAIN_TYPE), gcc)
BUILD_LIBJVM_vmStructs.cpp_CXXFLAGS := -fno-var-tracking-assignments -O0
+ BUILD_LIBJVM_jvmciCompilerToVM.cpp_CXXFLAGS := -fno-var-tracking-assignments
endif
ifeq ($(OPENJDK_TARGET_OS), linux)
--- a/hotspot/make/test/JtregNative.gmk Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/make/test/JtregNative.gmk Fri Oct 14 11:11:19 2016 -0700
@@ -55,6 +55,9 @@
$(HOTSPOT_TOPDIR)/test/testlibrary/jvmti \
$(HOTSPOT_TOPDIR)/test/compiler/jvmci/jdk.vm.ci.code.test \
$(HOTSPOT_TOPDIR)/test/serviceability/jvmti/GetModulesInfo \
+ $(HOTSPOT_TOPDIR)/test/serviceability/jvmti/ModuleAwareAgents/ClassFileLoadHook \
+ $(HOTSPOT_TOPDIR)/test/serviceability/jvmti/ModuleAwareAgents/ClassLoadPrepare \
+ $(HOTSPOT_TOPDIR)/test/serviceability/jvmti/ModuleAwareAgents/ThreadStart \
#
# Add conditional directories here when needed.
@@ -75,6 +78,9 @@
BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_liboverflow := -lc
BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libSimpleClassFileLoadHook := -lc
BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libGetNamedModuleTest := -lc
+ BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libMAAClassFileLoadHook := -lc
+ BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libMAAClassLoadPrepare := -lc
+ BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libMAAThreadStart := -lc
endif
ifeq ($(OPENJDK_TARGET_OS), linux)
--- a/hotspot/src/cpu/aarch64/vm/c1_LIRGenerator_aarch64.cpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/cpu/aarch64/vm/c1_LIRGenerator_aarch64.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -140,10 +140,11 @@
LIR_Address* LIRGenerator::generate_address(LIR_Opr base, LIR_Opr index,
int shift, int disp, BasicType type) {
assert(base->is_register(), "must be");
+ intx large_disp = disp;
// accumulate fixed displacements
if (index->is_constant()) {
- disp += index->as_constant_ptr()->as_jint() << shift;
+ large_disp += (intx)(index->as_constant_ptr()->as_jint()) << shift;
index = LIR_OprFact::illegalOpr;
}
@@ -154,31 +155,31 @@
__ shift_left(index, shift, tmp);
index = tmp;
}
- if (disp != 0) {
+ if (large_disp != 0) {
LIR_Opr tmp = new_pointer_register();
- if (Assembler::operand_valid_for_add_sub_immediate(disp)) {
- __ add(tmp, tmp, LIR_OprFact::intptrConst(disp));
+ if (Assembler::operand_valid_for_add_sub_immediate(large_disp)) {
+ __ add(tmp, tmp, LIR_OprFact::intptrConst(large_disp));
index = tmp;
} else {
- __ move(tmp, LIR_OprFact::intptrConst(disp));
+ __ move(tmp, LIR_OprFact::intptrConst(large_disp));
__ add(tmp, index, tmp);
index = tmp;
}
- disp = 0;
+ large_disp = 0;
}
- } else if (disp != 0 && !Address::offset_ok_for_immed(disp, shift)) {
+ } else if (large_disp != 0 && !Address::offset_ok_for_immed(large_disp, shift)) {
// index is illegal so replace it with the displacement loaded into a register
index = new_pointer_register();
- __ move(LIR_OprFact::intptrConst(disp), index);
- disp = 0;
+ __ move(LIR_OprFact::intptrConst(large_disp), index);
+ large_disp = 0;
}
// at this point we either have base + index or base + displacement
- if (disp == 0) {
+ if (large_disp == 0) {
return new LIR_Address(base, index, type);
} else {
- assert(Address::offset_ok_for_immed(disp, 0), "must be");
- return new LIR_Address(base, disp, type);
+ assert(Address::offset_ok_for_immed(large_disp, 0), "must be");
+ return new LIR_Address(base, large_disp, type);
}
}
@@ -192,7 +193,7 @@
LIR_Address* addr;
if (index_opr->is_constant()) {
addr = new LIR_Address(array_opr,
- offset_in_bytes + index_opr->as_jint() * elem_size, type);
+ offset_in_bytes + (intx)(index_opr->as_jint()) * elem_size, type);
} else {
if (offset_in_bytes) {
LIR_Opr tmp = new_pointer_register();
@@ -1032,6 +1033,10 @@
Unimplemented();
}
+void LIRGenerator::do_FmaIntrinsic(Intrinsic* x) {
+ fatal("FMA intrinsic is not implemented on this platform");
+}
+
void LIRGenerator::do_vectorizedMismatch(Intrinsic* x) {
fatal("vectorizedMismatch intrinsic is not implemented on this platform");
}
--- a/hotspot/src/cpu/aarch64/vm/interp_masm_aarch64.cpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/cpu/aarch64/vm/interp_masm_aarch64.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -327,7 +327,7 @@
void InterpreterMacroAssembler::push_l(Register r) {
str(zr, pre(esp, -wordSize));
- str(r, pre(esp, -wordsize));
+ str(r, pre(esp, - wordSize));
}
void InterpreterMacroAssembler::pop_f(FloatRegister r) {
--- a/hotspot/src/cpu/aarch64/vm/vm_version_aarch64.cpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/cpu/aarch64/vm/vm_version_aarch64.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -262,6 +262,11 @@
FLAG_SET_DEFAULT(UseCRC32CIntrinsics, false);
}
+ if (UseFMA) {
+ warning("FMA instructions are not available on this CPU");
+ FLAG_SET_DEFAULT(UseFMA, false);
+ }
+
if (auxv & (HWCAP_SHA1 | HWCAP_SHA2)) {
if (FLAG_IS_DEFAULT(UseSHA)) {
FLAG_SET_DEFAULT(UseSHA, true);
--- a/hotspot/src/cpu/ppc/vm/assembler_ppc.hpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/cpu/ppc/vm/assembler_ppc.hpp Fri Oct 14 11:11:19 2016 -0700
@@ -506,6 +506,8 @@
// Vector-Scalar (VSX) instruction support.
LXVD2X_OPCODE = (31u << OPCODE_SHIFT | 844u << 1),
STXVD2X_OPCODE = (31u << OPCODE_SHIFT | 972u << 1),
+ MTVSRD_OPCODE = (31u << OPCODE_SHIFT | 179u << 1),
+ MFVSRD_OPCODE = (31u << OPCODE_SHIFT | 51u << 1),
// Vector Permute and Formatting
VPKPX_OPCODE = (4u << OPCODE_SHIFT | 782u ),
@@ -1573,6 +1575,9 @@
inline void stdu( Register d, int si16, Register s1);
inline void stdux(Register s, Register a, Register b);
+ inline void st_ptr(Register d, int si16, Register s1);
+ DEBUG_ONLY(inline void st_ptr(Register d, ByteSize b, Register s1);)
+
// PPC 1, section 3.3.13 Move To/From System Register Instructions
inline void mtlr( Register s1);
inline void mflr( Register d);
@@ -2099,6 +2104,8 @@
// Vector-Scalar (VSX) instructions.
inline void lxvd2x( VectorSRegister d, Register a, Register b);
inline void stxvd2x( VectorSRegister d, Register a, Register b);
+ inline void mtvrd( VectorRegister d, Register a);
+ inline void mfvrd( Register a, VectorRegister d);
// AES (introduced with Power 8)
inline void vcipher( VectorRegister d, VectorRegister a, VectorRegister b);
--- a/hotspot/src/cpu/ppc/vm/assembler_ppc.inline.hpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/cpu/ppc/vm/assembler_ppc.inline.hpp Fri Oct 14 11:11:19 2016 -0700
@@ -349,6 +349,9 @@
inline void Assembler::stdu( Register d, int si16, Register s1) { emit_int32(STDU_OPCODE | rs(d) | ds(si16) | rta0mem(s1));}
inline void Assembler::stdux(Register s, Register a, Register b) { emit_int32(STDUX_OPCODE| rs(s) | rta0mem(a) | rb(b));}
+inline void Assembler::st_ptr(Register d, int b, Register s1) { std(d, b, s1); }
+DEBUG_ONLY(inline void Assembler::st_ptr(Register d, ByteSize b, Register s1) { std(d, in_bytes(b), s1); })
+
// PPC 1, section 3.3.13 Move To/From System Register Instructions
inline void Assembler::mtlr( Register s1) { emit_int32(MTLR_OPCODE | rs(s1)); }
inline void Assembler::mflr( Register d ) { emit_int32(MFLR_OPCODE | rt(d)); }
@@ -733,6 +736,8 @@
// Vector-Scalar (VSX) instructions.
inline void Assembler::lxvd2x (VectorSRegister d, Register s1, Register s2) { emit_int32( LXVD2X_OPCODE | vsrt(d) | ra(s1) | rb(s2)); }
inline void Assembler::stxvd2x(VectorSRegister d, Register s1, Register s2) { emit_int32( STXVD2X_OPCODE | vsrt(d) | ra(s1) | rb(s2)); }
+inline void Assembler::mtvrd( VectorRegister d, Register a) { emit_int32( MTVSRD_OPCODE | vrt(d) | ra(a) | 1u); } // 1u: d is treated as Vector (VMX/Altivec).
+inline void Assembler::mfvrd( Register a, VectorRegister d) { emit_int32( MFVSRD_OPCODE | vrt(d) | ra(a) | 1u); } // 1u: d is treated as Vector (VMX/Altivec).
inline void Assembler::vpkpx( VectorRegister d, VectorRegister a, VectorRegister b) { emit_int32( VPKPX_OPCODE | vrt(d) | vra(a) | vrb(b)); }
inline void Assembler::vpkshss( VectorRegister d, VectorRegister a, VectorRegister b) { emit_int32( VPKSHSS_OPCODE | vrt(d) | vra(a) | vrb(b)); }
--- a/hotspot/src/cpu/ppc/vm/c1_LIRGenerator_ppc.cpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/cpu/ppc/vm/c1_LIRGenerator_ppc.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -157,10 +157,11 @@
LIR_Address* LIRGenerator::generate_address(LIR_Opr base, LIR_Opr index,
int shift, int disp, BasicType type) {
assert(base->is_register(), "must be");
+ intx large_disp = disp;
// Accumulate fixed displacements.
if (index->is_constant()) {
- disp += index->as_constant_ptr()->as_jint() << shift;
+ large_disp += (intx)(index->as_constant_ptr()->as_jint()) << shift;
index = LIR_OprFact::illegalOpr;
}
@@ -171,31 +172,31 @@
__ shift_left(index, shift, tmp);
index = tmp;
}
- if (disp != 0) {
+ if (large_disp != 0) {
LIR_Opr tmp = new_pointer_register();
- if (Assembler::is_simm16(disp)) {
- __ add(index, LIR_OprFact::intptrConst(disp), tmp);
+ if (Assembler::is_simm16(large_disp)) {
+ __ add(index, LIR_OprFact::intptrConst(large_disp), tmp);
index = tmp;
} else {
- __ move(LIR_OprFact::intptrConst(disp), tmp);
+ __ move(LIR_OprFact::intptrConst(large_disp), tmp);
__ add(tmp, index, tmp);
index = tmp;
}
- disp = 0;
+ large_disp = 0;
}
- } else if (!Assembler::is_simm16(disp)) {
+ } else if (!Assembler::is_simm16(large_disp)) {
// Index is illegal so replace it with the displacement loaded into a register.
index = new_pointer_register();
- __ move(LIR_OprFact::intptrConst(disp), index);
- disp = 0;
+ __ move(LIR_OprFact::intptrConst(large_disp), index);
+ large_disp = 0;
}
// At this point we either have base + index or base + displacement.
- if (disp == 0) {
+ if (large_disp == 0) {
return new LIR_Address(base, index, type);
} else {
- assert(Assembler::is_simm16(disp), "must be");
- return new LIR_Address(base, disp, type);
+ assert(Assembler::is_simm16(large_disp), "must be");
+ return new LIR_Address(base, large_disp, type);
}
}
@@ -206,11 +207,11 @@
int shift = exact_log2(elem_size);
LIR_Opr base_opr;
- int offset = arrayOopDesc::base_offset_in_bytes(type);
+ intx offset = arrayOopDesc::base_offset_in_bytes(type);
if (index_opr->is_constant()) {
- int i = index_opr->as_constant_ptr()->as_jint();
- int array_offset = i * elem_size;
+ intx i = index_opr->as_constant_ptr()->as_jint();
+ intx array_offset = i * elem_size;
if (Assembler::is_simm16(array_offset + offset)) {
base_opr = array_opr;
offset = array_offset + offset;
@@ -1433,6 +1434,10 @@
}
}
+void LIRGenerator::do_FmaIntrinsic(Intrinsic* x) {
+ fatal("FMA intrinsic is not implemented on this platform");
+}
+
void LIRGenerator::do_vectorizedMismatch(Intrinsic* x) {
fatal("vectorizedMismatch intrinsic is not implemented on this platform");
}
--- a/hotspot/src/cpu/ppc/vm/interp_masm_ppc_64.cpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/cpu/ppc/vm/interp_masm_ppc_64.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -261,6 +261,9 @@
}
void InterpreterMacroAssembler::push_l(Register r) {
+ // Clear unused slot.
+ load_const_optimized(R0, 0L);
+ std(R0, 0, R15_esp);
std(r, - Interpreter::stackElementSize, R15_esp);
addi(R15_esp, R15_esp, - 2 * Interpreter::stackElementSize );
}
--- a/hotspot/src/cpu/ppc/vm/macroAssembler_ppc.cpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/cpu/ppc/vm/macroAssembler_ppc.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -4332,6 +4332,565 @@
BLOCK_COMMENT("} kernel_crc32_1byte");
}
+/**
+ * @param crc register containing existing CRC (32-bit)
+ * @param buf register pointing to input byte buffer (byte*)
+ * @param len register containing number of bytes
+ * @param table register pointing to CRC table
+ * @param constants register pointing to CRC table for 128-bit aligned memory
+ * @param barretConstants register pointing to table for barrett reduction
+ * @param t0 volatile register
+ * @param t1 volatile register
+ * @param t2 volatile register
+ * @param t3 volatile register
+ */
+void MacroAssembler::kernel_crc32_1word_vpmsumd(Register crc, Register buf, Register len, Register table,
+ Register constants, Register barretConstants,
+ Register t0, Register t1, Register t2, Register t3, Register t4) {
+ assert_different_registers(crc, buf, len, table);
+
+ Label L_alignedHead, L_tail, L_alignTail, L_start, L_end;
+
+ Register prealign = t0;
+ Register postalign = t0;
+
+ BLOCK_COMMENT("kernel_crc32_1word_vpmsumb {");
+
+ // 1. use kernel_crc32_1word for shorter than 384bit
+ clrldi(len, len, 32);
+ cmpdi(CCR0, len, 384);
+ bge(CCR0, L_start);
+
+ Register tc0 = t4;
+ Register tc1 = constants;
+ Register tc2 = barretConstants;
+ kernel_crc32_1word(crc, buf, len, table,t0, t1, t2, t3, tc0, tc1, tc2, table);
+ b(L_end);
+
+ BIND(L_start);
+
+ // 2. ~c
+ nand(crc, crc, crc);
+
+ // 3. calculate from 0 to first 128bit-aligned address
+ clrldi_(prealign, buf, 57);
+ beq(CCR0, L_alignedHead);
+
+ subfic(prealign, prealign, 128);
+
+ subf(len, prealign, len);
+ update_byteLoop_crc32(crc, buf, prealign, table, t2, false, false);
+
+ // 4. calculate from first 128bit-aligned address to last 128bit-aligned address
+ BIND(L_alignedHead);
+
+ clrldi(postalign, len, 57);
+ subf(len, postalign, len);
+
+ // len must be more than 256bit
+ kernel_crc32_1word_aligned(crc, buf, len, constants, barretConstants, t1, t2, t3);
+
+ // 5. calculate remaining
+ cmpdi(CCR0, postalign, 0);
+ beq(CCR0, L_tail);
+
+ update_byteLoop_crc32(crc, buf, postalign, table, t2, false, false);
+
+ BIND(L_tail);
+
+ // 6. ~c
+ nand(crc, crc, crc);
+
+ BIND(L_end);
+
+ BLOCK_COMMENT("} kernel_crc32_1word_vpmsumb");
+}
+
+/**
+ * @param crc register containing existing CRC (32-bit)
+ * @param buf register pointing to input byte buffer (byte*)
+ * @param len register containing number of bytes
+ * @param constants register pointing to CRC table for 128-bit aligned memory
+ * @param barretConstants register pointing to table for barrett reduction
+ * @param t0 volatile register
+ * @param t1 volatile register
+ * @param t2 volatile register
+ */
+void MacroAssembler::kernel_crc32_1word_aligned(Register crc, Register buf, Register len,
+ Register constants, Register barretConstants, Register t0, Register t1, Register t2) {
+ Label L_mainLoop, L_tail, L_alignTail, L_barrett_reduction, L_end, L_first_warm_up_done, L_first_cool_down, L_second_cool_down, L_XOR, L_test;
+ Label L_lv0, L_lv1, L_lv2, L_lv3, L_lv4, L_lv5, L_lv6, L_lv7, L_lv8, L_lv9, L_lv10, L_lv11, L_lv12, L_lv13, L_lv14, L_lv15;
+ Label L_1, L_2, L_3, L_4;
+
+ Register rLoaded = t0;
+ Register rTmp1 = t1;
+ Register rTmp2 = t2;
+ Register off16 = R22;
+ Register off32 = R23;
+ Register off48 = R24;
+ Register off64 = R25;
+ Register off80 = R26;
+ Register off96 = R27;
+ Register off112 = R28;
+ Register rIdx = R29;
+ Register rMax = R30;
+ Register constantsPos = R31;
+
+ VectorRegister mask_32bit = VR24;
+ VectorRegister mask_64bit = VR25;
+ VectorRegister zeroes = VR26;
+ VectorRegister const1 = VR27;
+ VectorRegister const2 = VR28;
+
+ // Save non-volatile vector registers (frameless).
+ Register offset = t1; int offsetInt = 0;
+ offsetInt -= 16; li(offset, -16); stvx(VR20, offset, R1_SP);
+ offsetInt -= 16; addi(offset, offset, -16); stvx(VR21, offset, R1_SP);
+ offsetInt -= 16; addi(offset, offset, -16); stvx(VR22, offset, R1_SP);
+ offsetInt -= 16; addi(offset, offset, -16); stvx(VR23, offset, R1_SP);
+ offsetInt -= 16; addi(offset, offset, -16); stvx(VR24, offset, R1_SP);
+ offsetInt -= 16; addi(offset, offset, -16); stvx(VR25, offset, R1_SP);
+ offsetInt -= 16; addi(offset, offset, -16); stvx(VR26, offset, R1_SP);
+ offsetInt -= 16; addi(offset, offset, -16); stvx(VR27, offset, R1_SP);
+ offsetInt -= 16; addi(offset, offset, -16); stvx(VR28, offset, R1_SP);
+ offsetInt -= 8; std(R22, offsetInt, R1_SP);
+ offsetInt -= 8; std(R23, offsetInt, R1_SP);
+ offsetInt -= 8; std(R24, offsetInt, R1_SP);
+ offsetInt -= 8; std(R25, offsetInt, R1_SP);
+ offsetInt -= 8; std(R26, offsetInt, R1_SP);
+ offsetInt -= 8; std(R27, offsetInt, R1_SP);
+ offsetInt -= 8; std(R28, offsetInt, R1_SP);
+ offsetInt -= 8; std(R29, offsetInt, R1_SP);
+ offsetInt -= 8; std(R30, offsetInt, R1_SP);
+ offsetInt -= 8; std(R31, offsetInt, R1_SP);
+
+ // Set constants
+ li(off16, 16);
+ li(off32, 32);
+ li(off48, 48);
+ li(off64, 64);
+ li(off80, 80);
+ li(off96, 96);
+ li(off112, 112);
+
+ clrldi(crc, crc, 32);
+
+ vxor(zeroes, zeroes, zeroes);
+ vspltisw(VR0, -1);
+
+ vsldoi(mask_32bit, zeroes, VR0, 4);
+ vsldoi(mask_64bit, zeroes, VR0, -8);
+
+ // Get the initial value into v8
+ vxor(VR8, VR8, VR8);
+ mtvrd(VR8, crc);
+ vsldoi(VR8, zeroes, VR8, -8); // shift into bottom 32 bits
+
+ li (rLoaded, 0);
+
+ rldicr(rIdx, len, 0, 56);
+
+ {
+ BIND(L_1);
+ // Checksum in blocks of MAX_SIZE (32768)
+ lis(rMax, 0);
+ ori(rMax, rMax, 32768);
+ mr(rTmp2, rMax);
+ cmpd(CCR0, rIdx, rMax);
+ bgt(CCR0, L_2);
+ mr(rMax, rIdx);
+
+ BIND(L_2);
+ subf(rIdx, rMax, rIdx);
+
+ // our main loop does 128 bytes at a time
+ srdi(rMax, rMax, 7);
+
+ /*
+ * Work out the offset into the constants table to start at. Each
+ * constant is 16 bytes, and it is used against 128 bytes of input
+ * data - 128 / 16 = 8
+ */
+ sldi(rTmp1, rMax, 4);
+ srdi(rTmp2, rTmp2, 3);
+ subf(rTmp1, rTmp1, rTmp2);
+
+ // We reduce our final 128 bytes in a separate step
+ addi(rMax, rMax, -1);
+ mtctr(rMax);
+
+ // Find the start of our constants
+ add(constantsPos, constants, rTmp1);
+
+ // zero VR0-v7 which will contain our checksums
+ vxor(VR0, VR0, VR0);
+ vxor(VR1, VR1, VR1);
+ vxor(VR2, VR2, VR2);
+ vxor(VR3, VR3, VR3);
+ vxor(VR4, VR4, VR4);
+ vxor(VR5, VR5, VR5);
+ vxor(VR6, VR6, VR6);
+ vxor(VR7, VR7, VR7);
+
+ lvx(const1, constantsPos);
+
+ /*
+ * If we are looping back to consume more data we use the values
+ * already in VR16-v23.
+ */
+ cmpdi(CCR0, rLoaded, 1);
+ beq(CCR0, L_3);
+ {
+
+ // First warm up pass
+ lvx(VR16, buf);
+ lvx(VR17, off16, buf);
+ lvx(VR18, off32, buf);
+ lvx(VR19, off48, buf);
+ lvx(VR20, off64, buf);
+ lvx(VR21, off80, buf);
+ lvx(VR22, off96, buf);
+ lvx(VR23, off112, buf);
+ addi(buf, buf, 8*16);
+
+ // xor in initial value
+ vxor(VR16, VR16, VR8);
+ }
+
+ BIND(L_3);
+ bdz(L_first_warm_up_done);
+
+ addi(constantsPos, constantsPos, 16);
+ lvx(const2, constantsPos);
+
+ // Second warm up pass
+ vpmsumd(VR8, VR16, const1);
+ lvx(VR16, buf);
+
+ vpmsumd(VR9, VR17, const1);
+ lvx(VR17, off16, buf);
+
+ vpmsumd(VR10, VR18, const1);
+ lvx(VR18, off32, buf);
+
+ vpmsumd(VR11, VR19, const1);
+ lvx(VR19, off48, buf);
+
+ vpmsumd(VR12, VR20, const1);
+ lvx(VR20, off64, buf);
+
+ vpmsumd(VR13, VR21, const1);
+ lvx(VR21, off80, buf);
+
+ vpmsumd(VR14, VR22, const1);
+ lvx(VR22, off96, buf);
+
+ vpmsumd(VR15, VR23, const1);
+ lvx(VR23, off112, buf);
+
+ addi(buf, buf, 8 * 16);
+
+ bdz(L_first_cool_down);
+
+ /*
+ * main loop. We modulo schedule it such that it takes three iterations
+ * to complete - first iteration load, second iteration vpmsum, third
+ * iteration xor.
+ */
+ {
+ BIND(L_4);
+ lvx(const1, constantsPos); addi(constantsPos, constantsPos, 16);
+
+ vxor(VR0, VR0, VR8);
+ vpmsumd(VR8, VR16, const2);
+ lvx(VR16, buf);
+
+ vxor(VR1, VR1, VR9);
+ vpmsumd(VR9, VR17, const2);
+ lvx(VR17, off16, buf);
+
+ vxor(VR2, VR2, VR10);
+ vpmsumd(VR10, VR18, const2);
+ lvx(VR18, off32, buf);
+
+ vxor(VR3, VR3, VR11);
+ vpmsumd(VR11, VR19, const2);
+ lvx(VR19, off48, buf);
+ lvx(const2, constantsPos);
+
+ vxor(VR4, VR4, VR12);
+ vpmsumd(VR12, VR20, const1);
+ lvx(VR20, off64, buf);
+
+ vxor(VR5, VR5, VR13);
+ vpmsumd(VR13, VR21, const1);
+ lvx(VR21, off80, buf);
+
+ vxor(VR6, VR6, VR14);
+ vpmsumd(VR14, VR22, const1);
+ lvx(VR22, off96, buf);
+
+ vxor(VR7, VR7, VR15);
+ vpmsumd(VR15, VR23, const1);
+ lvx(VR23, off112, buf);
+
+ addi(buf, buf, 8 * 16);
+
+ bdnz(L_4);
+ }
+
+ BIND(L_first_cool_down);
+
+ // First cool down pass
+ lvx(const1, constantsPos);
+ addi(constantsPos, constantsPos, 16);
+
+ vxor(VR0, VR0, VR8);
+ vpmsumd(VR8, VR16, const1);
+
+ vxor(VR1, VR1, VR9);
+ vpmsumd(VR9, VR17, const1);
+
+ vxor(VR2, VR2, VR10);
+ vpmsumd(VR10, VR18, const1);
+
+ vxor(VR3, VR3, VR11);
+ vpmsumd(VR11, VR19, const1);
+
+ vxor(VR4, VR4, VR12);
+ vpmsumd(VR12, VR20, const1);
+
+ vxor(VR5, VR5, VR13);
+ vpmsumd(VR13, VR21, const1);
+
+ vxor(VR6, VR6, VR14);
+ vpmsumd(VR14, VR22, const1);
+
+ vxor(VR7, VR7, VR15);
+ vpmsumd(VR15, VR23, const1);
+
+ BIND(L_second_cool_down);
+ // Second cool down pass
+ vxor(VR0, VR0, VR8);
+ vxor(VR1, VR1, VR9);
+ vxor(VR2, VR2, VR10);
+ vxor(VR3, VR3, VR11);
+ vxor(VR4, VR4, VR12);
+ vxor(VR5, VR5, VR13);
+ vxor(VR6, VR6, VR14);
+ vxor(VR7, VR7, VR15);
+
+ /*
+ * vpmsumd produces a 96 bit result in the least significant bits
+ * of the register. Since we are bit reflected we have to shift it
+ * left 32 bits so it occupies the least significant bits in the
+ * bit reflected domain.
+ */
+ vsldoi(VR0, VR0, zeroes, 4);
+ vsldoi(VR1, VR1, zeroes, 4);
+ vsldoi(VR2, VR2, zeroes, 4);
+ vsldoi(VR3, VR3, zeroes, 4);
+ vsldoi(VR4, VR4, zeroes, 4);
+ vsldoi(VR5, VR5, zeroes, 4);
+ vsldoi(VR6, VR6, zeroes, 4);
+ vsldoi(VR7, VR7, zeroes, 4);
+
+ // xor with last 1024 bits
+ lvx(VR8, buf);
+ lvx(VR9, off16, buf);
+ lvx(VR10, off32, buf);
+ lvx(VR11, off48, buf);
+ lvx(VR12, off64, buf);
+ lvx(VR13, off80, buf);
+ lvx(VR14, off96, buf);
+ lvx(VR15, off112, buf);
+ addi(buf, buf, 8 * 16);
+
+ vxor(VR16, VR0, VR8);
+ vxor(VR17, VR1, VR9);
+ vxor(VR18, VR2, VR10);
+ vxor(VR19, VR3, VR11);
+ vxor(VR20, VR4, VR12);
+ vxor(VR21, VR5, VR13);
+ vxor(VR22, VR6, VR14);
+ vxor(VR23, VR7, VR15);
+
+ li(rLoaded, 1);
+ cmpdi(CCR0, rIdx, 0);
+ addi(rIdx, rIdx, 128);
+ bne(CCR0, L_1);
+ }
+
+ // Work out how many bytes we have left
+ andi_(len, len, 127);
+
+ // Calculate where in the constant table we need to start
+ subfic(rTmp1, len, 128);
+ add(constantsPos, constantsPos, rTmp1);
+
+ // How many 16 byte chunks are in the tail
+ srdi(rIdx, len, 4);
+ mtctr(rIdx);
+
+ /*
+ * Reduce the previously calculated 1024 bits to 64 bits, shifting
+ * 32 bits to include the trailing 32 bits of zeros
+ */
+ lvx(VR0, constantsPos);
+ lvx(VR1, off16, constantsPos);
+ lvx(VR2, off32, constantsPos);
+ lvx(VR3, off48, constantsPos);
+ lvx(VR4, off64, constantsPos);
+ lvx(VR5, off80, constantsPos);
+ lvx(VR6, off96, constantsPos);
+ lvx(VR7, off112, constantsPos);
+ addi(constantsPos, constantsPos, 8 * 16);
+
+ vpmsumw(VR0, VR16, VR0);
+ vpmsumw(VR1, VR17, VR1);
+ vpmsumw(VR2, VR18, VR2);
+ vpmsumw(VR3, VR19, VR3);
+ vpmsumw(VR4, VR20, VR4);
+ vpmsumw(VR5, VR21, VR5);
+ vpmsumw(VR6, VR22, VR6);
+ vpmsumw(VR7, VR23, VR7);
+
+ // Now reduce the tail (0 - 112 bytes)
+ cmpdi(CCR0, rIdx, 0);
+ beq(CCR0, L_XOR);
+
+ lvx(VR16, buf); addi(buf, buf, 16);
+ lvx(VR17, constantsPos);
+ vpmsumw(VR16, VR16, VR17);
+ vxor(VR0, VR0, VR16);
+ beq(CCR0, L_XOR);
+
+ lvx(VR16, buf); addi(buf, buf, 16);
+ lvx(VR17, off16, constantsPos);
+ vpmsumw(VR16, VR16, VR17);
+ vxor(VR0, VR0, VR16);
+ beq(CCR0, L_XOR);
+
+ lvx(VR16, buf); addi(buf, buf, 16);
+ lvx(VR17, off32, constantsPos);
+ vpmsumw(VR16, VR16, VR17);
+ vxor(VR0, VR0, VR16);
+ beq(CCR0, L_XOR);
+
+ lvx(VR16, buf); addi(buf, buf, 16);
+ lvx(VR17, off48,constantsPos);
+ vpmsumw(VR16, VR16, VR17);
+ vxor(VR0, VR0, VR16);
+ beq(CCR0, L_XOR);
+
+ lvx(VR16, buf); addi(buf, buf, 16);
+ lvx(VR17, off64, constantsPos);
+ vpmsumw(VR16, VR16, VR17);
+ vxor(VR0, VR0, VR16);
+ beq(CCR0, L_XOR);
+
+ lvx(VR16, buf); addi(buf, buf, 16);
+ lvx(VR17, off80, constantsPos);
+ vpmsumw(VR16, VR16, VR17);
+ vxor(VR0, VR0, VR16);
+ beq(CCR0, L_XOR);
+
+ lvx(VR16, buf); addi(buf, buf, 16);
+ lvx(VR17, off96, constantsPos);
+ vpmsumw(VR16, VR16, VR17);
+ vxor(VR0, VR0, VR16);
+
+ // Now xor all the parallel chunks together
+ BIND(L_XOR);
+ vxor(VR0, VR0, VR1);
+ vxor(VR2, VR2, VR3);
+ vxor(VR4, VR4, VR5);
+ vxor(VR6, VR6, VR7);
+
+ vxor(VR0, VR0, VR2);
+ vxor(VR4, VR4, VR6);
+
+ vxor(VR0, VR0, VR4);
+
+ b(L_barrett_reduction);
+
+ BIND(L_first_warm_up_done);
+ lvx(const1, constantsPos);
+ addi(constantsPos, constantsPos, 16);
+ vpmsumd(VR8, VR16, const1);
+ vpmsumd(VR9, VR17, const1);
+ vpmsumd(VR10, VR18, const1);
+ vpmsumd(VR11, VR19, const1);
+ vpmsumd(VR12, VR20, const1);
+ vpmsumd(VR13, VR21, const1);
+ vpmsumd(VR14, VR22, const1);
+ vpmsumd(VR15, VR23, const1);
+ b(L_second_cool_down);
+
+ BIND(L_barrett_reduction);
+
+ lvx(const1, barretConstants);
+ addi(barretConstants, barretConstants, 16);
+ lvx(const2, barretConstants);
+
+ vsldoi(VR1, VR0, VR0, -8);
+ vxor(VR0, VR0, VR1); // xor two 64 bit results together
+
+ // shift left one bit
+ vspltisb(VR1, 1);
+ vsl(VR0, VR0, VR1);
+
+ vand(VR0, VR0, mask_64bit);
+
+ /*
+ * The reflected version of Barrett reduction. Instead of bit
+ * reflecting our data (which is expensive to do), we bit reflect our
+ * constants and our algorithm, which means the intermediate data in
+ * our vector registers goes from 0-63 instead of 63-0. We can reflect
+ * the algorithm because we don't carry in mod 2 arithmetic.
+ */
+ vand(VR1, VR0, mask_32bit); // bottom 32 bits of a
+ vpmsumd(VR1, VR1, const1); // ma
+ vand(VR1, VR1, mask_32bit); // bottom 32bits of ma
+ vpmsumd(VR1, VR1, const2); // qn */
+ vxor(VR0, VR0, VR1); // a - qn, subtraction is xor in GF(2)
+
+ /*
+ * Since we are bit reflected, the result (ie the low 32 bits) is in
+ * the high 32 bits. We just need to shift it left 4 bytes
+ * V0 [ 0 1 X 3 ]
+ * V0 [ 0 X 2 3 ]
+ */
+ vsldoi(VR0, VR0, zeroes, 4); // shift result into top 64 bits of
+
+ // Get it into r3
+ mfvrd(crc, VR0);
+
+ BIND(L_end);
+
+ offsetInt = 0;
+ // Restore non-volatile Vector registers (frameless).
+ offsetInt -= 16; li(offset, -16); lvx(VR20, offset, R1_SP);
+ offsetInt -= 16; addi(offset, offset, -16); lvx(VR21, offset, R1_SP);
+ offsetInt -= 16; addi(offset, offset, -16); lvx(VR22, offset, R1_SP);
+ offsetInt -= 16; addi(offset, offset, -16); lvx(VR23, offset, R1_SP);
+ offsetInt -= 16; addi(offset, offset, -16); lvx(VR24, offset, R1_SP);
+ offsetInt -= 16; addi(offset, offset, -16); lvx(VR25, offset, R1_SP);
+ offsetInt -= 16; addi(offset, offset, -16); lvx(VR26, offset, R1_SP);
+ offsetInt -= 16; addi(offset, offset, -16); lvx(VR27, offset, R1_SP);
+ offsetInt -= 16; addi(offset, offset, -16); lvx(VR28, offset, R1_SP);
+ offsetInt -= 8; ld(R22, offsetInt, R1_SP);
+ offsetInt -= 8; ld(R23, offsetInt, R1_SP);
+ offsetInt -= 8; ld(R24, offsetInt, R1_SP);
+ offsetInt -= 8; ld(R25, offsetInt, R1_SP);
+ offsetInt -= 8; ld(R26, offsetInt, R1_SP);
+ offsetInt -= 8; ld(R27, offsetInt, R1_SP);
+ offsetInt -= 8; ld(R28, offsetInt, R1_SP);
+ offsetInt -= 8; ld(R29, offsetInt, R1_SP);
+ offsetInt -= 8; ld(R30, offsetInt, R1_SP);
+ offsetInt -= 8; ld(R31, offsetInt, R1_SP);
+}
+
void MacroAssembler::kernel_crc32_singleByte(Register crc, Register buf, Register len, Register table, Register tmp) {
assert_different_registers(crc, buf, /* len, not used!! */ table, tmp);
--- a/hotspot/src/cpu/ppc/vm/macroAssembler_ppc.hpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/cpu/ppc/vm/macroAssembler_ppc.hpp Fri Oct 14 11:11:19 2016 -0700
@@ -834,6 +834,13 @@
Register tc0, Register tc1, Register tc2, Register tc3);
void kernel_crc32_1byte(Register crc, Register buf, Register len, Register table,
Register t0, Register t1, Register t2, Register t3);
+ void kernel_crc32_1word_vpmsumd(Register crc, Register buf, Register len, Register table,
+ Register constants, Register barretConstants,
+ Register t0, Register t1, Register t2, Register t3, Register t4);
+ void kernel_crc32_1word_aligned(Register crc, Register buf, Register len,
+ Register constants, Register barretConstants,
+ Register t0, Register t1, Register t2);
+
void kernel_crc32_singleByte(Register crc, Register buf, Register len, Register table, Register tmp);
//
--- a/hotspot/src/cpu/ppc/vm/sharedRuntime_ppc.cpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/cpu/ppc/vm/sharedRuntime_ppc.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -2489,6 +2489,11 @@
__ verify_oop(R3_RET);
}
+ if (CheckJNICalls) {
+ // clear_pending_jni_exception_check
+ __ load_const_optimized(R0, 0L);
+ __ st_ptr(R0, JavaThread::pending_jni_exception_check_fn_offset(), R16_thread);
+ }
// Reset handle block.
// --------------------------------------------------------------------------
--- a/hotspot/src/cpu/ppc/vm/stubGenerator_ppc.cpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/cpu/ppc/vm/stubGenerator_ppc.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -3205,28 +3205,59 @@
const Register crc = R3_ARG1; // Current checksum, preset by caller or result from previous call.
const Register data = R4_ARG2; // source byte array
const Register dataLen = R5_ARG3; // #bytes to process
- const Register table = R6_ARG4; // crc table address
-
- const Register t0 = R2;
- const Register t1 = R7;
- const Register t2 = R8;
- const Register t3 = R9;
- const Register tc0 = R10;
- const Register tc1 = R11;
- const Register tc2 = R12;
-
- BLOCK_COMMENT("Stub body {");
- assert_different_registers(crc, data, dataLen, table);
-
- StubRoutines::ppc64::generate_load_crc_table_addr(_masm, table);
-
- __ kernel_crc32_1word(crc, data, dataLen, table, t0, t1, t2, t3, tc0, tc1, tc2, table);
-
- BLOCK_COMMENT("return");
- __ mr_if_needed(R3_RET, crc); // Updated crc is function result. No copying required (R3_ARG1 == R3_RET).
- __ blr();
-
- BLOCK_COMMENT("} Stub body");
+
+ const Register table = R6; // crc table address
+
+#ifdef VM_LITTLE_ENDIAN
+ if (VM_Version::has_vpmsumb()) {
+ const Register constants = R2; // constants address
+ const Register bconstants = R8; // barret table address
+
+ const Register t0 = R9;
+ const Register t1 = R10;
+ const Register t2 = R11;
+ const Register t3 = R12;
+ const Register t4 = R7;
+
+ BLOCK_COMMENT("Stub body {");
+ assert_different_registers(crc, data, dataLen, table);
+
+ StubRoutines::ppc64::generate_load_crc_table_addr(_masm, table);
+ StubRoutines::ppc64::generate_load_crc_constants_addr(_masm, constants);
+ StubRoutines::ppc64::generate_load_crc_barret_constants_addr(_masm, bconstants);
+
+ __ kernel_crc32_1word_vpmsumd(crc, data, dataLen, table, constants, bconstants, t0, t1, t2, t3, t4);
+
+ BLOCK_COMMENT("return");
+ __ mr_if_needed(R3_RET, crc); // Updated crc is function result. No copying required (R3_ARG1 == R3_RET).
+ __ blr();
+
+ BLOCK_COMMENT("} Stub body");
+ } else
+#endif
+ {
+ const Register t0 = R2;
+ const Register t1 = R7;
+ const Register t2 = R8;
+ const Register t3 = R9;
+ const Register tc0 = R10;
+ const Register tc1 = R11;
+ const Register tc2 = R12;
+
+ BLOCK_COMMENT("Stub body {");
+ assert_different_registers(crc, data, dataLen, table);
+
+ StubRoutines::ppc64::generate_load_crc_table_addr(_masm, table);
+
+ __ kernel_crc32_1word(crc, data, dataLen, table, t0, t1, t2, t3, tc0, tc1, tc2, table);
+
+ BLOCK_COMMENT("return");
+ __ mr_if_needed(R3_RET, crc); // Updated crc is function result. No copying required (R3_ARG1 == R3_RET).
+ __ blr();
+
+ BLOCK_COMMENT("} Stub body");
+ }
+
return start;
}
--- a/hotspot/src/cpu/ppc/vm/stubRoutines_ppc.hpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/cpu/ppc/vm/stubRoutines_ppc.hpp Fri Oct 14 11:11:19 2016 -0700
@@ -45,6 +45,8 @@
#else
#define CRC32_TABLES 1
#endif
+#define CRC32_CONSTANTS_SIZE 1084
+#define CRC32_BARRET_CONSTANTS 10
class ppc64 {
friend class StubGenerator;
@@ -53,11 +55,17 @@
// CRC32 Intrinsics.
static juint _crc_table[CRC32_TABLES][CRC32_COLUMN_SIZE];
+ static juint* _constants;
+ static juint* _barret_constants;
public:
// CRC32 Intrinsics.
static void generate_load_crc_table_addr(MacroAssembler* masm, Register table);
+ static void generate_load_crc_constants_addr(MacroAssembler* masm, Register table);
+ static void generate_load_crc_barret_constants_addr(MacroAssembler* masm, Register table);
+ static juint* generate_crc_constants();
+ static juint* generate_crc_barret_constants();
};
--- a/hotspot/src/cpu/ppc/vm/stubRoutines_ppc_64.cpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/cpu/ppc/vm/stubRoutines_ppc_64.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -37,6 +37,311 @@
__ load_const_optimized(table, StubRoutines::_crc_table_adr, R0);
}
+void StubRoutines::ppc64::generate_load_crc_constants_addr(MacroAssembler* masm, Register table) {
+ __ load_const_optimized(table, (address)StubRoutines::ppc64::_constants, R0);
+}
+
+void StubRoutines::ppc64::generate_load_crc_barret_constants_addr(MacroAssembler* masm, Register table) {
+ __ load_const_optimized(table, (address)StubRoutines::ppc64::_barret_constants, R0);
+}
+
+juint* StubRoutines::ppc64::generate_crc_constants() {
+ juint constants[CRC32_CONSTANTS_SIZE] = {
+ // Reduce 262144 kbits to 1024 bits
+ 0x99ea94a8UL, 0x00000000UL, 0x651797d2UL, 0x00000001UL, // x^261120 mod p(x)` << 1, x^261184 mod p(x)` << 1
+ 0x945a8420UL, 0x00000000UL, 0x21e0d56cUL, 0x00000000UL, // x^260096 mod p(x)` << 1, x^260160 mod p(x)` << 1
+ 0x30762706UL, 0x00000000UL, 0x0f95ecaaUL, 0x00000000UL, // x^259072 mod p(x)` << 1, x^259136 mod p(x)` << 1
+ 0xa52fc582UL, 0x00000001UL, 0xebd224acUL, 0x00000001UL, // x^258048 mod p(x)` << 1, x^258112 mod p(x)` << 1
+ 0xa4a7167aUL, 0x00000001UL, 0x0ccb97caUL, 0x00000000UL, // x^257024 mod p(x)` << 1, x^257088 mod p(x)` << 1
+ 0x0c18249aUL, 0x00000000UL, 0x006ec8a8UL, 0x00000001UL, // x^256000 mod p(x)` << 1, x^256064 mod p(x)` << 1
+ 0xa924ae7cUL, 0x00000000UL, 0x4f58f196UL, 0x00000001UL, // x^254976 mod p(x)` << 1, x^255040 mod p(x)` << 1
+ 0xe12ccc12UL, 0x00000001UL, 0xa7192ca6UL, 0x00000001UL, // x^253952 mod p(x)` << 1, x^254016 mod p(x)` << 1
+ 0xa0b9d4acUL, 0x00000000UL, 0x9a64bab2UL, 0x00000001UL, // x^252928 mod p(x)` << 1, x^252992 mod p(x)` << 1
+ 0x95e8ddfeUL, 0x00000000UL, 0x14f4ed2eUL, 0x00000000UL, // x^251904 mod p(x)` << 1, x^251968 mod p(x)` << 1
+ 0x233fddc4UL, 0x00000000UL, 0x1092b6a2UL, 0x00000001UL, // x^250880 mod p(x)` << 1, x^250944 mod p(x)` << 1
+ 0xb4529b62UL, 0x00000001UL, 0xc8a1629cUL, 0x00000000UL, // x^249856 mod p(x)` << 1, x^249920 mod p(x)` << 1
+ 0xa7fa0e64UL, 0x00000001UL, 0x7bf32e8eUL, 0x00000001UL, // x^248832 mod p(x)` << 1, x^248896 mod p(x)` << 1
+ 0xb5334592UL, 0x00000001UL, 0xf8cc6582UL, 0x00000001UL, // x^247808 mod p(x)` << 1, x^247872 mod p(x)` << 1
+ 0x1f8ee1b4UL, 0x00000001UL, 0x8631ddf0UL, 0x00000000UL, // x^246784 mod p(x)` << 1, x^246848 mod p(x)` << 1
+ 0x6252e632UL, 0x00000000UL, 0x7e5a76d0UL, 0x00000000UL, // x^245760 mod p(x)` << 1, x^245824 mod p(x)` << 1
+ 0xab973e84UL, 0x00000000UL, 0x2b09b31cUL, 0x00000000UL, // x^244736 mod p(x)` << 1, x^244800 mod p(x)` << 1
+ 0x7734f5ecUL, 0x00000000UL, 0xb2df1f84UL, 0x00000001UL, // x^243712 mod p(x)` << 1, x^243776 mod p(x)` << 1
+ 0x7c547798UL, 0x00000000UL, 0xd6f56afcUL, 0x00000001UL, // x^242688 mod p(x)` << 1, x^242752 mod p(x)` << 1
+ 0x7ec40210UL, 0x00000000UL, 0xb9b5e70cUL, 0x00000001UL, // x^241664 mod p(x)` << 1, x^241728 mod p(x)` << 1
+ 0xab1695a8UL, 0x00000001UL, 0x34b626d2UL, 0x00000000UL, // x^240640 mod p(x)` << 1, x^240704 mod p(x)` << 1
+ 0x90494bbaUL, 0x00000000UL, 0x4c53479aUL, 0x00000001UL, // x^239616 mod p(x)` << 1, x^239680 mod p(x)` << 1
+ 0x123fb816UL, 0x00000001UL, 0xa6d179a4UL, 0x00000001UL, // x^238592 mod p(x)` << 1, x^238656 mod p(x)` << 1
+ 0xe188c74cUL, 0x00000001UL, 0x5abd16b4UL, 0x00000001UL, // x^237568 mod p(x)` << 1, x^237632 mod p(x)` << 1
+ 0xc2d3451cUL, 0x00000001UL, 0x018f9852UL, 0x00000000UL, // x^236544 mod p(x)` << 1, x^236608 mod p(x)` << 1
+ 0xf55cf1caUL, 0x00000000UL, 0x1fb3084aUL, 0x00000000UL, // x^235520 mod p(x)` << 1, x^235584 mod p(x)` << 1
+ 0xa0531540UL, 0x00000001UL, 0xc53dfb04UL, 0x00000000UL, // x^234496 mod p(x)` << 1, x^234560 mod p(x)` << 1
+ 0x32cd7ebcUL, 0x00000001UL, 0xe10c9ad6UL, 0x00000000UL, // x^233472 mod p(x)` << 1, x^233536 mod p(x)` << 1
+ 0x73ab7f36UL, 0x00000000UL, 0x25aa994aUL, 0x00000000UL, // x^232448 mod p(x)` << 1, x^232512 mod p(x)` << 1
+ 0x41aed1c2UL, 0x00000000UL, 0xfa3a74c4UL, 0x00000000UL, // x^231424 mod p(x)` << 1, x^231488 mod p(x)` << 1
+ 0x36c53800UL, 0x00000001UL, 0x33eb3f40UL, 0x00000000UL, // x^230400 mod p(x)` << 1, x^230464 mod p(x)` << 1
+ 0x26835a30UL, 0x00000001UL, 0x7193f296UL, 0x00000001UL, // x^229376 mod p(x)` << 1, x^229440 mod p(x)` << 1
+ 0x6241b502UL, 0x00000000UL, 0x43f6c86aUL, 0x00000000UL, // x^228352 mod p(x)` << 1, x^228416 mod p(x)` << 1
+ 0xd5196ad4UL, 0x00000000UL, 0x6b513ec6UL, 0x00000001UL, // x^227328 mod p(x)` << 1, x^227392 mod p(x)` << 1
+ 0x9cfa769aUL, 0x00000000UL, 0xc8f25b4eUL, 0x00000000UL, // x^226304 mod p(x)` << 1, x^226368 mod p(x)` << 1
+ 0x920e5df4UL, 0x00000000UL, 0xa45048ecUL, 0x00000001UL, // x^225280 mod p(x)` << 1, x^225344 mod p(x)` << 1
+ 0x69dc310eUL, 0x00000001UL, 0x0c441004UL, 0x00000000UL, // x^224256 mod p(x)` << 1, x^224320 mod p(x)` << 1
+ 0x09fc331cUL, 0x00000000UL, 0x0e17cad6UL, 0x00000000UL, // x^223232 mod p(x)` << 1, x^223296 mod p(x)` << 1
+ 0x0d94a81eUL, 0x00000001UL, 0x253ae964UL, 0x00000001UL, // x^222208 mod p(x)` << 1, x^222272 mod p(x)` << 1
+ 0x27a20ab2UL, 0x00000000UL, 0xd7c88ebcUL, 0x00000001UL, // x^221184 mod p(x)` << 1, x^221248 mod p(x)` << 1
+ 0x14f87504UL, 0x00000001UL, 0xe7ca913aUL, 0x00000001UL, // x^220160 mod p(x)` << 1, x^220224 mod p(x)` << 1
+ 0x4b076d96UL, 0x00000000UL, 0x33ed078aUL, 0x00000000UL, // x^219136 mod p(x)` << 1, x^219200 mod p(x)` << 1
+ 0xda4d1e74UL, 0x00000000UL, 0xe1839c78UL, 0x00000000UL, // x^218112 mod p(x)` << 1, x^218176 mod p(x)` << 1
+ 0x1b81f672UL, 0x00000000UL, 0x322b267eUL, 0x00000001UL, // x^217088 mod p(x)` << 1, x^217152 mod p(x)` << 1
+ 0x9367c988UL, 0x00000000UL, 0x638231b6UL, 0x00000000UL, // x^216064 mod p(x)` << 1, x^216128 mod p(x)` << 1
+ 0x717214caUL, 0x00000001UL, 0xee7f16f4UL, 0x00000001UL, // x^215040 mod p(x)` << 1, x^215104 mod p(x)` << 1
+ 0x9f47d820UL, 0x00000000UL, 0x17d9924aUL, 0x00000001UL, // x^214016 mod p(x)` << 1, x^214080 mod p(x)` << 1
+ 0x0d9a47d2UL, 0x00000001UL, 0xe1a9e0c4UL, 0x00000000UL, // x^212992 mod p(x)` << 1, x^213056 mod p(x)` << 1
+ 0xa696c58cUL, 0x00000000UL, 0x403731dcUL, 0x00000001UL, // x^211968 mod p(x)` << 1, x^212032 mod p(x)` << 1
+ 0x2aa28ec6UL, 0x00000000UL, 0xa5ea9682UL, 0x00000001UL, // x^210944 mod p(x)` << 1, x^211008 mod p(x)` << 1
+ 0xfe18fd9aUL, 0x00000001UL, 0x01c5c578UL, 0x00000001UL, // x^209920 mod p(x)` << 1, x^209984 mod p(x)` << 1
+ 0x9d4fc1aeUL, 0x00000001UL, 0xdddf6494UL, 0x00000000UL, // x^208896 mod p(x)` << 1, x^208960 mod p(x)` << 1
+ 0xba0e3deaUL, 0x00000001UL, 0xf1c3db28UL, 0x00000000UL, // x^207872 mod p(x)` << 1, x^207936 mod p(x)` << 1
+ 0x74b59a5eUL, 0x00000000UL, 0x3112fb9cUL, 0x00000001UL, // x^206848 mod p(x)` << 1, x^206912 mod p(x)` << 1
+ 0xf2b5ea98UL, 0x00000000UL, 0xb680b906UL, 0x00000000UL, // x^205824 mod p(x)` << 1, x^205888 mod p(x)` << 1
+ 0x87132676UL, 0x00000001UL, 0x1a282932UL, 0x00000000UL, // x^204800 mod p(x)` << 1, x^204864 mod p(x)` << 1
+ 0x0a8c6ad4UL, 0x00000001UL, 0x89406e7eUL, 0x00000000UL, // x^203776 mod p(x)` << 1, x^203840 mod p(x)` << 1
+ 0xe21dfe70UL, 0x00000001UL, 0xdef6be8cUL, 0x00000001UL, // x^202752 mod p(x)` << 1, x^202816 mod p(x)` << 1
+ 0xda0050e4UL, 0x00000001UL, 0x75258728UL, 0x00000000UL, // x^201728 mod p(x)` << 1, x^201792 mod p(x)` << 1
+ 0x772172aeUL, 0x00000000UL, 0x9536090aUL, 0x00000001UL, // x^200704 mod p(x)` << 1, x^200768 mod p(x)` << 1
+ 0xe47724aaUL, 0x00000000UL, 0xf2455bfcUL, 0x00000000UL, // x^199680 mod p(x)` << 1, x^199744 mod p(x)` << 1
+ 0x3cd63ac4UL, 0x00000000UL, 0x8c40baf4UL, 0x00000001UL, // x^198656 mod p(x)` << 1, x^198720 mod p(x)` << 1
+ 0xbf47d352UL, 0x00000001UL, 0x4cd390d4UL, 0x00000000UL, // x^197632 mod p(x)` << 1, x^197696 mod p(x)` << 1
+ 0x8dc1d708UL, 0x00000001UL, 0xe4ece95aUL, 0x00000001UL, // x^196608 mod p(x)` << 1, x^196672 mod p(x)` << 1
+ 0x2d4620a4UL, 0x00000000UL, 0x1a3ee918UL, 0x00000000UL, // x^195584 mod p(x)` << 1, x^195648 mod p(x)` << 1
+ 0x58fd1740UL, 0x00000000UL, 0x7c652fb8UL, 0x00000000UL, // x^194560 mod p(x)` << 1, x^194624 mod p(x)` << 1
+ 0xdadd9bfcUL, 0x00000000UL, 0x1c67842cUL, 0x00000001UL, // x^193536 mod p(x)` << 1, x^193600 mod p(x)` << 1
+ 0xea2140beUL, 0x00000001UL, 0x254f759cUL, 0x00000000UL, // x^192512 mod p(x)` << 1, x^192576 mod p(x)` << 1
+ 0x9de128baUL, 0x00000000UL, 0x7ece94caUL, 0x00000000UL, // x^191488 mod p(x)` << 1, x^191552 mod p(x)` << 1
+ 0x3ac3aa8eUL, 0x00000001UL, 0x38f258c2UL, 0x00000000UL, // x^190464 mod p(x)` << 1, x^190528 mod p(x)` << 1
+ 0x99980562UL, 0x00000000UL, 0xcdf17b00UL, 0x00000001UL, // x^189440 mod p(x)` << 1, x^189504 mod p(x)` << 1
+ 0xc1579c86UL, 0x00000001UL, 0x1f882c16UL, 0x00000001UL, // x^188416 mod p(x)` << 1, x^188480 mod p(x)` << 1
+ 0x68dbbf94UL, 0x00000000UL, 0x00093fc8UL, 0x00000001UL, // x^187392 mod p(x)` << 1, x^187456 mod p(x)` << 1
+ 0x4509fb04UL, 0x00000000UL, 0xcd684f16UL, 0x00000001UL, // x^186368 mod p(x)` << 1, x^186432 mod p(x)` << 1
+ 0x202f6398UL, 0x00000001UL, 0x4bc6a70aUL, 0x00000000UL, // x^185344 mod p(x)` << 1, x^185408 mod p(x)` << 1
+ 0x3aea243eUL, 0x00000001UL, 0x4fc7e8e4UL, 0x00000000UL, // x^184320 mod p(x)` << 1, x^184384 mod p(x)` << 1
+ 0xb4052ae6UL, 0x00000001UL, 0x30103f1cUL, 0x00000001UL, // x^183296 mod p(x)` << 1, x^183360 mod p(x)` << 1
+ 0xcd2a0ae8UL, 0x00000001UL, 0x11b0024cUL, 0x00000001UL, // x^182272 mod p(x)` << 1, x^182336 mod p(x)` << 1
+ 0xfe4aa8b4UL, 0x00000001UL, 0x0b3079daUL, 0x00000001UL, // x^181248 mod p(x)` << 1, x^181312 mod p(x)` << 1
+ 0xd1559a42UL, 0x00000001UL, 0x0192bcc2UL, 0x00000001UL, // x^180224 mod p(x)` << 1, x^180288 mod p(x)` << 1
+ 0xf3e05eccUL, 0x00000001UL, 0x74838d50UL, 0x00000000UL, // x^179200 mod p(x)` << 1, x^179264 mod p(x)` << 1
+ 0x04ddd2ccUL, 0x00000001UL, 0x1b20f520UL, 0x00000000UL, // x^178176 mod p(x)` << 1, x^178240 mod p(x)` << 1
+ 0x5393153cUL, 0x00000001UL, 0x50c3590aUL, 0x00000000UL, // x^177152 mod p(x)` << 1, x^177216 mod p(x)` << 1
+ 0x57e942c6UL, 0x00000000UL, 0xb41cac8eUL, 0x00000000UL, // x^176128 mod p(x)` << 1, x^176192 mod p(x)` << 1
+ 0x2c633850UL, 0x00000001UL, 0x0c72cc78UL, 0x00000000UL, // x^175104 mod p(x)` << 1, x^175168 mod p(x)` << 1
+ 0xebcaae4cUL, 0x00000000UL, 0x30cdb032UL, 0x00000000UL, // x^174080 mod p(x)` << 1, x^174144 mod p(x)` << 1
+ 0x3ee532a6UL, 0x00000001UL, 0x3e09fc32UL, 0x00000001UL, // x^173056 mod p(x)` << 1, x^173120 mod p(x)` << 1
+ 0xbf0cbc7eUL, 0x00000001UL, 0x1ed624d2UL, 0x00000000UL, // x^172032 mod p(x)` << 1, x^172096 mod p(x)` << 1
+ 0xd50b7a5aUL, 0x00000000UL, 0x781aee1aUL, 0x00000000UL, // x^171008 mod p(x)` << 1, x^171072 mod p(x)` << 1
+ 0x02fca6e8UL, 0x00000000UL, 0xc4d8348cUL, 0x00000001UL, // x^169984 mod p(x)` << 1, x^170048 mod p(x)` << 1
+ 0x7af40044UL, 0x00000000UL, 0x57a40336UL, 0x00000000UL, // x^168960 mod p(x)` << 1, x^169024 mod p(x)` << 1
+ 0x16178744UL, 0x00000000UL, 0x85544940UL, 0x00000000UL, // x^167936 mod p(x)` << 1, x^168000 mod p(x)` << 1
+ 0x4c177458UL, 0x00000001UL, 0x9cd21e80UL, 0x00000001UL, // x^166912 mod p(x)` << 1, x^166976 mod p(x)` << 1
+ 0x1b6ddf04UL, 0x00000001UL, 0x3eb95bc0UL, 0x00000001UL, // x^165888 mod p(x)` << 1, x^165952 mod p(x)` << 1
+ 0xf3e29cccUL, 0x00000001UL, 0xdfc9fdfcUL, 0x00000001UL, // x^164864 mod p(x)` << 1, x^164928 mod p(x)` << 1
+ 0x35ae7562UL, 0x00000001UL, 0xcd028bc2UL, 0x00000000UL, // x^163840 mod p(x)` << 1, x^163904 mod p(x)` << 1
+ 0x90ef812cUL, 0x00000001UL, 0x90db8c44UL, 0x00000000UL, // x^162816 mod p(x)` << 1, x^162880 mod p(x)` << 1
+ 0x67a2c786UL, 0x00000000UL, 0x0010a4ceUL, 0x00000001UL, // x^161792 mod p(x)` << 1, x^161856 mod p(x)` << 1
+ 0x48b9496cUL, 0x00000000UL, 0xc8f4c72cUL, 0x00000001UL, // x^160768 mod p(x)` << 1, x^160832 mod p(x)` << 1
+ 0x5a422de6UL, 0x00000001UL, 0x1c26170cUL, 0x00000000UL, // x^159744 mod p(x)` << 1, x^159808 mod p(x)` << 1
+ 0xef0e3640UL, 0x00000001UL, 0xe3fccf68UL, 0x00000000UL, // x^158720 mod p(x)` << 1, x^158784 mod p(x)` << 1
+ 0x006d2d26UL, 0x00000001UL, 0xd513ed24UL, 0x00000000UL, // x^157696 mod p(x)` << 1, x^157760 mod p(x)` << 1
+ 0x170d56d6UL, 0x00000001UL, 0x141beadaUL, 0x00000000UL, // x^156672 mod p(x)` << 1, x^156736 mod p(x)` << 1
+ 0xa5fb613cUL, 0x00000000UL, 0x1071aea0UL, 0x00000001UL, // x^155648 mod p(x)` << 1, x^155712 mod p(x)` << 1
+ 0x40bbf7fcUL, 0x00000000UL, 0x2e19080aUL, 0x00000001UL, // x^154624 mod p(x)` << 1, x^154688 mod p(x)` << 1
+ 0x6ac3a5b2UL, 0x00000001UL, 0x00ecf826UL, 0x00000001UL, // x^153600 mod p(x)` << 1, x^153664 mod p(x)` << 1
+ 0xabf16230UL, 0x00000000UL, 0x69b09412UL, 0x00000000UL, // x^152576 mod p(x)` << 1, x^152640 mod p(x)` << 1
+ 0xebe23facUL, 0x00000001UL, 0x22297bacUL, 0x00000001UL, // x^151552 mod p(x)` << 1, x^151616 mod p(x)` << 1
+ 0x8b6a0894UL, 0x00000000UL, 0xe9e4b068UL, 0x00000000UL, // x^150528 mod p(x)` << 1, x^150592 mod p(x)` << 1
+ 0x288ea478UL, 0x00000001UL, 0x4b38651aUL, 0x00000000UL, // x^149504 mod p(x)` << 1, x^149568 mod p(x)` << 1
+ 0x6619c442UL, 0x00000001UL, 0x468360e2UL, 0x00000001UL, // x^148480 mod p(x)` << 1, x^148544 mod p(x)` << 1
+ 0x86230038UL, 0x00000000UL, 0x121c2408UL, 0x00000000UL, // x^147456 mod p(x)` << 1, x^147520 mod p(x)` << 1
+ 0x7746a756UL, 0x00000001UL, 0xda7e7d08UL, 0x00000000UL, // x^146432 mod p(x)` << 1, x^146496 mod p(x)` << 1
+ 0x91b8f8f8UL, 0x00000001UL, 0x058d7652UL, 0x00000001UL, // x^145408 mod p(x)` << 1, x^145472 mod p(x)` << 1
+ 0x8e167708UL, 0x00000000UL, 0x4a098a90UL, 0x00000001UL, // x^144384 mod p(x)` << 1, x^144448 mod p(x)` << 1
+ 0x48b22d54UL, 0x00000001UL, 0x20dbe72eUL, 0x00000000UL, // x^143360 mod p(x)` << 1, x^143424 mod p(x)` << 1
+ 0x44ba2c3cUL, 0x00000000UL, 0x1e7323e8UL, 0x00000001UL, // x^142336 mod p(x)` << 1, x^142400 mod p(x)` << 1
+ 0xb54d2b52UL, 0x00000000UL, 0xd5d4bf94UL, 0x00000000UL, // x^141312 mod p(x)` << 1, x^141376 mod p(x)` << 1
+ 0x05a4fd8aUL, 0x00000000UL, 0x99d8746cUL, 0x00000001UL, // x^140288 mod p(x)` << 1, x^140352 mod p(x)` << 1
+ 0x39f9fc46UL, 0x00000001UL, 0xce9ca8a0UL, 0x00000000UL, // x^139264 mod p(x)` << 1, x^139328 mod p(x)` << 1
+ 0x5a1fa824UL, 0x00000001UL, 0x136edeceUL, 0x00000000UL, // x^138240 mod p(x)` << 1, x^138304 mod p(x)` << 1
+ 0x0a61ae4cUL, 0x00000000UL, 0x9b92a068UL, 0x00000001UL, // x^137216 mod p(x)` << 1, x^137280 mod p(x)` << 1
+ 0x45e9113eUL, 0x00000001UL, 0x71d62206UL, 0x00000000UL, // x^136192 mod p(x)` << 1, x^136256 mod p(x)` << 1
+ 0x6a348448UL, 0x00000000UL, 0xdfc50158UL, 0x00000000UL, // x^135168 mod p(x)` << 1, x^135232 mod p(x)` << 1
+ 0x4d80a08cUL, 0x00000000UL, 0x517626bcUL, 0x00000001UL, // x^134144 mod p(x)` << 1, x^134208 mod p(x)` << 1
+ 0x4b6837a0UL, 0x00000001UL, 0x48d1e4faUL, 0x00000001UL, // x^133120 mod p(x)` << 1, x^133184 mod p(x)` << 1
+ 0x6896a7fcUL, 0x00000001UL, 0x94d8266eUL, 0x00000000UL, // x^132096 mod p(x)` << 1, x^132160 mod p(x)` << 1
+ 0x4f187140UL, 0x00000001UL, 0x606c5e34UL, 0x00000000UL, // x^131072 mod p(x)` << 1, x^131136 mod p(x)` << 1
+ 0x9581b9daUL, 0x00000001UL, 0x9766beaaUL, 0x00000001UL, // x^130048 mod p(x)` << 1, x^130112 mod p(x)` << 1
+ 0x091bc984UL, 0x00000001UL, 0xd80c506cUL, 0x00000001UL, // x^129024 mod p(x)` << 1, x^129088 mod p(x)` << 1
+ 0x1067223cUL, 0x00000000UL, 0x1e73837cUL, 0x00000000UL, // x^128000 mod p(x)` << 1, x^128064 mod p(x)` << 1
+ 0xab16ea02UL, 0x00000001UL, 0x64d587deUL, 0x00000000UL, // x^126976 mod p(x)` << 1, x^127040 mod p(x)` << 1
+ 0x3c4598a8UL, 0x00000001UL, 0xf4a507b0UL, 0x00000000UL, // x^125952 mod p(x)` << 1, x^126016 mod p(x)` << 1
+ 0xb3735430UL, 0x00000000UL, 0x40e342fcUL, 0x00000000UL, // x^124928 mod p(x)` << 1, x^124992 mod p(x)` << 1
+ 0xbb3fc0c0UL, 0x00000001UL, 0xd5ad9c3aUL, 0x00000001UL, // x^123904 mod p(x)` << 1, x^123968 mod p(x)` << 1
+ 0x570ae19cUL, 0x00000001UL, 0x94a691a4UL, 0x00000000UL, // x^122880 mod p(x)` << 1, x^122944 mod p(x)` << 1
+ 0xea910712UL, 0x00000001UL, 0x271ecdfaUL, 0x00000001UL, // x^121856 mod p(x)` << 1, x^121920 mod p(x)` << 1
+ 0x67127128UL, 0x00000001UL, 0x9e54475aUL, 0x00000000UL, // x^120832 mod p(x)` << 1, x^120896 mod p(x)` << 1
+ 0x19e790a2UL, 0x00000000UL, 0xc9c099eeUL, 0x00000000UL, // x^119808 mod p(x)` << 1, x^119872 mod p(x)` << 1
+ 0x3788f710UL, 0x00000000UL, 0x9a2f736cUL, 0x00000000UL, // x^118784 mod p(x)` << 1, x^118848 mod p(x)` << 1
+ 0x682a160eUL, 0x00000001UL, 0xbb9f4996UL, 0x00000000UL, // x^117760 mod p(x)` << 1, x^117824 mod p(x)` << 1
+ 0x7f0ebd2eUL, 0x00000000UL, 0xdb688050UL, 0x00000001UL, // x^116736 mod p(x)` << 1, x^116800 mod p(x)` << 1
+ 0x2b032080UL, 0x00000000UL, 0xe9b10af4UL, 0x00000000UL, // x^115712 mod p(x)` << 1, x^115776 mod p(x)` << 1
+ 0xcfd1664aUL, 0x00000000UL, 0x2d4545e4UL, 0x00000001UL, // x^114688 mod p(x)` << 1, x^114752 mod p(x)` << 1
+ 0xaa1181c2UL, 0x00000000UL, 0x0361139cUL, 0x00000000UL, // x^113664 mod p(x)` << 1, x^113728 mod p(x)` << 1
+ 0xddd08002UL, 0x00000000UL, 0xa5a1a3a8UL, 0x00000001UL, // x^112640 mod p(x)` << 1, x^112704 mod p(x)` << 1
+ 0xe8dd0446UL, 0x00000000UL, 0x6844e0b0UL, 0x00000000UL, // x^111616 mod p(x)` << 1, x^111680 mod p(x)` << 1
+ 0xbbd94a00UL, 0x00000001UL, 0xc3762f28UL, 0x00000000UL, // x^110592 mod p(x)` << 1, x^110656 mod p(x)` << 1
+ 0xab6cd180UL, 0x00000000UL, 0xd26287a2UL, 0x00000001UL, // x^109568 mod p(x)` << 1, x^109632 mod p(x)` << 1
+ 0x31803ce2UL, 0x00000000UL, 0xf6f0bba8UL, 0x00000001UL, // x^108544 mod p(x)` << 1, x^108608 mod p(x)` << 1
+ 0x24f40b0cUL, 0x00000000UL, 0x2ffabd62UL, 0x00000000UL, // x^107520 mod p(x)` << 1, x^107584 mod p(x)` << 1
+ 0xba1d9834UL, 0x00000001UL, 0xfb4516b8UL, 0x00000000UL, // x^106496 mod p(x)` << 1, x^106560 mod p(x)` << 1
+ 0x04de61aaUL, 0x00000001UL, 0x8cfa961cUL, 0x00000001UL, // x^105472 mod p(x)` << 1, x^105536 mod p(x)` << 1
+ 0x13e40d46UL, 0x00000001UL, 0x9e588d52UL, 0x00000001UL, // x^104448 mod p(x)` << 1, x^104512 mod p(x)` << 1
+ 0x415598a0UL, 0x00000001UL, 0x180f0bbcUL, 0x00000001UL, // x^103424 mod p(x)` << 1, x^103488 mod p(x)` << 1
+ 0xbf6c8c90UL, 0x00000000UL, 0xe1d9177aUL, 0x00000000UL, // x^102400 mod p(x)` << 1, x^102464 mod p(x)` << 1
+ 0x788b0504UL, 0x00000001UL, 0x05abc27cUL, 0x00000001UL, // x^101376 mod p(x)` << 1, x^101440 mod p(x)` << 1
+ 0x38385d02UL, 0x00000000UL, 0x972e4a58UL, 0x00000000UL, // x^100352 mod p(x)` << 1, x^100416 mod p(x)` << 1
+ 0xb6c83844UL, 0x00000001UL, 0x83499a5eUL, 0x00000001UL, // x^99328 mod p(x)` << 1, x^99392 mod p(x)` << 1
+ 0x51061a8aUL, 0x00000000UL, 0xc96a8ccaUL, 0x00000001UL, // x^98304 mod p(x)` << 1, x^98368 mod p(x)` << 1
+ 0x7351388aUL, 0x00000001UL, 0xa1a5b60cUL, 0x00000001UL, // x^97280 mod p(x)` << 1, x^97344 mod p(x)` << 1
+ 0x32928f92UL, 0x00000001UL, 0xe4b6ac9cUL, 0x00000000UL, // x^96256 mod p(x)` << 1, x^96320 mod p(x)` << 1
+ 0xe6b4f48aUL, 0x00000000UL, 0x807e7f5aUL, 0x00000001UL, // x^95232 mod p(x)` << 1, x^95296 mod p(x)` << 1
+ 0x39d15e90UL, 0x00000000UL, 0x7a7e3bc8UL, 0x00000001UL, // x^94208 mod p(x)` << 1, x^94272 mod p(x)` << 1
+ 0x312d6074UL, 0x00000000UL, 0xd73975daUL, 0x00000000UL, // x^93184 mod p(x)` << 1, x^93248 mod p(x)` << 1
+ 0x7bbb2cc4UL, 0x00000001UL, 0x7375d038UL, 0x00000001UL, // x^92160 mod p(x)` << 1, x^92224 mod p(x)` << 1
+ 0x6ded3e18UL, 0x00000001UL, 0x193680bcUL, 0x00000000UL, // x^91136 mod p(x)` << 1, x^91200 mod p(x)` << 1
+ 0xf1638b16UL, 0x00000000UL, 0x999b06f6UL, 0x00000000UL, // x^90112 mod p(x)` << 1, x^90176 mod p(x)` << 1
+ 0xd38b9eccUL, 0x00000001UL, 0xf685d2b8UL, 0x00000001UL, // x^89088 mod p(x)` << 1, x^89152 mod p(x)` << 1
+ 0x8b8d09dcUL, 0x00000001UL, 0xf4ecbed2UL, 0x00000001UL, // x^88064 mod p(x)` << 1, x^88128 mod p(x)` << 1
+ 0xe7bc27d2UL, 0x00000000UL, 0xba16f1a0UL, 0x00000000UL, // x^87040 mod p(x)` << 1, x^87104 mod p(x)` << 1
+ 0x275e1e96UL, 0x00000000UL, 0x15aceac4UL, 0x00000001UL, // x^86016 mod p(x)` << 1, x^86080 mod p(x)` << 1
+ 0xe2e3031eUL, 0x00000000UL, 0xaeff6292UL, 0x00000001UL, // x^84992 mod p(x)` << 1, x^85056 mod p(x)` << 1
+ 0x041c84d8UL, 0x00000001UL, 0x9640124cUL, 0x00000000UL, // x^83968 mod p(x)` << 1, x^84032 mod p(x)` << 1
+ 0x706ce672UL, 0x00000000UL, 0x14f41f02UL, 0x00000001UL, // x^82944 mod p(x)` << 1, x^83008 mod p(x)` << 1
+ 0x5d5070daUL, 0x00000001UL, 0x9c5f3586UL, 0x00000000UL, // x^81920 mod p(x)` << 1, x^81984 mod p(x)` << 1
+ 0x38f9493aUL, 0x00000000UL, 0x878275faUL, 0x00000001UL, // x^80896 mod p(x)` << 1, x^80960 mod p(x)` << 1
+ 0xa3348a76UL, 0x00000000UL, 0xddc42ce8UL, 0x00000000UL, // x^79872 mod p(x)` << 1, x^79936 mod p(x)` << 1
+ 0xad0aab92UL, 0x00000001UL, 0x81d2c73aUL, 0x00000001UL, // x^78848 mod p(x)` << 1, x^78912 mod p(x)` << 1
+ 0x9e85f712UL, 0x00000001UL, 0x41c9320aUL, 0x00000001UL, // x^77824 mod p(x)` << 1, x^77888 mod p(x)` << 1
+ 0x5a871e76UL, 0x00000000UL, 0x5235719aUL, 0x00000001UL, // x^76800 mod p(x)` << 1, x^76864 mod p(x)` << 1
+ 0x7249c662UL, 0x00000001UL, 0xbe27d804UL, 0x00000000UL, // x^75776 mod p(x)` << 1, x^75840 mod p(x)` << 1
+ 0x3a084712UL, 0x00000000UL, 0x6242d45aUL, 0x00000000UL, // x^74752 mod p(x)` << 1, x^74816 mod p(x)` << 1
+ 0xed438478UL, 0x00000000UL, 0x9a53638eUL, 0x00000000UL, // x^73728 mod p(x)` << 1, x^73792 mod p(x)` << 1
+ 0xabac34ccUL, 0x00000000UL, 0x001ecfb6UL, 0x00000001UL, // x^72704 mod p(x)` << 1, x^72768 mod p(x)` << 1
+ 0x5f35ef3eUL, 0x00000000UL, 0x6d7c2d64UL, 0x00000001UL, // x^71680 mod p(x)` << 1, x^71744 mod p(x)` << 1
+ 0x47d6608cUL, 0x00000000UL, 0xd0ce46c0UL, 0x00000001UL, // x^70656 mod p(x)` << 1, x^70720 mod p(x)` << 1
+ 0x2d01470eUL, 0x00000000UL, 0x24c907b4UL, 0x00000001UL, // x^69632 mod p(x)` << 1, x^69696 mod p(x)` << 1
+ 0x58bbc7b0UL, 0x00000001UL, 0x18a555caUL, 0x00000000UL, // x^68608 mod p(x)` << 1, x^68672 mod p(x)` << 1
+ 0xc0a23e8eUL, 0x00000000UL, 0x6b0980bcUL, 0x00000000UL, // x^67584 mod p(x)` << 1, x^67648 mod p(x)` << 1
+ 0xebd85c88UL, 0x00000001UL, 0x8bbba964UL, 0x00000000UL, // x^66560 mod p(x)` << 1, x^66624 mod p(x)` << 1
+ 0x9ee20bb2UL, 0x00000001UL, 0x070a5a1eUL, 0x00000001UL, // x^65536 mod p(x)` << 1, x^65600 mod p(x)` << 1
+ 0xacabf2d6UL, 0x00000001UL, 0x2204322aUL, 0x00000000UL, // x^64512 mod p(x)` << 1, x^64576 mod p(x)` << 1
+ 0xb7963d56UL, 0x00000001UL, 0xa27524d0UL, 0x00000000UL, // x^63488 mod p(x)` << 1, x^63552 mod p(x)` << 1
+ 0x7bffa1feUL, 0x00000001UL, 0x20b1e4baUL, 0x00000000UL, // x^62464 mod p(x)` << 1, x^62528 mod p(x)` << 1
+ 0x1f15333eUL, 0x00000000UL, 0x32cc27fcUL, 0x00000000UL, // x^61440 mod p(x)` << 1, x^61504 mod p(x)` << 1
+ 0x8593129eUL, 0x00000001UL, 0x44dd22b8UL, 0x00000000UL, // x^60416 mod p(x)` << 1, x^60480 mod p(x)` << 1
+ 0x9cb32602UL, 0x00000001UL, 0xdffc9e0aUL, 0x00000000UL, // x^59392 mod p(x)` << 1, x^59456 mod p(x)` << 1
+ 0x42b05cc8UL, 0x00000001UL, 0xb7a0ed14UL, 0x00000001UL, // x^58368 mod p(x)` << 1, x^58432 mod p(x)` << 1
+ 0xbe49e7a4UL, 0x00000001UL, 0xc7842488UL, 0x00000000UL, // x^57344 mod p(x)` << 1, x^57408 mod p(x)` << 1
+ 0x08f69d6cUL, 0x00000001UL, 0xc02a4feeUL, 0x00000001UL, // x^56320 mod p(x)` << 1, x^56384 mod p(x)` << 1
+ 0x6c0971f0UL, 0x00000000UL, 0x3c273778UL, 0x00000000UL, // x^55296 mod p(x)` << 1, x^55360 mod p(x)` << 1
+ 0x5b16467aUL, 0x00000000UL, 0xd63f8894UL, 0x00000001UL, // x^54272 mod p(x)` << 1, x^54336 mod p(x)` << 1
+ 0x551a628eUL, 0x00000001UL, 0x6be557d6UL, 0x00000000UL, // x^53248 mod p(x)` << 1, x^53312 mod p(x)` << 1
+ 0x9e42ea92UL, 0x00000001UL, 0x6a7806eaUL, 0x00000000UL, // x^52224 mod p(x)` << 1, x^52288 mod p(x)` << 1
+ 0x2fa83ff2UL, 0x00000001UL, 0x6155aa0cUL, 0x00000001UL, // x^51200 mod p(x)` << 1, x^51264 mod p(x)` << 1
+ 0x1ca9cde0UL, 0x00000001UL, 0x908650acUL, 0x00000000UL, // x^50176 mod p(x)` << 1, x^50240 mod p(x)` << 1
+ 0xc8e5cd74UL, 0x00000000UL, 0xaa5a8084UL, 0x00000000UL, // x^49152 mod p(x)` << 1, x^49216 mod p(x)` << 1
+ 0x96c27f0cUL, 0x00000000UL, 0x91bb500aUL, 0x00000001UL, // x^48128 mod p(x)` << 1, x^48192 mod p(x)` << 1
+ 0x2baed926UL, 0x00000000UL, 0x64e9bed0UL, 0x00000000UL, // x^47104 mod p(x)` << 1, x^47168 mod p(x)` << 1
+ 0x7c8de8d2UL, 0x00000001UL, 0x9444f302UL, 0x00000000UL, // x^46080 mod p(x)` << 1, x^46144 mod p(x)` << 1
+ 0xd43d6068UL, 0x00000000UL, 0x9db07d3cUL, 0x00000001UL, // x^45056 mod p(x)` << 1, x^45120 mod p(x)` << 1
+ 0xcb2c4b26UL, 0x00000000UL, 0x359e3e6eUL, 0x00000001UL, // x^44032 mod p(x)` << 1, x^44096 mod p(x)` << 1
+ 0x45b8da26UL, 0x00000001UL, 0xe4f10dd2UL, 0x00000001UL, // x^43008 mod p(x)` << 1, x^43072 mod p(x)` << 1
+ 0x8fff4b08UL, 0x00000001UL, 0x24f5735eUL, 0x00000001UL, // x^41984 mod p(x)` << 1, x^42048 mod p(x)` << 1
+ 0x50b58ed0UL, 0x00000001UL, 0x24760a4cUL, 0x00000001UL, // x^40960 mod p(x)` << 1, x^41024 mod p(x)` << 1
+ 0x549f39bcUL, 0x00000001UL, 0x0f1fc186UL, 0x00000000UL, // x^39936 mod p(x)` << 1, x^40000 mod p(x)` << 1
+ 0xef4d2f42UL, 0x00000000UL, 0x150e4cc4UL, 0x00000000UL, // x^38912 mod p(x)` << 1, x^38976 mod p(x)` << 1
+ 0xb1468572UL, 0x00000001UL, 0x2a6204e8UL, 0x00000000UL, // x^37888 mod p(x)` << 1, x^37952 mod p(x)` << 1
+ 0x3d7403b2UL, 0x00000001UL, 0xbeb1d432UL, 0x00000000UL, // x^36864 mod p(x)` << 1, x^36928 mod p(x)` << 1
+ 0xa4681842UL, 0x00000001UL, 0x35f3f1f0UL, 0x00000001UL, // x^35840 mod p(x)` << 1, x^35904 mod p(x)` << 1
+ 0x67714492UL, 0x00000001UL, 0x74fe2232UL, 0x00000000UL, // x^34816 mod p(x)` << 1, x^34880 mod p(x)` << 1
+ 0xe599099aUL, 0x00000001UL, 0x1ac6e2baUL, 0x00000000UL, // x^33792 mod p(x)` << 1, x^33856 mod p(x)` << 1
+ 0xfe128194UL, 0x00000000UL, 0x13fca91eUL, 0x00000000UL, // x^32768 mod p(x)` << 1, x^32832 mod p(x)` << 1
+ 0x77e8b990UL, 0x00000000UL, 0x83f4931eUL, 0x00000001UL, // x^31744 mod p(x)` << 1, x^31808 mod p(x)` << 1
+ 0xa267f63aUL, 0x00000001UL, 0xb6d9b4e4UL, 0x00000000UL, // x^30720 mod p(x)` << 1, x^30784 mod p(x)` << 1
+ 0x945c245aUL, 0x00000001UL, 0xb5188656UL, 0x00000000UL, // x^29696 mod p(x)` << 1, x^29760 mod p(x)` << 1
+ 0x49002e76UL, 0x00000001UL, 0x27a81a84UL, 0x00000000UL, // x^28672 mod p(x)` << 1, x^28736 mod p(x)` << 1
+ 0xbb8310a4UL, 0x00000001UL, 0x25699258UL, 0x00000001UL, // x^27648 mod p(x)` << 1, x^27712 mod p(x)` << 1
+ 0x9ec60bccUL, 0x00000001UL, 0xb23de796UL, 0x00000001UL, // x^26624 mod p(x)` << 1, x^26688 mod p(x)` << 1
+ 0x2d8590aeUL, 0x00000001UL, 0xfe4365dcUL, 0x00000000UL, // x^25600 mod p(x)` << 1, x^25664 mod p(x)` << 1
+ 0x65b00684UL, 0x00000000UL, 0xc68f497aUL, 0x00000000UL, // x^24576 mod p(x)` << 1, x^24640 mod p(x)` << 1
+ 0x5e5aeadcUL, 0x00000001UL, 0xfbf521eeUL, 0x00000000UL, // x^23552 mod p(x)` << 1, x^23616 mod p(x)` << 1
+ 0xb77ff2b0UL, 0x00000000UL, 0x5eac3378UL, 0x00000001UL, // x^22528 mod p(x)` << 1, x^22592 mod p(x)` << 1
+ 0x88da2ff6UL, 0x00000001UL, 0x34914b90UL, 0x00000001UL, // x^21504 mod p(x)` << 1, x^21568 mod p(x)` << 1
+ 0x63da929aUL, 0x00000000UL, 0x16335cfeUL, 0x00000000UL, // x^20480 mod p(x)` << 1, x^20544 mod p(x)` << 1
+ 0x389caa80UL, 0x00000001UL, 0x0372d10cUL, 0x00000001UL, // x^19456 mod p(x)` << 1, x^19520 mod p(x)` << 1
+ 0x3db599d2UL, 0x00000001UL, 0x5097b908UL, 0x00000001UL, // x^18432 mod p(x)` << 1, x^18496 mod p(x)` << 1
+ 0x22505a86UL, 0x00000001UL, 0x227a7572UL, 0x00000001UL, // x^17408 mod p(x)` << 1, x^17472 mod p(x)` << 1
+ 0x6bd72746UL, 0x00000001UL, 0x9a8f75c0UL, 0x00000000UL, // x^16384 mod p(x)` << 1, x^16448 mod p(x)` << 1
+ 0xc3faf1d4UL, 0x00000001UL, 0x682c77a2UL, 0x00000000UL, // x^15360 mod p(x)` << 1, x^15424 mod p(x)` << 1
+ 0x111c826cUL, 0x00000001UL, 0x231f091cUL, 0x00000000UL, // x^14336 mod p(x)` << 1, x^14400 mod p(x)` << 1
+ 0x153e9fb2UL, 0x00000000UL, 0x7d4439f2UL, 0x00000000UL, // x^13312 mod p(x)` << 1, x^13376 mod p(x)` << 1
+ 0x2b1f7b60UL, 0x00000000UL, 0x7e221efcUL, 0x00000001UL, // x^12288 mod p(x)` << 1, x^12352 mod p(x)` << 1
+ 0xb1dba570UL, 0x00000000UL, 0x67457c38UL, 0x00000001UL, // x^11264 mod p(x)` << 1, x^11328 mod p(x)` << 1
+ 0xf6397b76UL, 0x00000001UL, 0xbdf081c4UL, 0x00000000UL, // x^10240 mod p(x)` << 1, x^10304 mod p(x)` << 1
+ 0x56335214UL, 0x00000001UL, 0x6286d6b0UL, 0x00000001UL, // x^9216 mod p(x)` << 1, x^9280 mod p(x)` << 1
+ 0xd70e3986UL, 0x00000001UL, 0xc84f001cUL, 0x00000000UL, // x^8192 mod p(x)` << 1, x^8256 mod p(x)` << 1
+ 0x3701a774UL, 0x00000000UL, 0x64efe7c0UL, 0x00000000UL, // x^7168 mod p(x)` << 1, x^7232 mod p(x)` << 1
+ 0xac81ef72UL, 0x00000000UL, 0x0ac2d904UL, 0x00000000UL, // x^6144 mod p(x)` << 1, x^6208 mod p(x)` << 1
+ 0x33212464UL, 0x00000001UL, 0xfd226d14UL, 0x00000000UL, // x^5120 mod p(x)` << 1, x^5184 mod p(x)` << 1
+ 0xe4e45610UL, 0x00000000UL, 0x1cfd42e0UL, 0x00000001UL, // x^4096 mod p(x)` << 1, x^4160 mod p(x)` << 1
+ 0x0c1bd370UL, 0x00000000UL, 0x6e5a5678UL, 0x00000001UL, // x^3072 mod p(x)` << 1, x^3136 mod p(x)` << 1
+ 0xa7b9e7a6UL, 0x00000001UL, 0xd888fe22UL, 0x00000001UL, // x^2048 mod p(x)` << 1, x^2112 mod p(x)` << 1
+ 0x7d657a10UL, 0x00000000UL, 0xaf77fcd4UL, 0x00000001UL, // x^1024 mod p(x)` << 1, x^1088 mod p(x)` << 1
+
+ // Reduce final 1024-2048 bits to 64 bits, shifting 32 bits to include the trailing 32 bits of zeros
+ 0xec447f11UL, 0x99168a18UL, 0x13e8221eUL, 0xed837b26UL, // x^2048 mod p(x)`, x^2016 mod p(x)`, x^1984 mod p(x)`, x^1952 mod p(x)`
+ 0x8fd2cd3cUL, 0xe23e954eUL, 0x47b9ce5aUL, 0xc8acdd81UL, // x^1920 mod p(x)`, x^1888 mod p(x)`, x^1856 mod p(x)`, x^1824 mod p(x)`
+ 0x6b1d2b53UL, 0x92f8befeUL, 0xd4277e25UL, 0xd9ad6d87UL, // x^1792 mod p(x)`, x^1760 mod p(x)`, x^1728 mod p(x)`, x^1696 mod p(x)`
+ 0x291ea462UL, 0xf38a3556UL, 0x33fbca3bUL, 0xc10ec5e0UL, // x^1664 mod p(x)`, x^1632 mod p(x)`, x^1600 mod p(x)`, x^1568 mod p(x)`
+ 0x62b6ca4bUL, 0x974ac562UL, 0x82e02e2fUL, 0xc0b55b0eUL, // x^1536 mod p(x)`, x^1504 mod p(x)`, x^1472 mod p(x)`, x^1440 mod p(x)`
+ 0x784d2a56UL, 0x855712b3UL, 0xe172334dUL, 0x71aa1df0UL, // x^1408 mod p(x)`, x^1376 mod p(x)`, x^1344 mod p(x)`, x^1312 mod p(x)`
+ 0x0eaee722UL, 0xa5abe9f8UL, 0x3969324dUL, 0xfee3053eUL, // x^1280 mod p(x)`, x^1248 mod p(x)`, x^1216 mod p(x)`, x^1184 mod p(x)`
+ 0xdb54814cUL, 0x1fa0943dUL, 0x3eb2bd08UL, 0xf44779b9UL, // x^1152 mod p(x)`, x^1120 mod p(x)`, x^1088 mod p(x)`, x^1056 mod p(x)`
+ 0xd7bbfe6aUL, 0xa53ff440UL, 0x00cc3374UL, 0xf5449b3fUL, // x^1024 mod p(x)`, x^992 mod p(x)`, x^960 mod p(x)`, x^928 mod p(x)`
+ 0x6325605cUL, 0xebe7e356UL, 0xd777606eUL, 0x6f8346e1UL, // x^896 mod p(x)`, x^864 mod p(x)`, x^832 mod p(x)`, x^800 mod p(x)`
+ 0xe5b592b8UL, 0xc65a272cUL, 0xc0b95347UL, 0xe3ab4f2aUL, // x^768 mod p(x)`, x^736 mod p(x)`, x^704 mod p(x)`, x^672 mod p(x)`
+ 0x4721589fUL, 0x5705a9caUL, 0x329ecc11UL, 0xaa2215eaUL, // x^640 mod p(x)`, x^608 mod p(x)`, x^576 mod p(x)`, x^544 mod p(x)`
+ 0x88d14467UL, 0xe3720acbUL, 0xd95efd26UL, 0x1ed8f66eUL, // x^512 mod p(x)`, x^480 mod p(x)`, x^448 mod p(x)`, x^416 mod p(x)`
+ 0x15141c31UL, 0xba1aca03UL, 0xa700e96aUL, 0x78ed02d5UL, // x^384 mod p(x)`, x^352 mod p(x)`, x^320 mod p(x)`, x^288 mod p(x)`
+ 0xed627daeUL, 0xad2a31b3UL, 0x32b39da3UL, 0xba8ccbe8UL, // x^256 mod p(x)`, x^224 mod p(x)`, x^192 mod p(x)`, x^160 mod p(x)`
+ 0xa06a2517UL, 0x6655004fUL, 0xb1e6b092UL, 0xedb88320UL // x^128 mod p(x)`, x^96 mod p(x)`, x^64 mod p(x)`, x^32 mod p(x)`
+ };
+
+ juint* ptr = (juint*) malloc(sizeof(juint) * CRC32_CONSTANTS_SIZE);
+ guarantee(((intptr_t)ptr & 0xF) == 0, "16-byte alignment needed");
+ guarantee(ptr != NULL, "allocation error of a crc table");
+ memcpy((void*)ptr, constants, sizeof(juint) * CRC32_CONSTANTS_SIZE);
+ return ptr;
+}
+
+juint* StubRoutines::ppc64::generate_crc_barret_constants() {
+ juint barret_constants[CRC32_BARRET_CONSTANTS] = {
+ 0xf7011641UL, 0x00000001UL, 0x00000000UL, 0x00000000UL,
+ 0xdb710641UL, 0x00000001UL, 0x00000000UL, 0x00000000UL
+ };
+ juint* ptr = (juint*) malloc(sizeof(juint) * CRC32_CONSTANTS_SIZE);
+ guarantee(((intptr_t)ptr & 0xF) == 0, "16-byte alignment needed");
+ guarantee(ptr != NULL, "allocation error of a crc table");
+ memcpy((void*) ptr, barret_constants, sizeof(juint) * CRC32_BARRET_CONSTANTS);
+ return ptr;
+}
+
// CRC32 Intrinsics.
/**
* crc_table[] from jdk/src/share/native/java/util/zip/zlib-1.2.8/crc32.h
@@ -477,3 +782,7 @@
#endif
}
};
+
+juint* StubRoutines::ppc64::_constants = StubRoutines::ppc64::generate_crc_constants();
+
+juint* StubRoutines::ppc64::_barret_constants = StubRoutines::ppc64::generate_crc_barret_constants();
--- a/hotspot/src/cpu/ppc/vm/templateInterpreterGenerator_ppc.cpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/cpu/ppc/vm/templateInterpreterGenerator_ppc.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -1544,6 +1544,12 @@
__ fence();
}
+ if (CheckJNICalls) {
+ // clear_pending_jni_exception_check
+ __ load_const_optimized(R0, 0L);
+ __ st_ptr(R0, JavaThread::pending_jni_exception_check_fn_offset(), R16_thread);
+ }
+
__ reset_last_Java_frame();
// Jvmdi/jvmpi support. Whether we've got an exception pending or
--- a/hotspot/src/cpu/ppc/vm/vm_version_ppc.cpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/cpu/ppc/vm/vm_version_ppc.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -230,6 +230,11 @@
FLAG_SET_DEFAULT(UseGHASHIntrinsics, false);
}
+ if (UseFMA) {
+ warning("FMA instructions are not available on this CPU");
+ FLAG_SET_DEFAULT(UseFMA, false);
+ }
+
if (UseSHA) {
warning("SHA instructions are not available on this CPU");
FLAG_SET_DEFAULT(UseSHA, false);
@@ -274,7 +279,14 @@
}
bool os_too_old = true;
#ifdef AIX
- if (os::Aix::os_version() >= 0x0701031e) { // at least AIX 7.1.3.30
+ // Actually, this is supported since AIX 7.1.. Unfortunately, this first
+ // contained bugs, so that it can only be enabled after AIX 7.1.3.30.
+ // The Java property os.version, which is used in RTM tests to decide
+ // whether the feature is available, only knows major and minor versions.
+ // We don't want to change this property, as user code might depend on it.
+ // So the tests can not check on subversion 3.30, and we only enable RTM
+ // with AIX 7.2.
+ if (os::Aix::os_version() >= 0x07020000) { // At least AIX 7.2.
os_too_old = false;
}
#endif
--- a/hotspot/src/cpu/sparc/vm/c1_LIRGenerator_sparc.cpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/cpu/sparc/vm/c1_LIRGenerator_sparc.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -147,10 +147,11 @@
LIR_Address* LIRGenerator::generate_address(LIR_Opr base, LIR_Opr index,
int shift, int disp, BasicType type) {
assert(base->is_register(), "must be");
+ intx large_disp = disp;
// accumulate fixed displacements
if (index->is_constant()) {
- disp += index->as_constant_ptr()->as_jint() << shift;
+ large_disp += (intx)(index->as_constant_ptr()->as_jint()) << shift;
index = LIR_OprFact::illegalOpr;
}
@@ -161,31 +162,31 @@
__ shift_left(index, shift, tmp);
index = tmp;
}
- if (disp != 0) {
+ if (large_disp != 0) {
LIR_Opr tmp = new_pointer_register();
- if (Assembler::is_simm13(disp)) {
- __ add(tmp, LIR_OprFact::intptrConst(disp), tmp);
+ if (Assembler::is_simm13(large_disp)) {
+ __ add(tmp, LIR_OprFact::intptrConst(large_disp), tmp);
index = tmp;
} else {
- __ move(LIR_OprFact::intptrConst(disp), tmp);
+ __ move(LIR_OprFact::intptrConst(large_disp), tmp);
__ add(tmp, index, tmp);
index = tmp;
}
- disp = 0;
+ large_disp = 0;
}
- } else if (disp != 0 && !Assembler::is_simm13(disp)) {
+ } else if (large_disp != 0 && !Assembler::is_simm13(large_disp)) {
// index is illegal so replace it with the displacement loaded into a register
index = new_pointer_register();
- __ move(LIR_OprFact::intptrConst(disp), index);
- disp = 0;
+ __ move(LIR_OprFact::intptrConst(large_disp), index);
+ large_disp = 0;
}
// at this point we either have base + index or base + displacement
- if (disp == 0) {
+ if (large_disp == 0) {
return new LIR_Address(base, index, type);
} else {
- assert(Assembler::is_simm13(disp), "must be");
- return new LIR_Address(base, disp, type);
+ assert(Assembler::is_simm13(large_disp), "must be");
+ return new LIR_Address(base, large_disp, type);
}
}
@@ -196,11 +197,11 @@
int shift = exact_log2(elem_size);
LIR_Opr base_opr;
- int offset = arrayOopDesc::base_offset_in_bytes(type);
+ intx offset = arrayOopDesc::base_offset_in_bytes(type);
if (index_opr->is_constant()) {
- int i = index_opr->as_constant_ptr()->as_jint();
- int array_offset = i * elem_size;
+ intx i = index_opr->as_constant_ptr()->as_jint();
+ intx array_offset = i * elem_size;
if (Assembler::is_simm13(array_offset + offset)) {
base_opr = array_opr;
offset = array_offset + offset;
@@ -953,6 +954,10 @@
}
}
+void LIRGenerator::do_FmaIntrinsic(Intrinsic* x) {
+ fatal("FMA intrinsic is not implemented on this platform");
+}
+
void LIRGenerator::do_vectorizedMismatch(Intrinsic* x) {
fatal("vectorizedMismatch intrinsic is not implemented on this platform");
}
--- a/hotspot/src/cpu/sparc/vm/c1_Runtime1_sparc.cpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/cpu/sparc/vm/c1_Runtime1_sparc.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -881,20 +881,15 @@
__ delayed()->st_ptr(tmp, G2_thread, satb_q_index_byte_offset);
__ bind(refill);
- __ save_frame(0);
- __ mov(pre_val, L0);
- __ mov(tmp, L1);
- __ mov(tmp2, L2);
+ save_live_registers(sasm);
__ call_VM_leaf(L7_thread_cache,
CAST_FROM_FN_PTR(address,
SATBMarkQueueSet::handle_zero_index_for_thread),
G2_thread);
- __ mov(L0, pre_val);
- __ mov(L1, tmp);
- __ mov(L2, tmp2);
+ restore_live_registers(sasm);
__ br(Assembler::always, /*annul*/false, Assembler::pt, restart);
__ delayed()->restore();
@@ -986,20 +981,15 @@
__ delayed()->st_ptr(tmp3, G2_thread, dirty_card_q_index_byte_offset);
__ bind(refill);
- __ save_frame(0);
- __ mov(tmp2, L0);
- __ mov(tmp3, L1);
- __ mov(tmp4, L2);
+ save_live_registers(sasm);
__ call_VM_leaf(L7_thread_cache,
CAST_FROM_FN_PTR(address,
DirtyCardQueueSet::handle_zero_index_for_thread),
G2_thread);
- __ mov(L0, tmp2);
- __ mov(L1, tmp3);
- __ mov(L2, tmp4);
+ restore_live_registers(sasm);
__ br(Assembler::always, /*annul*/false, Assembler::pt, restart);
__ delayed()->restore();
--- a/hotspot/src/cpu/sparc/vm/vm_version_sparc.cpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/cpu/sparc/vm/vm_version_sparc.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -266,6 +266,11 @@
FLAG_SET_DEFAULT(UseGHASHIntrinsics, false);
}
+ if (UseFMA) {
+ warning("FMA instructions are not available on this CPU");
+ FLAG_SET_DEFAULT(UseFMA, false);
+ }
+
// SHA1, SHA256, and SHA512 instructions were added to SPARC T-series at different times
if (has_sha1() || has_sha256() || has_sha512()) {
if (UseVIS > 0) { // SHA intrinsics use VIS1 instructions
--- a/hotspot/src/cpu/x86/vm/abstractInterpreter_x86.cpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/cpu/x86/vm/abstractInterpreter_x86.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -172,7 +172,9 @@
case Interpreter::java_lang_math_log10 : // fall thru
case Interpreter::java_lang_math_sqrt : // fall thru
case Interpreter::java_lang_math_pow : // fall thru
- case Interpreter::java_lang_math_exp :
+ case Interpreter::java_lang_math_exp : // fall thru
+ case Interpreter::java_lang_math_fmaD : // fall thru
+ case Interpreter::java_lang_math_fmaF :
return false;
default:
return true;
--- a/hotspot/src/cpu/x86/vm/assembler_x86.cpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/cpu/x86/vm/assembler_x86.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -4769,6 +4769,22 @@
emit_int8((unsigned char)(0xC0 | encode));
}
+void Assembler::vfmadd231sd(XMMRegister dst, XMMRegister src1, XMMRegister src2) {
+ assert(VM_Version::supports_fma(), "");
+ InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false);
+ int encode = vex_prefix_and_encode(dst->encoding(), src1->encoding(), src2->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes);
+ emit_int8((unsigned char)0xB9);
+ emit_int8((unsigned char)(0xC0 | encode));
+}
+
+void Assembler::vfmadd231ss(XMMRegister dst, XMMRegister src1, XMMRegister src2) {
+ assert(VM_Version::supports_fma(), "");
+ InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false);
+ int encode = vex_prefix_and_encode(dst->encoding(), src1->encoding(), src2->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes);
+ emit_int8((unsigned char)0xB9);
+ emit_int8((unsigned char)(0xC0 | encode));
+}
+
void Assembler::vmulsd(XMMRegister dst, XMMRegister nds, Address src) {
assert(VM_Version::supports_avx(), "");
InstructionMark im(this);
--- a/hotspot/src/cpu/x86/vm/assembler_x86.hpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/cpu/x86/vm/assembler_x86.hpp Fri Oct 14 11:11:19 2016 -0700
@@ -1860,6 +1860,8 @@
void vdivsd(XMMRegister dst, XMMRegister nds, XMMRegister src);
void vdivss(XMMRegister dst, XMMRegister nds, Address src);
void vdivss(XMMRegister dst, XMMRegister nds, XMMRegister src);
+ void vfmadd231sd(XMMRegister dst, XMMRegister nds, XMMRegister src);
+ void vfmadd231ss(XMMRegister dst, XMMRegister nds, XMMRegister src);
void vmulsd(XMMRegister dst, XMMRegister nds, Address src);
void vmulsd(XMMRegister dst, XMMRegister nds, XMMRegister src);
void vmulss(XMMRegister dst, XMMRegister nds, Address src);
--- a/hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -1345,6 +1345,18 @@
op->result_opr(),
op->info());
break;
+ case lir_fmad:
+ __ fmad(op->result_opr()->as_xmm_double_reg(),
+ op->in_opr1()->as_xmm_double_reg(),
+ op->in_opr2()->as_xmm_double_reg(),
+ op->in_opr3()->as_xmm_double_reg());
+ break;
+ case lir_fmaf:
+ __ fmaf(op->result_opr()->as_xmm_float_reg(),
+ op->in_opr1()->as_xmm_float_reg(),
+ op->in_opr2()->as_xmm_float_reg(),
+ op->in_opr3()->as_xmm_float_reg());
+ break;
default: ShouldNotReachHere(); break;
}
}
--- a/hotspot/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -152,7 +152,7 @@
assert(base->is_register(), "must be");
if (index->is_constant()) {
return new LIR_Address(base,
- (index->as_constant_ptr()->as_jint() << shift) + disp,
+ ((intx)(index->as_constant_ptr()->as_jint()) << shift) + disp,
type);
} else {
return new LIR_Address(base, index, (LIR_Address::Scale)shift, disp, type);
@@ -168,7 +168,7 @@
if (index_opr->is_constant()) {
int elem_size = type2aelembytes(type);
addr = new LIR_Address(array_opr,
- offset_in_bytes + index_opr->as_jint() * elem_size, type);
+ offset_in_bytes + (intx)(index_opr->as_jint()) * elem_size, type);
} else {
#ifdef _LP64
if (index_opr->type() == T_INT) {
@@ -806,6 +806,32 @@
}
}
+void LIRGenerator::do_FmaIntrinsic(Intrinsic* x) {
+ assert(x->number_of_arguments() == 3, "wrong type");
+ assert(UseFMA, "Needs FMA instructions support.");
+ LIRItem value(x->argument_at(0), this);
+ LIRItem value1(x->argument_at(1), this);
+ LIRItem value2(x->argument_at(2), this);
+
+ value2.set_destroys_register();
+
+ value.load_item();
+ value1.load_item();
+ value2.load_item();
+
+ LIR_Opr calc_input = value.result();
+ LIR_Opr calc_input1 = value1.result();
+ LIR_Opr calc_input2 = value2.result();
+ LIR_Opr calc_result = rlock_result(x);
+
+ switch (x->id()) {
+ case vmIntrinsics::_fmaD: __ fmad(calc_input, calc_input1, calc_input2, calc_result); break;
+ case vmIntrinsics::_fmaF: __ fmaf(calc_input, calc_input1, calc_input2, calc_result); break;
+ default: ShouldNotReachHere();
+ }
+
+}
+
void LIRGenerator::do_MathIntrinsic(Intrinsic* x) {
assert(x->number_of_arguments() == 1 || (x->number_of_arguments() == 2 && x->id() == vmIntrinsics::_dpow), "wrong type");
--- a/hotspot/src/cpu/x86/vm/c1_LinearScan_x86.hpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/cpu/x86/vm/c1_LinearScan_x86.hpp Fri Oct 14 11:11:19 2016 -0700
@@ -100,9 +100,11 @@
inline bool LinearScanWalker::pd_init_regs_for_alloc(Interval* cur) {
int last_xmm_reg = pd_last_xmm_reg;
+#ifdef _LP64
if (UseAVX < 3) {
last_xmm_reg = pd_first_xmm_reg + (pd_nof_xmm_regs_frame_map / 2) - 1;
}
+#endif
if (allocator()->gen()->is_vreg_flag_set(cur->reg_num(), LIRGenerator::byte_reg)) {
assert(cur->type() != T_FLOAT && cur->type() != T_DOUBLE, "cpu regs only");
_first_reg = pd_first_byte_reg;
--- a/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -3147,6 +3147,24 @@
fpop();
}
+// dst = c = a * b + c
+void MacroAssembler::fmad(XMMRegister dst, XMMRegister a, XMMRegister b, XMMRegister c) {
+ Assembler::vfmadd231sd(c, a, b);
+ if (dst != c) {
+ movdbl(dst, c);
+ }
+}
+
+// dst = c = a * b + c
+void MacroAssembler::fmaf(XMMRegister dst, XMMRegister a, XMMRegister b, XMMRegister c) {
+ Assembler::vfmadd231ss(c, a, b);
+ if (dst != c) {
+ movflt(dst, c);
+ }
+}
+
+
+
void MacroAssembler::incrementl(AddressLiteral dst) {
if (reachable(dst)) {
--- a/hotspot/src/cpu/x86/vm/macroAssembler_x86.hpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/cpu/x86/vm/macroAssembler_x86.hpp Fri Oct 14 11:11:19 2016 -0700
@@ -449,6 +449,10 @@
// tmp is a temporary register, if none is available use noreg
void fremr(Register tmp);
+ // dst = c = a * b + c
+ void fmad(XMMRegister dst, XMMRegister a, XMMRegister b, XMMRegister c);
+ void fmaf(XMMRegister dst, XMMRegister a, XMMRegister b, XMMRegister c);
+
// same as fcmp2int, but using SSE2
void cmpss2int(XMMRegister opr1, XMMRegister opr2, Register dst, bool unordered_is_less);
--- a/hotspot/src/cpu/x86/vm/macroAssembler_x86_sha.cpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/cpu/x86/vm/macroAssembler_x86_sha.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -720,19 +720,13 @@
enum {
_XFER_SIZE = 2*64*4, // 2 blocks, 64 rounds, 4 bytes/round
-#ifndef _WIN64
- _XMM_SAVE_SIZE = 0,
-#else
- _XMM_SAVE_SIZE = 8*16,
-#endif
_INP_END_SIZE = 8,
_INP_SIZE = 8,
_CTX_SIZE = 8,
_RSP_SIZE = 8,
_XFER = 0,
- _XMM_SAVE = _XFER + _XFER_SIZE,
- _INP_END = _XMM_SAVE + _XMM_SAVE_SIZE,
+ _INP_END = _XFER + _XFER_SIZE,
_INP = _INP_END + _INP_END_SIZE,
_CTX = _INP + _INP_SIZE,
_RSP = _CTX + _CTX_SIZE,
--- a/hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -3236,11 +3236,6 @@
#ifdef _WIN64
// on win64, fill len_reg from stack position
__ movl(len_reg, len_mem);
- // save the xmm registers which must be preserved 6-15
- __ subptr(rsp, -rsp_after_call_off * wordSize);
- for (int i = 6; i <= XMM_REG_NUM_KEY_LAST; i++) {
- __ movdqu(xmm_save(i), as_XMMRegister(i));
- }
#else
__ push(len_reg); // Save
#endif
@@ -3281,10 +3276,6 @@
__ movdqu(Address(rvec, 0), xmm_result); // final value of r stored in rvec of CipherBlockChaining object
#ifdef _WIN64
- // restore xmm regs belonging to calling function
- for (int i = 6; i <= XMM_REG_NUM_KEY_LAST; i++) {
- __ movdqu(as_XMMRegister(i), xmm_save(i));
- }
__ movl(rax, len_mem);
#else
__ pop(rax); // return length
@@ -3446,11 +3437,6 @@
#ifdef _WIN64
// on win64, fill len_reg from stack position
__ movl(len_reg, len_mem);
- // save the xmm registers which must be preserved 6-15
- __ subptr(rsp, -rsp_after_call_off * wordSize);
- for (int i = 6; i <= XMM_REG_NUM_KEY_LAST; i++) {
- __ movdqu(xmm_save(i), as_XMMRegister(i));
- }
#else
__ push(len_reg); // Save
#endif
@@ -3644,10 +3630,6 @@
__ movdqu(Address(rvec, 0), xmm_prev_block_cipher); // final value of r stored in rvec of CipherBlockChaining object
__ pop(rbx);
#ifdef _WIN64
- // restore regs belonging to calling function
- for (int i = 6; i <= XMM_REG_NUM_KEY_LAST; i++) {
- __ movdqu(as_XMMRegister(i), xmm_save(i));
- }
__ movl(rax, len_mem);
#else
__ pop(rax); // return length
@@ -3699,25 +3681,12 @@
__ enter();
-#ifdef _WIN64
- // save the xmm registers which must be preserved 6-7
- __ subptr(rsp, 4 * wordSize);
- __ movdqu(Address(rsp, 0), xmm6);
- __ movdqu(Address(rsp, 2 * wordSize), xmm7);
-#endif
-
__ subptr(rsp, 4 * wordSize);
__ fast_sha1(abcd, e0, e1, msg0, msg1, msg2, msg3, shuf_mask,
buf, state, ofs, limit, rsp, multi_block);
__ addptr(rsp, 4 * wordSize);
-#ifdef _WIN64
- // restore xmm regs belonging to calling function
- __ movdqu(xmm6, Address(rsp, 0));
- __ movdqu(xmm7, Address(rsp, 2 * wordSize));
- __ addptr(rsp, 4 * wordSize);
-#endif
__ leave();
__ ret(0);
@@ -3775,22 +3744,6 @@
const XMMRegister shuf_mask = xmm8;
__ enter();
-#ifdef _WIN64
- // save the xmm registers which must be preserved 6-7
- __ subptr(rsp, 6 * wordSize);
- __ movdqu(Address(rsp, 0), xmm6);
- __ movdqu(Address(rsp, 2 * wordSize), xmm7);
- __ movdqu(Address(rsp, 4 * wordSize), xmm8);
-
- if (!VM_Version::supports_sha() && VM_Version::supports_avx2()) {
- __ subptr(rsp, 10 * wordSize);
- __ movdqu(Address(rsp, 0), xmm9);
- __ movdqu(Address(rsp, 2 * wordSize), xmm10);
- __ movdqu(Address(rsp, 4 * wordSize), xmm11);
- __ movdqu(Address(rsp, 6 * wordSize), xmm12);
- __ movdqu(Address(rsp, 8 * wordSize), xmm13);
- }
-#endif
__ subptr(rsp, 4 * wordSize);
@@ -3802,21 +3755,7 @@
buf, state, ofs, limit, rsp, multi_block, shuf_mask);
}
__ addptr(rsp, 4 * wordSize);
-#ifdef _WIN64
- // restore xmm regs belonging to calling function
- if (!VM_Version::supports_sha() && VM_Version::supports_avx2()) {
- __ movdqu(xmm9, Address(rsp, 0));
- __ movdqu(xmm10, Address(rsp, 2 * wordSize));
- __ movdqu(xmm11, Address(rsp, 4 * wordSize));
- __ movdqu(xmm12, Address(rsp, 6 * wordSize));
- __ movdqu(xmm13, Address(rsp, 8 * wordSize));
- __ addptr(rsp, 10 * wordSize);
- }
- __ movdqu(xmm6, Address(rsp, 0));
- __ movdqu(xmm7, Address(rsp, 2 * wordSize));
- __ movdqu(xmm8, Address(rsp, 4 * wordSize));
- __ addptr(rsp, 6 * wordSize);
-#endif
+
__ leave();
__ ret(0);
return start;
@@ -3917,18 +3856,14 @@
}
#ifdef _WIN64
- // save the xmm registers which must be preserved 6-14
- const int XMM_REG_NUM_KEY_LAST = 14;
- __ subptr(rsp, -rsp_after_call_off * wordSize);
- for (int i = 6; i <= XMM_REG_NUM_KEY_LAST; i++) {
- __ movdqu(xmm_save(i), as_XMMRegister(i));
- }
-
- const Address r13_save(rbp, rdi_off * wordSize);
- const Address r14_save(rbp, rsi_off * wordSize);
-
- __ movptr(r13_save, r13);
- __ movptr(r14_save, r14);
+ // allocate spill slots for r13, r14
+ enum {
+ saved_r13_offset,
+ saved_r14_offset
+ };
+ __ subptr(rsp, 2 * wordSize);
+ __ movptr(Address(rsp, saved_r13_offset * wordSize), r13);
+ __ movptr(Address(rsp, saved_r14_offset * wordSize), r14);
// on win64, fill len_reg from stack position
__ movl(len_reg, len_mem);
@@ -4130,13 +4065,10 @@
__ movdqu(Address(counter, 0), xmm_curr_counter); //save counter back
__ pop(rbx); // pop the saved RBX.
#ifdef _WIN64
- // restore regs belonging to calling function
- for (int i = 6; i <= XMM_REG_NUM_KEY_LAST; i++) {
- __ movdqu(as_XMMRegister(i), xmm_save(i));
- }
__ movl(rax, len_mem);
- __ movptr(r13, r13_save);
- __ movptr(r14, r14_save);
+ __ movptr(r13, Address(rsp, saved_r13_offset * wordSize));
+ __ movptr(r14, Address(rsp, saved_r14_offset * wordSize));
+ __ addptr(rsp, 2 * wordSize);
#else
__ pop(rax); // return 'len'
#endif
@@ -4177,10 +4109,6 @@
const Register data = c_rarg2;
const Register blocks = c_rarg3;
-#ifdef _WIN64
- const int XMM_REG_LAST = 10;
-#endif
-
const XMMRegister xmm_temp0 = xmm0;
const XMMRegister xmm_temp1 = xmm1;
const XMMRegister xmm_temp2 = xmm2;
@@ -4203,14 +4131,6 @@
__ kmovql(k1, rax);
}
-#ifdef _WIN64
- // save the xmm registers which must be preserved 6-10
- __ subptr(rsp, -rsp_after_call_off * wordSize);
- for (int i = 6; i <= XMM_REG_LAST; i++) {
- __ movdqu(xmm_save(i), as_XMMRegister(i));
- }
-#endif
-
__ movdqu(xmm_temp10, ExternalAddress(StubRoutines::x86::ghash_long_swap_mask_addr()));
__ movdqu(xmm_temp0, Address(state, 0));
@@ -4310,12 +4230,6 @@
__ pshufb(xmm_temp6, xmm_temp10); // Byte swap 16-byte result
__ movdqu(Address(state, 0), xmm_temp6); // store the result
-#ifdef _WIN64
- // restore xmm regs belonging to calling function
- for (int i = 6; i <= XMM_REG_LAST; i++) {
- __ movdqu(as_XMMRegister(i), xmm_save(i));
- }
-#endif
__ leave();
__ ret(0);
return start;
@@ -4652,21 +4566,8 @@
BLOCK_COMMENT("Entry:");
__ enter(); // required for proper stackwalking of RuntimeStub frame
-#ifdef _WIN64
- // save the xmm registers which must be preserved 6-7
- __ subptr(rsp, 4 * wordSize);
- __ movdqu(Address(rsp, 0), xmm6);
- __ movdqu(Address(rsp, 2 * wordSize), xmm7);
-#endif
__ fast_exp(x0, x1, x2, x3, x4, x5, x6, x7, rax, rcx, rdx, tmp);
-#ifdef _WIN64
- // restore xmm regs belonging to calling function
- __ movdqu(xmm6, Address(rsp, 0));
- __ movdqu(xmm7, Address(rsp, 2 * wordSize));
- __ addptr(rsp, 4 * wordSize);
-#endif
-
__ leave(); // required for proper stackwalking of RuntimeStub frame
__ ret(0);
@@ -4693,21 +4594,8 @@
BLOCK_COMMENT("Entry:");
__ enter(); // required for proper stackwalking of RuntimeStub frame
-#ifdef _WIN64
- // save the xmm registers which must be preserved 6-7
- __ subptr(rsp, 4 * wordSize);
- __ movdqu(Address(rsp, 0), xmm6);
- __ movdqu(Address(rsp, 2 * wordSize), xmm7);
-#endif
__ fast_log(x0, x1, x2, x3, x4, x5, x6, x7, rax, rcx, rdx, tmp1, tmp2);
-#ifdef _WIN64
- // restore xmm regs belonging to calling function
- __ movdqu(xmm6, Address(rsp, 0));
- __ movdqu(xmm7, Address(rsp, 2 * wordSize));
- __ addptr(rsp, 4 * wordSize);
-#endif
-
__ leave(); // required for proper stackwalking of RuntimeStub frame
__ ret(0);
@@ -4733,21 +4621,8 @@
BLOCK_COMMENT("Entry:");
__ enter(); // required for proper stackwalking of RuntimeStub frame
-#ifdef _WIN64
- // save the xmm registers which must be preserved 6-7
- __ subptr(rsp, 4 * wordSize);
- __ movdqu(Address(rsp, 0), xmm6);
- __ movdqu(Address(rsp, 2 * wordSize), xmm7);
-#endif
__ fast_log10(x0, x1, x2, x3, x4, x5, x6, x7, rax, rcx, rdx, tmp);
-#ifdef _WIN64
- // restore xmm regs belonging to calling function
- __ movdqu(xmm6, Address(rsp, 0));
- __ movdqu(xmm7, Address(rsp, 2 * wordSize));
- __ addptr(rsp, 4 * wordSize);
-#endif
-
__ leave(); // required for proper stackwalking of RuntimeStub frame
__ ret(0);
@@ -4776,21 +4651,8 @@
BLOCK_COMMENT("Entry:");
__ enter(); // required for proper stackwalking of RuntimeStub frame
-#ifdef _WIN64
- // save the xmm registers which must be preserved 6-7
- __ subptr(rsp, 4 * wordSize);
- __ movdqu(Address(rsp, 0), xmm6);
- __ movdqu(Address(rsp, 2 * wordSize), xmm7);
-#endif
__ fast_pow(x0, x1, x2, x3, x4, x5, x6, x7, rax, rcx, rdx, tmp1, tmp2, tmp3, tmp4);
-#ifdef _WIN64
- // restore xmm regs belonging to calling function
- __ movdqu(xmm6, Address(rsp, 0));
- __ movdqu(xmm7, Address(rsp, 2 * wordSize));
- __ addptr(rsp, 4 * wordSize);
-#endif
-
__ leave(); // required for proper stackwalking of RuntimeStub frame
__ ret(0);
@@ -4822,18 +4684,10 @@
#ifdef _WIN64
__ push(rsi);
__ push(rdi);
- // save the xmm registers which must be preserved 6-7
- __ subptr(rsp, 4 * wordSize);
- __ movdqu(Address(rsp, 0), xmm6);
- __ movdqu(Address(rsp, 2 * wordSize), xmm7);
#endif
__ fast_sin(x0, x1, x2, x3, x4, x5, x6, x7, rax, rbx, rcx, rdx, tmp1, tmp2, tmp3, tmp4);
#ifdef _WIN64
- // restore xmm regs belonging to calling function
- __ movdqu(xmm6, Address(rsp, 0));
- __ movdqu(xmm7, Address(rsp, 2 * wordSize));
- __ addptr(rsp, 4 * wordSize);
__ pop(rdi);
__ pop(rsi);
#endif
@@ -4869,18 +4723,10 @@
#ifdef _WIN64
__ push(rsi);
__ push(rdi);
- // save the xmm registers which must be preserved 6-7
- __ subptr(rsp, 4 * wordSize);
- __ movdqu(Address(rsp, 0), xmm6);
- __ movdqu(Address(rsp, 2 * wordSize), xmm7);
#endif
__ fast_cos(x0, x1, x2, x3, x4, x5, x6, x7, rax, rcx, rdx, tmp1, tmp2, tmp3, tmp4);
#ifdef _WIN64
- // restore xmm regs belonging to calling function
- __ movdqu(xmm6, Address(rsp, 0));
- __ movdqu(xmm7, Address(rsp, 2 * wordSize));
- __ addptr(rsp, 4 * wordSize);
__ pop(rdi);
__ pop(rsi);
#endif
@@ -4916,18 +4762,10 @@
#ifdef _WIN64
__ push(rsi);
__ push(rdi);
- // save the xmm registers which must be preserved 6-7
- __ subptr(rsp, 4 * wordSize);
- __ movdqu(Address(rsp, 0), xmm6);
- __ movdqu(Address(rsp, 2 * wordSize), xmm7);
#endif
__ fast_tan(x0, x1, x2, x3, x4, x5, x6, x7, rax, rcx, rdx, tmp1, tmp2, tmp3, tmp4);
#ifdef _WIN64
- // restore xmm regs belonging to calling function
- __ movdqu(xmm6, Address(rsp, 0));
- __ movdqu(xmm7, Address(rsp, 2 * wordSize));
- __ addptr(rsp, 4 * wordSize);
__ pop(rdi);
__ pop(rsi);
#endif
--- a/hotspot/src/cpu/x86/vm/templateInterpreterGenerator_x86.cpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/cpu/x86/vm/templateInterpreterGenerator_x86.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -55,7 +55,7 @@
// Run with +PrintInterpreter to get the VM to print out the size.
// Max size with JVMTI
#ifdef AMD64
-int TemplateInterpreter::InterpreterCodeSize = 256 * 1024;
+int TemplateInterpreter::InterpreterCodeSize = JVMCI_ONLY(268) NOT_JVMCI(256) * 1024;
#else
int TemplateInterpreter::InterpreterCodeSize = 224 * 1024;
#endif // AMD64
--- a/hotspot/src/cpu/x86/vm/templateInterpreterGenerator_x86_32.cpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/cpu/x86/vm/templateInterpreterGenerator_x86_32.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -341,6 +341,27 @@
// [ lo(arg) ]
// [ hi(arg) ]
//
+ if (kind == Interpreter::java_lang_math_fmaD) {
+ __ movdbl(xmm2, Address(rsp, 5 * wordSize));
+ __ movdbl(xmm1, Address(rsp, 3 * wordSize));
+ __ movdbl(xmm0, Address(rsp, 1 * wordSize));
+ __ fmad(xmm0, xmm1, xmm2, xmm0);
+ __ pop(rdi); // get return address
+ __ mov(rsp, rsi); // set sp to sender sp
+ __ jmp(rdi);
+
+ return entry_point;
+ } else if (kind == Interpreter::java_lang_math_fmaF) {
+ __ movflt(xmm2, Address(rsp, 3 * wordSize));
+ __ movflt(xmm1, Address(rsp, 2 * wordSize));
+ __ movflt(xmm0, Address(rsp, 1 * wordSize));
+ __ fmaf(xmm0, xmm1, xmm2, xmm0);
+ __ pop(rdi); // get return address
+ __ mov(rsp, rsi); // set sp to sender sp
+ __ jmp(rdi);
+
+ return entry_point;
+ }
__ fld_d(Address(rsp, 1*wordSize));
switch (kind) {
--- a/hotspot/src/cpu/x86/vm/templateInterpreterGenerator_x86_64.cpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/cpu/x86/vm/templateInterpreterGenerator_x86_64.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -369,8 +369,17 @@
// [ hi(arg) ]
//
-
- if (kind == Interpreter::java_lang_math_sqrt) {
+ if (kind == Interpreter::java_lang_math_fmaD) {
+ __ movdbl(xmm0, Address(rsp, wordSize));
+ __ movdbl(xmm1, Address(rsp, 3 * wordSize));
+ __ movdbl(xmm2, Address(rsp, 5 * wordSize));
+ __ fmad(xmm0, xmm1, xmm2, xmm0);
+ } else if (kind == Interpreter::java_lang_math_fmaF) {
+ __ movflt(xmm0, Address(rsp, wordSize));
+ __ movflt(xmm1, Address(rsp, 2 * wordSize));
+ __ movflt(xmm2, Address(rsp, 3 * wordSize));
+ __ fmaf(xmm0, xmm1, xmm2, xmm0);
+ } else if (kind == Interpreter::java_lang_math_sqrt) {
__ sqrtsd(xmm0, Address(rsp, wordSize));
} else if (kind == Interpreter::java_lang_math_exp) {
__ movdbl(xmm0, Address(rsp, wordSize));
--- a/hotspot/src/cpu/x86/vm/vmStructs_x86.hpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/cpu/x86/vm/vmStructs_x86.hpp Fri Oct 14 11:11:19 2016 -0700
@@ -73,6 +73,7 @@
#define VM_LONG_CONSTANTS_CPU(declare_constant, declare_preprocessor_constant, declare_c1_constant, declare_c2_constant, declare_c2_preprocessor_constant) \
declare_preprocessor_constant("VM_Version::CPU_AVX512BW", CPU_AVX512BW) \
declare_preprocessor_constant("VM_Version::CPU_AVX512VL", CPU_AVX512VL) \
- declare_preprocessor_constant("VM_Version::CPU_SHA", CPU_SHA)
+ declare_preprocessor_constant("VM_Version::CPU_SHA", CPU_SHA) \
+ declare_preprocessor_constant("VM_Version::CPU_FMA", CPU_FMA)
#endif // CPU_X86_VM_VMSTRUCTS_X86_HPP
--- a/hotspot/src/cpu/x86/vm/vm_version_x86.cpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/cpu/x86/vm/vm_version_x86.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -578,7 +578,7 @@
}
char buf[256];
- jio_snprintf(buf, sizeof(buf), "(%u cores per cpu, %u threads per core) family %d model %d stepping %d%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
+ jio_snprintf(buf, sizeof(buf), "(%u cores per cpu, %u threads per core) family %d model %d stepping %d%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
cores_per_cpu(), threads_per_core(),
cpu_family(), _model, _stepping,
(supports_cmov() ? ", cmov" : ""),
@@ -610,7 +610,8 @@
(supports_bmi2() ? ", bmi2" : ""),
(supports_adx() ? ", adx" : ""),
(supports_evex() ? ", evex" : ""),
- (supports_sha() ? ", sha" : ""));
+ (supports_sha() ? ", sha" : ""),
+ (supports_fma() ? ", fma" : ""));
_features_string = os::strdup(buf);
// UseSSE is set to the smaller of what hardware supports and what
@@ -732,6 +733,15 @@
FLAG_SET_DEFAULT(UseGHASHIntrinsics, false);
}
+ if (supports_fma() && UseSSE >= 2) {
+ if (FLAG_IS_DEFAULT(UseFMA)) {
+ UseFMA = true;
+ }
+ } else if (UseFMA) {
+ warning("FMA instructions are not available on this CPU");
+ FLAG_SET_DEFAULT(UseFMA, false);
+ }
+
if (supports_sha() LP64_ONLY(|| supports_avx2() && supports_bmi2())) {
if (FLAG_IS_DEFAULT(UseSHA)) {
UseSHA = true;
@@ -773,7 +783,6 @@
FLAG_SET_DEFAULT(UseAdler32Intrinsics, false);
}
- // Adjust RTM (Restricted Transactional Memory) flags
if (!supports_rtm() && UseRTMLocking) {
// Can't continue because UseRTMLocking affects UseBiasedLocking flag
// setting during arguments processing. See use_biased_locking().
--- a/hotspot/src/cpu/x86/vm/vm_version_x86.hpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/cpu/x86/vm/vm_version_x86.hpp Fri Oct 14 11:11:19 2016 -0700
@@ -74,7 +74,8 @@
: 1,
ssse3 : 1,
cid : 1,
- : 2,
+ : 1,
+ fma : 1,
cmpxchg16: 1,
: 4,
dca : 1,
@@ -289,6 +290,7 @@
#define CPU_AVX512BW ((uint64_t)UCONST64(0x100000000)) // enums are limited to 31 bit
#define CPU_AVX512VL ((uint64_t)UCONST64(0x200000000)) // EVEX instructions with smaller vector length
#define CPU_SHA ((uint64_t)UCONST64(0x400000000)) // SHA instructions
+#define CPU_FMA ((uint64_t)UCONST64(0x800000000)) // FMA instructions
enum Extended_Family {
// AMD
@@ -522,6 +524,8 @@
result |= CPU_SHA;
if(_cpuid_info.ext_cpuid1_ecx.bits.lzcnt_intel != 0)
result |= CPU_LZCNT;
+ if (_cpuid_info.std_cpuid1_ecx.bits.fma != 0)
+ result |= CPU_FMA;
// for Intel, ecx.bits.misalignsse bit (bit 8) indicates support for prefetchw
if (_cpuid_info.ext_cpuid1_ecx.bits.misalignsse != 0) {
result |= CPU_3DNOW_PREFETCH;
@@ -726,6 +730,7 @@
static bool supports_avx256only() { return (supports_avx2() && !supports_evex()); }
static bool supports_avxonly() { return ((supports_avx2() || supports_avx()) && !supports_evex()); }
static bool supports_sha() { return (_features & CPU_SHA) != 0; }
+ static bool supports_fma() { return (_features & CPU_FMA) != 0; }
// Intel features
static bool is_intel_family_core() { return is_intel() &&
extended_cpu_family() == CPU_FAMILY_INTEL_CORE; }
--- a/hotspot/src/cpu/x86/vm/x86.ad Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/cpu/x86/vm/x86.ad Fri Oct 14 11:11:19 2016 -0700
@@ -176,451 +176,6 @@
reg_def XMM5o( SOC, SOC, Op_RegF, 5, xmm5->as_VMReg()->next(14));
reg_def XMM5p( SOC, SOC, Op_RegF, 5, xmm5->as_VMReg()->next(15));
-#ifdef _WIN64
-
-reg_def XMM6 ( SOC, SOE, Op_RegF, 6, xmm6->as_VMReg());
-reg_def XMM6b( SOC, SOE, Op_RegF, 6, xmm6->as_VMReg()->next(1));
-reg_def XMM6c( SOC, SOE, Op_RegF, 6, xmm6->as_VMReg()->next(2));
-reg_def XMM6d( SOC, SOE, Op_RegF, 6, xmm6->as_VMReg()->next(3));
-reg_def XMM6e( SOC, SOE, Op_RegF, 6, xmm6->as_VMReg()->next(4));
-reg_def XMM6f( SOC, SOE, Op_RegF, 6, xmm6->as_VMReg()->next(5));
-reg_def XMM6g( SOC, SOE, Op_RegF, 6, xmm6->as_VMReg()->next(6));
-reg_def XMM6h( SOC, SOE, Op_RegF, 6, xmm6->as_VMReg()->next(7));
-reg_def XMM6i( SOC, SOE, Op_RegF, 6, xmm6->as_VMReg()->next(8));
-reg_def XMM6j( SOC, SOE, Op_RegF, 6, xmm6->as_VMReg()->next(9));
-reg_def XMM6k( SOC, SOE, Op_RegF, 6, xmm6->as_VMReg()->next(10));
-reg_def XMM6l( SOC, SOE, Op_RegF, 6, xmm6->as_VMReg()->next(11));
-reg_def XMM6m( SOC, SOE, Op_RegF, 6, xmm6->as_VMReg()->next(12));
-reg_def XMM6n( SOC, SOE, Op_RegF, 6, xmm6->as_VMReg()->next(13));
-reg_def XMM6o( SOC, SOE, Op_RegF, 6, xmm6->as_VMReg()->next(14));
-reg_def XMM6p( SOC, SOE, Op_RegF, 6, xmm6->as_VMReg()->next(15));
-
-reg_def XMM7 ( SOC, SOE, Op_RegF, 7, xmm7->as_VMReg());
-reg_def XMM7b( SOC, SOE, Op_RegF, 7, xmm7->as_VMReg()->next(1));
-reg_def XMM7c( SOC, SOE, Op_RegF, 7, xmm7->as_VMReg()->next(2));
-reg_def XMM7d( SOC, SOE, Op_RegF, 7, xmm7->as_VMReg()->next(3));
-reg_def XMM7e( SOC, SOE, Op_RegF, 7, xmm7->as_VMReg()->next(4));
-reg_def XMM7f( SOC, SOE, Op_RegF, 7, xmm7->as_VMReg()->next(5));
-reg_def XMM7g( SOC, SOE, Op_RegF, 7, xmm7->as_VMReg()->next(6));
-reg_def XMM7h( SOC, SOE, Op_RegF, 7, xmm7->as_VMReg()->next(7));
-reg_def XMM7i( SOC, SOE, Op_RegF, 7, xmm7->as_VMReg()->next(8));
-reg_def XMM7j( SOC, SOE, Op_RegF, 7, xmm7->as_VMReg()->next(9));
-reg_def XMM7k( SOC, SOE, Op_RegF, 7, xmm7->as_VMReg()->next(10));
-reg_def XMM7l( SOC, SOE, Op_RegF, 7, xmm7->as_VMReg()->next(11));
-reg_def XMM7m( SOC, SOE, Op_RegF, 7, xmm7->as_VMReg()->next(12));
-reg_def XMM7n( SOC, SOE, Op_RegF, 7, xmm7->as_VMReg()->next(13));
-reg_def XMM7o( SOC, SOE, Op_RegF, 7, xmm7->as_VMReg()->next(14));
-reg_def XMM7p( SOC, SOE, Op_RegF, 7, xmm7->as_VMReg()->next(15));
-
-reg_def XMM8 ( SOC, SOE, Op_RegF, 8, xmm8->as_VMReg());
-reg_def XMM8b( SOC, SOE, Op_RegF, 8, xmm8->as_VMReg()->next(1));
-reg_def XMM8c( SOC, SOE, Op_RegF, 8, xmm8->as_VMReg()->next(2));
-reg_def XMM8d( SOC, SOE, Op_RegF, 8, xmm8->as_VMReg()->next(3));
-reg_def XMM8e( SOC, SOE, Op_RegF, 8, xmm8->as_VMReg()->next(4));
-reg_def XMM8f( SOC, SOE, Op_RegF, 8, xmm8->as_VMReg()->next(5));
-reg_def XMM8g( SOC, SOE, Op_RegF, 8, xmm8->as_VMReg()->next(6));
-reg_def XMM8h( SOC, SOE, Op_RegF, 8, xmm8->as_VMReg()->next(7));
-reg_def XMM8i( SOC, SOE, Op_RegF, 8, xmm8->as_VMReg()->next(8));
-reg_def XMM8j( SOC, SOE, Op_RegF, 8, xmm8->as_VMReg()->next(9));
-reg_def XMM8k( SOC, SOE, Op_RegF, 8, xmm8->as_VMReg()->next(10));
-reg_def XMM8l( SOC, SOE, Op_RegF, 8, xmm8->as_VMReg()->next(11));
-reg_def XMM8m( SOC, SOE, Op_RegF, 8, xmm8->as_VMReg()->next(12));
-reg_def XMM8n( SOC, SOE, Op_RegF, 8, xmm8->as_VMReg()->next(13));
-reg_def XMM8o( SOC, SOE, Op_RegF, 8, xmm8->as_VMReg()->next(14));
-reg_def XMM8p( SOC, SOE, Op_RegF, 8, xmm8->as_VMReg()->next(15));
-
-reg_def XMM9 ( SOC, SOE, Op_RegF, 9, xmm9->as_VMReg());
-reg_def XMM9b( SOC, SOE, Op_RegF, 9, xmm9->as_VMReg()->next(1));
-reg_def XMM9c( SOC, SOE, Op_RegF, 9, xmm9->as_VMReg()->next(2));
-reg_def XMM9d( SOC, SOE, Op_RegF, 9, xmm9->as_VMReg()->next(3));
-reg_def XMM9e( SOC, SOE, Op_RegF, 9, xmm9->as_VMReg()->next(4));
-reg_def XMM9f( SOC, SOE, Op_RegF, 9, xmm9->as_VMReg()->next(5));
-reg_def XMM9g( SOC, SOE, Op_RegF, 9, xmm9->as_VMReg()->next(6));
-reg_def XMM9h( SOC, SOE, Op_RegF, 9, xmm9->as_VMReg()->next(7));
-reg_def XMM9i( SOC, SOE, Op_RegF, 9, xmm9->as_VMReg()->next(8));
-reg_def XMM9j( SOC, SOE, Op_RegF, 9, xmm9->as_VMReg()->next(9));
-reg_def XMM9k( SOC, SOE, Op_RegF, 9, xmm9->as_VMReg()->next(10));
-reg_def XMM9l( SOC, SOE, Op_RegF, 9, xmm9->as_VMReg()->next(11));
-reg_def XMM9m( SOC, SOE, Op_RegF, 9, xmm9->as_VMReg()->next(12));
-reg_def XMM9n( SOC, SOE, Op_RegF, 9, xmm9->as_VMReg()->next(13));
-reg_def XMM9o( SOC, SOE, Op_RegF, 9, xmm9->as_VMReg()->next(14));
-reg_def XMM9p( SOC, SOE, Op_RegF, 9, xmm9->as_VMReg()->next(15));
-
-reg_def XMM10 ( SOC, SOE, Op_RegF, 10, xmm10->as_VMReg());
-reg_def XMM10b( SOC, SOE, Op_RegF, 10, xmm10->as_VMReg()->next(1));
-reg_def XMM10c( SOC, SOE, Op_RegF, 10, xmm10->as_VMReg()->next(2));
-reg_def XMM10d( SOC, SOE, Op_RegF, 10, xmm10->as_VMReg()->next(3));
-reg_def XMM10e( SOC, SOE, Op_RegF, 10, xmm10->as_VMReg()->next(4));
-reg_def XMM10f( SOC, SOE, Op_RegF, 10, xmm10->as_VMReg()->next(5));
-reg_def XMM10g( SOC, SOE, Op_RegF, 10, xmm10->as_VMReg()->next(6));
-reg_def XMM10h( SOC, SOE, Op_RegF, 10, xmm10->as_VMReg()->next(7));
-reg_def XMM10i( SOC, SOE, Op_RegF, 10, xmm10->as_VMReg()->next(8));
-reg_def XMM10j( SOC, SOE, Op_RegF, 10, xmm10->as_VMReg()->next(9));
-reg_def XMM10k( SOC, SOE, Op_RegF, 10, xmm10->as_VMReg()->next(10));
-reg_def XMM10l( SOC, SOE, Op_RegF, 10, xmm10->as_VMReg()->next(11));
-reg_def XMM10m( SOC, SOE, Op_RegF, 10, xmm10->as_VMReg()->next(12));
-reg_def XMM10n( SOC, SOE, Op_RegF, 10, xmm10->as_VMReg()->next(13));
-reg_def XMM10o( SOC, SOE, Op_RegF, 10, xmm10->as_VMReg()->next(14));
-reg_def XMM10p( SOC, SOE, Op_RegF, 10, xmm10->as_VMReg()->next(15));
-
-reg_def XMM11 ( SOC, SOE, Op_RegF, 11, xmm11->as_VMReg());
-reg_def XMM11b( SOC, SOE, Op_RegF, 11, xmm11->as_VMReg()->next(1));
-reg_def XMM11c( SOC, SOE, Op_RegF, 11, xmm11->as_VMReg()->next(2));
-reg_def XMM11d( SOC, SOE, Op_RegF, 11, xmm11->as_VMReg()->next(3));
-reg_def XMM11e( SOC, SOE, Op_RegF, 11, xmm11->as_VMReg()->next(4));
-reg_def XMM11f( SOC, SOE, Op_RegF, 11, xmm11->as_VMReg()->next(5));
-reg_def XMM11g( SOC, SOE, Op_RegF, 11, xmm11->as_VMReg()->next(6));
-reg_def XMM11h( SOC, SOE, Op_RegF, 11, xmm11->as_VMReg()->next(7));
-reg_def XMM11i( SOC, SOE, Op_RegF, 11, xmm11->as_VMReg()->next(8));
-reg_def XMM11j( SOC, SOE, Op_RegF, 11, xmm11->as_VMReg()->next(9));
-reg_def XMM11k( SOC, SOE, Op_RegF, 11, xmm11->as_VMReg()->next(10));
-reg_def XMM11l( SOC, SOE, Op_RegF, 11, xmm11->as_VMReg()->next(11));
-reg_def XMM11m( SOC, SOE, Op_RegF, 11, xmm11->as_VMReg()->next(12));
-reg_def XMM11n( SOC, SOE, Op_RegF, 11, xmm11->as_VMReg()->next(13));
-reg_def XMM11o( SOC, SOE, Op_RegF, 11, xmm11->as_VMReg()->next(14));
-reg_def XMM11p( SOC, SOE, Op_RegF, 11, xmm11->as_VMReg()->next(15));
-
-reg_def XMM12 ( SOC, SOE, Op_RegF, 12, xmm12->as_VMReg());
-reg_def XMM12b( SOC, SOE, Op_RegF, 12, xmm12->as_VMReg()->next(1));
-reg_def XMM12c( SOC, SOE, Op_RegF, 12, xmm12->as_VMReg()->next(2));
-reg_def XMM12d( SOC, SOE, Op_RegF, 12, xmm12->as_VMReg()->next(3));
-reg_def XMM12e( SOC, SOE, Op_RegF, 12, xmm12->as_VMReg()->next(4));
-reg_def XMM12f( SOC, SOE, Op_RegF, 12, xmm12->as_VMReg()->next(5));
-reg_def XMM12g( SOC, SOE, Op_RegF, 12, xmm12->as_VMReg()->next(6));
-reg_def XMM12h( SOC, SOE, Op_RegF, 12, xmm12->as_VMReg()->next(7));
-reg_def XMM12i( SOC, SOE, Op_RegF, 12, xmm12->as_VMReg()->next(8));
-reg_def XMM12j( SOC, SOE, Op_RegF, 12, xmm12->as_VMReg()->next(9));
-reg_def XMM12k( SOC, SOE, Op_RegF, 12, xmm12->as_VMReg()->next(10));
-reg_def XMM12l( SOC, SOE, Op_RegF, 12, xmm12->as_VMReg()->next(11));
-reg_def XMM12m( SOC, SOE, Op_RegF, 12, xmm12->as_VMReg()->next(12));
-reg_def XMM12n( SOC, SOE, Op_RegF, 12, xmm12->as_VMReg()->next(13));
-reg_def XMM12o( SOC, SOE, Op_RegF, 12, xmm12->as_VMReg()->next(14));
-reg_def XMM12p( SOC, SOE, Op_RegF, 12, xmm12->as_VMReg()->next(15));
-
-reg_def XMM13 ( SOC, SOE, Op_RegF, 13, xmm13->as_VMReg());
-reg_def XMM13b( SOC, SOE, Op_RegF, 13, xmm13->as_VMReg()->next(1));
-reg_def XMM13c( SOC, SOE, Op_RegF, 13, xmm13->as_VMReg()->next(2));
-reg_def XMM13d( SOC, SOE, Op_RegF, 13, xmm13->as_VMReg()->next(3));
-reg_def XMM13e( SOC, SOE, Op_RegF, 13, xmm13->as_VMReg()->next(4));
-reg_def XMM13f( SOC, SOE, Op_RegF, 13, xmm13->as_VMReg()->next(5));
-reg_def XMM13g( SOC, SOE, Op_RegF, 13, xmm13->as_VMReg()->next(6));
-reg_def XMM13h( SOC, SOE, Op_RegF, 13, xmm13->as_VMReg()->next(7));
-reg_def XMM13i( SOC, SOE, Op_RegF, 13, xmm13->as_VMReg()->next(8));
-reg_def XMM13j( SOC, SOE, Op_RegF, 13, xmm13->as_VMReg()->next(9));
-reg_def XMM13k( SOC, SOE, Op_RegF, 13, xmm13->as_VMReg()->next(10));
-reg_def XMM13l( SOC, SOE, Op_RegF, 13, xmm13->as_VMReg()->next(11));
-reg_def XMM13m( SOC, SOE, Op_RegF, 13, xmm13->as_VMReg()->next(12));
-reg_def XMM13n( SOC, SOE, Op_RegF, 13, xmm13->as_VMReg()->next(13));
-reg_def XMM13o( SOC, SOE, Op_RegF, 13, xmm13->as_VMReg()->next(14));
-reg_def XMM13p( SOC, SOE, Op_RegF, 13, xmm13->as_VMReg()->next(15));
-
-reg_def XMM14 ( SOC, SOE, Op_RegF, 14, xmm14->as_VMReg());
-reg_def XMM14b( SOC, SOE, Op_RegF, 14, xmm14->as_VMReg()->next(1));
-reg_def XMM14c( SOC, SOE, Op_RegF, 14, xmm14->as_VMReg()->next(2));
-reg_def XMM14d( SOC, SOE, Op_RegF, 14, xmm14->as_VMReg()->next(3));
-reg_def XMM14e( SOC, SOE, Op_RegF, 14, xmm14->as_VMReg()->next(4));
-reg_def XMM14f( SOC, SOE, Op_RegF, 14, xmm14->as_VMReg()->next(5));
-reg_def XMM14g( SOC, SOE, Op_RegF, 14, xmm14->as_VMReg()->next(6));
-reg_def XMM14h( SOC, SOE, Op_RegF, 14, xmm14->as_VMReg()->next(7));
-reg_def XMM14i( SOC, SOE, Op_RegF, 14, xmm14->as_VMReg()->next(8));
-reg_def XMM14j( SOC, SOE, Op_RegF, 14, xmm14->as_VMReg()->next(9));
-reg_def XMM14k( SOC, SOE, Op_RegF, 14, xmm14->as_VMReg()->next(10));
-reg_def XMM14l( SOC, SOE, Op_RegF, 14, xmm14->as_VMReg()->next(11));
-reg_def XMM14m( SOC, SOE, Op_RegF, 14, xmm14->as_VMReg()->next(12));
-reg_def XMM14n( SOC, SOE, Op_RegF, 14, xmm14->as_VMReg()->next(13));
-reg_def XMM14o( SOC, SOE, Op_RegF, 14, xmm14->as_VMReg()->next(14));
-reg_def XMM14p( SOC, SOE, Op_RegF, 14, xmm14->as_VMReg()->next(15));
-
-reg_def XMM15 ( SOC, SOE, Op_RegF, 15, xmm15->as_VMReg());
-reg_def XMM15b( SOC, SOE, Op_RegF, 15, xmm15->as_VMReg()->next(1));
-reg_def XMM15c( SOC, SOE, Op_RegF, 15, xmm15->as_VMReg()->next(2));
-reg_def XMM15d( SOC, SOE, Op_RegF, 15, xmm15->as_VMReg()->next(3));
-reg_def XMM15e( SOC, SOE, Op_RegF, 15, xmm15->as_VMReg()->next(4));
-reg_def XMM15f( SOC, SOE, Op_RegF, 15, xmm15->as_VMReg()->next(5));
-reg_def XMM15g( SOC, SOE, Op_RegF, 15, xmm15->as_VMReg()->next(6));
-reg_def XMM15h( SOC, SOE, Op_RegF, 15, xmm15->as_VMReg()->next(7));
-reg_def XMM15i( SOC, SOE, Op_RegF, 15, xmm15->as_VMReg()->next(8));
-reg_def XMM15j( SOC, SOE, Op_RegF, 15, xmm15->as_VMReg()->next(9));
-reg_def XMM15k( SOC, SOE, Op_RegF, 15, xmm15->as_VMReg()->next(10));
-reg_def XMM15l( SOC, SOE, Op_RegF, 15, xmm15->as_VMReg()->next(11));
-reg_def XMM15m( SOC, SOE, Op_RegF, 15, xmm15->as_VMReg()->next(12));
-reg_def XMM15n( SOC, SOE, Op_RegF, 15, xmm15->as_VMReg()->next(13));
-reg_def XMM15o( SOC, SOE, Op_RegF, 15, xmm15->as_VMReg()->next(14));
-reg_def XMM15p( SOC, SOE, Op_RegF, 15, xmm15->as_VMReg()->next(15));
-
-reg_def XMM16 ( SOC, SOE, Op_RegF, 16, xmm16->as_VMReg());
-reg_def XMM16b( SOC, SOE, Op_RegF, 16, xmm16->as_VMReg()->next(1));
-reg_def XMM16c( SOC, SOE, Op_RegF, 16, xmm16->as_VMReg()->next(2));
-reg_def XMM16d( SOC, SOE, Op_RegF, 16, xmm16->as_VMReg()->next(3));
-reg_def XMM16e( SOC, SOE, Op_RegF, 16, xmm16->as_VMReg()->next(4));
-reg_def XMM16f( SOC, SOE, Op_RegF, 16, xmm16->as_VMReg()->next(5));
-reg_def XMM16g( SOC, SOE, Op_RegF, 16, xmm16->as_VMReg()->next(6));
-reg_def XMM16h( SOC, SOE, Op_RegF, 16, xmm16->as_VMReg()->next(7));
-reg_def XMM16i( SOC, SOE, Op_RegF, 16, xmm15->as_VMReg()->next(8));
-reg_def XMM16j( SOC, SOE, Op_RegF, 16, xmm16->as_VMReg()->next(9));
-reg_def XMM16k( SOC, SOE, Op_RegF, 16, xmm16->as_VMReg()->next(10));
-reg_def XMM16l( SOC, SOE, Op_RegF, 16, xmm16->as_VMReg()->next(11));
-reg_def XMM16m( SOC, SOE, Op_RegF, 16, xmm16->as_VMReg()->next(12));
-reg_def XMM16n( SOC, SOE, Op_RegF, 16, xmm16->as_VMReg()->next(13));
-reg_def XMM16o( SOC, SOE, Op_RegF, 16, xmm16->as_VMReg()->next(14));
-reg_def XMM16p( SOC, SOE, Op_RegF, 16, xmm16->as_VMReg()->next(15));
-
-reg_def XMM17 ( SOC, SOE, Op_RegF, 17, xmm17->as_VMReg());
-reg_def XMM17b( SOC, SOE, Op_RegF, 17, xmm17->as_VMReg()->next(1));
-reg_def XMM17c( SOC, SOE, Op_RegF, 17, xmm17->as_VMReg()->next(2));
-reg_def XMM17d( SOC, SOE, Op_RegF, 17, xmm17->as_VMReg()->next(3));
-reg_def XMM17e( SOC, SOE, Op_RegF, 17, xmm17->as_VMReg()->next(4));
-reg_def XMM17f( SOC, SOE, Op_RegF, 17, xmm17->as_VMReg()->next(5));
-reg_def XMM17g( SOC, SOE, Op_RegF, 17, xmm17->as_VMReg()->next(6));
-reg_def XMM17h( SOC, SOE, Op_RegF, 17, xmm17->as_VMReg()->next(7));
-reg_def XMM17i( SOC, SOE, Op_RegF, 17, xmm17->as_VMReg()->next(8));
-reg_def XMM17j( SOC, SOE, Op_RegF, 17, xmm17->as_VMReg()->next(9));
-reg_def XMM17k( SOC, SOE, Op_RegF, 17, xmm17->as_VMReg()->next(10));
-reg_def XMM17l( SOC, SOE, Op_RegF, 17, xmm17->as_VMReg()->next(11));
-reg_def XMM17m( SOC, SOE, Op_RegF, 17, xmm17->as_VMReg()->next(12));
-reg_def XMM17n( SOC, SOE, Op_RegF, 17, xmm17->as_VMReg()->next(13));
-reg_def XMM17o( SOC, SOE, Op_RegF, 17, xmm17->as_VMReg()->next(14));
-reg_def XMM17p( SOC, SOE, Op_RegF, 17, xmm17->as_VMReg()->next(15));
-
-reg_def XMM18 ( SOC, SOE, Op_RegF, 18, xmm18->as_VMReg());
-reg_def XMM18b( SOC, SOE, Op_RegF, 18, xmm18->as_VMReg()->next(1));
-reg_def XMM18c( SOC, SOE, Op_RegF, 18, xmm18->as_VMReg()->next(2));
-reg_def XMM18d( SOC, SOE, Op_RegF, 18, xmm18->as_VMReg()->next(3));
-reg_def XMM18e( SOC, SOE, Op_RegF, 18, xmm18->as_VMReg()->next(4));
-reg_def XMM18f( SOC, SOE, Op_RegF, 18, xmm18->as_VMReg()->next(5));
-reg_def XMM18g( SOC, SOE, Op_RegF, 18, xmm18->as_VMReg()->next(6));
-reg_def XMM18h( SOC, SOE, Op_RegF, 18, xmm18->as_VMReg()->next(7));
-reg_def XMM18i( SOC, SOE, Op_RegF, 18, xmm18->as_VMReg()->next(8));
-reg_def XMM18j( SOC, SOE, Op_RegF, 18, xmm18->as_VMReg()->next(9));
-reg_def XMM18k( SOC, SOE, Op_RegF, 18, xmm18->as_VMReg()->next(10));
-reg_def XMM18l( SOC, SOE, Op_RegF, 18, xmm18->as_VMReg()->next(11));
-reg_def XMM18m( SOC, SOE, Op_RegF, 18, xmm18->as_VMReg()->next(12));
-reg_def XMM18n( SOC, SOE, Op_RegF, 18, xmm18->as_VMReg()->next(13));
-reg_def XMM18o( SOC, SOE, Op_RegF, 18, xmm18->as_VMReg()->next(14));
-reg_def XMM18p( SOC, SOE, Op_RegF, 18, xmm18->as_VMReg()->next(15));
-
-reg_def XMM19 ( SOC, SOE, Op_RegF, 19, xmm19->as_VMReg());
-reg_def XMM19b( SOC, SOE, Op_RegF, 19, xmm19->as_VMReg()->next(1));
-reg_def XMM19c( SOC, SOE, Op_RegF, 19, xmm19->as_VMReg()->next(2));
-reg_def XMM19d( SOC, SOE, Op_RegF, 19, xmm19->as_VMReg()->next(3));
-reg_def XMM19e( SOC, SOE, Op_RegF, 19, xmm19->as_VMReg()->next(4));
-reg_def XMM19f( SOC, SOE, Op_RegF, 19, xmm19->as_VMReg()->next(5));
-reg_def XMM19g( SOC, SOE, Op_RegF, 19, xmm19->as_VMReg()->next(6));
-reg_def XMM19h( SOC, SOE, Op_RegF, 19, xmm19->as_VMReg()->next(7));
-reg_def XMM19i( SOC, SOE, Op_RegF, 19, xmm19->as_VMReg()->next(8));
-reg_def XMM19j( SOC, SOE, Op_RegF, 19, xmm19->as_VMReg()->next(9));
-reg_def XMM19k( SOC, SOE, Op_RegF, 19, xmm19->as_VMReg()->next(10));
-reg_def XMM19l( SOC, SOE, Op_RegF, 19, xmm19->as_VMReg()->next(11));
-reg_def XMM19m( SOC, SOE, Op_RegF, 19, xmm19->as_VMReg()->next(12));
-reg_def XMM19n( SOC, SOE, Op_RegF, 19, xmm19->as_VMReg()->next(13));
-reg_def XMM19o( SOC, SOE, Op_RegF, 19, xmm19->as_VMReg()->next(14));
-reg_def XMM19p( SOC, SOE, Op_RegF, 19, xmm19->as_VMReg()->next(15));
-
-reg_def XMM20 ( SOC, SOE, Op_RegF, 20, xmm20->as_VMReg());
-reg_def XMM20b( SOC, SOE, Op_RegF, 20, xmm20->as_VMReg()->next(1));
-reg_def XMM20c( SOC, SOE, Op_RegF, 20, xmm20->as_VMReg()->next(2));
-reg_def XMM20d( SOC, SOE, Op_RegF, 20, xmm20->as_VMReg()->next(3));
-reg_def XMM20e( SOC, SOE, Op_RegF, 20, xmm20->as_VMReg()->next(4));
-reg_def XMM20f( SOC, SOE, Op_RegF, 20, xmm20->as_VMReg()->next(5));
-reg_def XMM20g( SOC, SOE, Op_RegF, 20, xmm20->as_VMReg()->next(6));
-reg_def XMM20h( SOC, SOE, Op_RegF, 20, xmm20->as_VMReg()->next(7));
-reg_def XMM20i( SOC, SOE, Op_RegF, 20, xmm20->as_VMReg()->next(8));
-reg_def XMM20j( SOC, SOE, Op_RegF, 20, xmm20->as_VMReg()->next(9));
-reg_def XMM20k( SOC, SOE, Op_RegF, 20, xmm20->as_VMReg()->next(10));
-reg_def XMM20l( SOC, SOE, Op_RegF, 20, xmm20->as_VMReg()->next(11));
-reg_def XMM20m( SOC, SOE, Op_RegF, 20, xmm20->as_VMReg()->next(12));
-reg_def XMM20n( SOC, SOE, Op_RegF, 20, xmm20->as_VMReg()->next(13));
-reg_def XMM20o( SOC, SOE, Op_RegF, 20, xmm20->as_VMReg()->next(14));
-reg_def XMM20p( SOC, SOE, Op_RegF, 20, xmm20->as_VMReg()->next(15));
-
-reg_def XMM21 ( SOC, SOE, Op_RegF, 21, xmm21->as_VMReg());
-reg_def XMM21b( SOC, SOE, Op_RegF, 21, xmm21->as_VMReg()->next(1));
-reg_def XMM21c( SOC, SOE, Op_RegF, 21, xmm21->as_VMReg()->next(2));
-reg_def XMM21d( SOC, SOE, Op_RegF, 21, xmm21->as_VMReg()->next(3));
-reg_def XMM21e( SOC, SOE, Op_RegF, 21, xmm21->as_VMReg()->next(4));
-reg_def XMM21f( SOC, SOE, Op_RegF, 21, xmm21->as_VMReg()->next(5));
-reg_def XMM21g( SOC, SOE, Op_RegF, 21, xmm21->as_VMReg()->next(6));
-reg_def XMM21h( SOC, SOE, Op_RegF, 21, xmm21->as_VMReg()->next(7));
-reg_def XMM21i( SOC, SOE, Op_RegF, 21, xmm21->as_VMReg()->next(8));
-reg_def XMM21j( SOC, SOE, Op_RegF, 21, xmm21->as_VMReg()->next(9));
-reg_def XMM21k( SOC, SOE, Op_RegF, 21, xmm21->as_VMReg()->next(10));
-reg_def XMM21l( SOC, SOE, Op_RegF, 21, xmm21->as_VMReg()->next(11));
-reg_def XMM21m( SOC, SOE, Op_RegF, 21, xmm21->as_VMReg()->next(12));
-reg_def XMM21n( SOC, SOE, Op_RegF, 21, xmm21->as_VMReg()->next(13));
-reg_def XMM21o( SOC, SOE, Op_RegF, 21, xmm21->as_VMReg()->next(14));
-reg_def XMM21p( SOC, SOE, Op_RegF, 21, xmm21->as_VMReg()->next(15));
-
-reg_def XMM22 ( SOC, SOE, Op_RegF, 22, xmm22->as_VMReg());
-reg_def XMM22b( SOC, SOE, Op_RegF, 22, xmm22->as_VMReg()->next(1));
-reg_def XMM22c( SOC, SOE, Op_RegF, 22, xmm22->as_VMReg()->next(2));
-reg_def XMM22d( SOC, SOE, Op_RegF, 22, xmm22->as_VMReg()->next(3));
-reg_def XMM22e( SOC, SOE, Op_RegF, 22, xmm22->as_VMReg()->next(4));
-reg_def XMM22f( SOC, SOE, Op_RegF, 22, xmm22->as_VMReg()->next(5));
-reg_def XMM22g( SOC, SOE, Op_RegF, 22, xmm22->as_VMReg()->next(6));
-reg_def XMM22h( SOC, SOE, Op_RegF, 22, xmm22->as_VMReg()->next(7));
-reg_def XMM22i( SOC, SOE, Op_RegF, 22, xmm22->as_VMReg()->next(8));
-reg_def XMM22j( SOC, SOE, Op_RegF, 22, xmm22->as_VMReg()->next(9));
-reg_def XMM22k( SOC, SOE, Op_RegF, 22, xmm22->as_VMReg()->next(10));
-reg_def XMM22l( SOC, SOE, Op_RegF, 22, xmm22->as_VMReg()->next(11));
-reg_def XMM22m( SOC, SOE, Op_RegF, 22, xmm22->as_VMReg()->next(12));
-reg_def XMM22n( SOC, SOE, Op_RegF, 22, xmm22->as_VMReg()->next(13));
-reg_def XMM22o( SOC, SOE, Op_RegF, 22, xmm22->as_VMReg()->next(14));
-reg_def XMM22p( SOC, SOE, Op_RegF, 22, xmm22->as_VMReg()->next(15));
-
-reg_def XMM23 ( SOC, SOE, Op_RegF, 23, xmm23->as_VMReg());
-reg_def XMM23b( SOC, SOE, Op_RegF, 23, xmm23->as_VMReg()->next(1));
-reg_def XMM23c( SOC, SOE, Op_RegF, 23, xmm23->as_VMReg()->next(2));
-reg_def XMM23d( SOC, SOE, Op_RegF, 23, xmm23->as_VMReg()->next(3));
-reg_def XMM23e( SOC, SOE, Op_RegF, 23, xmm23->as_VMReg()->next(4));
-reg_def XMM23f( SOC, SOE, Op_RegF, 23, xmm23->as_VMReg()->next(5));
-reg_def XMM23g( SOC, SOE, Op_RegF, 23, xmm23->as_VMReg()->next(6));
-reg_def XMM23h( SOC, SOE, Op_RegF, 23, xmm23->as_VMReg()->next(7));
-reg_def XMM23i( SOC, SOE, Op_RegF, 23, xmm23->as_VMReg()->next(8));
-reg_def XMM23j( SOC, SOE, Op_RegF, 23, xmm23->as_VMReg()->next(9));
-reg_def XMM23k( SOC, SOE, Op_RegF, 23, xmm23->as_VMReg()->next(10));
-reg_def XMM23l( SOC, SOE, Op_RegF, 23, xmm23->as_VMReg()->next(11));
-reg_def XMM23m( SOC, SOE, Op_RegF, 23, xmm23->as_VMReg()->next(12));
-reg_def XMM23n( SOC, SOE, Op_RegF, 23, xmm23->as_VMReg()->next(13));
-reg_def XMM23o( SOC, SOE, Op_RegF, 23, xmm23->as_VMReg()->next(14));
-reg_def XMM23p( SOC, SOE, Op_RegF, 23, xmm23->as_VMReg()->next(15));
-
-reg_def XMM24 ( SOC, SOE, Op_RegF, 24, xmm24->as_VMReg());
-reg_def XMM24b( SOC, SOE, Op_RegF, 24, xmm24->as_VMReg()->next(1));
-reg_def XMM24c( SOC, SOE, Op_RegF, 24, xmm24->as_VMReg()->next(2));
-reg_def XMM24d( SOC, SOE, Op_RegF, 24, xmm24->as_VMReg()->next(3));
-reg_def XMM24e( SOC, SOE, Op_RegF, 24, xmm24->as_VMReg()->next(4));
-reg_def XMM24f( SOC, SOE, Op_RegF, 24, xmm24->as_VMReg()->next(5));
-reg_def XMM24g( SOC, SOE, Op_RegF, 24, xmm24->as_VMReg()->next(6));
-reg_def XMM24h( SOC, SOE, Op_RegF, 24, xmm24->as_VMReg()->next(7));
-reg_def XMM24i( SOC, SOE, Op_RegF, 24, xmm24->as_VMReg()->next(8));
-reg_def XMM24j( SOC, SOE, Op_RegF, 24, xmm24->as_VMReg()->next(9));
-reg_def XMM24k( SOC, SOE, Op_RegF, 24, xmm24->as_VMReg()->next(10));
-reg_def XMM24l( SOC, SOE, Op_RegF, 24, xmm24->as_VMReg()->next(11));
-reg_def XMM24m( SOC, SOE, Op_RegF, 24, xmm24->as_VMReg()->next(12));
-reg_def XMM24n( SOC, SOE, Op_RegF, 24, xmm24->as_VMReg()->next(13));
-reg_def XMM24o( SOC, SOE, Op_RegF, 24, xmm24->as_VMReg()->next(14));
-reg_def XMM24p( SOC, SOE, Op_RegF, 24, xmm24->as_VMReg()->next(15));
-
-reg_def XMM25 ( SOC, SOE, Op_RegF, 25, xmm25->as_VMReg());
-reg_def XMM25b( SOC, SOE, Op_RegF, 25, xmm25->as_VMReg()->next(1));
-reg_def XMM25c( SOC, SOE, Op_RegF, 25, xmm25->as_VMReg()->next(2));
-reg_def XMM25d( SOC, SOE, Op_RegF, 25, xmm25->as_VMReg()->next(3));
-reg_def XMM25e( SOC, SOE, Op_RegF, 25, xmm25->as_VMReg()->next(4));
-reg_def XMM25f( SOC, SOE, Op_RegF, 25, xmm25->as_VMReg()->next(5));
-reg_def XMM25g( SOC, SOE, Op_RegF, 25, xmm25->as_VMReg()->next(6));
-reg_def XMM25h( SOC, SOE, Op_RegF, 25, xmm25->as_VMReg()->next(7));
-reg_def XMM25i( SOC, SOE, Op_RegF, 25, xmm25->as_VMReg()->next(8));
-reg_def XMM25j( SOC, SOE, Op_RegF, 25, xmm25->as_VMReg()->next(9));
-reg_def XMM25k( SOC, SOE, Op_RegF, 25, xmm25->as_VMReg()->next(10));
-reg_def XMM25l( SOC, SOE, Op_RegF, 25, xmm25->as_VMReg()->next(11));
-reg_def XMM25m( SOC, SOE, Op_RegF, 25, xmm25->as_VMReg()->next(12));
-reg_def XMM25n( SOC, SOE, Op_RegF, 25, xmm25->as_VMReg()->next(13));
-reg_def XMM25o( SOC, SOE, Op_RegF, 25, xmm25->as_VMReg()->next(14));
-reg_def XMM25p( SOC, SOE, Op_RegF, 25, xmm25->as_VMReg()->next(15));
-
-reg_def XMM26 ( SOC, SOE, Op_RegF, 26, xmm26->as_VMReg());
-reg_def XMM26b( SOC, SOE, Op_RegF, 26, xmm26->as_VMReg()->next(1));
-reg_def XMM26c( SOC, SOE, Op_RegF, 26, xmm26->as_VMReg()->next(2));
-reg_def XMM26d( SOC, SOE, Op_RegF, 26, xmm26->as_VMReg()->next(3));
-reg_def XMM26e( SOC, SOE, Op_RegF, 26, xmm26->as_VMReg()->next(4));
-reg_def XMM26f( SOC, SOE, Op_RegF, 26, xmm26->as_VMReg()->next(5));
-reg_def XMM26g( SOC, SOE, Op_RegF, 26, xmm26->as_VMReg()->next(6));
-reg_def XMM26h( SOC, SOE, Op_RegF, 26, xmm26->as_VMReg()->next(7));
-reg_def XMM26i( SOC, SOE, Op_RegF, 26, xmm26->as_VMReg()->next(8));
-reg_def XMM26j( SOC, SOE, Op_RegF, 26, xmm26->as_VMReg()->next(9));
-reg_def XMM26k( SOC, SOE, Op_RegF, 26, xmm26->as_VMReg()->next(10));
-reg_def XMM26l( SOC, SOE, Op_RegF, 26, xmm26->as_VMReg()->next(11));
-reg_def XMM26m( SOC, SOE, Op_RegF, 26, xmm26->as_VMReg()->next(12));
-reg_def XMM26n( SOC, SOE, Op_RegF, 26, xmm26->as_VMReg()->next(13));
-reg_def XMM26o( SOC, SOE, Op_RegF, 26, xmm26->as_VMReg()->next(14));
-reg_def XMM26p( SOC, SOE, Op_RegF, 26, xmm26->as_VMReg()->next(15));
-
-reg_def XMM27g( SOC, SOE, Op_RegF, 27, xmm27->as_VMReg()->next(1));
-reg_def XMM27c( SOC, SOE, Op_RegF, 27, xmm27->as_VMReg()->next(2));
-reg_def XMM27d( SOC, SOE, Op_RegF, 27, xmm27->as_VMReg()->next(3));
-reg_def XMM27e( SOC, SOE, Op_RegF, 27, xmm27->as_VMReg()->next(4));
-reg_def XMM27f( SOC, SOE, Op_RegF, 27, xmm27->as_VMReg()->next(5));
-reg_def XMM27g( SOC, SOE, Op_RegF, 27, xmm27->as_VMReg()->next(6));
-reg_def XMM27h( SOC, SOE, Op_RegF, 27, xmm27->as_VMReg()->next(7));
-reg_def XMM27i( SOC, SOE, Op_RegF, 27, xmm27->as_VMReg()->next(8));
-reg_def XMM27j( SOC, SOE, Op_RegF, 27, xmm27->as_VMReg()->next(9));
-reg_def XMM27k( SOC, SOE, Op_RegF, 27, xmm27->as_VMReg()->next(10));
-reg_def XMM27l( SOC, SOE, Op_RegF, 27, xmm27->as_VMReg()->next(11));
-reg_def XMM27m( SOC, SOE, Op_RegF, 27, xmm27->as_VMReg()->next(12));
-reg_def XMM27n( SOC, SOE, Op_RegF, 27, xmm27->as_VMReg()->next(13));
-reg_def XMM27o( SOC, SOE, Op_RegF, 27, xmm27->as_VMReg()->next(14));
-reg_def XMM27p( SOC, SOE, Op_RegF, 27, xmm27->as_VMReg()->next(15));
-
-reg_def XMM28 ( SOC, SOE, Op_RegF, 28, xmm28->as_VMReg());
-reg_def XMM28b( SOC, SOE, Op_RegF, 28, xmm28->as_VMReg()->next(1));
-reg_def XMM28c( SOC, SOE, Op_RegF, 28, xmm28->as_VMReg()->next(2));
-reg_def XMM28d( SOC, SOE, Op_RegF, 28, xmm28->as_VMReg()->next(3));
-reg_def XMM28e( SOC, SOE, Op_RegF, 28, xmm28->as_VMReg()->next(4));
-reg_def XMM28f( SOC, SOE, Op_RegF, 28, xmm28->as_VMReg()->next(5));
-reg_def XMM28g( SOC, SOE, Op_RegF, 28, xmm28->as_VMReg()->next(6));
-reg_def XMM28h( SOC, SOE, Op_RegF, 28, xmm28->as_VMReg()->next(7));
-reg_def XMM28i( SOC, SOE, Op_RegF, 28, xmm28->as_VMReg()->next(8));
-reg_def XMM28j( SOC, SOE, Op_RegF, 28, xmm28->as_VMReg()->next(9));
-reg_def XMM28k( SOC, SOE, Op_RegF, 28, xmm28->as_VMReg()->next(10));
-reg_def XMM28l( SOC, SOE, Op_RegF, 28, xmm28->as_VMReg()->next(11));
-reg_def XMM28m( SOC, SOE, Op_RegF, 28, xmm28->as_VMReg()->next(12));
-reg_def XMM28n( SOC, SOE, Op_RegF, 28, xmm28->as_VMReg()->next(13));
-reg_def XMM28o( SOC, SOE, Op_RegF, 28, xmm28->as_VMReg()->next(14));
-reg_def XMM28p( SOC, SOE, Op_RegF, 28, xmm28->as_VMReg()->next(15));
-
-reg_def XMM29 ( SOC, SOE, Op_RegF, 29, xmm29->as_VMReg());
-reg_def XMM29b( SOC, SOE, Op_RegF, 29, xmm29->as_VMReg()->next(1));
-reg_def XMM29c( SOC, SOE, Op_RegF, 29, xmm29->as_VMReg()->next(2));
-reg_def XMM29d( SOC, SOE, Op_RegF, 29, xmm29->as_VMReg()->next(3));
-reg_def XMM29e( SOC, SOE, Op_RegF, 29, xmm29->as_VMReg()->next(4));
-reg_def XMM29f( SOC, SOE, Op_RegF, 29, xmm29->as_VMReg()->next(5));
-reg_def XMM29g( SOC, SOE, Op_RegF, 29, xmm29->as_VMReg()->next(6));
-reg_def XMM29h( SOC, SOE, Op_RegF, 29, xmm29->as_VMReg()->next(7));
-reg_def XMM29i( SOC, SOE, Op_RegF, 29, xmm29->as_VMReg()->next(8));
-reg_def XMM29j( SOC, SOE, Op_RegF, 29, xmm29->as_VMReg()->next(9));
-reg_def XMM29k( SOC, SOE, Op_RegF, 29, xmm29->as_VMReg()->next(10));
-reg_def XMM29l( SOC, SOE, Op_RegF, 29, xmm29->as_VMReg()->next(11));
-reg_def XMM29m( SOC, SOE, Op_RegF, 29, xmm29->as_VMReg()->next(12));
-reg_def XMM29n( SOC, SOE, Op_RegF, 29, xmm29->as_VMReg()->next(13));
-reg_def XMM29o( SOC, SOE, Op_RegF, 29, xmm29->as_VMReg()->next(14));
-reg_def XMM29p( SOC, SOE, Op_RegF, 29, xmm29->as_VMReg()->next(15));
-
-reg_def XMM30 ( SOC, SOE, Op_RegF, 30, xmm30->as_VMReg());
-reg_def XMM30b( SOC, SOE, Op_RegF, 30, xmm30->as_VMReg()->next(1));
-reg_def XMM30c( SOC, SOE, Op_RegF, 30, xmm30->as_VMReg()->next(2));
-reg_def XMM30d( SOC, SOE, Op_RegF, 30, xmm30->as_VMReg()->next(3));
-reg_def XMM30e( SOC, SOE, Op_RegF, 30, xmm30->as_VMReg()->next(4));
-reg_def XMM30f( SOC, SOE, Op_RegF, 30, xmm30->as_VMReg()->next(5));
-reg_def XMM30g( SOC, SOE, Op_RegF, 30, xmm30->as_VMReg()->next(6));
-reg_def XMM30h( SOC, SOE, Op_RegF, 30, xmm30->as_VMReg()->next(7));
-reg_def XMM30i( SOC, SOE, Op_RegF, 30, xmm30->as_VMReg()->next(8));
-reg_def XMM30j( SOC, SOE, Op_RegF, 30, xmm30->as_VMReg()->next(9));
-reg_def XMM30k( SOC, SOE, Op_RegF, 30, xmm30->as_VMReg()->next(10));
-reg_def XMM30l( SOC, SOE, Op_RegF, 30, xmm30->as_VMReg()->next(11));
-reg_def XMM30m( SOC, SOE, Op_RegF, 30, xmm30->as_VMReg()->next(12));
-reg_def XMM30n( SOC, SOE, Op_RegF, 30, xmm30->as_VMReg()->next(13));
-reg_def XMM30o( SOC, SOE, Op_RegF, 30, xmm30->as_VMReg()->next(14));
-reg_def XMM30p( SOC, SOE, Op_RegF, 30, xmm30->as_VMReg()->next(15));
-
-reg_def XMM31 ( SOC, SOE, Op_RegF, 31, xmm31->as_VMReg());
-reg_def XMM31b( SOC, SOE, Op_RegF, 31, xmm31->as_VMReg()->next(1));
-reg_def XMM31c( SOC, SOE, Op_RegF, 31, xmm31->as_VMReg()->next(2));
-reg_def XMM31d( SOC, SOE, Op_RegF, 31, xmm31->as_VMReg()->next(3));
-reg_def XMM31e( SOC, SOE, Op_RegF, 31, xmm31->as_VMReg()->next(4));
-reg_def XMM31f( SOC, SOE, Op_RegF, 31, xmm31->as_VMReg()->next(5));
-reg_def XMM31g( SOC, SOE, Op_RegF, 31, xmm31->as_VMReg()->next(6));
-reg_def XMM31h( SOC, SOE, Op_RegF, 31, xmm31>-as_VMReg()->next(7));
-reg_def XMM31i( SOC, SOE, Op_RegF, 31, xmm31->as_VMReg()->next(8));
-reg_def XMM31j( SOC, SOE, Op_RegF, 31, xmm31->as_VMReg()->next(9));
-reg_def XMM31k( SOC, SOE, Op_RegF, 31, xmm31->as_VMReg()->next(10));
-reg_def XMM31l( SOC, SOE, Op_RegF, 31, xmm31->as_VMReg()->next(11));
-reg_def XMM31m( SOC, SOE, Op_RegF, 31, xmm31->as_VMReg()->next(12));
-reg_def XMM31n( SOC, SOE, Op_RegF, 31, xmm31->as_VMReg()->next(13));
-reg_def XMM31o( SOC, SOE, Op_RegF, 31, xmm31->as_VMReg()->next(14));
-reg_def XMM31p( SOC, SOE, Op_RegF, 31, xmm31->as_VMReg()->next(15));
-
-#else // _WIN64
-
reg_def XMM6 ( SOC, SOC, Op_RegF, 6, xmm6->as_VMReg());
reg_def XMM6b( SOC, SOC, Op_RegF, 6, xmm6->as_VMReg()->next(1));
reg_def XMM6c( SOC, SOC, Op_RegF, 6, xmm6->as_VMReg()->next(2));
@@ -1067,8 +622,6 @@
#endif // _LP64
-#endif // _WIN64
-
#ifdef _LP64
reg_def RFLAGS(SOC, SOC, 0, 16, VMRegImpl::Bad());
#else
@@ -3113,6 +2666,30 @@
ins_pipe(pipe_slow);
%}
+// a * b + c
+instruct fmaD_reg(regD a, regD b, regD c) %{
+ predicate(UseFMA);
+ match(Set c (FmaD c (Binary a b)));
+ format %{ "fmasd $a,$b,$c\t# $c = $a * $b + $c" %}
+ ins_cost(150);
+ ins_encode %{
+ __ fmad($c$$XMMRegister, $a$$XMMRegister, $b$$XMMRegister, $c$$XMMRegister);
+ %}
+ ins_pipe( pipe_slow );
+%}
+
+// a * b + c
+instruct fmaF_reg(regF a, regF b, regF c) %{
+ predicate(UseFMA);
+ match(Set c (FmaF c (Binary a b)));
+ format %{ "fmass $a,$b,$c\t# $c = $a * $b + $c" %}
+ ins_cost(150);
+ ins_encode %{
+ __ fmaf($c$$XMMRegister, $a$$XMMRegister, $b$$XMMRegister, $c$$XMMRegister);
+ %}
+ ins_pipe( pipe_slow );
+%}
+
// ====================VECTOR INSTRUCTIONS=====================================
// Load vectors (4 bytes long)
--- a/hotspot/src/cpu/x86/vm/x86_32.ad Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/cpu/x86/vm/x86_32.ad Fri Oct 14 11:11:19 2016 -0700
@@ -104,14 +104,14 @@
//
// Empty fill registers, which are never used, but supply alignment to xmm regs
//
-reg_def FILL0( SOC, SOC, Op_RegF, 7, as_FloatRegister(6)->as_VMReg()->next(2));
-reg_def FILL1( SOC, SOC, Op_RegF, 7, as_FloatRegister(6)->as_VMReg()->next(3));
-reg_def FILL2( SOC, SOC, Op_RegF, 7, as_FloatRegister(6)->as_VMReg()->next(4));
-reg_def FILL3( SOC, SOC, Op_RegF, 7, as_FloatRegister(6)->as_VMReg()->next(5));
-reg_def FILL4( SOC, SOC, Op_RegF, 7, as_FloatRegister(6)->as_VMReg()->next(6));
-reg_def FILL5( SOC, SOC, Op_RegF, 7, as_FloatRegister(6)->as_VMReg()->next(7));
-reg_def FILL6( SOC, SOC, Op_RegF, 7, as_FloatRegister(6)->as_VMReg()->next(8));
-reg_def FILL7( SOC, SOC, Op_RegF, 7, as_FloatRegister(6)->as_VMReg()->next(9));
+reg_def FILL0( SOC, SOC, Op_RegF, 8, VMRegImpl::Bad());
+reg_def FILL1( SOC, SOC, Op_RegF, 9, VMRegImpl::Bad());
+reg_def FILL2( SOC, SOC, Op_RegF, 10, VMRegImpl::Bad());
+reg_def FILL3( SOC, SOC, Op_RegF, 11, VMRegImpl::Bad());
+reg_def FILL4( SOC, SOC, Op_RegF, 12, VMRegImpl::Bad());
+reg_def FILL5( SOC, SOC, Op_RegF, 13, VMRegImpl::Bad());
+reg_def FILL6( SOC, SOC, Op_RegF, 14, VMRegImpl::Bad());
+reg_def FILL7( SOC, SOC, Op_RegF, 15, VMRegImpl::Bad());
// Specify priority of register selection within phases of register
// allocation. Highest priority is first. A useful heuristic is to
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.amd64/src/jdk/vm/ci/amd64/AMD64.java Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.amd64/src/jdk/vm/ci/amd64/AMD64.java Fri Oct 14 11:11:19 2016 -0700
@@ -205,7 +205,8 @@
AVX512CD,
AVX512BW,
AVX512VL,
- SHA
+ SHA,
+ FMA
}
private final EnumSet<CPUFeature> features;
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot.amd64/src/jdk/vm/ci/hotspot/amd64/AMD64HotSpotJVMCIBackendFactory.java Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot.amd64/src/jdk/vm/ci/hotspot/amd64/AMD64HotSpotJVMCIBackendFactory.java Fri Oct 14 11:11:19 2016 -0700
@@ -124,6 +124,9 @@
if ((config.vmVersionFeatures & config.amd64SHA) != 0) {
features.add(AMD64.CPUFeature.SHA);
}
+ if ((config.vmVersionFeatures & config.amd64FMA) != 0) {
+ features.add(AMD64.CPUFeature.FMA);
+ }
return features;
}
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot.amd64/src/jdk/vm/ci/hotspot/amd64/AMD64HotSpotVMConfig.java Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot.amd64/src/jdk/vm/ci/hotspot/amd64/AMD64HotSpotVMConfig.java Fri Oct 14 11:11:19 2016 -0700
@@ -78,4 +78,5 @@
final long amd64AVX512BW = getConstant("VM_Version::CPU_AVX512BW", Long.class);
final long amd64AVX512VL = getConstant("VM_Version::CPU_AVX512VL", Long.class);
final long amd64SHA = getConstant("VM_Version::CPU_SHA", Long.class);
+ final long amd64FMA = getConstant("VM_Version::CPU_FMA", Long.class);
}
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/CompilerToVM.java Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/CompilerToVM.java Fri Oct 14 11:11:19 2016 -0700
@@ -26,8 +26,7 @@
import static jdk.vm.ci.common.InitTimer.timer;
import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Method;
+import java.lang.reflect.Executable;
import jdk.vm.ci.code.BytecodeFrame;
import jdk.vm.ci.code.InstalledCode;
@@ -385,10 +384,9 @@
native boolean hasFinalizableSubclass(HotSpotResolvedObjectTypeImpl type);
/**
- * Gets the method corresponding to {@code holder} and slot number {@code slot} (i.e.
- * {@link Method#slot} or {@link Constructor#slot}).
+ * Gets the method corresponding to {@code executable}.
*/
- native HotSpotResolvedJavaMethodImpl getResolvedJavaMethodAtSlot(Class<?> holder, int slot);
+ native HotSpotResolvedJavaMethodImpl asResolvedJavaMethod(Executable executable);
/**
* Gets the maximum absolute offset of a PC relative call to {@code address} from any position
@@ -616,4 +614,9 @@
*/
native int interpreterFrameSize(BytecodeFrame frame);
+ /**
+ * Invokes non-public method {@code java.lang.invoke.LambdaForm.compileToBytecode()} on
+ * {@code lambdaForm} (which must be a {@code java.lang.invoke.LambdaForm} instance).
+ */
+ native void compileToBytecode(Object lambdaForm);
}
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotCodeCacheProvider.java Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotCodeCacheProvider.java Fri Oct 14 11:11:19 2016 -0700
@@ -22,7 +22,7 @@
*/
package jdk.vm.ci.hotspot;
-import java.lang.reflect.Field;
+import java.util.Map;
import jdk.vm.ci.code.BailoutException;
import jdk.vm.ci.code.BytecodeFrame;
@@ -56,16 +56,11 @@
@Override
public String getMarkName(Mark mark) {
int markId = (int) mark.id;
- Field[] fields = runtime.getConfig().getClass().getDeclaredFields();
- for (Field f : fields) {
- if (f.getName().startsWith("MARKID_")) {
- f.setAccessible(true);
- try {
- if (f.getInt(runtime.getConfig()) == markId) {
- return f.getName();
- }
- } catch (Exception e) {
- }
+ HotSpotVMConfigStore store = runtime.getConfigStore();
+ for (Map.Entry<String, Long> e : store.getConstants().entrySet()) {
+ String name = e.getKey();
+ if (name.startsWith("MARKID_") && e.getValue() == markId) {
+ return name;
}
}
return CodeCacheProvider.super.getMarkName(mark);
@@ -76,17 +71,13 @@
*/
@Override
public String getTargetName(Call call) {
- Field[] fields = runtime.getConfig().getClass().getDeclaredFields();
- for (Field f : fields) {
- if (f.getName().endsWith("Stub")) {
- f.setAccessible(true);
- Object address;
- try {
- address = f.get(runtime.getConfig());
- if (address.equals(call.target)) {
- return f.getName() + ":0x" + Long.toHexString((Long) address);
- }
- } catch (IllegalArgumentException | IllegalAccessException e) {
+ if (call.target instanceof HotSpotForeignCallTarget) {
+ long address = ((HotSpotForeignCallTarget) call.target).address;
+ HotSpotVMConfigStore store = runtime.getConfigStore();
+ for (Map.Entry<String, VMField> e : store.getFields().entrySet()) {
+ VMField field = e.getValue();
+ if (field.isStatic() && field.value != null && field.value == address) {
+ return e.getValue() + ":0x" + Long.toHexString(address);
}
}
}
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMetaAccessProvider.java Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMetaAccessProvider.java Fri Oct 14 11:11:19 2016 -0700
@@ -28,11 +28,10 @@
import static jdk.vm.ci.hotspot.UnsafeAccess.UNSAFE;
import java.lang.reflect.Array;
-import java.lang.reflect.Constructor;
import java.lang.reflect.Executable;
import java.lang.reflect.Field;
-import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
+import java.util.Objects;
import jdk.vm.ci.code.CodeUtil;
import jdk.vm.ci.code.TargetDescription;
@@ -78,35 +77,8 @@
return new HotSpotSignature(runtime, signature);
}
- /**
- * {@link Field} object of {@link Method#slot}.
- */
- private Field reflectionMethodSlot = getReflectionSlotField(Method.class);
-
- /**
- * {@link Field} object of {@link Constructor#slot}.
- */
- private Field reflectionConstructorSlot = getReflectionSlotField(Constructor.class);
-
- private static Field getReflectionSlotField(Class<?> reflectionClass) {
- try {
- Field field = reflectionClass.getDeclaredField("slot");
- field.setAccessible(true);
- return field;
- } catch (NoSuchFieldException | SecurityException e) {
- throw new JVMCIError(e);
- }
- }
-
public ResolvedJavaMethod lookupJavaMethod(Executable reflectionMethod) {
- try {
- Class<?> holder = reflectionMethod.getDeclaringClass();
- Field slotField = reflectionMethod instanceof Constructor ? reflectionConstructorSlot : reflectionMethodSlot;
- final int slot = slotField.getInt(reflectionMethod);
- return runtime.getCompilerToVM().getResolvedJavaMethodAtSlot(holder, slot);
- } catch (IllegalArgumentException | IllegalAccessException e) {
- throw new JVMCIError(e);
- }
+ return runtime.getCompilerToVM().asResolvedJavaMethod(Objects.requireNonNull(reflectionMethod));
}
public ResolvedJavaField lookupJavaField(Field reflectionField) {
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMethodHandleAccessProvider.java Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMethodHandleAccessProvider.java Fri Oct 14 11:11:19 2016 -0700
@@ -24,16 +24,17 @@
import static jdk.vm.ci.hotspot.CompilerToVM.compilerToVM;
import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime;
-import static jdk.vm.ci.hotspot.HotSpotResolvedObjectTypeImpl.fromObjectClass;
+
+import java.lang.invoke.MethodHandle;
+import java.util.Objects;
+
import jdk.vm.ci.common.JVMCIError;
import jdk.vm.ci.meta.ConstantReflectionProvider;
import jdk.vm.ci.meta.JavaConstant;
-import jdk.vm.ci.meta.JavaKind;
import jdk.vm.ci.meta.MethodHandleAccessProvider;
import jdk.vm.ci.meta.ResolvedJavaField;
import jdk.vm.ci.meta.ResolvedJavaMethod;
import jdk.vm.ci.meta.ResolvedJavaType;
-import jdk.vm.ci.meta.Signature;
public class HotSpotMethodHandleAccessProvider implements MethodHandleAccessProvider {
@@ -48,88 +49,46 @@
* possible after the {@link HotSpotJVMCIRuntime} is fully initialized.
*/
static class LazyInitialization {
+ static final ResolvedJavaType lambdaFormType;
static final ResolvedJavaField methodHandleFormField;
static final ResolvedJavaField lambdaFormVmentryField;
- static final ResolvedJavaMethod lambdaFormCompileToBytecodeMethod;
static final HotSpotResolvedJavaField memberNameVmtargetField;
- static final ResolvedJavaType CLASS = fromObjectClass(LazyInitialization.class);
-
/**
* Search for an instance field with the given name in a class.
*
- * @param className name of the class to search in
+ * @param declaringType the type declaring the field
* @param fieldName name of the field to be searched
* @param fieldType resolved Java type of the field
* @return resolved Java field
- * @throws ClassNotFoundException
* @throws NoSuchFieldError
*/
- private static ResolvedJavaField findFieldInClass(String className, String fieldName, ResolvedJavaType fieldType)
- throws ClassNotFoundException {
- Class<?> clazz = Class.forName(className);
- ResolvedJavaType type = runtime().fromClass(clazz);
- ResolvedJavaField[] fields = type.getInstanceFields(false);
+ private static ResolvedJavaField findFieldInClass(ResolvedJavaType declaringType, String fieldName, ResolvedJavaType fieldType) {
+ ResolvedJavaField[] fields = declaringType.getInstanceFields(false);
for (ResolvedJavaField field : fields) {
if (field.getName().equals(fieldName) && field.getType().equals(fieldType)) {
return field;
}
}
- throw new NoSuchFieldError(fieldType.getName() + " " + className + "." + fieldName);
+ throw new NoSuchFieldError(fieldType.getName() + " " + declaringType + "." + fieldName);
}
- private static ResolvedJavaMethod findMethodInClass(String className, String methodName,
- ResolvedJavaType resultType, ResolvedJavaType[] parameterTypes) throws ClassNotFoundException {
- Class<?> clazz = Class.forName(className);
- HotSpotResolvedObjectTypeImpl type = fromObjectClass(clazz);
- ResolvedJavaMethod result = null;
- for (ResolvedJavaMethod method : type.getDeclaredMethods()) {
- if (method.getName().equals(methodName) && signatureMatches(method, resultType, parameterTypes)) {
- result = method;
- }
- }
- if (result == null) {
- StringBuilder sig = new StringBuilder("(");
- for (ResolvedJavaType t : parameterTypes) {
- sig.append(t.getName()).append(",");
- }
- if (sig.length() > 1) {
- sig.replace(sig.length() - 1, sig.length(), ")");
- } else {
- sig.append(')');
- }
- throw new NoSuchMethodError(resultType.getName() + " " + className + "." + methodName + sig.toString());
- }
- return result;
+ private static ResolvedJavaType resolveType(Class<?> c) {
+ return runtime().fromClass(c);
}
- private static boolean signatureMatches(ResolvedJavaMethod m, ResolvedJavaType resultType,
- ResolvedJavaType[] parameterTypes) {
- Signature s = m.getSignature();
- if (!s.getReturnType(CLASS).equals(resultType)) {
- return false;
- }
- if (s.getParameterCount(false) != parameterTypes.length) {
- return false;
- }
- for (int i = 0; i < s.getParameterCount(false); ++i) {
- if (!s.getParameterType(i, CLASS).equals(parameterTypes[i])) {
- return false;
- }
- }
- return true;
+ private static ResolvedJavaType resolveType(String className) throws ClassNotFoundException {
+ return resolveType(Class.forName(className));
}
static {
try {
- methodHandleFormField = findFieldInClass("java.lang.invoke.MethodHandle", "form",
- fromObjectClass(Class.forName("java.lang.invoke.LambdaForm")));
- lambdaFormVmentryField = findFieldInClass("java.lang.invoke.LambdaForm", "vmentry",
- fromObjectClass(Class.forName("java.lang.invoke.MemberName")));
- lambdaFormCompileToBytecodeMethod = findMethodInClass("java.lang.invoke.LambdaForm", "compileToBytecode",
- new HotSpotResolvedPrimitiveType(JavaKind.Void), new ResolvedJavaType[]{});
- memberNameVmtargetField = (HotSpotResolvedJavaField) findFieldInClass("java.lang.invoke.MemberName", "vmtarget",
- new HotSpotResolvedPrimitiveType(JavaKind.Long));
+ ResolvedJavaType methodHandleType = resolveType(MethodHandle.class);
+ ResolvedJavaType memberNameType = resolveType("java.lang.invoke.MemberName");
+ lambdaFormType = resolveType("java.lang.invoke.LambdaForm");
+ methodHandleFormField = findFieldInClass(methodHandleType, "form", lambdaFormType);
+ lambdaFormVmentryField = findFieldInClass(lambdaFormType, "vmentry", memberNameType);
+ memberNameVmtargetField = (HotSpotResolvedJavaField) findFieldInClass(memberNameType, "vmtarget", resolveType(long.class));
} catch (Throwable ex) {
throw new JVMCIError(ex);
}
@@ -173,12 +132,13 @@
return null;
}
- if (forceBytecodeGeneration) {
- /* Invoke non-public method: MemberName LambdaForm.compileToBytecode() */
- LazyInitialization.lambdaFormCompileToBytecodeMethod.invoke(lambdaForm, new JavaConstant[0]);
+ JavaConstant memberName = constantReflection.readFieldValue(LazyInitialization.lambdaFormVmentryField, lambdaForm);
+ if (memberName.isNull() && forceBytecodeGeneration) {
+ Object lf = ((HotSpotObjectConstant) lambdaForm).asObject(LazyInitialization.lambdaFormType);
+ compilerToVM().compileToBytecode(Objects.requireNonNull(lf));
+ memberName = constantReflection.readFieldValue(LazyInitialization.lambdaFormVmentryField, lambdaForm);
+ assert memberName.isNonNull();
}
- /* Load non-public field: MemberName LambdaForm.vmentry */
- JavaConstant memberName = constantReflection.readFieldValue(LazyInitialization.lambdaFormVmentryField, lambdaForm);
return getTargetMethod(memberName);
}
@@ -200,4 +160,3 @@
return compilerToVM().getResolvedJavaMethod(object, LazyInitialization.memberNameVmtargetField.offset());
}
}
-
--- /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/HotSpotModifiers.java Fri Oct 14 11:11:19 2016 -0700
@@ -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 jdk.vm.ci.hotspot;
+
+import static java.lang.reflect.Modifier.ABSTRACT;
+import static java.lang.reflect.Modifier.FINAL;
+import static java.lang.reflect.Modifier.INTERFACE;
+import static java.lang.reflect.Modifier.NATIVE;
+import static java.lang.reflect.Modifier.PRIVATE;
+import static java.lang.reflect.Modifier.PROTECTED;
+import static java.lang.reflect.Modifier.PUBLIC;
+import static java.lang.reflect.Modifier.STATIC;
+import static java.lang.reflect.Modifier.STRICT;
+import static java.lang.reflect.Modifier.SYNCHRONIZED;
+import static java.lang.reflect.Modifier.TRANSIENT;
+import static java.lang.reflect.Modifier.VOLATILE;
+import static jdk.vm.ci.hotspot.HotSpotVMConfig.config;
+
+import java.lang.reflect.Modifier;
+
+/**
+ * The non-public modifiers in {@link Modifier} that need to be retrieved from
+ * {@link HotSpotVMConfig}.
+ */
+public class HotSpotModifiers {
+
+ // @formatter:off
+ public static final int ANNOTATION = config().jvmAccAnnotation;
+ public static final int ENUM = config().jvmAccEnum;
+ public static final int VARARGS = config().jvmAccVarargs;
+ public static final int BRIDGE = config().jvmAccBridge;
+ public static final int SYNTHETIC = config().jvmAccSynthetic;
+ // @formatter:on
+
+ public static int jvmClassModifiers() {
+ return PUBLIC | FINAL | INTERFACE | ABSTRACT | ANNOTATION | ENUM | SYNTHETIC;
+ }
+
+ public static int jvmMethodModifiers() {
+ return PUBLIC | PRIVATE | PROTECTED | STATIC | FINAL | SYNCHRONIZED | BRIDGE | VARARGS | NATIVE | ABSTRACT | STRICT | SYNTHETIC;
+ }
+
+ public static int jvmFieldModifiers() {
+ return PUBLIC | PRIVATE | PROTECTED | STATIC | FINAL | VOLATILE | TRANSIENT | ENUM | SYNTHETIC;
+ }
+}
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaFieldImpl.java Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaFieldImpl.java Fri Oct 14 11:11:19 2016 -0700
@@ -22,6 +22,7 @@
*/
package jdk.vm.ci.hotspot;
+import static jdk.vm.ci.hotspot.HotSpotModifiers.jvmFieldModifiers;
import static jdk.vm.ci.hotspot.HotSpotVMConfig.config;
import java.lang.annotation.Annotation;
@@ -29,7 +30,6 @@
import jdk.internal.vm.annotation.Stable;
import jdk.vm.ci.meta.JavaType;
-import jdk.vm.ci.meta.ModifiersProvider;
import jdk.vm.ci.meta.ResolvedJavaType;
/**
@@ -81,7 +81,7 @@
@Override
public int getModifiers() {
- return modifiers & ModifiersProvider.jvmFieldModifiers();
+ return modifiers & jvmFieldModifiers();
}
@Override
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl.java Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl.java Fri Oct 14 11:11:19 2016 -0700
@@ -24,13 +24,15 @@
import static jdk.vm.ci.hotspot.CompilerToVM.compilerToVM;
import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime;
+import static jdk.vm.ci.hotspot.HotSpotModifiers.BRIDGE;
+import static jdk.vm.ci.hotspot.HotSpotModifiers.SYNTHETIC;
+import static jdk.vm.ci.hotspot.HotSpotModifiers.VARARGS;
+import static jdk.vm.ci.hotspot.HotSpotModifiers.jvmMethodModifiers;
import static jdk.vm.ci.hotspot.HotSpotVMConfig.config;
import static jdk.vm.ci.hotspot.UnsafeAccess.UNSAFE;
import java.lang.annotation.Annotation;
import java.lang.reflect.Executable;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.lang.reflect.Type;
import java.util.HashMap;
@@ -42,13 +44,11 @@
import jdk.vm.ci.meta.ConstantPool;
import jdk.vm.ci.meta.DefaultProfilingInfo;
import jdk.vm.ci.meta.ExceptionHandler;
-import jdk.vm.ci.meta.JavaConstant;
import jdk.vm.ci.meta.JavaMethod;
import jdk.vm.ci.meta.JavaType;
import jdk.vm.ci.meta.LineNumberTable;
import jdk.vm.ci.meta.Local;
import jdk.vm.ci.meta.LocalVariableTable;
-import jdk.vm.ci.meta.ModifiersProvider;
import jdk.vm.ci.meta.ProfilingInfo;
import jdk.vm.ci.meta.ResolvedJavaMethod;
import jdk.vm.ci.meta.ResolvedJavaType;
@@ -210,7 +210,7 @@
@Override
public int getModifiers() {
- return getAllModifiers() & ModifiersProvider.jvmMethodModifiers();
+ return getAllModifiers() & jvmMethodModifiers();
}
@Override
@@ -490,6 +490,19 @@
return javaMethod == null ? null : javaMethod.getAnnotation(annotationClass);
}
+ public boolean isBridge() {
+ return (BRIDGE & getModifiers()) != 0;
+ }
+
+ @Override
+ public boolean isSynthetic() {
+ return (SYNTHETIC & getModifiers()) != 0;
+ }
+
+ public boolean isVarArgs() {
+ return (VARARGS & getModifiers()) != 0;
+ }
+
public boolean isDefault() {
if (isConstructor()) {
return false;
@@ -697,27 +710,6 @@
return (getFlags() & config().methodFlagsIntrinsicCandidate) != 0;
}
- @Override
- public JavaConstant invoke(JavaConstant receiver, JavaConstant[] arguments) {
- assert !isConstructor();
- Method javaMethod = (Method) toJava();
- javaMethod.setAccessible(true);
-
- Object[] objArguments = new Object[arguments.length];
- for (int i = 0; i < arguments.length; i++) {
- objArguments[i] = HotSpotObjectConstantImpl.asBoxedValue(arguments[i]);
- }
- Object objReceiver = receiver != null && !receiver.isNull() ? ((HotSpotObjectConstantImpl) receiver).object() : null;
-
- try {
- Object objResult = javaMethod.invoke(objReceiver, objArguments);
- return javaMethod.getReturnType() == void.class ? null : HotSpotObjectConstantImpl.forBoxedValue(getSignature().getReturnKind(), objResult);
-
- } catch (IllegalAccessException | InvocationTargetException ex) {
- throw new IllegalArgumentException(ex);
- }
- }
-
/**
* Allocates a compile id for this method by asking the VM for one.
*
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl.java Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl.java Fri Oct 14 11:11:19 2016 -0700
@@ -26,6 +26,7 @@
import static jdk.vm.ci.hotspot.CompilerToVM.compilerToVM;
import static jdk.vm.ci.hotspot.HotSpotConstantPool.isSignaturePolymorphicHolder;
import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime;
+import static jdk.vm.ci.hotspot.HotSpotModifiers.jvmClassModifiers;
import static jdk.vm.ci.hotspot.HotSpotVMConfig.config;
import static jdk.vm.ci.hotspot.UnsafeAccess.UNSAFE;
@@ -49,7 +50,6 @@
import jdk.vm.ci.meta.JavaConstant;
import jdk.vm.ci.meta.JavaKind;
import jdk.vm.ci.meta.JavaType;
-import jdk.vm.ci.meta.ModifiersProvider;
import jdk.vm.ci.meta.ResolvedJavaField;
import jdk.vm.ci.meta.ResolvedJavaMethod;
import jdk.vm.ci.meta.ResolvedJavaType;
@@ -152,7 +152,7 @@
if (isArray()) {
return (getElementalType().getModifiers() & (Modifier.PUBLIC | Modifier.PRIVATE | Modifier.PROTECTED)) | Modifier.FINAL | Modifier.ABSTRACT;
} else {
- return getAccessFlags() & ModifiersProvider.jvmClassModifiers();
+ return getAccessFlags() & jvmClassModifiers();
}
}
@@ -507,7 +507,7 @@
synchronized HotSpotResolvedJavaField createField(String fieldName, JavaType type, long offset, int rawFlags) {
HotSpotResolvedJavaField result = null;
- final int flags = rawFlags & ModifiersProvider.jvmFieldModifiers();
+ final int flags = rawFlags & HotSpotModifiers.jvmFieldModifiers();
final long id = offset + ((long) flags << 32);
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfig.java Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfig.java Fri Oct 14 11:11:19 2016 -0700
@@ -117,8 +117,12 @@
final int jvmAccFieldHasGenericSignature = getConstant("JVM_ACC_FIELD_HAS_GENERIC_SIGNATURE", Integer.class);
final int jvmAccIsCloneableFast = getConstant("JVM_ACC_IS_CLONEABLE_FAST", Integer.class);
- // Modifier.SYNTHETIC is not public so we get it via vmStructs.
+ // These modifiers are not public in Modifier so we get them via vmStructs.
final int jvmAccSynthetic = getConstant("JVM_ACC_SYNTHETIC", Integer.class);
+ final int jvmAccAnnotation = getConstant("JVM_ACC_ANNOTATION", Integer.class);
+ final int jvmAccBridge = getConstant("JVM_ACC_BRIDGE", Integer.class);
+ final int jvmAccVarargs = getConstant("JVM_ACC_VARARGS", Integer.class);
+ final int jvmAccEnum = getConstant("JVM_ACC_ENUM", Integer.class);
// This is only valid on AMD64.
final int runtimeCallStackSize = getConstant("frame::arg_reg_save_area_bytes", Integer.class, osArch.equals("amd64") ? null : 0);
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/UnsafeAccess.java Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/UnsafeAccess.java Fri Oct 14 11:11:19 2016 -0700
@@ -22,8 +22,6 @@
*/
package jdk.vm.ci.hotspot;
-import java.lang.reflect.Field;
-
import jdk.internal.misc.Unsafe;
/**
@@ -31,21 +29,5 @@
*/
class UnsafeAccess {
- static final Unsafe UNSAFE = initUnsafe();
-
- private static Unsafe initUnsafe() {
- try {
- // Fast path when we are trusted.
- return Unsafe.getUnsafe();
- } catch (SecurityException se) {
- // Slow path when we are not trusted.
- try {
- Field theUnsafe = Unsafe.class.getDeclaredField("theUnsafe");
- theUnsafe.setAccessible(true);
- return (Unsafe) theUnsafe.get(Unsafe.class);
- } catch (Exception e) {
- throw new RuntimeException("exception while trying to get Unsafe", e);
- }
- }
- }
+ static final Unsafe UNSAFE = Unsafe.getUnsafe();
}
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/MetaUtil.java Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/MetaUtil.java Fri Oct 14 11:11:19 2016 -0700
@@ -22,9 +22,6 @@
*/
package jdk.vm.ci.meta;
-import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
-
/**
* Miscellaneous collection of utility methods used by {@code jdk.vm.ci.meta} and its clients.
*/
@@ -226,17 +223,4 @@
}
return obj.getClass().getName() + "@" + System.identityHashCode(obj);
}
-
- /**
- * Used to lookup constants from {@link Modifier} that are not public (VARARGS, SYNTHETIC etc.).
- */
- static int getNonPublicModifierStaticField(String name) {
- try {
- Field field = Modifier.class.getDeclaredField(name);
- field.setAccessible(true);
- return field.getInt(null);
- } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
- throw new InternalError(e);
- }
- }
}
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/ModifiersProvider.java Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/ModifiersProvider.java Fri Oct 14 11:11:19 2016 -0700
@@ -22,18 +22,9 @@
*/
package jdk.vm.ci.meta;
-import static java.lang.reflect.Modifier.ABSTRACT;
-import static java.lang.reflect.Modifier.FINAL;
-import static java.lang.reflect.Modifier.INTERFACE;
-import static java.lang.reflect.Modifier.NATIVE;
import static java.lang.reflect.Modifier.PRIVATE;
import static java.lang.reflect.Modifier.PROTECTED;
import static java.lang.reflect.Modifier.PUBLIC;
-import static java.lang.reflect.Modifier.STATIC;
-import static java.lang.reflect.Modifier.STRICT;
-import static java.lang.reflect.Modifier.SYNCHRONIZED;
-import static java.lang.reflect.Modifier.TRANSIENT;
-import static java.lang.reflect.Modifier.VOLATILE;
import java.lang.reflect.Modifier;
@@ -42,17 +33,9 @@
* language {@linkplain #getModifiers() modifiers}.
*/
public interface ModifiersProvider {
- int BRIDGE = MetaUtil.getNonPublicModifierStaticField("BRIDGE");
- int VARARGS = MetaUtil.getNonPublicModifierStaticField("VARARGS");
- int SYNTHETIC = MetaUtil.getNonPublicModifierStaticField("SYNTHETIC");
- int ANNOTATION = MetaUtil.getNonPublicModifierStaticField("ANNOTATION");
- int ENUM = MetaUtil.getNonPublicModifierStaticField("ENUM");
- int MANDATED = MetaUtil.getNonPublicModifierStaticField("MANDATED");
/**
- * Returns the Java Virtual Machine modifiers for this element. Note that this can differ from
- * standard Java Reflection modifiers. For example at the JVM level, classes (
- * {@link ResolvedJavaType}) can not be private or protected.
+ * Returns the modifiers for this element.
*/
int getModifiers();
@@ -161,17 +144,4 @@
default boolean isConcrete() {
return !isAbstract();
}
-
- static int jvmClassModifiers() {
- // no SUPER
- return PUBLIC | FINAL | INTERFACE | ABSTRACT | ANNOTATION | ENUM | SYNTHETIC;
- }
-
- static int jvmMethodModifiers() {
- return PUBLIC | PRIVATE | PROTECTED | STATIC | FINAL | SYNCHRONIZED | BRIDGE | VARARGS | NATIVE | ABSTRACT | STRICT | SYNTHETIC;
- }
-
- static int jvmFieldModifiers() {
- return PUBLIC | PRIVATE | PROTECTED | STATIC | FINAL | VOLATILE | TRANSIENT | ENUM | SYNTHETIC;
- }
}
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/ResolvedJavaMethod.java Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/ResolvedJavaMethod.java Fri Oct 14 11:11:19 2016 -0700
@@ -26,7 +26,6 @@
import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.Array;
import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
import java.lang.reflect.Type;
/**
@@ -72,14 +71,6 @@
*/
int getMaxStackSize();
- /**
- * {@inheritDoc}
- * <p>
- * Only the {@linkplain Modifier#methodModifiers() method flags} specified in the JVM
- * specification will be included in the returned mask.
- */
- int getModifiers();
-
default boolean isFinal() {
return ModifiersProvider.super.isFinalFlagSet();
}
@@ -88,9 +79,7 @@
* Determines if this method is a synthetic method as defined by the Java Language
* Specification.
*/
- default boolean isSynthetic() {
- return (SYNTHETIC & getModifiers()) == SYNTHETIC;
- }
+ boolean isSynthetic();
/**
* Checks that the method is a
@@ -99,9 +88,7 @@
*
* @return whether the method is a varargs method
*/
- default boolean isVarArgs() {
- return (VARARGS & getModifiers()) == VARARGS;
- }
+ boolean isVarArgs();
/**
* Checks that the method is a
@@ -110,9 +97,7 @@
*
* @return whether the method is a bridge method
*/
- default boolean isBridge() {
- return (BRIDGE & getModifiers()) == BRIDGE;
- }
+ boolean isBridge();
/**
* Returns {@code true} if this method is a default method; returns {@code false} otherwise.
@@ -228,18 +213,6 @@
LocalVariableTable getLocalVariableTable();
/**
- * Invokes the underlying method represented by this object, on the specified object with the
- * specified parameters. This method is similar to a reflective method invocation by
- * {@link Method#invoke}.
- *
- * @param receiver The receiver for the invocation, or {@code null} if it is a static method.
- * @param arguments The arguments for the invocation.
- * @return The value returned by the method invocation, or {@code null} if the return type is
- * {@code void}.
- */
- JavaConstant invoke(JavaConstant receiver, JavaConstant[] arguments);
-
- /**
* Gets the encoding of (that is, a constant representing the value of) this method.
*
* @return a constant representing a reference to this method
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/ResolvedJavaType.java Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/ResolvedJavaType.java Fri Oct 14 11:11:19 2016 -0700
@@ -68,15 +68,6 @@
*/
boolean isPrimitive();
- /**
- * {@inheritDoc}
- * <p>
- * Only the flags specified in the JVM specification will be included in the returned mask. This
- * method is identical to {@link Class#getModifiers()} in terms of the value return for this
- * type.
- */
- int getModifiers();
-
/*
* The setting of the final bit for types is a bit confusing since arrays are marked as final.
* This method provides a semantically equivalent test that appropriate for types.
--- a/hotspot/src/os/windows/vm/os_windows.cpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/os/windows/vm/os_windows.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -2366,7 +2366,9 @@
if (Interpreter::contains(pc)) {
*fr = os::fetch_frame_from_context((void*)exceptionInfo->ContextRecord);
if (!fr->is_first_java_frame()) {
- assert(fr->safe_for_sender(thread), "Safety check");
+ // get_frame_at_stack_banging_point() is only called when we
+ // have well defined stacks so java_sender() calls do not need
+ // to assert safe_for_sender() first.
*fr = fr->java_sender();
}
} else {
@@ -2383,7 +2385,7 @@
// has been pushed on the stack
*fr = frame(fr->sp() + 1, fr->fp(), (address)*(fr->sp()));
if (!fr->is_java_frame()) {
- assert(fr->safe_for_sender(thread), "Safety check");
+ // See java_sender() comment above.
*fr = fr->java_sender();
}
}
--- a/hotspot/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -378,7 +378,9 @@
// method returns the Java sender of the current frame.
*fr = os::fetch_frame_from_ucontext(thread, uc);
if (!fr->is_first_java_frame()) {
- assert(fr->safe_for_sender(thread), "Safety check");
+ // get_frame_at_stack_banging_point() is only called when we
+ // have well defined stacks so java_sender() calls do not need
+ // to assert safe_for_sender() first.
*fr = fr->java_sender();
}
} else {
@@ -395,7 +397,7 @@
// has been pushed on the stack
*fr = frame(fr->sp() + 1, fr->fp(), (address)*(fr->sp()));
if (!fr->is_java_frame()) {
- assert(fr->safe_for_sender(thread), "Safety check");
+ // See java_sender() comment above.
*fr = fr->java_sender();
}
}
--- a/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -191,7 +191,9 @@
// method returns the Java sender of the current frame.
*fr = os::fetch_frame_from_ucontext(thread, uc);
if (!fr->is_first_java_frame()) {
- assert(fr->safe_for_sender(thread), "Safety check");
+ // get_frame_at_stack_banging_point() is only called when we
+ // have well defined stacks so java_sender() calls do not need
+ // to assert safe_for_sender() first.
*fr = fr->java_sender();
}
} else {
@@ -209,8 +211,8 @@
intptr_t* sp = os::Linux::ucontext_get_sp(uc);
*fr = frame(sp + 1, fp, (address)*sp);
if (!fr->is_java_frame()) {
- assert(fr->safe_for_sender(thread), "Safety check");
assert(!fr->is_first_frame(), "Safety check");
+ // See java_sender() comment above.
*fr = fr->java_sender();
}
}
--- a/hotspot/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -255,7 +255,9 @@
// method returns the Java sender of the current frame.
*fr = os::fetch_frame_from_ucontext(thread, uc);
if (!fr->is_first_java_frame()) {
- assert(fr->safe_for_sender(thread), "Safety check");
+ // get_frame_at_stack_banging_point() is only called when we
+ // have well defined stacks so java_sender() calls do not need
+ // to assert safe_for_sender() first.
*fr = fr->java_sender();
}
} else {
@@ -273,7 +275,7 @@
intptr_t* sp = os::Solaris::ucontext_get_sp(uc);
*fr = frame(sp + 1, fp, (address)*sp);
if (!fr->is_java_frame()) {
- assert(fr->safe_for_sender(thread), "Safety check");
+ // See java_sender() comment above.
*fr = fr->java_sender();
}
}
--- a/hotspot/src/share/vm/adlc/formssel.cpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/adlc/formssel.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -1245,6 +1245,7 @@
this != short_branch && // Don't match myself
!is_short_branch() && // Don't match another short branch variant
reduce_result() != NULL &&
+ strstr(_ident, "restoreMask") == NULL && // Don't match side effects
strcmp(reduce_result(), short_branch->reduce_result()) == 0 &&
_matrule->equivalent(AD.globalNames(), short_branch->_matrule)) {
// The instructions are equivalent.
@@ -4037,6 +4038,8 @@
strcmp(opType,"EncodeP")==0 ||
strcmp(opType,"EncodePKlass")==0 ||
strcmp(opType,"DecodeNKlass")==0 ||
+ strcmp(opType,"FmaD") == 0 ||
+ strcmp(opType,"FmaF") == 0 ||
strcmp(opType,"RoundDouble")==0 ||
strcmp(opType,"RoundFloat")==0 ||
strcmp(opType,"ReverseBytesI")==0 ||
--- a/hotspot/src/share/vm/c1/c1_Compiler.cpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/c1/c1_Compiler.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -162,6 +162,8 @@
case vmIntrinsics::_dlog10:
case vmIntrinsics::_dexp:
case vmIntrinsics::_dpow:
+ case vmIntrinsics::_fmaD:
+ case vmIntrinsics::_fmaF:
case vmIntrinsics::_getObject:
case vmIntrinsics::_getBoolean:
case vmIntrinsics::_getByte:
--- a/hotspot/src/share/vm/c1/c1_LIR.cpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/c1/c1_LIR.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -666,7 +666,9 @@
// LIR_Op3
case lir_idiv:
- case lir_irem: {
+ case lir_irem:
+ case lir_fmad:
+ case lir_fmaf: {
assert(op->as_Op3() != NULL, "must be");
LIR_Op3* op3= (LIR_Op3*)op;
@@ -1663,6 +1665,8 @@
// LIR_Op3
case lir_idiv: s = "idiv"; break;
case lir_irem: s = "irem"; break;
+ case lir_fmad: s = "fmad"; break;
+ case lir_fmaf: s = "fmaf"; break;
// LIR_OpJavaCall
case lir_static_call: s = "static"; break;
case lir_optvirtual_call: s = "optvirtual"; break;
--- a/hotspot/src/share/vm/c1/c1_LIR.hpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/c1/c1_LIR.hpp Fri Oct 14 11:11:19 2016 -0700
@@ -956,6 +956,8 @@
, begin_op3
, lir_idiv
, lir_irem
+ , lir_fmad
+ , lir_fmaf
, end_op3
, begin_opJavaCall
, lir_static_call
@@ -2149,6 +2151,8 @@
void abs (LIR_Opr from, LIR_Opr to, LIR_Opr tmp) { append(new LIR_Op2(lir_abs , from, tmp, to)); }
void sqrt(LIR_Opr from, LIR_Opr to, LIR_Opr tmp) { append(new LIR_Op2(lir_sqrt, from, tmp, to)); }
+ void fmad(LIR_Opr from, LIR_Opr from1, LIR_Opr from2, LIR_Opr to) { append(new LIR_Op3(lir_fmad, from, from1, from2, to)); }
+ void fmaf(LIR_Opr from, LIR_Opr from1, LIR_Opr from2, LIR_Opr to) { append(new LIR_Op3(lir_fmaf, from, from1, from2, to)); }
void log10 (LIR_Opr from, LIR_Opr to, LIR_Opr tmp) { append(new LIR_Op2(lir_log10, from, LIR_OprFact::illegalOpr, to, tmp)); }
void tan (LIR_Opr from, LIR_Opr to, LIR_Opr tmp1, LIR_Opr tmp2) { append(new LIR_Op2(lir_tan , from, tmp1, to, tmp2)); }
--- a/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -3181,6 +3181,9 @@
case vmIntrinsics::_dpow : do_MathIntrinsic(x); break;
case vmIntrinsics::_arraycopy: do_ArrayCopy(x); break;
+ case vmIntrinsics::_fmaD: do_FmaIntrinsic(x); break;
+ case vmIntrinsics::_fmaF: do_FmaIntrinsic(x); break;
+
// java.nio.Buffer.checkIndex
case vmIntrinsics::_checkIndex: do_NIOCheckIndex(x); break;
@@ -3244,14 +3247,14 @@
Bytecodes::Code bc = x->method()->java_code_at_bci(bci);
int start = 0;
int stop = data->is_CallTypeData() ? ((ciCallTypeData*)data)->number_of_arguments() : ((ciVirtualCallTypeData*)data)->number_of_arguments();
- if (x->inlined() && x->callee()->is_static() && Bytecodes::has_receiver(bc)) {
+ if (x->callee()->is_loaded() && x->callee()->is_static() && Bytecodes::has_receiver(bc)) {
// first argument is not profiled at call (method handle invoke)
assert(x->method()->raw_code_at_bci(bci) == Bytecodes::_invokehandle, "invokehandle expected");
start = 1;
}
ciSignature* callee_signature = x->callee()->signature();
// method handle call to virtual method
- bool has_receiver = x->inlined() && !x->callee()->is_static() && !Bytecodes::has_receiver(bc);
+ bool has_receiver = x->callee()->is_loaded() && !x->callee()->is_static() && !Bytecodes::has_receiver(bc);
ciSignatureStream callee_signature_stream(callee_signature, has_receiver ? x->callee()->holder() : NULL);
bool ignored_will_link;
--- a/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp Fri Oct 14 11:11:19 2016 -0700
@@ -245,6 +245,7 @@
void do_isPrimitive(Intrinsic* x);
void do_getClass(Intrinsic* x);
void do_currentThread(Intrinsic* x);
+ void do_FmaIntrinsic(Intrinsic* x);
void do_MathIntrinsic(Intrinsic* x);
void do_LibmIntrinsic(Intrinsic* x);
void do_ArrayCopy(Intrinsic* x);
--- a/hotspot/src/share/vm/classfile/classLoader.cpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/classfile/classLoader.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -85,6 +85,7 @@
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);
+typedef void (JNICALL *FreeEntry_t)(jzfile *zip, jzentry *entry);
static ZipOpen_t ZipOpen = NULL;
static ZipClose_t ZipClose = NULL;
@@ -95,6 +96,7 @@
static canonicalize_fn_t CanonicalizeEntry = NULL;
static ZipInflateFully_t ZipInflateFully = NULL;
static Crc32_t Crc32 = NULL;
+static FreeEntry_t FreeEntry = NULL;
// Entry points for jimage.dll for loading jimage file entries
@@ -150,6 +152,7 @@
GrowableArray<char*>* ClassLoader::_boot_modules_array = NULL;
GrowableArray<char*>* ClassLoader::_platform_modules_array = NULL;
SharedPathsMiscInfo* ClassLoader::_shared_paths_misc_info = NULL;
+int ClassLoader::_num_patch_mod_prefixes = 0;
#endif
// helper routines
@@ -319,6 +322,20 @@
FREE_C_HEAP_ARRAY(char, _zip_name);
}
+bool ClassPathZipEntry::stream_exists(const char* name) {
+ // enable call to C land
+ JavaThread* thread = JavaThread::current();
+ ThreadToNativeFromVM ttn(thread);
+ // check whether zip archive contains name
+ jint name_len, filesize;
+ jzentry* entry = (*FindEntry)(_zip, name, &filesize, &name_len);
+ if (entry != NULL) {
+ (*FreeEntry)(_zip, entry);
+ return true;
+ }
+ return false;
+}
+
u1* ClassPathZipEntry::open_entry(const char* name, jint* filesize, bool nul_terminate, TRAPS) {
// enable call to C land
JavaThread* thread = JavaThread::current();
@@ -640,7 +657,7 @@
struct stat st;
if (os::stat(path, &st) == 0) {
- if ((st.st_mode & S_IFREG) != S_IFREG) { // is directory
+ if ((st.st_mode & S_IFMT) != S_IFREG) { // is not a regular file
if (!os::dir_is_empty(path)) {
tty->print_cr("Error: non-empty directory '%s'", path);
exit_with_path_failure("CDS allows only empty directories in archived classpaths", NULL);
@@ -693,8 +710,6 @@
GrowableArray<ModulePatchPath*>* patch_mod_args = Arguments::get_patch_mod_prefix();
int num_of_entries = patch_mod_args->length();
- assert(!DumpSharedSpaces, "DumpSharedSpaces not supported with --patch-module");
- assert(!UseSharedSpaces, "UseSharedSpaces not supported with --patch-module");
// Set up the boot loader's _patch_mod_entries list
_patch_mod_entries = new (ResourceObj::C_HEAP, mtModule) GrowableArray<ModuleClassPathList*>(num_of_entries, true);
@@ -851,7 +866,7 @@
bool is_boot_append, TRAPS) {
JavaThread* thread = JavaThread::current();
ClassPathEntry* new_entry = NULL;
- if ((st->st_mode & S_IFREG) == S_IFREG) {
+ if ((st->st_mode & S_IFMT) == S_IFREG) {
ResourceMark rm(thread);
// Regular file, should be a zip or jimage file
// Canonicalized filename
@@ -914,7 +929,7 @@
// check for a regular file
struct stat st;
if (os::stat(path, &st) == 0) {
- if ((st.st_mode & S_IFREG) == S_IFREG) {
+ if ((st.st_mode & S_IFMT) == S_IFREG) {
char canonical_path[JVM_MAXPATHLEN];
if (get_canonical_path(path, canonical_path, JVM_MAXPATHLEN)) {
char* error_msg = NULL;
@@ -1068,6 +1083,7 @@
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"));
+ FreeEntry = CAST_TO_FN_PTR(FreeEntry_t, os::dll_lookup(handle, "ZIP_FreeEntry"));
// ZIP_Close is not exported on Windows in JDK5.0 so don't abort if ZIP_Close is NULL
if (ZipOpen == NULL || FindEntry == NULL || ReadEntry == NULL ||
@@ -1395,6 +1411,57 @@
return NULL;
}
+#if INCLUDE_CDS
+// The following function is only used during CDS dump time.
+// It checks if a class can be found in the jar entries of the _patch_mod_entries.
+// It does not support non-jar entries.
+bool ClassLoader::is_in_patch_module(const char* const file_name) {
+ assert(DumpSharedSpaces, "dump time only");
+ if (_patch_mod_entries == NULL) {
+ return false;
+ }
+
+ int num_of_entries = _patch_mod_entries->length();
+ char* class_module_name = NULL;
+ ResourceMark rm;
+ const char *pkg_name = package_from_name(file_name);
+ // Using the jimage to obtain the class' module name.
+ // The ModuleEntryTable cannot be used at this point during dump time
+ // because the module system hasn't been initialized yet.
+ if (pkg_name != NULL) {
+ JImageFile *jimage = _jrt_entry->jimage();
+ class_module_name = (char*)(*JImagePackageToModule)(jimage, pkg_name);
+ }
+
+ if (class_module_name == NULL) {
+ return false;
+ }
+
+ // Loop through all the patch module entries looking for module
+ for (int i = 0; i < num_of_entries; i++) {
+ ModuleClassPathList* module_cpl = _patch_mod_entries->at(i);
+ Symbol* module_cpl_name = module_cpl->module_name();
+
+ if (strcmp(module_cpl_name->as_C_string(), class_module_name) == 0) {
+ // Class' module has been located, attempt to locate
+ // the class from the module's ClassPathEntry list.
+ ClassPathEntry* e = module_cpl->module_first_entry();
+ while (e != NULL) {
+ if (e->is_jar_file()) {
+ if (e->stream_exists(file_name)) {
+ return true;
+ } else {
+ e = e->next();
+ }
+ }
+ }
+ }
+ }
+
+ return false;
+}
+#endif // INCLUDE_CDS
+
instanceKlassHandle ClassLoader::load_class(Symbol* name, bool search_append_only, TRAPS) {
assert(name != NULL, "invariant");
assert(THREAD->is_Java_thread(), "must be a JavaThread");
@@ -1420,8 +1487,8 @@
// If DumpSharedSpaces is true boot loader visibility boundaries are set to:
// - [jimage] + [_first_append_entry to _last_append_entry] (all path entries).
- // No --patch-module entries or exploded module builds are included since CDS
- // is not supported if --patch-module or exploded module builds are used.
+ // If a class is found in the --patch-module entries, the class will not be included in the
+ // CDS archive. Also, CDS is not supported if exploded module builds are used.
//
// If search_append_only is true, boot loader visibility boundaries are
// set to be _first_append_entry to the end. This includes:
@@ -1444,8 +1511,17 @@
// found within its module specification, the search should continue to Load Attempt #2.
// Note: The --patch-module entries are never searched if the boot loader's
// visibility boundary is limited to only searching the append entries.
- if (_patch_mod_entries != NULL && !search_append_only && !DumpSharedSpaces) {
- stream = search_module_entries(_patch_mod_entries, class_name, file_name, CHECK_NULL);
+ if (_patch_mod_entries != NULL && !search_append_only) {
+ if (!DumpSharedSpaces) {
+ stream = search_module_entries(_patch_mod_entries, class_name, file_name, CHECK_NULL);
+ } else {
+#if INCLUDE_CDS
+ if (is_in_patch_module(file_name)) {
+ tty->print_cr("Preload Warning: Skip archiving class %s found in --patch-module entry", class_name);
+ return NULL;
+ }
+#endif
+ }
}
// Load Attempt #2: [jimage | exploded build]
@@ -1596,8 +1672,57 @@
}
#if INCLUDE_CDS
+// Capture all the --patch-module entries specified during CDS dump time.
+// It also captures the non-existing path(s) and the required file(s) during inspecting
+// the entries.
+void ClassLoader::setup_patch_mod_path() {
+ assert(DumpSharedSpaces, "only used with -Xshare:dump");
+ ResourceMark rm;
+ GrowableArray<ModulePatchPath*>* patch_mod_args = Arguments::get_patch_mod_prefix();
+ if (patch_mod_args != NULL) {
+ int num_of_entries = patch_mod_args->length();
+ for (int i = 0; i < num_of_entries; i++) {
+ const char* module_name = (patch_mod_args->at(i))->module_name();
+ const char* module_path = (patch_mod_args->at(i))->path_string();
+ int path_len = (int)strlen(module_path);
+ int name_len = (int)strlen(module_name);
+ int buf_len = name_len + path_len + 2; // add 2 for the '=' and NULL terminator
+ int end = 0;
+ char* buf = NEW_C_HEAP_ARRAY(char, buf_len, mtInternal);
+ // Iterate over the module's class path entries
+ for (int start = 0; start < path_len; start = end) {
+ while (module_path[end] && module_path[end] != os::path_separator()[0]) {
+ end++;
+ }
+ strncpy(buf, &module_path[start], end - start);
+ buf[end - start] = '\0';
+ struct stat st;
+ if (os::stat(buf, &st) != 0) {
+ // File not found
+ _shared_paths_misc_info->add_nonexist_path(buf);
+ } else {
+ if ((st.st_mode & S_IFMT) != S_IFREG) { // is not a regular file
+ vm_exit_during_initialization(
+ "--patch-module requires a regular file during dumping", buf);
+ } else {
+ _shared_paths_misc_info->add_required_file(buf);
+ }
+ }
+ while (module_path[end] == os::path_separator()[0]) {
+ end++;
+ }
+ };
+ jio_snprintf(buf, buf_len, "%s=%s", module_name, module_path);
+ _shared_paths_misc_info->add_patch_mod_classpath((const char*)buf);
+ _num_patch_mod_prefixes++;
+ FREE_C_HEAP_ARRAY(char, buf);
+ }
+ }
+}
+
void ClassLoader::initialize_shared_path() {
if (DumpSharedSpaces) {
+ setup_patch_mod_path();
ClassLoaderExt::setup_search_paths();
_shared_paths_misc_info->write_jint(0); // see comments in SharedPathsMiscInfo::check()
}
--- a/hotspot/src/share/vm/classfile/classLoader.hpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/classfile/classLoader.hpp Fri Oct 14 11:11:19 2016 -0700
@@ -69,6 +69,7 @@
// Attempt to locate file_name through this class path entry.
// Returns a class file parsing stream if successfull.
virtual ClassFileStream* open_stream(const char* name, TRAPS) = 0;
+ virtual bool stream_exists(const char* name) = 0;
// Debugging
NOT_PRODUCT(virtual void compile_the_world(Handle loader, TRAPS) = 0;)
};
@@ -83,6 +84,7 @@
JImageFile* jimage() const { return NULL; }
ClassPathDirEntry(const char* dir);
ClassFileStream* open_stream(const char* name, TRAPS);
+ bool stream_exists(const char* name) { return false; }
// Debugging
NOT_PRODUCT(void compile_the_world(Handle loader, TRAPS);)
};
@@ -126,6 +128,7 @@
ClassFileStream* open_stream(const char* name, TRAPS);
void contents_do(void f(const char* name, void* context), void* context);
bool is_multiple_versioned(TRAPS) NOT_CDS_RETURN_(false);
+ bool stream_exists(const char* name);
// Debugging
NOT_PRODUCT(void compile_the_world(Handle loader, TRAPS);)
};
@@ -145,6 +148,7 @@
ClassPathImageEntry(JImageFile* jimage, const char* name);
~ClassPathImageEntry();
ClassFileStream* open_stream(const char* name, TRAPS);
+ bool stream_exists(const char* name) { return false; }
// Debugging
NOT_PRODUCT(void compile_the_world(Handle loader, TRAPS);)
@@ -255,6 +259,7 @@
// Info used by CDS
CDS_ONLY(static SharedPathsMiscInfo * _shared_paths_misc_info;)
+ CDS_ONLY(static int _num_patch_mod_prefixes;)
// Initialization:
// - setup the boot loader's system class path
@@ -427,6 +432,9 @@
static void initialize_module_loader_map(JImageFile* jimage);
static s2 classloader_type(Symbol* class_name, ClassPathEntry* e,
int classpath_index, TRAPS);
+ static bool is_in_patch_module(const char* const file_name);
+ static void setup_patch_mod_path(); // Only when -Xshare:dump
+ static int num_patch_mod_prefixes() { return _num_patch_mod_prefixes; }
#endif
static void trace_class_path(const char* msg, const char* name = NULL);
--- a/hotspot/src/share/vm/classfile/sharedPathsMiscInfo.cpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/classfile/sharedPathsMiscInfo.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -86,6 +86,9 @@
case REQUIRED:
out->print("Expecting that file %s must exist and is not altered", path);
break;
+ case PATCH_MOD:
+ out->print("Expecting --patch-module=%s", path);
+ break;
default:
ShouldNotReachHere();
}
@@ -146,6 +149,9 @@
// But we want it to not exist -> fail
return fail("File must not exist");
}
+ if ((st.st_mode & S_IFMT) != S_IFREG) {
+ return fail("Did not get a regular file as expected.");
+ }
time_t timestamp;
long filesize;
@@ -161,7 +167,26 @@
}
}
break;
-
+ case PATCH_MOD:
+ {
+ GrowableArray<ModulePatchPath*>* patch_mod_args = Arguments::get_patch_mod_prefix();
+ if (patch_mod_args != NULL) {
+ int num_of_entries = patch_mod_args->length();
+ for (int i = 0; i < num_of_entries; i++) {
+ const char* module_name = (patch_mod_args->at(i))->module_name();
+ const char* path_string = (patch_mod_args->at(i))->path_string();
+ size_t n = strlen(module_name);
+ // path contains the module name, followed by '=', and one or more entries.
+ // E.g.: "java.base=foo" or "java.naming=dir1:dir2:dir3"
+ if ((strncmp(module_name, path, n) != 0) ||
+ (path[n] != '=') ||
+ (strcmp(path + n + 1, path_string) != 0)) {
+ return fail("--patch-module mismatch, path not found in run time: ", path);
+ }
+ }
+ }
+ }
+ break;
default:
return fail("Corrupted archive file header");
}
--- a/hotspot/src/share/vm/classfile/sharedPathsMiscInfo.hpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/classfile/sharedPathsMiscInfo.hpp Fri Oct 14 11:11:19 2016 -0700
@@ -104,10 +104,28 @@
add_path(path, NON_EXIST);
}
+ // The path must exist and have required size and modification time
+ void add_required_file(const char* path) {
+ add_path(path, REQUIRED);
+
+ struct stat st;
+ if (os::stat(path, &st) != 0) {
+ assert(0, "sanity");
+#if INCLUDE_CDS
+ ClassLoader::exit_with_path_failure("failed to os::stat(%s)", path); // should not happen
+#endif
+ }
+ write_time(st.st_mtime);
+ write_long(st.st_size);
+ }
+
// The path must exist, and must contain exactly <num_entries> files/dirs
void add_boot_classpath(const char* path) {
add_path(path, BOOT);
}
+ void add_patch_mod_classpath(const char* path) {
+ add_path(path, PATCH_MOD);
+ }
int write_jint(jint num) {
write(&num, sizeof(num));
return 0;
@@ -129,7 +147,8 @@
enum {
BOOT = 1,
NON_EXIST = 2,
- REQUIRED = 3
+ REQUIRED = 3,
+ PATCH_MOD = 4
};
virtual const char* type_name(int type) {
@@ -137,6 +156,7 @@
case BOOT: return "BOOT";
case NON_EXIST: return "NON_EXIST";
case REQUIRED: return "REQUIRED";
+ case PATCH_MOD: return "PATCH_MOD";
default: ShouldNotReachHere(); return "?";
}
}
--- a/hotspot/src/share/vm/classfile/symbolTable.cpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/classfile/symbolTable.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -710,53 +710,3 @@
return 0;
}
}
-
-#ifndef PRODUCT
-// Internal test of TempNewSymbol
-void Test_TempNewSymbol() {
- // Assert messages assume these symbols are unique, and the refcounts start at
- // one, but code does not rely on this.
- Thread* THREAD = Thread::current();
- Symbol* abc = SymbolTable::new_symbol("abc", CATCH);
- int abccount = abc->refcount();
- TempNewSymbol ss = abc;
- assert(ss->refcount() == abccount, "only one abc");
- assert(ss->refcount() == abc->refcount(), "should match TempNewSymbol");
-
- Symbol* efg = SymbolTable::new_symbol("efg", CATCH);
- Symbol* hij = SymbolTable::new_symbol("hij", CATCH);
- int efgcount = efg->refcount();
- int hijcount = hij->refcount();
-
- TempNewSymbol s1 = efg;
- TempNewSymbol s2 = hij;
- assert(s1->refcount() == efgcount, "one efg");
- assert(s2->refcount() == hijcount, "one hij");
-
- // Assignment operator
- s1 = s2;
- assert(hij->refcount() == hijcount + 1, "should be two hij");
- assert(efg->refcount() == efgcount - 1, "should be no efg");
-
- s1 = ss; // s1 is abc
- assert(s1->refcount() == abccount + 1, "should be two abc (s1 and ss)");
- assert(hij->refcount() == hijcount, "should only have one hij now (s2)");
-
- s1 = s1; // self assignment
- assert(s1->refcount() == abccount + 1, "should still be two abc (s1 and ss)");
-
- TempNewSymbol s3;
- Symbol* klm = SymbolTable::new_symbol("klm", CATCH);
- int klmcount = klm->refcount();
- s3 = klm; // assignment
- assert(s3->refcount() == klmcount, "only one klm now");
-
- Symbol* xyz = SymbolTable::new_symbol("xyz", CATCH);
- int xyzcount = xyz->refcount();
- { // inner scope
- TempNewSymbol s_inner = xyz;
- }
- assert(xyz->refcount() == (xyzcount - 1),
- "Should have been decremented by dtor in inner scope");
-}
-#endif // PRODUCT
--- a/hotspot/src/share/vm/classfile/vmSymbols.cpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/classfile/vmSymbols.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -355,6 +355,8 @@
case vmIntrinsics::_updateBytesCRC32:
case vmIntrinsics::_updateByteBufferCRC32:
case vmIntrinsics::_vectorizedMismatch:
+ case vmIntrinsics::_fmaD:
+ case vmIntrinsics::_fmaF:
return true;
default:
return false;
@@ -388,6 +390,8 @@
case vmIntrinsics::_updateBytesCRC32:
case vmIntrinsics::_updateByteBufferCRC32:
case vmIntrinsics::_vectorizedMismatch:
+ case vmIntrinsics::_fmaD:
+ case vmIntrinsics::_fmaF:
return false;
default:
return true;
@@ -536,6 +540,10 @@
case vmIntrinsics::_doubleToLongBits:
if (!InlineMathNatives) return true;
break;
+ case vmIntrinsics::_fmaD:
+ case vmIntrinsics::_fmaF:
+ if (!InlineMathNatives || !UseFMA) return true;
+ break;
case vmIntrinsics::_arraycopy:
if (!InlineArrayCopy) return true;
break;
--- a/hotspot/src/share/vm/classfile/vmSymbols.hpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/classfile/vmSymbols.hpp Fri Oct 14 11:11:19 2016 -0700
@@ -755,8 +755,10 @@
do_class(java_lang_Math, "java/lang/Math") \
do_class(java_lang_StrictMath, "java/lang/StrictMath") \
do_signature(double2_double_signature, "(DD)D") \
+ do_signature(double3_double_signature, "(DDD)D") \
+ do_signature(float3_float_signature, "(FFF)F") \
do_signature(int2_int_signature, "(II)I") \
- do_signature(long2_long_signature, "(JJ)J") \
+ do_signature(long2_long_signature, "(JJ)J") \
\
/* here are the math names, all together: */ \
do_name(abs_name,"abs") do_name(sin_name,"sin") do_name(cos_name,"cos") \
@@ -770,6 +772,7 @@
do_name(multiplyExact_name,"multiplyExact") \
do_name(negateExact_name,"negateExact") \
do_name(subtractExact_name,"subtractExact") \
+ do_name(fma_name, "fma") \
\
do_intrinsic(_dabs, java_lang_Math, abs_name, double_double_signature, F_S) \
do_intrinsic(_dsin, java_lang_Math, sin_name, double_double_signature, F_S) \
@@ -795,6 +798,8 @@
do_intrinsic(_negateExactL, java_lang_Math, negateExact_name, long_long_signature, F_S) \
do_intrinsic(_subtractExactI, java_lang_Math, subtractExact_name, int2_int_signature, F_S) \
do_intrinsic(_subtractExactL, java_lang_Math, subtractExact_name, long2_long_signature, F_S) \
+ do_intrinsic(_fmaD, java_lang_Math, fma_name, double3_double_signature, F_S) \
+ do_intrinsic(_fmaF, java_lang_Math, fma_name, float3_float_signature, F_S) \
\
do_intrinsic(_floatToRawIntBits, java_lang_Float, floatToRawIntBits_name, float_int_signature, F_S) \
do_name( floatToRawIntBits_name, "floatToRawIntBits") \
--- a/hotspot/src/share/vm/gc/cms/cmsOopClosures.hpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/gc/cms/cmsOopClosures.hpp Fri Oct 14 11:11:19 2016 -0700
@@ -258,16 +258,15 @@
// the closure ParMarkFromRootsClosure.
class ParPushOrMarkClosure: public MetadataAwareOopClosure {
private:
- CMSCollector* _collector;
- MemRegion _whole_span;
- MemRegion _span; // local chunk
- CMSBitMap* _bit_map;
- OopTaskQueue* _work_queue;
- CMSMarkStack* _overflow_stack;
- HeapWord* const _finger;
- HeapWord** const _global_finger_addr;
- ParMarkFromRootsClosure* const
- _parent;
+ CMSCollector* _collector;
+ MemRegion _whole_span;
+ MemRegion _span; // local chunk
+ CMSBitMap* _bit_map;
+ OopTaskQueue* _work_queue;
+ CMSMarkStack* _overflow_stack;
+ HeapWord* const _finger;
+ HeapWord* volatile* const _global_finger_addr;
+ ParMarkFromRootsClosure* const _parent;
protected:
DO_OOP_WORK_DEFN
public:
@@ -277,7 +276,7 @@
OopTaskQueue* work_queue,
CMSMarkStack* mark_stack,
HeapWord* finger,
- HeapWord** global_finger_addr,
+ HeapWord* volatile* global_finger_addr,
ParMarkFromRootsClosure* parent);
virtual void do_oop(oop* p);
virtual void do_oop(narrowOop* p);
--- a/hotspot/src/share/vm/gc/cms/concurrentMarkSweepGeneration.cpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/gc/cms/concurrentMarkSweepGeneration.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -3025,14 +3025,14 @@
// MT Concurrent Marking Task
class CMSConcMarkingTask: public YieldingFlexibleGangTask {
- CMSCollector* _collector;
- uint _n_workers; // requested/desired # workers
- bool _result;
- CompactibleFreeListSpace* _cms_space;
- char _pad_front[64]; // padding to ...
- HeapWord* _global_finger; // ... avoid sharing cache line
- char _pad_back[64];
- HeapWord* _restart_addr;
+ CMSCollector* _collector;
+ uint _n_workers; // requested/desired # workers
+ bool _result;
+ CompactibleFreeListSpace* _cms_space;
+ char _pad_front[64]; // padding to ...
+ HeapWord* volatile _global_finger; // ... avoid sharing cache line
+ char _pad_back[64];
+ HeapWord* _restart_addr;
// Exposed here for yielding support
Mutex* const _bit_map_lock;
@@ -3068,7 +3068,7 @@
OopTaskQueue* work_queue(int i) { return task_queues()->queue(i); }
- HeapWord** global_finger_addr() { return &_global_finger; }
+ HeapWord* volatile* global_finger_addr() { return &_global_finger; }
CMSConcMarkingTerminator* terminator() { return &_term; }
@@ -6554,7 +6554,7 @@
// Note: the local finger doesn't advance while we drain
// the stack below, but the global finger sure can and will.
- HeapWord** gfa = _task->global_finger_addr();
+ HeapWord* volatile* gfa = _task->global_finger_addr();
ParPushOrMarkClosure pushOrMarkClosure(_collector,
_span, _bit_map,
_work_queue,
@@ -6721,7 +6721,7 @@
OopTaskQueue* work_queue,
CMSMarkStack* overflow_stack,
HeapWord* finger,
- HeapWord** global_finger_addr,
+ HeapWord* volatile* global_finger_addr,
ParMarkFromRootsClosure* parent) :
MetadataAwareOopClosure(collector->ref_processor()),
_collector(collector),
--- a/hotspot/src/share/vm/gc/cms/concurrentMarkSweepGeneration.hpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/gc/cms/concurrentMarkSweepGeneration.hpp Fri Oct 14 11:11:19 2016 -0700
@@ -540,7 +540,7 @@
// Overflow list of grey objects, threaded through mark-word
// Manipulated with CAS in the parallel/multi-threaded case.
- oop _overflow_list;
+ oopDesc* volatile _overflow_list;
// The following array-pair keeps track of mark words
// displaced for accommodating overflow list above.
// This code will likely be revisited under RFE#4922830.
@@ -724,12 +724,12 @@
// Support for parallelizing young gen rescan in CMS remark phase
ParNewGeneration* _young_gen;
- HeapWord** _top_addr; // ... Top of Eden
- HeapWord** _end_addr; // ... End of Eden
- Mutex* _eden_chunk_lock;
- HeapWord** _eden_chunk_array; // ... Eden partitioning array
- size_t _eden_chunk_index; // ... top (exclusive) of array
- size_t _eden_chunk_capacity; // ... max entries in array
+ HeapWord* volatile* _top_addr; // ... Top of Eden
+ HeapWord** _end_addr; // ... End of Eden
+ Mutex* _eden_chunk_lock;
+ HeapWord** _eden_chunk_array; // ... Eden partitioning array
+ size_t _eden_chunk_index; // ... top (exclusive) of array
+ size_t _eden_chunk_capacity; // ... max entries in array
// Support for parallelizing survivor space rescan
HeapWord** _survivor_chunk_array;
--- a/hotspot/src/share/vm/gc/cms/parNewGeneration.hpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/gc/cms/parNewGeneration.hpp Fri Oct 14 11:11:19 2016 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -323,7 +323,7 @@
// A list of from-space images of to-be-scanned objects, threaded through
// klass-pointers (klass information already copied to the forwarded
// image.) Manipulated with CAS.
- oop _overflow_list;
+ oopDesc* volatile _overflow_list;
NOT_PRODUCT(ssize_t _num_par_pushes;)
// This closure is used by the reference processor to filter out
--- a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -2474,8 +2474,16 @@
}
jlong G1CollectedHeap::millis_since_last_gc() {
- // assert(false, "NYI");
- return 0;
+ // See the notes in GenCollectedHeap::millis_since_last_gc()
+ // for more information about the implementation.
+ jlong ret_val = (os::javaTimeNanos() / NANOSECS_PER_MILLISEC) -
+ _g1_policy->collection_pause_end_millis();
+ if (ret_val < 0) {
+ log_warning(gc)("millis_since_last_gc() would return : " JLONG_FORMAT
+ ". returning zero instead.", ret_val);
+ return 0;
+ }
+ return ret_val;
}
void G1CollectedHeap::prepare_for_verify() {
--- a/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.cpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -66,7 +66,8 @@
_phase_times(new G1GCPhaseTimes(ParallelGCThreads)),
_tenuring_threshold(MaxTenuringThreshold),
_max_survivor_regions(0),
- _survivors_age_table(true) { }
+ _survivors_age_table(true),
+ _collection_pause_end_millis(os::javaTimeNanos() / NANOSECS_PER_MILLISEC) { }
G1DefaultPolicy::~G1DefaultPolicy() {
delete _ihop_control;
@@ -575,6 +576,8 @@
record_pause(young_gc_pause_kind(), end_time_sec - pause_time_ms / 1000.0, end_time_sec);
+ _collection_pause_end_millis = os::javaTimeNanos() / NANOSECS_PER_MILLISEC;
+
last_pause_included_initial_mark = collector_state()->during_initial_mark_pause();
if (last_pause_included_initial_mark) {
record_concurrent_mark_init_end(0.0);
--- a/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.hpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.hpp Fri Oct 14 11:11:19 2016 -0700
@@ -64,6 +64,8 @@
double _full_collection_start_sec;
+ jlong _collection_pause_end_millis;
+
uint _young_list_target_length;
uint _young_list_fixed_length;
@@ -237,6 +239,8 @@
double reclaimable_bytes_perc(size_t reclaimable_bytes) const;
+ jlong collection_pause_end_millis() { return _collection_pause_end_millis; }
+
private:
// Sets up marking if proper conditions are met.
void maybe_start_marking();
--- a/hotspot/src/share/vm/gc/g1/g1IHOPControl.cpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/gc/g1/g1IHOPControl.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -81,47 +81,6 @@
_last_marking_length_s(0.0) {
}
-#ifndef PRODUCT
-static void test_update(G1IHOPControl* ctrl, double alloc_time, size_t alloc_amount, size_t young_size, double mark_time) {
- for (int i = 0; i < 100; i++) {
- ctrl->update_allocation_info(alloc_time, alloc_amount, young_size);
- ctrl->update_marking_length(mark_time);
- }
-}
-
-void G1StaticIHOPControl::test() {
- size_t const initial_ihop = 45;
-
- G1StaticIHOPControl ctrl(initial_ihop);
- ctrl.update_target_occupancy(100);
-
- size_t threshold = ctrl.get_conc_mark_start_threshold();
- assert(threshold == initial_ihop,
- "Expected IHOP threshold of " SIZE_FORMAT " but is " SIZE_FORMAT, initial_ihop, threshold);
-
- ctrl.update_allocation_info(100.0, 100, 100);
- threshold = ctrl.get_conc_mark_start_threshold();
- assert(threshold == initial_ihop,
- "Expected IHOP threshold of " SIZE_FORMAT " but is " SIZE_FORMAT, initial_ihop, threshold);
-
- ctrl.update_marking_length(1000.0);
- threshold = ctrl.get_conc_mark_start_threshold();
- assert(threshold == initial_ihop,
- "Expected IHOP threshold of " SIZE_FORMAT " but is " SIZE_FORMAT, initial_ihop, threshold);
-
- // Whatever we pass, the IHOP value must stay the same.
- test_update(&ctrl, 2, 10, 10, 3);
- threshold = ctrl.get_conc_mark_start_threshold();
- assert(threshold == initial_ihop,
- "Expected IHOP threshold of " SIZE_FORMAT " but is " SIZE_FORMAT, initial_ihop, threshold);
-
- test_update(&ctrl, 12, 10, 10, 3);
- threshold = ctrl.get_conc_mark_start_threshold();
- assert(threshold == initial_ihop,
- "Expected IHOP threshold of " SIZE_FORMAT " but is " SIZE_FORMAT, initial_ihop, threshold);
-}
-#endif
-
G1AdaptiveIHOPControl::G1AdaptiveIHOPControl(double ihop_percent,
G1Predictions const* predictor,
size_t heap_reserve_percent,
@@ -224,79 +183,3 @@
_predictor->get_new_prediction(&_marking_times_s),
have_enough_data_for_prediction());
}
-
-#ifndef PRODUCT
-void G1AdaptiveIHOPControl::test() {
- size_t const initial_threshold = 45;
- size_t const young_size = 10;
- size_t const target_size = 100;
-
- // The final IHOP value is always
- // target_size - (young_size + alloc_amount/alloc_time * marking_time)
-
- G1Predictions pred(0.95);
- G1AdaptiveIHOPControl ctrl(initial_threshold, &pred, 0, 0);
- ctrl.update_target_occupancy(target_size);
-
- // First "load".
- size_t const alloc_time1 = 2;
- size_t const alloc_amount1 = 10;
- size_t const marking_time1 = 2;
- size_t const settled_ihop1 = target_size - (young_size + alloc_amount1/alloc_time1 * marking_time1);
-
- size_t threshold;
- threshold = ctrl.get_conc_mark_start_threshold();
- assert(threshold == initial_threshold,
- "Expected IHOP threshold of " SIZE_FORMAT " but is " SIZE_FORMAT, initial_threshold, threshold);
- for (size_t i = 0; i < G1AdaptiveIHOPNumInitialSamples - 1; i++) {
- ctrl.update_allocation_info(alloc_time1, alloc_amount1, young_size);
- ctrl.update_marking_length(marking_time1);
- // Not enough data yet.
- threshold = ctrl.get_conc_mark_start_threshold();
- assert(threshold == initial_threshold,
- "Expected IHOP threshold of " SIZE_FORMAT " but is " SIZE_FORMAT, initial_threshold, threshold);
- }
-
- test_update(&ctrl, alloc_time1, alloc_amount1, young_size, marking_time1);
-
- threshold = ctrl.get_conc_mark_start_threshold();
- assert(threshold == settled_ihop1,
- "Expected IHOP threshold to settle at " SIZE_FORMAT " but is " SIZE_FORMAT, settled_ihop1, threshold);
-
- // Second "load". A bit higher allocation rate.
- size_t const alloc_time2 = 2;
- size_t const alloc_amount2 = 30;
- size_t const marking_time2 = 2;
- size_t const settled_ihop2 = target_size - (young_size + alloc_amount2/alloc_time2 * marking_time2);
-
- test_update(&ctrl, alloc_time2, alloc_amount2, young_size, marking_time2);
-
- threshold = ctrl.get_conc_mark_start_threshold();
- assert(threshold < settled_ihop1,
- "Expected IHOP threshold to settle at a value lower than " SIZE_FORMAT " but is " SIZE_FORMAT, settled_ihop1, threshold);
-
- // Third "load". Very high (impossible) allocation rate.
- size_t const alloc_time3 = 1;
- size_t const alloc_amount3 = 50;
- size_t const marking_time3 = 2;
- size_t const settled_ihop3 = 0;
-
- test_update(&ctrl, alloc_time3, alloc_amount3, young_size, marking_time3);
- threshold = ctrl.get_conc_mark_start_threshold();
-
- assert(threshold == settled_ihop3,
- "Expected IHOP threshold to settle at " SIZE_FORMAT " but is " SIZE_FORMAT, settled_ihop3, threshold);
-
- // And back to some arbitrary value.
- test_update(&ctrl, alloc_time2, alloc_amount2, young_size, marking_time2);
-
- threshold = ctrl.get_conc_mark_start_threshold();
- assert(threshold > settled_ihop3,
- "Expected IHOP threshold to settle at value larger than " SIZE_FORMAT " but is " SIZE_FORMAT, settled_ihop3, threshold);
-}
-
-void IHOP_test() {
- G1StaticIHOPControl::test();
- G1AdaptiveIHOPControl::test();
-}
-#endif
--- a/hotspot/src/share/vm/gc/g1/g1IHOPControl.hpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/gc/g1/g1IHOPControl.hpp Fri Oct 14 11:11:19 2016 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -99,10 +99,6 @@
assert(marking_length_s > 0.0, "Marking length must be larger than zero but is %.3f", marking_length_s);
_last_marking_length_s = marking_length_s;
}
-
-#ifndef PRODUCT
- static void test();
-#endif
};
// This algorithm tries to return a concurrent mark starting occupancy value that
@@ -148,9 +144,6 @@
virtual void print();
virtual void send_trace_event(G1NewTracer* tracer);
-#ifndef PRODUCT
- static void test();
-#endif
};
#endif // SHARE_VM_GC_G1_G1IHOPCONTROL_HPP
--- a/hotspot/src/share/vm/gc/g1/g1Policy.hpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/gc/g1/g1Policy.hpp Fri Oct 14 11:11:19 2016 -0700
@@ -119,6 +119,8 @@
virtual void record_full_collection_start() = 0;
virtual void record_full_collection_end() = 0;
+ virtual jlong collection_pause_end_millis() = 0;
+
// Must currently be called while the world is stopped.
virtual void record_concurrent_mark_init_end(double mark_init_elapsed_time_ms) = 0;
--- a/hotspot/src/share/vm/gc/g1/g1RemSet.cpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/gc/g1/g1RemSet.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -668,20 +668,18 @@
// fail arbitrarily). We tell the iteration code to perform this
// filtering when it has been determined that there has been an actual
// allocation in this region and making it safe to check the young type.
- bool filter_young = true;
- HeapWord* stop_point =
+ bool card_processed =
r->oops_on_card_seq_iterate_careful(dirtyRegion,
&filter_then_update_rs_oop_cl,
- filter_young,
card_ptr);
- // If stop_point is non-null, then we encountered an unallocated region
- // (perhaps the unfilled portion of a TLAB.) For now, we'll dirty the
- // card and re-enqueue: if we put off the card until a GC pause, then the
- // unallocated portion will be filled in. Alternatively, we might try
- // the full complexity of the technique used in "regular" precleaning.
- if (stop_point != NULL) {
+ // If unable to process the card then we encountered an unparsable
+ // part of the heap (e.g. a partially allocated object). Redirty
+ // and re-enqueue: if we put off the card until a GC pause, then the
+ // allocation will have completed.
+ if (!card_processed) {
+ assert(!_g1->is_gc_active(), "Unparsable heap during GC");
// The card might have gotten re-dirtied and re-enqueued while we
// worked. (In fact, it's pretty likely.)
if (*card_ptr != CardTableModRefBS::dirty_card_val()) {
--- a/hotspot/src/share/vm/gc/g1/heapRegion.cpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/gc/g1/heapRegion.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -352,19 +352,10 @@
_prev_marked_bytes = marked_bytes;
}
-HeapWord*
-HeapRegion::
-oops_on_card_seq_iterate_careful(MemRegion mr,
- FilterOutOfRegionClosure* cl,
- bool filter_young,
- jbyte* card_ptr) {
- // Currently, we should only have to clean the card if filter_young
- // is true and vice versa.
- if (filter_young) {
- assert(card_ptr != NULL, "pre-condition");
- } else {
- assert(card_ptr == NULL, "pre-condition");
- }
+bool HeapRegion::oops_on_card_seq_iterate_careful(MemRegion mr,
+ FilterOutOfRegionClosure* cl,
+ jbyte* card_ptr) {
+ assert(card_ptr != NULL, "pre-condition");
G1CollectedHeap* g1h = G1CollectedHeap::heap();
// If we're within a stop-world GC, then we might look at a card in a
@@ -375,7 +366,9 @@
} else {
mr = mr.intersection(used_region());
}
- if (mr.is_empty()) return NULL;
+ if (mr.is_empty()) {
+ return true;
+ }
// Otherwise, find the obj that extends onto mr.start().
// The intersection of the incoming mr (for the card) and the
@@ -384,27 +377,21 @@
// G1CollectedHeap.cpp that allocates a new region sets the
// is_young tag on the region before allocating. Thus we
// safely know if this region is young.
- if (is_young() && filter_young) {
- return NULL;
+ if (is_young()) {
+ return true;
}
- assert(!is_young(), "check value of filter_young");
-
// We can only clean the card here, after we make the decision that
- // the card is not young. And we only clean the card if we have been
- // asked to (i.e., card_ptr != NULL).
- if (card_ptr != NULL) {
- *card_ptr = CardTableModRefBS::clean_card_val();
- // We must complete this write before we do any of the reads below.
- OrderAccess::storeload();
- }
+ // the card is not young.
+ *card_ptr = CardTableModRefBS::clean_card_val();
+ // We must complete this write before we do any of the reads below.
+ OrderAccess::storeload();
// Cache the boundaries of the memory region in some const locals
HeapWord* const start = mr.start();
HeapWord* const end = mr.end();
- // We used to use "block_start_careful" here. But we're actually happy
- // to update the BOT while we do this...
+ // Update BOT as needed while finding start of (potential) object.
HeapWord* cur = block_start(start);
assert(cur <= start, "Postcondition");
@@ -416,7 +403,9 @@
obj = oop(cur);
if (obj->klass_or_null() == NULL) {
// Ran into an unparseable point.
- return cur;
+ assert(!g1h->is_gc_active(),
+ "Unparsable heap during GC at " PTR_FORMAT, p2i(cur));
+ return false;
}
// Otherwise...
next = cur + block_size(cur);
@@ -433,7 +422,9 @@
assert((cur + block_size(cur)) > (HeapWord*)obj, "Loop invariant");
if (obj->klass_or_null() == NULL) {
// Ran into an unparseable point.
- return cur;
+ assert(!g1h->is_gc_active(),
+ "Unparsable heap during GC at " PTR_FORMAT, p2i(cur));
+ return false;
}
// Advance the current pointer. "obj" still points to the object to iterate.
@@ -452,7 +443,7 @@
}
} while (cur < end);
- return NULL;
+ return true;
}
// Code roots support
--- a/hotspot/src/share/vm/gc/g1/heapRegion.hpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/gc/g1/heapRegion.hpp Fri Oct 14 11:11:19 2016 -0700
@@ -653,16 +653,17 @@
}
}
- // filter_young: if true and the region is a young region then we
- // skip the iteration.
- // card_ptr: if not NULL, and we decide that the card is not young
- // and we iterate over it, we'll clean the card before we start the
- // iteration.
- HeapWord*
- oops_on_card_seq_iterate_careful(MemRegion mr,
- FilterOutOfRegionClosure* cl,
- bool filter_young,
- jbyte* card_ptr);
+ // Iterate over the card in the card designated by card_ptr,
+ // applying cl to all references in the region.
+ // mr: the memory region covered by the card.
+ // card_ptr: if we decide that the card is not young and we iterate
+ // over it, we'll clean the card before we start the iteration.
+ // Returns true if card was successfully processed, false if an
+ // unparsable part of the heap was encountered, which should only
+ // happen when invoked concurrently with the mutator.
+ bool oops_on_card_seq_iterate_careful(MemRegion mr,
+ FilterOutOfRegionClosure* cl,
+ jbyte* card_ptr);
size_t recorded_rs_length() const { return _recorded_rs_length; }
double predicted_elapsed_time_ms() const { return _predicted_elapsed_time_ms; }
--- a/hotspot/src/share/vm/gc/g1/heapRegionManager.cpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/gc/g1/heapRegionManager.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -482,8 +482,9 @@
HeapRegionClaimer::HeapRegionClaimer(uint n_workers) :
_n_workers(n_workers), _n_regions(G1CollectedHeap::heap()->_hrm._allocated_heapregions_length), _claims(NULL) {
assert(n_workers > 0, "Need at least one worker.");
- _claims = NEW_C_HEAP_ARRAY(uint, _n_regions, mtGC);
- memset(_claims, Unclaimed, sizeof(*_claims) * _n_regions);
+ uint* new_claims = NEW_C_HEAP_ARRAY(uint, _n_regions, mtGC);
+ memset(new_claims, Unclaimed, sizeof(*_claims) * _n_regions);
+ _claims = new_claims;
}
HeapRegionClaimer::~HeapRegionClaimer() {
--- a/hotspot/src/share/vm/gc/g1/heapRegionManager.hpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/gc/g1/heapRegionManager.hpp Fri Oct 14 11:11:19 2016 -0700
@@ -259,9 +259,9 @@
// The HeapRegionClaimer is used during parallel iteration over heap regions,
// allowing workers to claim heap regions, gaining exclusive rights to these regions.
class HeapRegionClaimer : public StackObj {
- uint _n_workers;
- uint _n_regions;
- uint* _claims;
+ uint _n_workers;
+ uint _n_regions;
+ volatile uint* _claims;
static const uint Unclaimed = 0;
static const uint Claimed = 1;
@@ -285,4 +285,3 @@
bool claim_region(uint region_index);
};
#endif // SHARE_VM_GC_G1_HEAPREGIONMANAGER_HPP
-
--- a/hotspot/src/share/vm/gc/g1/heapRegionRemSet.cpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/gc/g1/heapRegionRemSet.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -56,7 +56,7 @@
PerRegionTable * _collision_list_next;
// Global free list of PRTs
- static PerRegionTable* _free_list;
+ static PerRegionTable* volatile _free_list;
protected:
// We need access in order to union things into the base table.
@@ -249,7 +249,7 @@
static void test_fl_mem_size();
};
-PerRegionTable* PerRegionTable::_free_list = NULL;
+PerRegionTable* volatile PerRegionTable::_free_list = NULL;
size_t OtherRegionsTable::_max_fine_entries = 0;
size_t OtherRegionsTable::_mod_max_fine_entries_mask = 0;
--- a/hotspot/src/share/vm/gc/g1/sparsePRT.cpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/gc/g1/sparsePRT.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -283,7 +283,7 @@
// ----------------------------------------------------------------------
-SparsePRT* SparsePRT::_head_expanded_list = NULL;
+SparsePRT* volatile SparsePRT::_head_expanded_list = NULL;
void SparsePRT::add_to_expanded_list(SparsePRT* sprt) {
// We could expand multiple times in a pause -- only put on list once.
--- a/hotspot/src/share/vm/gc/g1/sparsePRT.hpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/gc/g1/sparsePRT.hpp Fri Oct 14 11:11:19 2016 -0700
@@ -250,7 +250,7 @@
bool should_be_on_expanded_list();
- static SparsePRT* _head_expanded_list;
+ static SparsePRT* volatile _head_expanded_list;
public:
SparsePRT(HeapRegion* hr);
--- a/hotspot/src/share/vm/gc/parallel/mutableSpace.hpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/gc/parallel/mutableSpace.hpp Fri Oct 14 11:11:19 2016 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -51,7 +51,7 @@
MemRegion _last_setup_region;
size_t _alignment;
protected:
- HeapWord* _top;
+ HeapWord* volatile _top;
MutableSpaceMangler* mangler() { return _mangler; }
@@ -69,7 +69,7 @@
HeapWord* top() const { return _top; }
virtual void set_top(HeapWord* value) { _top = value; }
- HeapWord** top_addr() { return &_top; }
+ HeapWord* volatile* top_addr() { return &_top; }
HeapWord** end_addr() { return &_end; }
virtual void set_bottom(HeapWord* value) { _bottom = value; }
--- a/hotspot/src/share/vm/gc/parallel/parallelScavengeHeap.hpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/gc/parallel/parallelScavengeHeap.hpp Fri Oct 14 11:11:19 2016 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -175,7 +175,7 @@
bool supports_inline_contig_alloc() const { return !UseNUMA; }
- HeapWord** top_addr() const { return !UseNUMA ? young_gen()->top_addr() : (HeapWord**)-1; }
+ HeapWord* volatile* top_addr() const { return !UseNUMA ? young_gen()->top_addr() : (HeapWord* volatile*)-1; }
HeapWord** end_addr() const { return !UseNUMA ? young_gen()->end_addr() : (HeapWord**)-1; }
void ensure_parsability(bool retire_tlabs);
--- a/hotspot/src/share/vm/gc/parallel/psYoungGen.hpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/gc/parallel/psYoungGen.hpp Fri Oct 14 11:11:19 2016 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -162,7 +162,7 @@
return result;
}
- HeapWord** top_addr() const { return eden_space()->top_addr(); }
+ HeapWord* volatile* top_addr() const { return eden_space()->top_addr(); }
HeapWord** end_addr() const { return eden_space()->end_addr(); }
// Iteration.
--- a/hotspot/src/share/vm/gc/parallel/vmStructs_parallelgc.hpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/gc/parallel/vmStructs_parallelgc.hpp Fri Oct 14 11:11:19 2016 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,8 @@
#define SHARE_VM_GC_PARALLEL_VMSTRUCTS_PARALLELGC_HPP
#define VM_STRUCTS_PARALLELGC(nonstatic_field, \
- static_field) \
+ volatile_nonstatic_field, \
+ static_field) \
\
/**********************/ \
/* Parallel GC fields */ \
@@ -40,7 +41,7 @@
nonstatic_field(ImmutableSpace, _bottom, HeapWord*) \
nonstatic_field(ImmutableSpace, _end, HeapWord*) \
\
- nonstatic_field(MutableSpace, _top, HeapWord*) \
+ volatile_nonstatic_field(MutableSpace, _top, HeapWord*) \
\
nonstatic_field(PSYoungGen, _reserved, MemRegion) \
nonstatic_field(PSYoungGen, _virtual_space, PSVirtualSpace*) \
--- a/hotspot/src/share/vm/gc/serial/defNewGeneration.cpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/gc/serial/defNewGeneration.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -512,7 +512,7 @@
}
-HeapWord** DefNewGeneration::top_addr() const { return eden()->top_addr(); }
+HeapWord* volatile* DefNewGeneration::top_addr() const { return eden()->top_addr(); }
HeapWord** DefNewGeneration::end_addr() const { return eden()->end_addr(); }
void DefNewGeneration::object_iterate(ObjectClosure* blk) {
--- a/hotspot/src/share/vm/gc/serial/defNewGeneration.hpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/gc/serial/defNewGeneration.hpp Fri Oct 14 11:11:19 2016 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -225,7 +225,7 @@
size_t max_survivor_size() const { return _max_survivor_size; }
bool supports_inline_contig_alloc() const { return true; }
- HeapWord** top_addr() const;
+ HeapWord* volatile* top_addr() const;
HeapWord** end_addr() const;
// Thread-local allocation buffers
--- a/hotspot/src/share/vm/gc/shared/collectedHeap.hpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/gc/shared/collectedHeap.hpp Fri Oct 14 11:11:19 2016 -0700
@@ -350,7 +350,7 @@
// These functions return the addresses of the fields that define the
// boundaries of the contiguous allocation area. (These fields should be
// physically near to one another.)
- virtual HeapWord** top_addr() const {
+ virtual HeapWord* volatile* top_addr() const {
guarantee(false, "inline contiguous allocation not supported");
return NULL;
}
--- a/hotspot/src/share/vm/gc/shared/genCollectedHeap.cpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/gc/shared/genCollectedHeap.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -721,7 +721,7 @@
return _young_gen->supports_inline_contig_alloc();
}
-HeapWord** GenCollectedHeap::top_addr() const {
+HeapWord* volatile* GenCollectedHeap::top_addr() const {
return _young_gen->top_addr();
}
@@ -1256,21 +1256,20 @@
};
jlong GenCollectedHeap::millis_since_last_gc() {
- // We need a monotonically non-decreasing time in ms but
- // os::javaTimeMillis() does not guarantee monotonicity.
+ // javaTimeNanos() is guaranteed to be monotonically non-decreasing
+ // provided the underlying platform provides such a time source
+ // (and it is bug free). So we still have to guard against getting
+ // back a time later than 'now'.
jlong now = os::javaTimeNanos() / NANOSECS_PER_MILLISEC;
GenTimeOfLastGCClosure tolgc_cl(now);
// iterate over generations getting the oldest
// time that a generation was collected
generation_iterate(&tolgc_cl, false);
- // javaTimeNanos() is guaranteed to be monotonically non-decreasing
- // provided the underlying platform provides such a time source
- // (and it is bug free). So we still have to guard against getting
- // back a time later than 'now'.
jlong retVal = now - tolgc_cl.time();
if (retVal < 0) {
- NOT_PRODUCT(log_warning(gc)("time warp: " JLONG_FORMAT, retVal);)
+ log_warning(gc)("millis_since_last_gc() would return : " JLONG_FORMAT
+ ". returning zero instead.", retVal);
return 0;
}
return retVal;
--- a/hotspot/src/share/vm/gc/shared/genCollectedHeap.hpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/gc/shared/genCollectedHeap.hpp Fri Oct 14 11:11:19 2016 -0700
@@ -184,7 +184,7 @@
// We may support a shared contiguous allocation area, if the youngest
// generation does.
bool supports_inline_contig_alloc() const;
- HeapWord** top_addr() const;
+ HeapWord* volatile* top_addr() const;
HeapWord** end_addr() const;
// Perform a full collection of the heap; intended for use in implementing
--- a/hotspot/src/share/vm/gc/shared/generation.hpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/gc/shared/generation.hpp Fri Oct 14 11:11:19 2016 -0700
@@ -263,7 +263,7 @@
// These functions return the addresses of the fields that define the
// boundaries of the contiguous allocation area. (These fields should be
// physically near to one another.)
- virtual HeapWord** top_addr() const { return NULL; }
+ virtual HeapWord* volatile* top_addr() const { return NULL; }
virtual HeapWord** end_addr() const { return NULL; }
// Thread-local allocation buffers
--- a/hotspot/src/share/vm/gc/shared/workgroup.cpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/gc/shared/workgroup.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -472,23 +472,21 @@
}
bool SequentialSubTasksDone::is_task_claimed(uint& t) {
- uint* n_claimed_ptr = &_n_claimed;
- t = *n_claimed_ptr;
+ t = _n_claimed;
while (t < _n_tasks) {
- jint res = Atomic::cmpxchg(t+1, n_claimed_ptr, t);
+ jint res = Atomic::cmpxchg(t+1, &_n_claimed, t);
if (res == (jint)t) {
return false;
}
- t = *n_claimed_ptr;
+ t = res;
}
return true;
}
bool SequentialSubTasksDone::all_tasks_completed() {
- uint* n_completed_ptr = &_n_completed;
- uint complete = *n_completed_ptr;
+ uint complete = _n_completed;
while (true) {
- uint res = Atomic::cmpxchg(complete+1, n_completed_ptr, complete);
+ uint res = Atomic::cmpxchg(complete+1, &_n_completed, complete);
if (res == complete) {
break;
}
--- a/hotspot/src/share/vm/gc/shared/workgroup.hpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/gc/shared/workgroup.hpp Fri Oct 14 11:11:19 2016 -0700
@@ -318,9 +318,9 @@
// enumeration type.
class SubTasksDone: public CHeapObj<mtInternal> {
- uint* _tasks;
+ volatile uint* _tasks;
uint _n_tasks;
- uint _threads_completed;
+ volatile uint _threads_completed;
#ifdef ASSERT
volatile uint _claimed;
#endif
@@ -363,11 +363,11 @@
class SequentialSubTasksDone : public StackObj {
protected:
uint _n_tasks; // Total number of tasks available.
- uint _n_claimed; // Number of tasks claimed.
+ volatile uint _n_claimed; // Number of tasks claimed.
// _n_threads is used to determine when a sub task is done.
// See comments on SubTasksDone::_n_threads
uint _n_threads; // Total number of parallel threads.
- uint _n_completed; // Number of completed threads.
+ volatile uint _n_completed; // Number of completed threads.
void clear();
--- a/hotspot/src/share/vm/interpreter/abstractInterpreter.cpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/interpreter/abstractInterpreter.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -194,6 +194,13 @@
return java_lang_ref_reference_get;
}
+ if (UseFMA) {
+ switch (m->intrinsic_id()) {
+ case vmIntrinsics::_fmaD: return java_lang_math_fmaD;
+ case vmIntrinsics::_fmaF: return java_lang_math_fmaF;
+ }
+ }
+
// Accessor method?
if (m->is_getter()) {
// TODO: We should have used ::is_accessor above, but fast accessors in Zero expect only getters.
@@ -281,6 +288,8 @@
case java_lang_math_sqrt : tty->print("java_lang_math_sqrt" ); break;
case java_lang_math_log : tty->print("java_lang_math_log" ); break;
case java_lang_math_log10 : tty->print("java_lang_math_log10" ); break;
+ case java_lang_math_fmaD : tty->print("java_lang_math_fmaD" ); break;
+ case java_lang_math_fmaF : tty->print("java_lang_math_fmaF" ); break;
case java_util_zip_CRC32_update : tty->print("java_util_zip_CRC32_update"); break;
case java_util_zip_CRC32_updateBytes : tty->print("java_util_zip_CRC32_updateBytes"); break;
case java_util_zip_CRC32_updateByteBuffer : tty->print("java_util_zip_CRC32_updateByteBuffer"); break;
--- a/hotspot/src/share/vm/interpreter/abstractInterpreter.hpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/interpreter/abstractInterpreter.hpp Fri Oct 14 11:11:19 2016 -0700
@@ -76,6 +76,8 @@
java_lang_math_log10, // implementation of java.lang.Math.log10 (x)
java_lang_math_pow, // implementation of java.lang.Math.pow (x,y)
java_lang_math_exp, // implementation of java.lang.Math.exp (x)
+ java_lang_math_fmaF, // implementation of java.lang.Math.fma (x, y, z)
+ java_lang_math_fmaD, // implementation of java.lang.Math.fma (x, y, z)
java_lang_ref_reference_get, // implementation of java.lang.ref.Reference.get()
java_util_zip_CRC32_update, // implementation of java.util.zip.CRC32.update()
java_util_zip_CRC32_updateBytes, // implementation of java.util.zip.CRC32.updateBytes()
--- a/hotspot/src/share/vm/interpreter/templateInterpreterGenerator.cpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/interpreter/templateInterpreterGenerator.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -239,6 +239,10 @@
method_entry(java_lang_math_log10)
method_entry(java_lang_math_exp )
method_entry(java_lang_math_pow )
+ if (UseFMA) {
+ method_entry(java_lang_math_fmaF)
+ method_entry(java_lang_math_fmaD)
+ }
method_entry(java_lang_ref_reference_get)
AbstractInterpreter::initialize_method_handle_entries();
@@ -445,7 +449,9 @@
case Interpreter::java_lang_math_log10 : // fall thru
case Interpreter::java_lang_math_sqrt : // fall thru
case Interpreter::java_lang_math_pow : // fall thru
- case Interpreter::java_lang_math_exp : entry_point = generate_math_entry(kind); break;
+ case Interpreter::java_lang_math_exp : // fall thru
+ case Interpreter::java_lang_math_fmaD : // fall thru
+ case Interpreter::java_lang_math_fmaF : entry_point = generate_math_entry(kind); break;
case Interpreter::java_lang_ref_reference_get
: entry_point = generate_Reference_get_entry(); break;
case Interpreter::java_util_zip_CRC32_update
--- a/hotspot/src/share/vm/jvmci/jvmciCompiler.cpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/jvmci/jvmciCompiler.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -114,11 +114,11 @@
JVMCIRuntime::bootstrap_finished(CHECK);
}
-#define CHECK_ABORT THREAD); \
+#define CHECK_EXIT THREAD); \
if (HAS_PENDING_EXCEPTION) { \
char buf[256]; \
jio_snprintf(buf, 256, "Uncaught exception at %s:%d", __FILE__, __LINE__); \
- JVMCICompiler::abort_on_pending_exception(PENDING_EXCEPTION, buf); \
+ JVMCICompiler::exit_on_pending_exception(PENDING_EXCEPTION, buf); \
return; \
} \
(void)(0
@@ -133,10 +133,10 @@
return;
}
- JVMCIRuntime::initialize_well_known_classes(CHECK_ABORT);
+ JVMCIRuntime::initialize_well_known_classes(CHECK_EXIT);
HandleMark hm;
- Handle receiver = JVMCIRuntime::get_HotSpotJVMCIRuntime(CHECK_ABORT);
+ Handle receiver = JVMCIRuntime::get_HotSpotJVMCIRuntime(CHECK_EXIT);
JavaValue method_result(T_OBJECT);
JavaCallArguments args;
@@ -202,23 +202,22 @@
return level;
}
-/**
- * Aborts the VM due to an unexpected exception.
- */
-void JVMCICompiler::abort_on_pending_exception(Handle exception, const char* message, bool dump_core) {
- Thread* THREAD = Thread::current();
+void JVMCICompiler::exit_on_pending_exception(Handle exception, const char* message) {
+ JavaThread* THREAD = JavaThread::current();
CLEAR_PENDING_EXCEPTION;
- java_lang_Throwable::java_printStackTrace(exception, THREAD);
+ static volatile int report_error = 0;
+ if (!report_error && Atomic::cmpxchg(1, &report_error, 0) == 0) {
+ // Only report an error once
+ tty->print_raw_cr(message);
+ java_lang_Throwable::java_printStackTrace(exception, THREAD);
+ } else {
+ // Allow error reporting thread to print the stack trace.
+ os::sleep(THREAD, 200, false);
+ }
- // Give other aborting threads to also print their stack traces.
- // This can be very useful when debugging class initialization
- // failures.
- assert(THREAD->is_Java_thread(), "compiler threads should be Java threads");
- const bool interruptible = true;
- os::sleep(THREAD, 200, interruptible);
-
- vm_abort(dump_core);
+ before_exit(THREAD);
+ vm_exit(-1);
}
// Compilation entry point for methods
--- a/hotspot/src/share/vm/jvmci/jvmciCompiler.hpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/jvmci/jvmciCompiler.hpp Fri Oct 14 11:11:19 2016 -0700
@@ -47,7 +47,10 @@
static elapsedTimer _codeInstallTimer;
- static void abort_on_pending_exception(Handle exception, const char* message, bool dump_core = false);
+ /**
+ * Exits the VM due to an unexpected exception.
+ */
+ static void exit_on_pending_exception(Handle exception, const char* message);
public:
JVMCICompiler();
--- a/hotspot/src/share/vm/jvmci/jvmciCompilerToVM.cpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/jvmci/jvmciCompilerToVM.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -112,7 +112,7 @@
bool CompilerToVM::Data::_supports_inline_contig_alloc;
HeapWord** CompilerToVM::Data::_heap_end_addr;
-HeapWord** CompilerToVM::Data::_heap_top_addr;
+HeapWord* volatile* CompilerToVM::Data::_heap_top_addr;
int CompilerToVM::Data::_max_oop_map_stack_offset;
jbyte* CompilerToVM::Data::cardtable_start_address;
@@ -153,7 +153,7 @@
_supports_inline_contig_alloc = Universe::heap()->supports_inline_contig_alloc();
_heap_end_addr = _supports_inline_contig_alloc ? Universe::heap()->end_addr() : (HeapWord**) -1;
- _heap_top_addr = _supports_inline_contig_alloc ? Universe::heap()->top_addr() : (HeapWord**) -1;
+ _heap_top_addr = _supports_inline_contig_alloc ? Universe::heap()->top_addr() : (HeapWord* volatile*) -1;
_max_oop_map_stack_offset = (OopMapValue::register_mask - VMRegImpl::stack2reg(0)->value()) * VMRegImpl::stack_slot_size;
int max_oop_map_stack_index = _max_oop_map_stack_offset / VMRegImpl::stack_slot_size;
@@ -473,9 +473,20 @@
return (jlong) (address) method->exception_table_start();
C2V_END
-C2V_VMENTRY(jobject, getResolvedJavaMethodAtSlot, (JNIEnv *, jobject, jclass holder_handle, jint slot))
- oop java_class = JNIHandles::resolve(holder_handle);
- Klass* holder = java_lang_Class::as_Klass(java_class);
+C2V_VMENTRY(jobject, asResolvedJavaMethod, (JNIEnv *, jobject, jobject executable_handle))
+ oop executable = JNIHandles::resolve(executable_handle);
+ oop mirror = NULL;
+ int slot = 0;
+
+ if (executable->klass() == SystemDictionary::reflect_Constructor_klass()) {
+ mirror = java_lang_reflect_Constructor::clazz(executable);
+ slot = java_lang_reflect_Constructor::slot(executable);
+ } else {
+ assert(executable->klass() == SystemDictionary::reflect_Method_klass(), "wrong type");
+ mirror = java_lang_reflect_Method::clazz(executable);
+ slot = java_lang_reflect_Method::slot(executable);
+ }
+ Klass* holder = java_lang_Class::as_Klass(mirror);
methodHandle method = InstanceKlass::cast(holder)->method_with_idnum(slot);
oop result = CompilerToVM::get_jvmci_method(method, CHECK_NULL);
return JNIHandles::make_local(THREAD, result);
@@ -1518,6 +1529,17 @@
return size + Deoptimization::last_frame_adjust(0, callee_locals) * BytesPerWord;
C2V_END
+C2V_VMENTRY(void, compileToBytecode, (JNIEnv*, jobject, jobject lambda_form_handle))
+ Handle lambda_form = JNIHandles::resolve_non_null(lambda_form_handle);
+ if (lambda_form->is_a(SystemDictionary::LambdaForm_klass())) {
+ TempNewSymbol compileToBytecode = SymbolTable::new_symbol("compileToBytecode", CHECK);
+ JavaValue result(T_VOID);
+ JavaCalls::call_special(&result, lambda_form, SystemDictionary::LambdaForm_klass(), compileToBytecode, vmSymbols::void_method_signature(), CHECK);
+ } else {
+ THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
+ err_msg("Unexpected type: %s", lambda_form->klass()->external_name()));
+ }
+C2V_END
#define CC (char*) /*cast a literal from (const char*)*/
#define FN_PTR(f) CAST_FROM_FN_PTR(void*, &(c2v_ ## f))
@@ -1525,6 +1547,7 @@
#define STRING "Ljava/lang/String;"
#define OBJECT "Ljava/lang/Object;"
#define CLASS "Ljava/lang/Class;"
+#define EXECUTABLE "Ljava/lang/reflect/Executable;"
#define STACK_TRACE_ELEMENT "Ljava/lang/StackTraceElement;"
#define INSTALLED_CODE "Ljdk/vm/ci/code/InstalledCode;"
#define TARGET_DESCRIPTION "Ljdk/vm/ci/code/TargetDescription;"
@@ -1572,7 +1595,7 @@
{CC "getClassInitializer", CC "(" HS_RESOLVED_KLASS ")" HS_RESOLVED_METHOD, FN_PTR(getClassInitializer)},
{CC "hasFinalizableSubclass", CC "(" HS_RESOLVED_KLASS ")Z", FN_PTR(hasFinalizableSubclass)},
{CC "getMaxCallTargetOffset", CC "(J)J", FN_PTR(getMaxCallTargetOffset)},
- {CC "getResolvedJavaMethodAtSlot", CC "(" CLASS "I)" HS_RESOLVED_METHOD, FN_PTR(getResolvedJavaMethodAtSlot)},
+ {CC "asResolvedJavaMethod", CC "(" EXECUTABLE ")" HS_RESOLVED_METHOD, FN_PTR(asResolvedJavaMethod)},
{CC "getResolvedJavaMethod", CC "(Ljava/lang/Object;J)" HS_RESOLVED_METHOD, FN_PTR(getResolvedJavaMethod)},
{CC "getConstantPool", CC "(Ljava/lang/Object;)" HS_CONSTANT_POOL, FN_PTR(getConstantPool)},
{CC "getResolvedJavaType", CC "(Ljava/lang/Object;JZ)" HS_RESOLVED_KLASS, FN_PTR(getResolvedJavaType)},
@@ -1599,9 +1622,9 @@
{CC "flushDebugOutput", CC "()V", FN_PTR(flushDebugOutput)},
{CC "methodDataProfileDataSize", CC "(JI)I", FN_PTR(methodDataProfileDataSize)},
{CC "interpreterFrameSize", CC "(" BYTECODE_FRAME ")I", FN_PTR(interpreterFrameSize)},
+ {CC "compileToBytecode", CC "(" OBJECT ")V", FN_PTR(compileToBytecode)},
};
int CompilerToVM::methods_count() {
return sizeof(methods) / sizeof(JNINativeMethod);
}
-
--- a/hotspot/src/share/vm/jvmci/jvmciCompilerToVM.hpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/jvmci/jvmciCompilerToVM.hpp Fri Oct 14 11:11:19 2016 -0700
@@ -58,7 +58,7 @@
static bool _supports_inline_contig_alloc;
static HeapWord** _heap_end_addr;
- static HeapWord** _heap_top_addr;
+ static HeapWord* volatile* _heap_top_addr;
static int _max_oop_map_stack_offset;
static jbyte* cardtable_start_address;
--- a/hotspot/src/share/vm/jvmci/jvmciRuntime.cpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/jvmci/jvmciRuntime.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -817,16 +817,6 @@
}
JVM_END
-#define CHECK_WARN_ABORT_(message) THREAD); \
- if (HAS_PENDING_EXCEPTION) { \
- warning(message); \
- char buf[512]; \
- jio_snprintf(buf, 512, "Uncaught exception at %s:%d", __FILE__, __LINE__); \
- JVMCIRuntime::abort_on_pending_exception(PENDING_EXCEPTION, buf); \
- return; \
- } \
- (void)(0
-
void JVMCIRuntime::shutdown(TRAPS) {
if (_HotSpotJVMCIRuntime_instance != NULL) {
_shutdown_called = true;
--- a/hotspot/src/share/vm/jvmci/vmStructs_jvmci.cpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/jvmci/vmStructs_jvmci.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -69,7 +69,7 @@
\
static_field(CompilerToVM::Data, _supports_inline_contig_alloc, bool) \
static_field(CompilerToVM::Data, _heap_end_addr, HeapWord**) \
- static_field(CompilerToVM::Data, _heap_top_addr, HeapWord**) \
+ static_field(CompilerToVM::Data, _heap_top_addr, HeapWord* volatile*) \
\
static_field(CompilerToVM::Data, _max_oop_map_stack_offset, int) \
\
@@ -327,8 +327,11 @@
declare_constant(JVM_ACC_FIELD_INTERNAL) \
declare_constant(JVM_ACC_FIELD_STABLE) \
declare_constant(JVM_ACC_FIELD_HAS_GENERIC_SIGNATURE) \
+ declare_preprocessor_constant("JVM_ACC_VARARGS", JVM_ACC_VARARGS) \
+ declare_preprocessor_constant("JVM_ACC_BRIDGE", JVM_ACC_BRIDGE) \
+ declare_preprocessor_constant("JVM_ACC_ANNOTATION", JVM_ACC_ANNOTATION) \
+ declare_preprocessor_constant("JVM_ACC_ENUM", JVM_ACC_ENUM) \
declare_preprocessor_constant("JVM_ACC_SYNTHETIC", JVM_ACC_SYNTHETIC) \
- declare_preprocessor_constant("JVM_RECOGNIZED_FIELD_MODIFIERS", JVM_RECOGNIZED_FIELD_MODIFIERS) \
\
declare_constant(JVM_CONSTANT_Utf8) \
declare_constant(JVM_CONSTANT_Unicode) \
@@ -660,7 +663,8 @@
#define VM_LONG_CONSTANTS_CPU(declare_constant, declare_preprocessor_constant, declare_c1_constant, declare_c2_constant, declare_c2_preprocessor_constant) \
declare_preprocessor_constant("VM_Version::CPU_AVX512BW", CPU_AVX512BW) \
declare_preprocessor_constant("VM_Version::CPU_AVX512VL", CPU_AVX512VL) \
- declare_preprocessor_constant("VM_Version::CPU_SHA", CPU_SHA)
+ declare_preprocessor_constant("VM_Version::CPU_SHA", CPU_SHA) \
+ declare_preprocessor_constant("VM_Version::CPU_FMA", CPU_FMA)
#endif
--- a/hotspot/src/share/vm/memory/filemap.cpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/memory/filemap.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -179,6 +179,7 @@
_classpath_entry_table_size = mapinfo->_classpath_entry_table_size;
_classpath_entry_table = mapinfo->_classpath_entry_table;
_classpath_entry_size = mapinfo->_classpath_entry_size;
+ _num_patch_mod_prefixes = ClassLoader::num_patch_mod_prefixes();
// The following fields are for sanity checks for whether this archive
// will function correctly with this JVM and the bootclasspath it's
@@ -911,11 +912,6 @@
return false;
}
- if (Arguments::get_patch_mod_prefix() != NULL) {
- FileMapInfo::fail_continue("The shared archive file cannot be used with --patch-module.");
- return false;
- }
-
if (!Arguments::has_jimage()) {
FileMapInfo::fail_continue("The shared archive file cannot be used with an exploded module build.");
return false;
@@ -952,6 +948,23 @@
return false;
}
+ // Check if there is a mismatch in --patch-module entry counts between dump time and run time.
+ // More checks will be performed on individual --patch-module entry in the
+ // SharedPathsMiscInfo::check() function.
+ GrowableArray<ModulePatchPath*>* patch_mod_args = Arguments::get_patch_mod_prefix();
+ if (patch_mod_args != NULL) {
+ if (_num_patch_mod_prefixes == 0) {
+ FileMapInfo::fail_stop("--patch-module found in run time but none was specified in dump time");
+ }
+ if (patch_mod_args->length() != _num_patch_mod_prefixes) {
+ FileMapInfo::fail_stop("mismatched --patch-module entry counts between dump time and run time");
+ }
+ } else {
+ if (_num_patch_mod_prefixes > 0) {
+ FileMapInfo::fail_stop("--patch-module specified in dump time but none was specified in run time");
+ }
+ }
+
return true;
}
--- a/hotspot/src/share/vm/memory/filemap.hpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/memory/filemap.hpp Fri Oct 14 11:11:19 2016 -0700
@@ -155,6 +155,7 @@
// loading failures during runtime.
int _classpath_entry_table_size;
size_t _classpath_entry_size;
+ int _num_patch_mod_prefixes; // number of --patch-module entries
SharedClassPathEntry* _classpath_entry_table;
char* region_addr(int idx);
--- a/hotspot/src/share/vm/oops/arrayOop.cpp Fri Oct 14 19:12:37 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,62 +0,0 @@
-/*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please 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 "oops/arrayOop.hpp"
-#include "oops/oop.inline.hpp"
-#include "utilities/globalDefinitions.hpp"
-
-bool arrayOopDesc::check_max_length_overflow(BasicType type) {
- julong length = max_array_length(type);
- julong bytes_per_element = type2aelembytes(type);
- julong bytes = length * bytes_per_element + header_size_in_bytes();
- return (julong)(size_t)bytes == bytes;
-}
-
-static void test_max_array_length() {
- assert(arrayOopDesc::check_max_length_overflow(T_BOOLEAN), "size_t overflow for boolean array");
- assert(arrayOopDesc::check_max_length_overflow(T_CHAR), "size_t overflow for char array");
- assert(arrayOopDesc::check_max_length_overflow(T_FLOAT), "size_t overflow for float array");
- assert(arrayOopDesc::check_max_length_overflow(T_DOUBLE), "size_t overflow for double array");
- assert(arrayOopDesc::check_max_length_overflow(T_BYTE), "size_t overflow for byte array");
- assert(arrayOopDesc::check_max_length_overflow(T_SHORT), "size_t overflow for short array");
- assert(arrayOopDesc::check_max_length_overflow(T_INT), "size_t overflow for int array");
- assert(arrayOopDesc::check_max_length_overflow(T_LONG), "size_t overflow for long array");
- assert(arrayOopDesc::check_max_length_overflow(T_OBJECT), "size_t overflow for object array");
- assert(arrayOopDesc::check_max_length_overflow(T_ARRAY), "size_t overflow for array array");
- assert(arrayOopDesc::check_max_length_overflow(T_NARROWOOP), "size_t overflow for narrowOop array");
-
- // T_VOID and T_ADDRESS are not supported by max_array_length()
-}
-
-void arrayOopDesc_test() {
- test_max_array_length();
-}
-
-#endif //PRODUCT
--- a/hotspot/src/share/vm/oops/arrayOop.hpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/oops/arrayOop.hpp Fri Oct 14 11:11:19 2016 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -41,6 +41,7 @@
class arrayOopDesc : public oopDesc {
friend class VMStructs;
+ friend class arrayOopDescTest;
// Interpreter/Compiler offsets
@@ -124,10 +125,6 @@
return (int32_t)max_elements_per_size_t;
}
-// for unit testing
-#ifndef PRODUCT
- static bool check_max_length_overflow(BasicType type);
-#endif
};
#endif // SHARE_VM_OOPS_ARRAYOOP_HPP
--- a/hotspot/src/share/vm/oops/instanceKlass.cpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/oops/instanceKlass.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -517,7 +517,11 @@
bool InstanceKlass::link_class_impl(
instanceKlassHandle this_k, bool throw_verifyerror, TRAPS) {
- // check for error state
+ // check for error state.
+ // This is checking for the wrong state. If the state is initialization_error,
+ // then this class *was* linked. The CDS code does a try_link_class and uses
+ // initialization_error to mark classes to not include in the archive during
+ // DumpSharedSpaces. This should be removed when the CDS bug is fixed.
if (this_k->is_in_error_state()) {
ResourceMark rm(THREAD);
THROW_MSG_(vmSymbols::java_lang_NoClassDefFoundError(),
@@ -670,36 +674,21 @@
// Eagerly initialize superinterfaces that declare default methods (concrete instance: any access)
void InstanceKlass::initialize_super_interfaces(instanceKlassHandle this_k, TRAPS) {
- if (this_k->has_default_methods()) {
- for (int i = 0; i < this_k->local_interfaces()->length(); ++i) {
- Klass* iface = this_k->local_interfaces()->at(i);
- InstanceKlass* ik = InstanceKlass::cast(iface);
- if (ik->should_be_initialized()) {
- if (ik->has_default_methods()) {
- ik->initialize_super_interfaces(ik, THREAD);
- }
- // Only initialize() interfaces that "declare" concrete methods.
- // has_default_methods drives searching superinterfaces since it
- // means has_default_methods in its superinterface hierarchy
- if (!HAS_PENDING_EXCEPTION && ik->declares_default_methods()) {
- ik->initialize(THREAD);
- }
- if (HAS_PENDING_EXCEPTION) {
- Handle e(THREAD, PENDING_EXCEPTION);
- CLEAR_PENDING_EXCEPTION;
- {
- EXCEPTION_MARK;
- // Locks object, set state, and notify all waiting threads
- this_k->set_initialization_state_and_notify(
- initialization_error, THREAD);
-
- // ignore any exception thrown, superclass initialization error is
- // thrown below
- CLEAR_PENDING_EXCEPTION;
- }
- THROW_OOP(e());
- }
- }
+ assert (this_k->has_default_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()) {
+ ik->initialize_super_interfaces(ik, CHECK);
+ }
+
+ // Only initialize() interfaces that "declare" concrete methods.
+ if (ik->should_be_initialized() && ik->declares_default_methods()) {
+ ik->initialize(CHECK);
}
}
}
@@ -765,32 +754,36 @@
}
// Step 7
- Klass* super_klass = this_k->super();
- if (super_klass != NULL && !this_k->is_interface() && super_klass->should_be_initialized()) {
- super_klass->initialize(THREAD);
-
+ // Next, if C is a class rather than an interface, initialize it's super class and super
+ // interfaces.
+ if (!this_k->is_interface()) {
+ Klass* super_klass = this_k->super();
+ 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,
+ // 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()) {
+ this_k->initialize_super_interfaces(this_k, THREAD);
+ }
+
+ // If any exceptions, complete abruptly, throwing the same exception as above.
if (HAS_PENDING_EXCEPTION) {
Handle e(THREAD, PENDING_EXCEPTION);
CLEAR_PENDING_EXCEPTION;
{
EXCEPTION_MARK;
- this_k->set_initialization_state_and_notify(initialization_error, THREAD); // Locks object, set state, and notify all waiting threads
- CLEAR_PENDING_EXCEPTION; // ignore any exception thrown, superclass initialization error is thrown below
+ // Locks object, set state, and notify all waiting threads
+ this_k->set_initialization_state_and_notify(initialization_error, THREAD);
+ CLEAR_PENDING_EXCEPTION;
}
DTRACE_CLASSINIT_PROBE_WAIT(super__failed, this_k(), -1,wait);
THROW_OOP(e());
}
}
- // If C is an interface that declares a non-abstract, non-static method,
- // the initialization of a class (not an interface) that implements C directly or
- // indirectly.
- // Recursively initialize any superinterfaces that declare default methods
- // Only need to recurse if has_default_methods which includes declaring and
- // inheriting default methods
- if (!this_k->is_interface() && this_k->has_default_methods()) {
- this_k->initialize_super_interfaces(this_k, CHECK);
- }
// Step 8
{
@@ -852,10 +845,15 @@
void InstanceKlass::set_initialization_state_and_notify_impl(instanceKlassHandle this_k, ClassState state, TRAPS) {
oop init_lock = this_k->init_lock();
- ObjectLocker ol(init_lock, THREAD, init_lock != NULL);
- this_k->set_init_state(state);
- this_k->fence_and_clear_init_lock();
- ol.notify_all(CHECK);
+ if (init_lock != NULL) {
+ ObjectLocker ol(init_lock, THREAD);
+ this_k->set_init_state(state);
+ this_k->fence_and_clear_init_lock();
+ ol.notify_all(CHECK);
+ } else {
+ assert(init_lock != NULL, "The initialization state should never be set twice");
+ this_k->set_init_state(state);
+ }
}
// The embedded _implementor field can only record one implementor.
--- a/hotspot/src/share/vm/oops/klass.cpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/oops/klass.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -734,27 +734,3 @@
}
#endif
-
-/////////////// Unit tests ///////////////
-
-#ifndef PRODUCT
-
-class TestKlass {
- public:
- static void test_oop_is_instanceClassLoader() {
- Klass* klass = SystemDictionary::ClassLoader_klass();
- guarantee(klass->is_instance_klass(), "assert");
- guarantee(InstanceKlass::cast(klass)->is_class_loader_instance_klass(), "test failed");
-
- klass = SystemDictionary::String_klass();
- guarantee(!klass->is_instance_klass() ||
- !InstanceKlass::cast(klass)->is_class_loader_instance_klass(),
- "test failed");
- }
-};
-
-void TestKlass_test() {
- TestKlass::test_oop_is_instanceClassLoader();
-}
-
-#endif // PRODUCT
--- a/hotspot/src/share/vm/oops/oop.hpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/oops/oop.hpp Fri Oct 14 11:11:19 2016 -0700
@@ -83,6 +83,7 @@
inline Klass* klass() const;
inline Klass* klass_or_null() const volatile;
+ inline Klass* klass_or_null_acquire() const volatile;
inline Klass** klass_addr();
inline narrowKlass* compressed_klass_addr();
--- a/hotspot/src/share/vm/oops/oop.inline.hpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/oops/oop.inline.hpp Fri Oct 14 11:11:19 2016 -0700
@@ -109,7 +109,6 @@
}
Klass* oopDesc::klass_or_null() const volatile {
- // can be NULL in CMS
if (UseCompressedClassPointers) {
return Klass::decode_klass(_metadata._compressed_klass);
} else {
@@ -117,6 +116,17 @@
}
}
+Klass* oopDesc::klass_or_null_acquire() const volatile {
+ if (UseCompressedClassPointers) {
+ // Workaround for non-const load_acquire parameter.
+ const volatile narrowKlass* addr = &_metadata._compressed_klass;
+ volatile narrowKlass* xaddr = const_cast<volatile narrowKlass*>(addr);
+ return Klass::decode_klass(OrderAccess::load_acquire(xaddr));
+ } else {
+ return (Klass*)OrderAccess::load_ptr_acquire(&_metadata._klass);
+ }
+}
+
Klass** oopDesc::klass_addr() {
// Only used internally and with CMS and will not work with
// UseCompressedOops
--- a/hotspot/src/share/vm/opto/c2compiler.cpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/opto/c2compiler.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -416,6 +416,12 @@
case vmIntrinsics::_onSpinWait:
if (!Matcher::match_rule_supported(Op_OnSpinWait)) return false;
break;
+ case vmIntrinsics::_fmaD:
+ if (!UseFMA || !Matcher::match_rule_supported(Op_FmaD)) return false;
+ break;
+ case vmIntrinsics::_fmaF:
+ if (!UseFMA || !Matcher::match_rule_supported(Op_FmaF)) return false;
+ break;
case vmIntrinsics::_hashCode:
case vmIntrinsics::_identityHashCode:
case vmIntrinsics::_getClass:
--- a/hotspot/src/share/vm/opto/classes.hpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/opto/classes.hpp Fri Oct 14 11:11:19 2016 -0700
@@ -151,6 +151,8 @@
macro(EncodePKlass)
macro(FastLock)
macro(FastUnlock)
+macro(FmaD)
+macro(FmaF)
macro(Goto)
macro(Halt)
macro(HasNegatives)
--- a/hotspot/src/share/vm/opto/library_call.cpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/opto/library_call.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -320,6 +320,7 @@
bool inline_montgomeryMultiply();
bool inline_montgomerySquare();
bool inline_vectorizedMismatch();
+ bool inline_fma(vmIntrinsics::ID id);
bool inline_profileBoolean();
bool inline_isCompileConstant();
@@ -829,6 +830,10 @@
case vmIntrinsics::_hasNegatives:
return inline_hasNegatives();
+ case vmIntrinsics::_fmaD:
+ case vmIntrinsics::_fmaF:
+ return inline_fma(intrinsic_id());
+
default:
// If you get here, it may be that someone has added a new intrinsic
// to the list in vmSymbols.hpp without implementing it here.
@@ -6698,6 +6703,35 @@
return instof_false; // even if it is NULL
}
+//-------------inline_fma-----------------------------------
+bool LibraryCallKit::inline_fma(vmIntrinsics::ID id) {
+ Node *a = NULL;
+ Node *b = NULL;
+ Node *c = NULL;
+ Node* result = NULL;
+ switch (id) {
+ case vmIntrinsics::_fmaD:
+ assert(callee()->signature()->size() == 6, "fma has 3 parameters of size 2 each.");
+ // no receiver since it is static method
+ a = round_double_node(argument(0));
+ b = round_double_node(argument(2));
+ c = round_double_node(argument(4));
+ result = _gvn.transform(new FmaDNode(control(), a, b, c));
+ break;
+ case vmIntrinsics::_fmaF:
+ assert(callee()->signature()->size() == 3, "fma has 3 parameters of size 1 each.");
+ a = argument(0);
+ b = argument(1);
+ c = argument(2);
+ result = _gvn.transform(new FmaFNode(control(), a, b, c));
+ break;
+ default:
+ fatal_unexpected_iid(id); break;
+ }
+ set_result(result);
+ return true;
+}
+
bool LibraryCallKit::inline_profileBoolean() {
Node* counts = argument(1);
const TypeAryPtr* ary = NULL;
--- a/hotspot/src/share/vm/opto/matcher.cpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/opto/matcher.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -2117,6 +2117,8 @@
case Op_StrInflatedCopy:
case Op_StrCompressedCopy:
case Op_EncodeISOArray:
+ case Op_FmaD:
+ case Op_FmaF:
set_shared(n); // Force result into register (it will be anyways)
break;
case Op_ConP: { // Convert pointers above the centerline to NUL
@@ -2305,6 +2307,15 @@
n->del_req(4);
break;
}
+ case Op_FmaD:
+ case Op_FmaF: {
+ // Restructure into a binary tree for Matching.
+ Node* pair = new BinaryNode(n->in(1), n->in(2));
+ n->set_req(2, pair);
+ n->set_req(1, n->in(3));
+ n->del_req(3);
+ break;
+ }
default:
break;
}
--- a/hotspot/src/share/vm/opto/mulnode.cpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/opto/mulnode.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -1343,3 +1343,47 @@
return TypeLong::LONG; // Give up
}
+
+//=============================================================================
+//------------------------------Value------------------------------------------
+const Type* FmaDNode::Value(PhaseGVN* phase) const {
+ const Type *t1 = phase->type(in(1));
+ if (t1 == Type::TOP) return Type::TOP;
+ if (t1->base() != Type::DoubleCon) return Type::DOUBLE;
+ const Type *t2 = phase->type(in(2));
+ if (t2 == Type::TOP) return Type::TOP;
+ if (t2->base() != Type::DoubleCon) return Type::DOUBLE;
+ const Type *t3 = phase->type(in(3));
+ if (t3 == Type::TOP) return Type::TOP;
+ if (t3->base() != Type::DoubleCon) return Type::DOUBLE;
+#ifndef __STDC_IEC_559__
+ return Type::DOUBLE;
+#else
+ double d1 = t1->getd();
+ double d2 = t2->getd();
+ double d3 = t3->getd();
+ return TypeD::make(fma(d1, d2, d3));
+#endif
+}
+
+//=============================================================================
+//------------------------------Value------------------------------------------
+const Type* FmaFNode::Value(PhaseGVN* phase) const {
+ const Type *t1 = phase->type(in(1));
+ if (t1 == Type::TOP) return Type::TOP;
+ if (t1->base() != Type::FloatCon) return Type::FLOAT;
+ const Type *t2 = phase->type(in(2));
+ if (t2 == Type::TOP) return Type::TOP;
+ if (t2->base() != Type::FloatCon) return Type::FLOAT;
+ const Type *t3 = phase->type(in(3));
+ if (t3 == Type::TOP) return Type::TOP;
+ if (t3->base() != Type::FloatCon) return Type::FLOAT;
+#ifndef __STDC_IEC_559__
+ return Type::FLOAT;
+#else
+ float f1 = t1->getf();
+ float f2 = t2->getf();
+ float f3 = t3->getf();
+ return TypeF::make(fma(f1, f2, f3));
+#endif
+}
--- a/hotspot/src/share/vm/opto/mulnode.hpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/opto/mulnode.hpp Fri Oct 14 11:11:19 2016 -0700
@@ -263,4 +263,26 @@
virtual uint ideal_reg() const { return Op_RegL; }
};
+//------------------------------FmaDNode--------------------------------------
+// fused-multiply-add double
+class FmaDNode : public Node {
+public:
+ FmaDNode(Node *c, Node *in1, Node *in2, Node *in3) : Node(c, in1, in2, in3) {}
+ virtual int Opcode() const;
+ const Type *bottom_type() const { return Type::DOUBLE; }
+ virtual uint ideal_reg() const { return Op_RegD; }
+ virtual const Type* Value(PhaseGVN* phase) const;
+};
+
+//------------------------------FmaFNode--------------------------------------
+// fused-multiply-add float
+class FmaFNode : public Node {
+public:
+ FmaFNode(Node *c, Node *in1, Node *in2, Node *in3) : Node(c, in1, in2, in3) {}
+ virtual int Opcode() const;
+ const Type *bottom_type() const { return Type::FLOAT; }
+ virtual uint ideal_reg() const { return Op_RegF; }
+ virtual const Type* Value(PhaseGVN* phase) const;
+};
+
#endif // SHARE_VM_OPTO_MULNODE_HPP
--- a/hotspot/src/share/vm/prims/jvm.cpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/prims/jvm.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -562,8 +562,8 @@
}
Handle stackStream_h(THREAD, JNIHandles::resolve_non_null(stackStream));
- return StackWalk::moreFrames(stackStream_h, mode, anchor, frame_count,
- start_index, frames_array_h, THREAD);
+ return StackWalk::fetchNextBatch(stackStream_h, mode, anchor, frame_count,
+ start_index, frames_array_h, THREAD);
JVM_END
JVM_ENTRY(void, JVM_ToStackTraceElement(JNIEnv *env, jobject frame, jobject stack))
--- a/hotspot/src/share/vm/prims/jvmti.xml Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/prims/jvmti.xml Fri Oct 14 11:11:19 2016 -0700
@@ -21,7 +21,6 @@
Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
or visit www.oracle.com if you need additional information or have any
questions.
-
-->
<!DOCTYPE specification [
--- a/hotspot/src/share/vm/prims/jvmtiEnter.xsl Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/prims/jvmtiEnter.xsl Fri Oct 14 11:11:19 2016 -0700
@@ -487,8 +487,8 @@
</xsl:text>
<xsl:if test="$trace='Trace'">
<xsl:text> if (trace_flags) {
- log_trace(jvmti)("[-] %s %s", func_name,
- JvmtiUtil::error_name(JVMTI_ERROR_WRONG_PHASE));
+ log_trace(jvmti)("[-] %s %s(%d)", func_name,
+ JvmtiUtil::error_name(JVMTI_ERROR_WRONG_PHASE), JvmtiEnv::get_phase());
}
</xsl:text>
</xsl:if>
--- a/hotspot/src/share/vm/prims/jvmtiH.xsl Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/prims/jvmtiH.xsl Fri Oct 14 11:11:19 2016 -0700
@@ -95,7 +95,7 @@
</xsl:template>
<xsl:template name="intro">
- <xsl:call-template name="includeHeader"/>
+ <xsl:call-template name="include_GPL_CP_Header"/>
<xsl:text>
/* Include file for the Java(tm) Virtual Machine Tool Interface */
--- a/hotspot/src/share/vm/prims/jvmtiLib.xsl Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/prims/jvmtiLib.xsl Fri Oct 14 11:11:19 2016 -0700
@@ -43,13 +43,56 @@
<xsl:call-template name="microversion"/>
</xsl:template>
+ <xsl:variable name="GPL_header">
+ <!-- The Copyright comment from jvmti.xml -->
+ <xsl:value-of select="/comment()[position()=1]"/>
+ </xsl:variable>
+
+ <xsl:variable name="GPL_CP_header_body">
+ <xsl:text> * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
</xsl:text>
+ <xsl:text> *
</xsl:text>
+ <xsl:text> * This code is free software; you can redistribute it and/or modify it
</xsl:text>
+ <xsl:text> * under the terms of the GNU General Public License version 2 only, as
</xsl:text>
+ <xsl:text> * published by the Free Software Foundation. Oracle designates this
</xsl:text>
+ <xsl:text> * particular file as subject to the "Classpath" exception as provided
</xsl:text>
+ <xsl:text> * by Oracle in the LICENSE file that accompanied this code.
</xsl:text>
+ <xsl:text> *
</xsl:text>
+ <xsl:text> * This code is distributed in the hope that it will be useful, but WITHOUT
</xsl:text>
+ <xsl:text> * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
</xsl:text>
+ <xsl:text> * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
</xsl:text>
+ <xsl:text> * version 2 for more details (a copy is included in the LICENSE file that
</xsl:text>
+ <xsl:text> * accompanied this code).
</xsl:text>
+ <xsl:text> *
</xsl:text>
+ <xsl:text> * You should have received a copy of the GNU General Public License version
</xsl:text>
+ <xsl:text> * 2 along with this work; if not, write to the Free Software Foundation,
</xsl:text>
+ <xsl:text> * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
</xsl:text>
+ <xsl:text> *
</xsl:text>
+ <xsl:text> * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
</xsl:text>
+ <xsl:text> * or visit www.oracle.com if you need additional information or have any
</xsl:text>
+ <xsl:text> * questions.
</xsl:text>
+ </xsl:variable>
+
<xsl:template name="copyrightComment">
<xsl:text>/*</xsl:text>
- <!-- Copy the Copyright comment from jvmti.xml -->
- <xsl:value-of select="/comment()[position()=1]"/>
+ <!-- The Copyright comment from jvmti.xml -->
+ <xsl:value-of select="$GPL_header"/>
<xsl:text> */

</xsl:text>
</xsl:template>
+ <xsl:template name="GPL_CP_copyrightComment">
+ <xsl:text>/*
 *</xsl:text>
+ <!-- The Copyright year from jvmti.xml -->
+ <xsl:value-of select="substring-after(substring-before($GPL_header, ' DO NOT ALTER'), '
')"/>
+ <!-- The GPL+CP Copyright header body -->
+ <xsl:value-of select="$GPL_CP_header_body"/>
+ <xsl:text> */

</xsl:text>
+ </xsl:template>
+
+ <xsl:template name="include_GPL_CP_Header">
+ <xsl:call-template name="GPL_CP_copyrightComment"/>
+ <xsl:text> /* AUTOMATICALLY GENERATED FILE - DO NOT EDIT */
</xsl:text>
+ </xsl:template>
+
<xsl:template name="includeHeader">
<xsl:call-template name="copyrightComment"/>
<xsl:text> /* AUTOMATICALLY GENERATED FILE - DO NOT EDIT */
</xsl:text>
--- a/hotspot/src/share/vm/prims/stackwalk.cpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/prims/stackwalk.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -37,42 +37,47 @@
#include "utilities/globalDefinitions.hpp"
// setup and cleanup actions
-void JavaFrameStream::setup_magic_on_entry(objArrayHandle frames_array) {
+void BaseFrameStream::setup_magic_on_entry(objArrayHandle frames_array) {
frames_array->obj_at_put(magic_pos, _thread->threadObj());
_anchor = address_value();
assert(check_magic(frames_array), "invalid magic");
}
-bool JavaFrameStream::check_magic(objArrayHandle frames_array) {
+bool BaseFrameStream::check_magic(objArrayHandle frames_array) {
oop m1 = frames_array->obj_at(magic_pos);
jlong m2 = _anchor;
if (m1 == _thread->threadObj() && m2 == address_value()) return true;
return false;
}
-bool JavaFrameStream::cleanup_magic_on_exit(objArrayHandle frames_array) {
+bool BaseFrameStream::cleanup_magic_on_exit(objArrayHandle frames_array) {
bool ok = check_magic(frames_array);
frames_array->obj_at_put(magic_pos, NULL);
_anchor = 0L;
return ok;
}
-// Returns JavaFrameStream for the current stack being traversed.
+JavaFrameStream::JavaFrameStream(JavaThread* thread, int mode)
+ : BaseFrameStream(thread), _vfst(thread) {
+ _need_method_info = StackWalk::need_method_info(mode);
+}
+
+// Returns the BaseFrameStream for the current stack being traversed.
//
// Parameters:
// thread Current Java thread.
// magic Magic value used for each stack walking
// frames_array User-supplied buffers. The 0th element is reserved
-// to this JavaFrameStream to use
+// for this BaseFrameStream to use
//
-JavaFrameStream* JavaFrameStream::from_current(JavaThread* thread, jlong magic,
+BaseFrameStream* BaseFrameStream::from_current(JavaThread* thread, jlong magic,
objArrayHandle frames_array)
{
assert(thread != NULL && thread->is_Java_thread(), "");
oop m1 = frames_array->obj_at(magic_pos);
if (m1 != thread->threadObj()) return NULL;
if (magic == 0L) return NULL;
- JavaFrameStream* stream = (JavaFrameStream*) (intptr_t) magic;
+ BaseFrameStream* stream = (BaseFrameStream*) (intptr_t) magic;
if (!stream->is_valid_in(thread, frames_array)) return NULL;
return stream;
}
@@ -85,7 +90,7 @@
//
// Parameters:
// mode Restrict which frames to be decoded.
-// JavaFrameStream stream of javaVFrames
+// BaseFrameStream stream of frames
// max_nframes Maximum number of frames to be filled.
// start_index Start index to the user-supplied buffers.
// frames_array Buffer to store Class or StackFrame in, starting at start_index.
@@ -96,7 +101,7 @@
//
// Returns the number of frames whose information was transferred into the buffers.
//
-int StackWalk::fill_in_frames(jlong mode, JavaFrameStream& stream,
+int StackWalk::fill_in_frames(jlong mode, BaseFrameStream& stream,
int max_nframes, int start_index,
objArrayHandle frames_array,
int& end_index, TRAPS) {
@@ -110,7 +115,6 @@
int frames_decoded = 0;
for (; !stream.at_end(); stream.next()) {
Method* method = stream.method();
- int bci = stream.bci();
if (method == NULL) continue;
@@ -129,35 +133,42 @@
int index = end_index++;
if (TraceStackWalk) {
tty->print(" %d: frame method: ", index); method->print_short_name();
- tty->print_cr(" bci=%d", bci);
+ tty->print_cr(" bci=%d", stream.bci());
}
+ if (!need_method_info(mode) && get_caller_class(mode) &&
+ index == start_index && method->caller_sensitive()) {
+ ResourceMark rm(THREAD);
+ THROW_MSG_0(vmSymbols::java_lang_UnsupportedOperationException(),
+ err_msg("StackWalker::getCallerClass called from @CallerSensitive %s method",
+ method->name_and_sig_as_C_string()));
+ }
// fill in StackFrameInfo and initialize MemberName
- if (live_frame_info(mode)) {
- assert (use_frames_array(mode), "Bad mode for get live frame");
- Handle stackFrame(frames_array->obj_at(index));
- fill_live_stackframe(stackFrame, method, bci, stream.java_frame(), CHECK_0);
- } else if (need_method_info(mode)) {
- assert (use_frames_array(mode), "Bad mode for get stack frame");
- Handle stackFrame(frames_array->obj_at(index));
- fill_stackframe(stackFrame, method, bci);
- } else {
- assert (use_frames_array(mode) == false, "Bad mode for filling in Class object");
- if (get_caller_class(mode) && index == start_index && method->caller_sensitive()) {
- ResourceMark rm(THREAD);
- THROW_MSG_0(vmSymbols::java_lang_UnsupportedOperationException(),
- err_msg("StackWalker::getCallerClass called from @CallerSensitive %s method",
- method->name_and_sig_as_C_string()));
- }
-
- frames_array->obj_at_put(index, method->method_holder()->java_mirror());
- }
+ stream.fill_frame(index, frames_array, method, CHECK_0);
if (++frames_decoded >= max_nframes) break;
}
return frames_decoded;
}
-static oop create_primitive_value_instance(StackValueCollection* values, int i, TRAPS) {
+// Fill in the LiveStackFrameInfo at the given index in frames_array
+void LiveFrameStream::fill_frame(int index, objArrayHandle frames_array,
+ const methodHandle& method, TRAPS) {
+ Handle stackFrame(THREAD, frames_array->obj_at(index));
+ fill_live_stackframe(stackFrame, method, CHECK);
+}
+
+// Fill in the StackFrameInfo at the given index in frames_array
+void JavaFrameStream::fill_frame(int index, objArrayHandle frames_array,
+ const methodHandle& method, TRAPS) {
+ if (_need_method_info) {
+ Handle stackFrame(THREAD, frames_array->obj_at(index));
+ fill_stackframe(stackFrame, method);
+ } else {
+ frames_array->obj_at_put(index, method->method_holder()->java_mirror());
+ }
+}
+
+oop LiveFrameStream::create_primitive_value_instance(StackValueCollection* values, int i, TRAPS) {
Klass* k = SystemDictionary::resolve_or_null(vmSymbols::java_lang_LiveStackFrameInfo(), CHECK_NULL);
instanceKlassHandle ik (THREAD, k);
@@ -228,7 +239,7 @@
return (instanceOop) result.get_jobject();
}
-static objArrayHandle values_to_object_array(StackValueCollection* values, TRAPS) {
+objArrayHandle LiveFrameStream::values_to_object_array(StackValueCollection* values, TRAPS) {
objArrayHandle empty;
int length = values->size();
objArrayOop array_oop = oopFactory::new_objArray(SystemDictionary::Object_klass(),
@@ -243,7 +254,7 @@
return array_h;
}
-static objArrayHandle monitors_to_object_array(GrowableArray<MonitorInfo*>* monitors, TRAPS) {
+objArrayHandle LiveFrameStream::monitors_to_object_array(GrowableArray<MonitorInfo*>* monitors, TRAPS) {
int length = monitors->length();
objArrayOop array_oop = oopFactory::new_objArray(SystemDictionary::Object_klass(),
length, CHECK_(objArrayHandle()));
@@ -256,19 +267,19 @@
}
// Fill StackFrameInfo with declaringClass and bci and initialize memberName
-void StackWalk::fill_stackframe(Handle stackFrame, const methodHandle& method, int bci) {
+void BaseFrameStream::fill_stackframe(Handle stackFrame, const methodHandle& method) {
java_lang_StackFrameInfo::set_declaringClass(stackFrame(), method->method_holder()->java_mirror());
- java_lang_StackFrameInfo::set_method_and_bci(stackFrame(), method, bci);
+ java_lang_StackFrameInfo::set_method_and_bci(stackFrame(), method, bci());
}
// Fill LiveStackFrameInfo with locals, monitors, and expressions
-void StackWalk::fill_live_stackframe(Handle stackFrame, const methodHandle& method,
- int bci, javaVFrame* jvf, TRAPS) {
- fill_stackframe(stackFrame, method, bci);
- if (jvf != NULL) {
- StackValueCollection* locals = jvf->locals();
- StackValueCollection* expressions = jvf->expressions();
- GrowableArray<MonitorInfo*>* monitors = jvf->monitors();
+void LiveFrameStream::fill_live_stackframe(Handle stackFrame,
+ const methodHandle& method, TRAPS) {
+ fill_stackframe(stackFrame, method);
+ if (_jvf != NULL) {
+ StackValueCollection* locals = _jvf->locals();
+ StackValueCollection* expressions = _jvf->expressions();
+ GrowableArray<MonitorInfo*>* monitors = _jvf->monitors();
if (!locals->is_empty()) {
objArrayHandle locals_h = values_to_object_array(locals, CHECK);
@@ -315,15 +326,28 @@
THROW_MSG_(vmSymbols::java_lang_NullPointerException(), "frames_array is NULL", NULL);
}
- Klass* stackWalker_klass = SystemDictionary::StackWalker_klass();
- Klass* abstractStackWalker_klass = SystemDictionary::AbstractStackWalker_klass();
+ // Setup traversal onto my stack.
+ if (live_frame_info(mode)) {
+ assert (use_frames_array(mode), "Bad mode for get live frame");
+ RegisterMap regMap(jt, true);
+ LiveFrameStream stream(jt, ®Map);
+ return fetchFirstBatch(stream, stackStream, mode, skip_frames, frame_count,
+ start_index, frames_array, THREAD);
+ } else {
+ JavaFrameStream stream(jt, mode);
+ return fetchFirstBatch(stream, stackStream, mode, skip_frames, frame_count,
+ start_index, frames_array, THREAD);
+ }
+}
+oop StackWalk::fetchFirstBatch(BaseFrameStream& stream, Handle stackStream,
+ jlong mode, int skip_frames, int frame_count,
+ int start_index, objArrayHandle frames_array, TRAPS) {
methodHandle m_doStackWalk(THREAD, Universe::do_stack_walk_method());
- // Setup traversal onto my stack.
- RegisterMap regMap(jt, true);
- JavaFrameStream stream(jt, ®Map);
{
+ Klass* stackWalker_klass = SystemDictionary::StackWalker_klass();
+ Klass* abstractStackWalker_klass = SystemDictionary::AbstractStackWalker_klass();
while (!stream.at_end()) {
InstanceKlass* ik = stream.method()->method_holder();
if (ik != stackWalker_klass &&
@@ -341,10 +365,7 @@
// 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->print_cr(" frame id: " PTR_FORMAT " pc: " PTR_FORMAT,
- p2i(stream.java_frame()->fr().id()),
- p2i(stream.java_frame()->fr().pc()));
+ tty->print(" skip "); stream.method()->print_short_name(); tty->cr();
}
}
}
@@ -402,13 +423,13 @@
//
// Returns the end index of frame filled in the buffer.
//
-jint StackWalk::moreFrames(Handle stackStream, jlong mode, jlong magic,
- int frame_count, int start_index,
- objArrayHandle frames_array,
- TRAPS)
+jint StackWalk::fetchNextBatch(Handle stackStream, jlong mode, jlong magic,
+ int frame_count, int start_index,
+ objArrayHandle frames_array,
+ TRAPS)
{
JavaThread* jt = (JavaThread*)THREAD;
- JavaFrameStream* existing_stream = JavaFrameStream::from_current(jt, magic, frames_array);
+ BaseFrameStream* existing_stream = BaseFrameStream::from_current(jt, magic, frames_array);
if (existing_stream == NULL) {
THROW_MSG_(vmSymbols::java_lang_InternalError(), "doStackWalk: corrupted buffers", 0L);
}
@@ -418,7 +439,7 @@
}
if (TraceStackWalk) {
- tty->print_cr("StackWalk::moreFrames frame_count %d existing_stream " PTR_FORMAT " start %d frames %d",
+ 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());
}
int end_index = start_index;
@@ -429,7 +450,7 @@
int count = frame_count + start_index;
assert (frames_array->length() >= count, "not enough space in buffers");
- JavaFrameStream& stream = (*existing_stream);
+ BaseFrameStream& stream = (*existing_stream);
if (!stream.at_end()) {
stream.next(); // advance past the last frame decoded in previous batch
if (!stream.at_end()) {
--- a/hotspot/src/share/vm/prims/stackwalk.hpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/prims/stackwalk.hpp Fri Oct 14 11:11:19 2016 -0700
@@ -29,31 +29,34 @@
#include "oops/oop.hpp"
#include "runtime/vframe.hpp"
-//
-// JavaFrameStream is used by StackWalker to iterate through Java stack frames
-// on the given JavaThread.
-//
-class JavaFrameStream : public StackObj {
+// BaseFrameStream is an abstract base class for encapsulating the VM-side
+// implementation of the StackWalker API. There are two concrete subclasses:
+// - JavaFrameStream:
+// -based on vframeStream; used in most instances
+// - LiveFrameStream:
+// -based on javaVFrame; used for retrieving locals/monitors/operands for
+// LiveStackFrame
+class BaseFrameStream : public StackObj {
private:
enum {
magic_pos = 0
};
JavaThread* _thread;
- javaVFrame* _jvf;
jlong _anchor;
+protected:
+ void fill_stackframe(Handle stackFrame, const methodHandle& method);
public:
- JavaFrameStream(JavaThread* thread, RegisterMap* rm)
- : _thread(thread), _anchor(0L) {
- _jvf = _thread->last_java_vframe(rm);
- }
+ BaseFrameStream(JavaThread* thread) : _thread(thread), _anchor(0L) {}
+
+ virtual void next()=0;
+ virtual bool at_end()=0;
- javaVFrame* java_frame() { return _jvf; }
- void next() { _jvf = _jvf->java_sender(); }
- bool at_end() { return _jvf == NULL; }
+ virtual Method* method()=0;
+ virtual int bci()=0;
- Method* method() { return _jvf->method(); }
- int bci() { return _jvf->bci(); }
+ virtual void fill_frame(int index, objArrayHandle frames_array,
+ const methodHandle& method, TRAPS)=0;
void setup_magic_on_entry(objArrayHandle frames_array);
bool check_magic(objArrayHandle frames_array);
@@ -67,35 +70,72 @@
return (jlong) castable_address(this);
}
- static JavaFrameStream* from_current(JavaThread* thread, jlong magic, objArrayHandle frames_array);
+ static BaseFrameStream* from_current(JavaThread* thread, jlong magic, objArrayHandle frames_array);
+};
+
+class JavaFrameStream : public BaseFrameStream {
+private:
+ vframeStream _vfst;
+ bool _need_method_info;
+public:
+ JavaFrameStream(JavaThread* thread, int mode);
+
+ void next() { _vfst.next();}
+ bool at_end() { return _vfst.at_end(); }
+
+ Method* method() { return _vfst.method(); }
+ int bci() { return _vfst.bci(); }
+
+ void fill_frame(int index, objArrayHandle frames_array,
+ const methodHandle& method, TRAPS);
+};
+
+class LiveFrameStream : public BaseFrameStream {
+private:
+ javaVFrame* _jvf;
+
+ void fill_live_stackframe(Handle stackFrame, const methodHandle& method, TRAPS);
+ static oop create_primitive_value_instance(StackValueCollection* values,
+ int i, TRAPS);
+ static objArrayHandle monitors_to_object_array(GrowableArray<MonitorInfo*>* monitors,
+ TRAPS);
+ static objArrayHandle values_to_object_array(StackValueCollection* values, TRAPS);
+public:
+ LiveFrameStream(JavaThread* thread, RegisterMap* rm) : BaseFrameStream(thread) {
+ _jvf = thread->last_java_vframe(rm);
+ }
+
+ void next() { _jvf = _jvf->java_sender(); }
+ bool at_end() { return _jvf == NULL; }
+
+ Method* method() { return _jvf->method(); }
+ int bci() { return _jvf->bci(); }
+
+ void fill_frame(int index, objArrayHandle frames_array,
+ const methodHandle& method, TRAPS);
};
class StackWalk : public AllStatic {
private:
- static int fill_in_frames(jlong mode, JavaFrameStream& stream,
+ static int fill_in_frames(jlong mode, BaseFrameStream& stream,
int max_nframes, int start_index,
objArrayHandle frames_array,
int& end_index, TRAPS);
- static void fill_stackframe(Handle stackFrame, const methodHandle& method, int bci);
-
- static void fill_live_stackframe(Handle stackFrame, const methodHandle& method, int bci,
- javaVFrame* jvf, TRAPS);
-
static inline bool get_caller_class(int mode) {
return (mode & JVM_STACKWALK_GET_CALLER_CLASS) != 0;
}
static inline bool skip_hidden_frames(int mode) {
return (mode & JVM_STACKWALK_SHOW_HIDDEN_FRAMES) == 0;
}
- static inline bool need_method_info(int mode) {
- return (mode & JVM_STACKWALK_FILL_CLASS_REFS_ONLY) == 0;
- }
static inline bool live_frame_info(int mode) {
return (mode & JVM_STACKWALK_FILL_LIVE_STACK_FRAMES) != 0;
}
public:
+ static inline bool need_method_info(int mode) {
+ return (mode & JVM_STACKWALK_FILL_CLASS_REFS_ONLY) == 0;
+ }
static inline bool use_frames_array(int mode) {
return (mode & JVM_STACKWALK_FILL_CLASS_REFS_ONLY) == 0;
}
@@ -104,9 +144,12 @@
objArrayHandle frames_array,
TRAPS);
- static jint moreFrames(Handle stackStream, jlong mode, jlong magic,
- int frame_count, int start_index,
- objArrayHandle frames_array,
- TRAPS);
+ static oop fetchFirstBatch(BaseFrameStream& stream, Handle stackStream,
+ jlong mode, int skip_frames, int frame_count,
+ int start_index, objArrayHandle frames_array, TRAPS);
+
+ static jint fetchNextBatch(Handle stackStream, jlong mode, jlong magic,
+ int frame_count, int start_index,
+ objArrayHandle frames_array, TRAPS);
};
#endif // SHARE_VM_PRIMS_STACKWALK_HPP
--- a/hotspot/src/share/vm/runtime/arguments.cpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/runtime/arguments.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -3897,10 +3897,6 @@
void Arguments::set_shared_spaces_flags() {
if (DumpSharedSpaces) {
- if (Arguments::get_patch_mod_prefix() != NULL) {
- vm_exit_during_initialization(
- "Cannot use the following option when dumping the shared archive: --patch-module");
- }
if (RequireSharedSpaces) {
warning("Cannot dump shared archive while using shared archive");
--- a/hotspot/src/share/vm/runtime/globals.hpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/runtime/globals.hpp Fri Oct 14 11:11:19 2016 -0700
@@ -659,6 +659,9 @@
product(bool, UseAES, false, \
"Control whether AES instructions can be used on x86/x64") \
\
+ product(bool, UseFMA, false, \
+ "Control whether FMA instructions can be used") \
+ \
product(bool, UseSHA, false, \
"Control whether SHA instructions can be used " \
"on SPARC, on ARM and on x86") \
--- a/hotspot/src/share/vm/runtime/vmStructs.cpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/runtime/vmStructs.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -2103,6 +2103,8 @@
declare_c2_type(OverflowAddLNode, OverflowLNode) \
declare_c2_type(OverflowSubLNode, OverflowLNode) \
declare_c2_type(OverflowMulLNode, OverflowLNode) \
+ declare_c2_type(FmaDNode, Node) \
+ declare_c2_type(FmaFNode, Node) \
\
/*********************/ \
/* Adapter Blob Entries */ \
@@ -2970,6 +2972,7 @@
#if INCLUDE_ALL_GCS
VM_STRUCTS_PARALLELGC(GENERATE_NONSTATIC_VM_STRUCT_ENTRY,
+ GENERATE_NONSTATIC_VM_STRUCT_ENTRY,
GENERATE_STATIC_VM_STRUCT_ENTRY)
VM_STRUCTS_CMS(GENERATE_NONSTATIC_VM_STRUCT_ENTRY,
@@ -2982,7 +2985,7 @@
#if INCLUDE_TRACE
VM_STRUCTS_TRACE(GENERATE_NONSTATIC_VM_STRUCT_ENTRY,
- GENERATE_STATIC_VM_STRUCT_ENTRY)
+ GENERATE_STATIC_VM_STRUCT_ENTRY)
#endif
VM_STRUCTS_EXT(GENERATE_NONSTATIC_VM_STRUCT_ENTRY,
@@ -3168,11 +3171,12 @@
#if INCLUDE_ALL_GCS
VM_STRUCTS_PARALLELGC(CHECK_NONSTATIC_VM_STRUCT_ENTRY,
- CHECK_STATIC_VM_STRUCT_ENTRY);
+ CHECK_VOLATILE_NONSTATIC_VM_STRUCT_ENTRY,
+ CHECK_STATIC_VM_STRUCT_ENTRY);
VM_STRUCTS_CMS(CHECK_NONSTATIC_VM_STRUCT_ENTRY,
- CHECK_VOLATILE_NONSTATIC_VM_STRUCT_ENTRY,
- CHECK_STATIC_VM_STRUCT_ENTRY);
+ CHECK_VOLATILE_NONSTATIC_VM_STRUCT_ENTRY,
+ CHECK_STATIC_VM_STRUCT_ENTRY);
VM_STRUCTS_G1(CHECK_NONSTATIC_VM_STRUCT_ENTRY,
CHECK_STATIC_VM_STRUCT_ENTRY);
@@ -3181,7 +3185,7 @@
#if INCLUDE_TRACE
VM_STRUCTS_TRACE(CHECK_NONSTATIC_VM_STRUCT_ENTRY,
- CHECK_STATIC_VM_STRUCT_ENTRY);
+ CHECK_STATIC_VM_STRUCT_ENTRY);
#endif
VM_STRUCTS_EXT(CHECK_NONSTATIC_VM_STRUCT_ENTRY,
@@ -3293,6 +3297,7 @@
CHECK_NO_OP));
#if INCLUDE_ALL_GCS
debug_only(VM_STRUCTS_PARALLELGC(ENSURE_FIELD_TYPE_PRESENT,
+ ENSURE_FIELD_TYPE_PRESENT,
ENSURE_FIELD_TYPE_PRESENT));
debug_only(VM_STRUCTS_CMS(ENSURE_FIELD_TYPE_PRESENT,
ENSURE_FIELD_TYPE_PRESENT,
--- a/hotspot/src/share/vm/utilities/chunkedList.cpp Fri Oct 14 19:12:37 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,109 +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.
- *
- */
-
-#include "precompiled.hpp"
-#include "utilities/chunkedList.hpp"
-#include "utilities/debug.hpp"
-
-/////////////// Unit tests ///////////////
-
-#ifndef PRODUCT
-
-template <typename T>
-class TestChunkedList {
- typedef ChunkedList<T, mtOther> ChunkedListT;
-
- public:
- static void testEmpty() {
- ChunkedListT buffer;
- assert(buffer.size() == 0, "assert");
- }
-
- static void testFull() {
- ChunkedListT buffer;
- for (uintptr_t i = 0; i < ChunkedListT::BufferSize; i++) {
- buffer.push((T)i);
- }
- assert(buffer.size() == ChunkedListT::BufferSize, "assert");
- assert(buffer.is_full(), "assert");
- }
-
- static void testSize() {
- ChunkedListT buffer;
- for (uintptr_t i = 0; i < ChunkedListT::BufferSize; i++) {
- assert(buffer.size() == i, "assert");
- buffer.push((T)i);
- assert(buffer.size() == i + 1, "assert");
- }
- }
-
- static void testClear() {
- ChunkedListT buffer;
-
- buffer.clear();
- assert(buffer.size() == 0, "assert");
-
- for (uintptr_t i = 0; i < ChunkedListT::BufferSize / 2; i++) {
- buffer.push((T)i);
- }
- buffer.clear();
- assert(buffer.size() == 0, "assert");
-
- for (uintptr_t i = 0; i < ChunkedListT::BufferSize; i++) {
- buffer.push((T)i);
- }
- buffer.clear();
- assert(buffer.size() == 0, "assert");
- }
-
- static void testAt() {
- ChunkedListT buffer;
-
- for (uintptr_t i = 0; i < ChunkedListT::BufferSize; i++) {
- buffer.push((T)i);
- assert(buffer.at(i) == (T)i, "assert");
- }
-
- for (uintptr_t i = 0; i < ChunkedListT::BufferSize; i++) {
- assert(buffer.at(i) == (T)i, "assert");
- }
- }
-
- static void test() {
- testEmpty();
- testFull();
- testSize();
- testClear();
- testAt();
- }
-};
-
-class Metadata;
-
-void TestChunkedList_test() {
- TestChunkedList<Metadata*>::test();
- TestChunkedList<size_t>::test();
-}
-
-#endif
--- a/hotspot/src/share/vm/utilities/internalVMTests.cpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/utilities/internalVMTests.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -52,19 +52,14 @@
run_unit_test(TestVirtualSpaceNode_test);
run_unit_test(TestGlobalDefinitions_test);
run_unit_test(GCTimer_test);
- run_unit_test(arrayOopDesc_test);
run_unit_test(CollectedHeap_test);
run_unit_test(QuickSort_test);
run_unit_test(GuardedMemory_test);
run_unit_test(TestNewSize_test);
run_unit_test(TestOldSize_test);
- run_unit_test(TestKlass_test);
run_unit_test(TestBitMap_test);
run_unit_test(TestResourcehash_test);
run_unit_test(ObjectMonitor_test);
- run_unit_test(Test_linked_list);
- run_unit_test(TestChunkedList_test);
- run_unit_test(JSON_test);
run_unit_test(Test_log_tag_combinations_limit);
run_unit_test(Test_logtarget);
run_unit_test(Test_logstream);
@@ -82,7 +77,6 @@
run_unit_test(Test_invalid_log_file);
run_unit_test(Test_multiline_logging);
run_unit_test(DirectivesParser_test);
- run_unit_test(Test_TempNewSymbol);
#if INCLUDE_VM_STRUCTS
run_unit_test(VMStructs_test);
#endif
@@ -91,7 +85,6 @@
run_unit_test(TestBufferingOopClosure_test);
if (UseG1GC) {
run_unit_test(FreeRegionList_test);
- run_unit_test(IHOP_test);
}
run_unit_test(WorkerDataArray_test);
run_unit_test(ParallelCompact_test);
--- a/hotspot/src/share/vm/utilities/json.cpp Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/src/share/vm/utilities/json.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -686,286 +686,3 @@
}
}
-#ifndef PRODUCT
-class JSONTest : public JSON {
- public:
- static void test();
-
- private:
- JSONTest(const char* text);
- static void test(const char* json, bool valid);
-
- void log(uint level, const char* format, ...) ATTRIBUTE_PRINTF(3, 4);
-
- bool callback(JSON_TYPE t, JSON_VAL* v, uint level);
- JSON_TYPE prev;
-};
-
-void JSON_test() {
- JSONTest::test();
-}
-
-void JSONTest::test(const char* text, bool should_pass) {
- JSONTest json(text);
- if (should_pass) {
- assert(json.valid() == true, "failed on a valid json string");
- if (VerboseInternalVMTests) {
- tty->print_cr("-- json test passed as expected --");
- }
- } else {
- assert(json.valid() == false, "succeeded on an invalid json string");
- if (VerboseInternalVMTests) {
- tty->print_cr("-- json test failed as expected --");
- }
- }
-}
-
-JSONTest::JSONTest(const char* text) : JSON(text, !VerboseInternalVMTests, tty) {
- prev = JSON_NONE;
- parse();
-}
-
-void JSONTest::test() {
- JSONTest::test("{}", true);
- JSONTest::test("[]", true);
- JSONTest::test(" { } ", true);
- JSONTest::test(" [ ] ", true);
-
- JSONTest::test("\"error\"", false);
- JSONTest::test("error", false);
- JSONTest::test("1", false);
- JSONTest::test("1.2", false);
- JSONTest::test("true", false);
- JSONTest::test("false", false);
- JSONTest::test("null", false);
-
- JSONTest::test("[ 1 ]", true);
- JSONTest::test("[ 1, ]", true);
- JSONTest::test("[ true ]", true);
- JSONTest::test("[ true, ]", true);
- JSONTest::test("[ false ]", true);
- JSONTest::test("[ false, ]", true);
- JSONTest::test("[ null ]", true);
- JSONTest::test("[ null, ]", true);
- JSONTest::test("[ \"\" ]", true);
- JSONTest::test("[ \"\", ]", true);
- JSONTest::test("[ \"elem1\" ]", true);
- JSONTest::test("[ \"elem1\", ]", true);
- JSONTest::test("[ \"elem1\", ]", true);
- JSONTest::test("[ \"elem1\" ]", true);
- JSONTest::test("[ \"elem1\", \"elem2\" ]", true);
- JSONTest::test("[ \"elem1\", \"elem2\", ]", true);
-
-
- JSONTest::test("[ \"elem1\" ] { }", false);
- JSONTest::test("[ elem1, \"elem2\" ]", false);
- JSONTest::test("[ \"elem1\"", false);
- JSONTest::test("[ \"elem1 ]", false);
- JSONTest::test("[ \"elem1\", \"elem2\"", false);
- JSONTest::test("[ truefoo ]", false);
- JSONTest::test("[ falsefoo ]", false);
- JSONTest::test("[ nullfoo ]", false);
-
- JSONTest::test("{ key : 1 }", true);
- JSONTest::test("{ key : 1, }", true);
- JSONTest::test("{ key : true }", true);
- JSONTest::test("{ key : true, }", true);
- JSONTest::test("{ key : false }", true);
- JSONTest::test("{ key : false, }", true);
- JSONTest::test("{ key : null }", true);
- JSONTest::test("{ key : null, }", true);
- JSONTest::test("{ \"\" : \"\" }", true);
- JSONTest::test("{ \"\" : \"\", }", true);
- JSONTest::test("{ \"key1\" : \"val1\" }", true);
- JSONTest::test("{ \"key1\" : \"val1\", }", true);
- JSONTest::test("{ \"key1\" : \"val1\", \"key2\" : \"val2\" }", true);
- JSONTest::test("{ \"key1\" : \"val1\", \"key2\" : \"val2\", }", true);
-
- JSONTest::test("{ \"key\" : \"val\" } [ \"error\" ]", false);
- JSONTest::test("{ \"key\" : \"val\" ", false);
-
- JSONTest::test("/**/ { }", true);
- JSONTest::test("/* */ { }", true);
- JSONTest::test("/*foo*/ { }", true);
- JSONTest::test("/* *foo */ { }", true);
- JSONTest::test("/* *foo* */ { }", true);
- JSONTest::test("/* /*foo */ { }", true);
- JSONTest::test("{ } /* foo */", true);
- JSONTest::test("{ } /* foo */ ", true);
- JSONTest::test("{ } //", true);
- JSONTest::test("{ } // ", true);
- JSONTest::test("{ } // foo", true);
-
- JSONTest::test("/* * / { }", false);
- JSONTest::test("/ * */ { }", false);
- JSONTest::test("// { }", false);
- JSONTest::test("/* { } */", false);
- JSONTest::test("/* { } */ ", false);
- JSONTest::test("/* { } ", false);
- JSONTest::test("{ } /* ", false);
- JSONTest::test("/* { } *", false);
- JSONTest::test("{ /* } */", false);
- JSONTest::test("[ /* ] */", false);
- JSONTest::test("{ key : \"val\", /* } */", false);
- JSONTest::test("[ \"val\", /* ] */", false);
-
- JSONTest::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);
- JSONTest::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);
- JSONTest::test("/*comment*/{\"ff1 fsd\":{\"☃\":{\"☃\":[\"☃\",\"☃\"]},\"☃\":true},\"☃\":[\"☃\"],\"foo\":\"☃\",}", true);
- JSONTest::test("/* comment */ { key1 error : { \"☃\" : { \"☃\" : [ \"☃\", \"☃\" ] }, \"☃\" : true }, \"baz\" : [ \"☃\" ], foo : \"☃\",}", false); // first key needs to be quoted since it contains a space
-
-
- JSONTest::test("[\n]", true);
-
- JSONTest::test(
- "[" "\n"
- " {"
- " // pattern to match against class+method+signature" "\n"
- " // leading and trailing wildcard (*) allowed" "\n"
- " match: \"foo.bar.*\"," "\n"
- " " "\n"
- " // override defaults for specified compiler" "\n"
- " // we may differentiate between levels too. TBD." "\n"
- " c1: {" "\n"
- " //override c1 presets " "\n"
- " array_bounds_check_removal: false" "\n"
- " }," "\n"
- "" "\n"
- " c2: {" "\n"
- " // control inlining of method" "\n"
- " // + force inline, - dont inline" "\n"
- " inline : [ \"+java.util.*\", \"-com.sun.*\"]," "\n"
- " }," "\n"
- "" "\n"
- " // directives outside a specific preset applies to all compilers" "\n"
- " inline : [ \"+java.util.*\", \"-com.sun.*\"]," "\n"
- " print_assembly: true," "\n"
- " verify_oopmaps: true," "\n"
- " max_loop_unrolling: 5" "\n"
- " }," "\n"
- " {" "\n"
- " // matching several patterns require an array" "\n"
- " match: [\"baz.*\",\"frob*\"]," "\n"
- "" "\n"
- " // only enable c1 for this directive" "\n"
- " // all enabled by default. Command disables all not listed" "\n"
- " enable: \"c1\"," "\n"
- "" "\n"
- " // applies to all compilers" "\n"
- " // + force inline, - dont inline" "\n"
- " inline : [ \"+java.util.*\", \"-com.sun.*\"]," "\n"
- " print_inlining: true," "\n"
- "" "\n"
- " // force matching compiles to be blocking/syncronous" "\n"
- " blocking_compile: true" "\n"
- " }," "\n"
- "]" "\n", true);
-}
-
-void JSONTest::log(uint indent, const char* format, ...) {
- if (VerboseInternalVMTests) {
- if (prev != JSON_KEY) {
- for (uint i = 0; i < indent; i++) {
- _st->print(" ");
- }
- }
- va_list args;
- va_start(args, format);
- _st->vprint(format, args);
- va_end(args);
- }
-}
-
-bool JSONTest::callback(JSON_TYPE t, JSON_VAL* v, uint rlevel) {
- switch (t) {
- case JSON_OBJECT_BEGIN:
- log(rlevel, "{\n");
- prev = JSON_NONE; // Only care about JSON_KEY, to indent correctly
- return true;
-
- case JSON_OBJECT_END:
- log(rlevel, "},\n");
- prev = JSON_NONE;
- return true;
-
- case JSON_ARRAY_BEGIN:
- log(rlevel, "[\n");
- prev = JSON_NONE;
- return true;
-
- case JSON_ARRAY_END:
- log(rlevel, "],\n");
- prev = JSON_NONE;
- return true;
-
- case JSON_KEY:
- if (VerboseInternalVMTests) {
- for (uint i = 0; i < rlevel; i++) {
- _st->print(" ");
- }
- _st->print("<key>");
- for (size_t i = 0; i < v->str.length; i++) {
- u_char c = v->str.start[i];
- assert(c != 0, "string overrun");
- if (c == 0) {
- return false;
- }
- _st->print("%c", c);
- }
- _st->print(" : ");
- }
- prev = JSON_KEY;
- return true;
-
- case JSON_STRING:
- if (VerboseInternalVMTests) {
- if (prev != JSON_KEY) {
- for (uint i = 0; i < rlevel; i++) {
- _st->print(" ");
- }
- }
- _st->print("<str>");
- for (size_t i = 0; i < v->str.length; i++) {
- u_char c = v->str.start[i];
- assert(c != 0, "string overrun");
- if (c == 0) {
- return false;
- }
- _st->print("%c", c);
- }
- _st->print(",\n");
- }
- prev = JSON_NONE;
- return true;
-
- case JSON_NUMBER_INT:
- log(rlevel, "<int>%" PRId64 ",\n", v->int_value);
- prev = JSON_NONE;
- return true;
-
- case JSON_NUMBER_FLOAT:
- log(rlevel, "<double>%lf,\n", v->double_value);
- prev = JSON_NONE;
- return true;
-
- case JSON_TRUE:
- log(rlevel, "<true>,\n");
- prev = JSON_NONE;
- return true;
-
- case JSON_FALSE:
- log(rlevel, "<false>,\n");
- prev = JSON_NONE;
- return true;
-
- case JSON_NULL:
- log(rlevel, "<null>,\n");
- prev = JSON_NONE;
- return true;
-
- default:
- error(INTERNAL_ERROR, "unknown JSON type");
- return false;
- }
-}
-#endif
--- a/hotspot/src/share/vm/utilities/linkedlist.cpp Fri Oct 14 19:12:37 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,114 +0,0 @@
-/*
- * Copyright (c) 2011, 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.
- *
- */
-
-#include "precompiled.hpp"
-
-/////////////// Unit tests ///////////////
-
-#ifndef PRODUCT
-
-#include "runtime/os.hpp"
-#include "utilities/linkedlist.hpp"
-#include "memory/allocation.hpp"
-#include "memory/allocation.inline.hpp"
-
-class Integer : public StackObj {
- private:
- int _value;
- public:
- Integer(int i) : _value(i) { }
-
- int value() const { return _value; }
- bool equals(const Integer& i) const {
- return _value == i.value();
- }
-};
-
-int compare_Integer(const Integer& i1, const Integer& i2) {
- return i1.value() - i2.value();
-}
-
-void check_list_values(const int* expected, const LinkedList<Integer>* list) {
- LinkedListNode<Integer>* head = list->head();
- int index = 0;
- while (head != NULL) {
- assert(head->peek()->value() == expected[index], "Unexpected value");
- head = head->next();
- index ++;
- }
-}
-
-void Test_linked_list() {
- LinkedListImpl<Integer, ResourceObj::C_HEAP, mtTest> ll;
-
-
- // Test regular linked list
- assert(ll.is_empty(), "Start with empty list");
- Integer one(1), two(2), three(3), four(4), five(5), six(6);
-
- ll.add(six);
- assert(!ll.is_empty(), "Should not be empty");
-
- Integer* i = ll.find(six);
- assert(i != NULL, "Should find it");
-
- i = ll.find(three);
- assert(i == NULL, "Not in the list");
-
- LinkedListNode<Integer>* node = ll.find_node(six);
- assert(node != NULL, "6 is in the list");
-
- ll.insert_after(three, node);
- ll.insert_before(one, node);
- int expected[3] = {1, 6, 3};
- check_list_values(expected, &ll);
-
- ll.add(two);
- ll.add(four);
- ll.add(five);
-
- // Test sorted linked list
- SortedLinkedList<Integer, compare_Integer, ResourceObj::C_HEAP, mtTest> sl;
- assert(sl.is_empty(), "Start with empty list");
-
- size_t ll_size = ll.size();
- sl.move(&ll);
- size_t sl_size = sl.size();
-
- assert(ll_size == sl_size, "Should be the same size");
- assert(ll.is_empty(), "No more entires");
-
- // sorted result
- int sorted_result[] = {1, 2, 3, 4, 5, 6};
- check_list_values(sorted_result, &sl);
-
- node = sl.find_node(four);
- assert(node != NULL, "4 is in the list");
- sl.remove_before(node);
- sl.remove_after(node);
- int remains[] = {1, 2, 4, 6};
- check_list_values(remains, &sl);
-}
-#endif // PRODUCT
-
--- a/hotspot/test/TEST.groups Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/test/TEST.groups Fri Oct 14 11:11:19 2016 -0700
@@ -351,16 +351,29 @@
hotspot_fast_runtime = \
runtime/ \
+ -runtime/6626217/Test6626217.sh \
+ -runtime/7100935 \
+ -runtime/7158988/FieldMonitor.java \
+ -runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java \
+ -runtime/CommandLine/PrintGCApplicationConcurrentTime.java \
+ -runtime/ConstantPool/IntfMethod.java \
+ -runtime/ErrorHandling/CreateCoredumpOnCrash.java \
-runtime/ErrorHandling/ErrorHandler.java \
- -runtime/RedefineObject/TestRedefineObject.java \
- -runtime/MirrorFrame/Test8003720.java \
+ -runtime/logging/MonitorMismatchTest.java \
+ -runtime/memory/ReserveMemory.java \
+ -runtime/memory/RunUnitTestsConcurrently.java \
-runtime/Metaspace/FragmentMetaspace.java \
-runtime/Metaspace/FragmentMetaspaceSimple.java \
- -runtime/Thread/TestThreadDumpMonitorContention.java \
- -runtime/SharedArchiveFile/SharedBaseAddress.java \
- -runtime/memory/ReserveMemory.java \
- -runtime/memory/RunUnitTestsConcurrently.java \
- -runtime/Unsafe/RangeCheck.java \
+ -runtime/MirrorFrame/Test8003720.java \
+ -runtime/modules/LoadUnloadModuleStress.java \
+ -runtime/modules/ModuleStress/ExportModuleStressTest.java \
+ -runtime/modules/ModuleStress/ModuleStressGC.java \
+ -runtime/NMT \
+ -runtime/RedefineObject/TestRedefineObject.java \
+ -runtime/RedefineTests/RedefinePreviousVersions.java \
+ -runtime/RedefineTests/RedefineRunningMethods.java \
+ -runtime/RedefineTests/RedefineRunningMethodsWithBacktrace.java \
+ -runtime/ReservedStack \
-runtime/SelectionResolution/AbstractMethodErrorTest.java \
-runtime/SelectionResolution/IllegalAccessErrorTest.java \
-runtime/SelectionResolution/InvokeInterfaceICCE.java \
@@ -372,14 +385,14 @@
-runtime/SelectionResolution/InvokeVirtualSuccessTest.java \
-runtime/SharedArchiveFile/CdsSameObjectAlignment.java \
-runtime/SharedArchiveFile/DefaultUseWithClient.java \
+ -runtime/SharedArchiveFile/SharedBaseAddress.java \
-runtime/Thread/CancellableThreadTest.java \
- -runtime/7158988/FieldMonitor.java \
- -runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java \
+ -runtime/Thread/TestThreadDumpMonitorContention.java \
+ -runtime/Unsafe/RangeCheck.java \
sanity/ \
testlibrary_tests/TestMutuallyExclusivePlatformPredicates.java
hotspot_fast_serviceability = \
- sanity/ExecuteInternalVMTests.java \
serviceability/dcmd/compiler \
serviceability/logging
@@ -398,6 +411,8 @@
hotspot_runtime_tier2 = \
runtime/ \
serviceability/ \
+ -runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java \
+ -runtime/Thread/TestThreadDumpMonitorContention.java \
-:hotspot_fast_runtime \
-:hotspot_fast_serviceability \
-:hotspot_runtime_tier2_platform_agnostic
@@ -405,6 +420,14 @@
hotspot_runtime_tier2_platform_agnostic = \
runtime/SelectionResolution \
-:hotspot_fast_runtime
+
+hotspot_runtime_tier3 = \
+ runtime/ \
+ serviceability/ \
+ -:hotspot_fast_runtime \
+ -:hotspot_fast_serviceability \
+ -:hotspot_runtime_tier2_platform_agnostic \
+ -:hotspot_runtime_tier2
hotspot_runtime_minimalvm = \
runtime/MinimalVM \
--- a/hotspot/test/compiler/codecache/stress/OverloadCompileQueueTest.java Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/test/compiler/codecache/stress/OverloadCompileQueueTest.java Fri Oct 14 11:11:19 2016 -0700
@@ -29,7 +29,7 @@
* @modules java.base/jdk.internal.misc
* java.management
*
- * @ignore 8071905
+ * @ignore 8166554
* @build sun.hotspot.WhiteBox
* @run driver ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/compilercontrol/share/processors/LogProcessor.java Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/test/compiler/compilercontrol/share/processors/LogProcessor.java Fri Oct 14 11:11:19 2016 -0700
@@ -74,7 +74,7 @@
if (loggedMethods.isEmpty()) {
return;
}
- matchTasks(getScanner());
+ matchTasks();
}
/*
@@ -95,19 +95,21 @@
* Parses for <task method='java.lang.String indexOf (I)I' >
* and finds if there is a compilation log for this task
*/
- private void matchTasks(Scanner scanner) {
- String task = scanner.findWithinHorizon(TASK_ELEMENT, 0);
- while (task != null) {
- String element = scanner.findWithinHorizon(ANY_ELEMENT, 0);
- if (Pattern.matches(TASK_DONE_ELEMENT, element)
- || Pattern.matches(TASK_END_ELEMENT, element)) {
- /* If there is nothing between <task> and </task>
- except <task done /> then compilation log is empty.
- Check the method in this task should not be logged */
- Asserts.assertFalse(matchMethod(task), "Compilation log "
- + "expected. Met: " + element);
- }
- task = scanner.findWithinHorizon(TASK_ELEMENT, 0);
+ private void matchTasks() {
+ try (Scanner scanner = getScanner()) {
+ String task = scanner.findWithinHorizon(TASK_ELEMENT, 0);
+ while (task != null) {
+ String element = scanner.findWithinHorizon(ANY_ELEMENT, 0);
+ if (Pattern.matches(TASK_DONE_ELEMENT, element)
+ || Pattern.matches(TASK_END_ELEMENT, element)) {
+ /* If there is nothing between <task> and </task>
+ except <task done /> then compilation log is empty.
+ Check the method in this task should not be logged */
+ Asserts.assertFalse(matchMethod(task), "Compilation log "
+ + "expected. Met: " + element);
+ }
+ task = scanner.findWithinHorizon(TASK_ELEMENT, 0);
+ }
}
}
--- a/hotspot/test/compiler/jsr292/NullConstantReceiver.java Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/test/compiler/jsr292/NullConstantReceiver.java Fri Oct 14 11:11:19 2016 -0700
@@ -23,10 +23,11 @@
/**
* @test
- * @bug 8059556 8158639
+ * @bug 8059556 8158639 8164508
*
* @run main/othervm -Xbatch compiler.jsr292.NullConstantReceiver
* @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::run compiler.jsr292.NullConstantReceiver
+ * @run main/othervm -Xbatch -XX:CompileCommand=compileonly,*::run compiler.jsr292.NullConstantReceiver
*/
package compiler.jsr292;
--- a/hotspot/test/compiler/jvmci/common/CTVMUtilities.java Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/test/compiler/jvmci/common/CTVMUtilities.java Fri Oct 14 11:11:19 2016 -0700
@@ -57,18 +57,7 @@
if (!(method instanceof Method || method instanceof Constructor)) {
throw new Error("wrong executable type " + method.getClass());
}
- Field slotField;
- int slot;
- try {
- slotField = method.getClass().getDeclaredField("slot");
- boolean old = slotField.isAccessible();
- slotField.setAccessible(true);
- slot = slotField.getInt(method);
- slotField.setAccessible(old);
- } catch (ReflectiveOperationException e) {
- throw new Error("TEST BUG: Can't get slot field", e);
- }
- return CompilerToVMHelper.getResolvedJavaMethodAtSlot(cls, slot);
+ return CompilerToVMHelper.asResolvedJavaMethod(method);
}
public static HotSpotResolvedJavaMethod getResolvedMethod(
--- a/hotspot/test/compiler/jvmci/common/patches/jdk.vm.ci/jdk/vm/ci/hotspot/CompilerToVMHelper.java Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/test/compiler/jvmci/common/patches/jdk.vm.ci/jdk/vm/ci/hotspot/CompilerToVMHelper.java Fri Oct 14 11:11:19 2016 -0700
@@ -28,6 +28,7 @@
import jdk.vm.ci.code.TargetDescription;
import jdk.vm.ci.meta.ConstantPool;
import jdk.vm.ci.meta.ResolvedJavaMethod;
+import java.lang.reflect.Executable;
/**
* A simple "proxy" class to get test access to CompilerToVM package-private methods
@@ -171,9 +172,9 @@
return CTVM.hasFinalizableSubclass((HotSpotResolvedObjectTypeImpl) type);
}
- public static HotSpotResolvedJavaMethodImpl getResolvedJavaMethodAtSlot(
- Class<?> holder, int slot) {
- return CTVM.getResolvedJavaMethodAtSlot(holder, slot);
+ public static HotSpotResolvedJavaMethodImpl asResolvedJavaMethod(
+ Executable executable) {
+ return CTVM.asResolvedJavaMethod(executable);
}
public static long getMaxCallTargetOffset(long address) {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/jvmci/compilerToVM/AsResolvedJavaMethodTest.java Fri Oct 14 11:11:19 2016 -0700
@@ -0,0 +1,113 @@
+/*
+ * 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 8136421
+ * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64")
+ * @library /test/lib /
+ * @library ../common/patches
+ * @modules java.base/jdk.internal.misc
+ * @modules java.base/jdk.internal.org.objectweb.asm
+ * java.base/jdk.internal.org.objectweb.asm.tree
+ * jdk.vm.ci/jdk.vm.ci.hotspot
+ * jdk.vm.ci/jdk.vm.ci.code
+ * jdk.vm.ci/jdk.vm.ci.meta
+ * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper
+ * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI
+ * compiler.jvmci.compilerToVM.AsResolvedJavaMethodTest
+ */
+
+package compiler.jvmci.compilerToVM;
+
+import jdk.test.lib.Asserts;
+import jdk.vm.ci.hotspot.CompilerToVMHelper;
+import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod;
+
+import java.lang.reflect.Executable;
+import java.util.Arrays;
+import java.util.ArrayList;
+import java.util.List;
+
+public class AsResolvedJavaMethodTest {
+
+ private static class A {
+ {
+ System.out.println("Dummy");
+ }
+ public void f1() {}
+ public int f2() { return 0; }
+ public String f3() { return ""; }
+ }
+
+
+ private static class S {
+ static {
+ System.out.println("Dummy static");
+ }
+ public S() {}
+ public void f1() {}
+ public int f2() { return 0; }
+ public String f3() { return ""; }
+ }
+
+ private class B extends A {
+ public void f4() {}
+ }
+
+ private interface I {
+ void f1();
+ int f2();
+ String f3();
+ }
+
+ public static void main(String[] args) {
+ List<Class<?>> testCases = getTestCases();
+ testCases.forEach(AsResolvedJavaMethodTest::test);
+ }
+
+ private static List<Class<?>> getTestCases() {
+ List<Class<?>> testCases = new ArrayList<>();
+ testCases.add(A.class);
+ testCases.add(S.class);
+ testCases.add(I.class);
+ testCases.add(B.class);
+ return testCases;
+ }
+
+ private static void test(Class<?> aClass) {
+ testCorrectMethods(aClass);
+ }
+
+ private static void testCorrectMethods(Class<?> holder) {
+ List<Executable> executables = new ArrayList<>();
+ executables.addAll(Arrays.asList(holder.getDeclaredMethods()));
+ executables.addAll(Arrays.asList(holder.getDeclaredConstructors()));
+ for (Executable executable : executables) {
+ HotSpotResolvedJavaMethod method = CompilerToVMHelper
+ .asResolvedJavaMethod(executable);
+ Asserts.assertNotNull(method, "could not convert " + method);
+ }
+ }
+}
--- a/hotspot/test/compiler/jvmci/compilerToVM/FindUniqueConcreteMethodTest.java Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/test/compiler/jvmci/compilerToVM/FindUniqueConcreteMethodTest.java Fri Oct 14 11:11:19 2016 -0700
@@ -74,45 +74,37 @@
private static Set<TestCase> createTestCases() {
Set<TestCase> result = new HashSet<>();
// a public method
- result.add(new TestCase(true, SingleSubclass.class,
- SingleSubclass.class, "usualMethod"));
+ result.add(new TestCase(true, SingleSubclass.class, "usualMethod"));
// overriden method
- result.add(new TestCase(true, SingleSubclass.class,
- SingleSubclass.class, "overridenMethod"));
+ result.add(new TestCase(true, SingleSubclass.class, "overridenMethod"));
// private method
- result.add(new TestCase(true, SingleSubclass.class,
- SingleSubclass.class, "privateMethod"));
+ result.add(new TestCase(true, SingleSubclass.class, "privateMethod"));
// protected method
- result.add(new TestCase(true, SingleSubclass.class,
- SingleSubclass.class, "protectedMethod"));
+ result.add(new TestCase(true, SingleSubclass.class, "protectedMethod"));
// default(package-private) method
- result.add(new TestCase(true, SingleSubclass.class,
- SingleSubclass.class, "defaultAccessMethod"));
+ result.add(new TestCase(true, SingleSubclass.class, "defaultAccessMethod"));
// default interface method redefined in implementer
- result.add(new TestCase(true, MultipleImplementer1.class,
- MultipleImplementer1.class, "defaultMethod"));
+ result.add(new TestCase(true, MultipleImplementer1.class, "defaultMethod"));
// interface method
- result.add(new TestCase(true, MultipleImplementer1.class,
- MultipleImplementer1.class, "testMethod"));
+ result.add(new TestCase(true, MultipleImplementer1.class, "testMethod"));
// default interface method not redefined in implementer
- result.add(new TestCase(true, SingleImplementer.class,
- SingleImplementerInterface.class, "defaultMethod"));
+ // result.add(new TestCase(true, SingleImplementer.class,
+ // SingleImplementerInterface.class, "defaultMethod"));
// static method
- result.add(new TestCase(false, SingleSubclass.class,
- SingleSubclass.class, "staticMethod"));
+ result.add(new TestCase(false, SingleSubclass.class, "staticMethod"));
// interface method
result.add(new TestCase(false, MultipleSuperImplementers.class,
- DuplicateSimpleSingleImplementerInterface.class, "interfaceMethod", false));
+ DuplicateSimpleSingleImplementerInterface.class, "interfaceMethod"));
result.add(new TestCase(false, MultipleSuperImplementers.class,
- SimpleSingleImplementerInterface.class, "interfaceMethod", false));
+ SimpleSingleImplementerInterface.class, "interfaceMethod"));
return result;
}
private void runTest(TestCase tcase) throws NoSuchMethodException {
System.out.println(tcase);
Method method = tcase.holder.getDeclaredMethod(tcase.methodName);
- HotSpotResolvedJavaMethod testMethod = CTVMUtilities
- .getResolvedMethod(tcase.methodFromReceiver ? tcase.receiver : tcase.holder, method);
+ HotSpotResolvedJavaMethod testMethod = CTVMUtilities.getResolvedMethod(method);
+
HotSpotResolvedObjectType resolvedType = CompilerToVMHelper
.lookupType(Utils.toJVMTypeSignature(tcase.receiver), getClass(),
/* resolve = */ true);
@@ -127,25 +119,23 @@
public final Class<?> holder;
public final String methodName;
public final boolean isPositive;
- public final boolean methodFromReceiver;
public TestCase(boolean isPositive, Class<?> clazz, Class<?> holder,
- String methodName, boolean methodFromReceiver) {
+ String methodName) {
this.receiver = clazz;
this.methodName = methodName;
this.isPositive = isPositive;
this.holder = holder;
- this.methodFromReceiver = methodFromReceiver;
}
- public TestCase(boolean isPositive, Class<?> clazz, Class<?> holder, String methodName) {
- this(isPositive, clazz, holder, methodName, true);
+ public TestCase(boolean isPositive, Class<?> clazz, String methodName) {
+ this(isPositive, clazz, clazz, methodName);
}
@Override
public String toString() {
- return String.format("CASE: receiver=%s, holder=%s, method=%s, isPositive=%s, methodFromReceiver=%s",
- receiver.getName(), holder.getName(), methodName, isPositive, methodFromReceiver);
+ return String.format("CASE: receiver=%s, holder=%s, method=%s, isPositive=%s",
+ receiver.getName(), holder.getName(), methodName, isPositive);
}
}
}
--- a/hotspot/test/compiler/jvmci/compilerToVM/GetResolvedJavaMethodAtSlotTest.java Fri Oct 14 19:12:37 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,121 +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.
- *
- */
-
-/**
- * @test
- * @bug 8136421
- * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64")
- * @library /test/lib /
- * @library ../common/patches
- * @modules java.base/jdk.internal.misc
- * @modules java.base/jdk.internal.org.objectweb.asm
- * java.base/jdk.internal.org.objectweb.asm.tree
- * jdk.vm.ci/jdk.vm.ci.hotspot
- * jdk.vm.ci/jdk.vm.ci.code
- * jdk.vm.ci/jdk.vm.ci.meta
- * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper
- * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI
- * compiler.jvmci.compilerToVM.GetResolvedJavaMethodAtSlotTest
- */
-
-package compiler.jvmci.compilerToVM;
-
-import jdk.test.lib.Asserts;
-import jdk.vm.ci.hotspot.CompilerToVMHelper;
-import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod;
-
-import java.util.HashMap;
-import java.util.Map;
-
-public class GetResolvedJavaMethodAtSlotTest {
-
- private static class A {
- {
- System.out.println("Dummy");
- }
- public void f1() {}
- public int f2() { return 0; }
- public String f3() { return ""; }
- }
-
-
- private static class S {
- static {
- System.out.println("Dummy static");
- }
- public S() {}
- public void f1() {}
- public int f2() { return 0; }
- public String f3() { return ""; }
- }
-
- private class B extends A {
- public void f4() {}
- }
-
- private interface I {
- void f1();
- int f2();
- String f3();
- }
-
- public static void main(String[] args) {
- Map<Class<?>, Integer> testCases = getTestCases();
- testCases.forEach(GetResolvedJavaMethodAtSlotTest::test);
- }
-
- private static Map<Class<?>, Integer> getTestCases() {
- Map<Class<?>, Integer> testCases = new HashMap<>();
- testCases.put(A.class, 5); // ctor, init, f1, f2, f3
- testCases.put(S.class, 5); // ctor, cinit, f1, f2, f3
- testCases.put(I.class, 3); // f1, f2, f3
- testCases.put(B.class, 2); // ctor, f4
- return testCases;
- }
-
- private static void test(Class<?> aClass, int methodNumber) {
- testSlotBigger(aClass);
- testCorrectMethods(aClass, methodNumber);
- }
-
- private static void testSlotBigger(Class<?> holder) {
- HotSpotResolvedJavaMethod method
- = CompilerToVMHelper.getResolvedJavaMethodAtSlot(holder, 50);
- Asserts.assertNull(method, "Got method for non existing slot 50 in "
- + holder);
- }
-
- private static void testCorrectMethods(Class<?> holder, int methodsNumber) {
- for (int i = 0; i < methodsNumber; i++) {
- String caseName = String.format("slot %d in %s",
- i, holder.getCanonicalName());
- HotSpotResolvedJavaMethod method = CompilerToVMHelper
- .getResolvedJavaMethodAtSlot(holder, i);
- Asserts.assertNotNull(method, caseName + " did not got method");
- Asserts.assertEQ(holder,
- CompilerToVMHelper.getMirror(method.getDeclaringClass()),
- caseName + " : unexpected declaring class");
- }
- }
-}
--- a/hotspot/test/compiler/jvmci/compilerToVM/GetResolvedJavaMethodTest.java Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/test/compiler/jvmci/compilerToVM/GetResolvedJavaMethodTest.java Fri Oct 14 11:11:19 2016 -0700
@@ -51,6 +51,7 @@
import sun.hotspot.WhiteBox;
import java.lang.reflect.Field;
+import java.lang.reflect.Method;
public class GetResolvedJavaMethodTest {
private static enum TestCase {
@@ -64,9 +65,7 @@
JAVA_METHOD_BASE {
@Override
HotSpotResolvedJavaMethod getResolvedJavaMethod() {
- HotSpotResolvedJavaMethod methodInstance
- = CompilerToVMHelper.getResolvedJavaMethodAtSlot(
- TEST_CLASS, 0);
+ HotSpotResolvedJavaMethod methodInstance = TEST_METHOD;
try {
METASPACE_METHOD_FIELD.set(methodInstance,
getPtrToMethod());
@@ -81,9 +80,7 @@
@Override
HotSpotResolvedJavaMethod getResolvedJavaMethod() {
long ptr = getPtrToMethod();
- HotSpotResolvedJavaMethod methodInstance
- = CompilerToVMHelper.getResolvedJavaMethodAtSlot(
- TEST_CLASS, 0);
+ HotSpotResolvedJavaMethod methodInstance = TEST_METHOD;
try {
METASPACE_METHOD_FIELD.set(methodInstance, ptr / 2L);
} catch (ReflectiveOperationException e) {
@@ -97,9 +94,7 @@
@Override
HotSpotResolvedJavaMethod getResolvedJavaMethod() {
long ptr = getPtrToMethod();
- HotSpotResolvedJavaMethod methodInstance
- = CompilerToVMHelper.getResolvedJavaMethodAtSlot(
- TEST_CLASS, 0);
+ HotSpotResolvedJavaMethod methodInstance = TEST_METHOD;
try {
METASPACE_METHOD_FIELD.set(methodInstance, 0L);
} catch (ReflectiveOperationException e) {
@@ -117,16 +112,21 @@
private static final WhiteBox WB = WhiteBox.getWhiteBox();
private static final Field METASPACE_METHOD_FIELD;
private static final Class<?> TEST_CLASS = GetResolvedJavaMethodTest.class;
+ private static final HotSpotResolvedJavaMethod TEST_METHOD;
private static final long PTR;
static {
- HotSpotResolvedJavaMethod method
- = CompilerToVMHelper.getResolvedJavaMethodAtSlot(TEST_CLASS, 0);
+ try {
+ Method method = TEST_CLASS.getDeclaredMethod("test", TestCase.class);
+ TEST_METHOD = CompilerToVMHelper.asResolvedJavaMethod(method);
+ } catch (NoSuchMethodException e) {
+ throw new Error("TESTBUG : " + e, e);
+ }
try {
// jdk.vm.ci.hotspot.HotSpotResolvedJavaMethodImpl.metaspaceMethod
- METASPACE_METHOD_FIELD = method.getClass()
+ METASPACE_METHOD_FIELD = TEST_METHOD.getClass()
.getDeclaredField("metaspaceMethod");
METASPACE_METHOD_FIELD.setAccessible(true);
- PTR = (long) METASPACE_METHOD_FIELD.get(method);
+ PTR = (long) METASPACE_METHOD_FIELD.get(TEST_METHOD);
} catch (ReflectiveOperationException e) {
throw new Error("TESTBUG : " + e, e);
}
--- a/hotspot/test/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/MemoryAccessProviderData.java Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/MemoryAccessProviderData.java Fri Oct 14 11:11:19 2016 -0700
@@ -23,6 +23,10 @@
package jdk.vm.ci.hotspot.test;
+import java.lang.reflect.Field;
+
+import org.testng.annotations.DataProvider;
+
import jdk.internal.misc.Unsafe;
import jdk.vm.ci.hotspot.HotSpotConstantReflectionProvider;
import jdk.vm.ci.hotspot.HotSpotJVMCIRuntimeProvider;
@@ -32,27 +36,14 @@
import jdk.vm.ci.meta.JavaConstant;
import jdk.vm.ci.meta.JavaKind;
import jdk.vm.ci.runtime.JVMCI;
-import org.testng.annotations.DataProvider;
-
-import java.lang.reflect.Field;
public class MemoryAccessProviderData {
- private static final Unsafe UNSAFE = getUnsafe();
+ private static final Unsafe UNSAFE = Unsafe.getUnsafe();
private static final HotSpotConstantReflectionProvider CONSTANT_REFLECTION = (HotSpotConstantReflectionProvider) JVMCI.getRuntime().getHostJVMCIBackend().getConstantReflection();
private static final TestClass TEST_OBJECT = new TestClass();
private static final JavaConstant TEST_CONSTANT = CONSTANT_REFLECTION.forObject(TEST_OBJECT);
private static final JavaConstant TEST_CLASS_CONSTANT = CONSTANT_REFLECTION.forObject(TestClass.class);
- private static Unsafe getUnsafe() {
- try {
- Field f = Unsafe.class.getDeclaredField("theUnsafe");
- f.setAccessible(true);
- return (Unsafe) f.get(null);
- } catch (NoSuchFieldException | IllegalAccessException e) {
- throw new RuntimeException("Unable to get Unsafe instance.", e);
- }
- }
-
@DataProvider(name = "positiveObject")
public static Object[][] getPositiveObjectJavaKind() {
HotSpotJVMCIRuntimeProvider runtime = (HotSpotJVMCIRuntimeProvider) JVMCI.getRuntime();
--- a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaMethod.java Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaMethod.java Fri Oct 14 11:11:19 2016 -0700
@@ -438,7 +438,6 @@
// @formatter:off
private static final String[] untestedApiMethods = {
- "invoke",
"newInstance",
"getDeclaringClass",
"getEncoding",
--- a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaType.java Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaType.java Fri Oct 14 11:11:19 2016 -0700
@@ -35,16 +35,18 @@
package jdk.vm.ci.runtime.test;
-import jdk.internal.reflect.ConstantPool;
-import jdk.vm.ci.common.JVMCIError;
-import jdk.vm.ci.meta.Assumptions.AssumptionResult;
-import jdk.vm.ci.meta.JavaConstant;
-import jdk.vm.ci.meta.JavaKind;
-import jdk.vm.ci.meta.ModifiersProvider;
-import jdk.vm.ci.meta.ResolvedJavaField;
-import jdk.vm.ci.meta.ResolvedJavaMethod;
-import jdk.vm.ci.meta.ResolvedJavaType;
-import org.junit.Test;
+import static java.lang.reflect.Modifier.isAbstract;
+import static java.lang.reflect.Modifier.isFinal;
+import static java.lang.reflect.Modifier.isPrivate;
+import static java.lang.reflect.Modifier.isProtected;
+import static java.lang.reflect.Modifier.isPublic;
+import static java.lang.reflect.Modifier.isStatic;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
@@ -57,18 +59,16 @@
import java.util.Map;
import java.util.Set;
-import static java.lang.reflect.Modifier.isAbstract;
-import static java.lang.reflect.Modifier.isFinal;
-import static java.lang.reflect.Modifier.isPrivate;
-import static java.lang.reflect.Modifier.isProtected;
-import static java.lang.reflect.Modifier.isPublic;
-import static java.lang.reflect.Modifier.isStatic;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import org.junit.Test;
+
+import jdk.internal.reflect.ConstantPool;
+import jdk.vm.ci.common.JVMCIError;
+import jdk.vm.ci.meta.Assumptions.AssumptionResult;
+import jdk.vm.ci.meta.JavaConstant;
+import jdk.vm.ci.meta.JavaKind;
+import jdk.vm.ci.meta.ResolvedJavaField;
+import jdk.vm.ci.meta.ResolvedJavaMethod;
+import jdk.vm.ci.meta.ResolvedJavaType;
/**
* Tests for {@link ResolvedJavaType}.
@@ -146,8 +146,9 @@
public void getModifiersTest() {
for (Class<?> c : classes) {
ResolvedJavaType type = metaAccess.lookupJavaType(c);
- int expected = c.getModifiers() & ModifiersProvider.jvmClassModifiers();
- int actual = type.getModifiers() & ModifiersProvider.jvmClassModifiers();
+ int mask = Modifier.classModifiers() & ~Modifier.STATIC;
+ int expected = c.getModifiers() & mask;
+ int actual = type.getModifiers() & mask;
Class<?> elementalType = c;
while (elementalType.isArray()) {
elementalType = elementalType.getComponentType();
--- a/hotspot/test/compiler/rtm/cli/RTMLockingAwareTest.java Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/test/compiler/rtm/cli/RTMLockingAwareTest.java Fri Oct 14 11:11:19 2016 -0700
@@ -25,6 +25,7 @@
package compiler.rtm.cli;
import compiler.testlibrary.rtm.predicate.SupportedCPU;
+import compiler.testlibrary.rtm.predicate.SupportedOS;
import compiler.testlibrary.rtm.predicate.SupportedVM;
import jdk.test.lib.process.ExitCode;
import jdk.test.lib.cli.CommandLineOptionTest;
@@ -66,7 +67,7 @@
boolean isExperimental, String defaultValue,
String[] correctValues, String[] incorrectValues,
String warningMessage) {
- super(new AndPredicate(new SupportedCPU(), new SupportedVM()),
+ super(new AndPredicate(new SupportedCPU(), new SupportedOS(), new SupportedVM()),
optionName, isBoolean, isExperimental, defaultValue);
this.correctValues = correctValues;
this.incorrectValues = incorrectValues;
--- a/hotspot/test/compiler/rtm/cli/TestPrintPreciseRTMLockingStatisticsOptionOnSupportedConfig.java Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/test/compiler/rtm/cli/TestPrintPreciseRTMLockingStatisticsOptionOnSupportedConfig.java Fri Oct 14 11:11:19 2016 -0700
@@ -42,6 +42,7 @@
package compiler.rtm.cli;
import compiler.testlibrary.rtm.predicate.SupportedCPU;
+import compiler.testlibrary.rtm.predicate.SupportedOS;
import compiler.testlibrary.rtm.predicate.SupportedVM;
import jdk.test.lib.cli.CommandLineOptionTest;
import jdk.test.lib.cli.predicate.AndPredicate;
@@ -49,7 +50,7 @@
public class TestPrintPreciseRTMLockingStatisticsOptionOnSupportedConfig
extends TestPrintPreciseRTMLockingStatisticsBase {
private TestPrintPreciseRTMLockingStatisticsOptionOnSupportedConfig() {
- super(new AndPredicate(new SupportedVM(), new SupportedCPU()));
+ super(new AndPredicate(new SupportedCPU(), new SupportedOS(), new SupportedVM()));
}
@Override
--- a/hotspot/test/compiler/rtm/cli/TestPrintPreciseRTMLockingStatisticsOptionOnUnsupportedConfig.java Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/test/compiler/rtm/cli/TestPrintPreciseRTMLockingStatisticsOptionOnUnsupportedConfig.java Fri Oct 14 11:11:19 2016 -0700
@@ -42,6 +42,7 @@
package compiler.rtm.cli;
import compiler.testlibrary.rtm.predicate.SupportedCPU;
+import compiler.testlibrary.rtm.predicate.SupportedOS;
import compiler.testlibrary.rtm.predicate.SupportedVM;
import jdk.test.lib.cli.predicate.AndPredicate;
import jdk.test.lib.cli.predicate.NotPredicate;
@@ -49,8 +50,8 @@
public class TestPrintPreciseRTMLockingStatisticsOptionOnUnsupportedConfig
extends TestPrintPreciseRTMLockingStatisticsBase {
private TestPrintPreciseRTMLockingStatisticsOptionOnUnsupportedConfig() {
- super(new NotPredicate(new AndPredicate(new SupportedCPU(),
- new SupportedVM())));
+ super(new NotPredicate(
+ new AndPredicate(new SupportedCPU(), new SupportedOS(), new SupportedVM())));
}
public static void main(String args[]) throws Throwable {
--- a/hotspot/test/compiler/rtm/cli/TestRTMAbortRatioOptionOnUnsupportedConfig.java Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/test/compiler/rtm/cli/TestRTMAbortRatioOptionOnUnsupportedConfig.java Fri Oct 14 11:11:19 2016 -0700
@@ -42,6 +42,7 @@
package compiler.rtm.cli;
import compiler.testlibrary.rtm.predicate.SupportedCPU;
+import compiler.testlibrary.rtm.predicate.SupportedOS;
import compiler.testlibrary.rtm.predicate.SupportedVM;
import jdk.test.lib.cli.predicate.AndPredicate;
import jdk.test.lib.cli.predicate.NotPredicate;
@@ -51,8 +52,8 @@
private static final String DEFAULT_VALUE = "50";
private TestRTMAbortRatioOptionOnUnsupportedConfig() {
- super(new NotPredicate(new AndPredicate(new SupportedVM(),
- new SupportedCPU())),
+ super(new NotPredicate(
+ new AndPredicate(new SupportedCPU(), new SupportedOS(), new SupportedVM())),
"RTMAbortRatio", false, true,
TestRTMAbortRatioOptionOnUnsupportedConfig.DEFAULT_VALUE,
"0", "10", "100", "200");
--- a/hotspot/test/compiler/rtm/cli/TestRTMTotalCountIncrRateOptionOnUnsupportedConfig.java Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/test/compiler/rtm/cli/TestRTMTotalCountIncrRateOptionOnUnsupportedConfig.java Fri Oct 14 11:11:19 2016 -0700
@@ -42,6 +42,7 @@
package compiler.rtm.cli;
import compiler.testlibrary.rtm.predicate.SupportedCPU;
+import compiler.testlibrary.rtm.predicate.SupportedOS;
import compiler.testlibrary.rtm.predicate.SupportedVM;
import jdk.test.lib.cli.predicate.AndPredicate;
import jdk.test.lib.cli.predicate.NotPredicate;
@@ -51,8 +52,8 @@
private static final String DEFAULT_VALUE = "64";
private TestRTMTotalCountIncrRateOptionOnUnsupportedConfig() {
- super(new NotPredicate(new AndPredicate(new SupportedCPU(),
- new SupportedVM())),
+ super(new NotPredicate(
+ new AndPredicate(new SupportedCPU(), new SupportedOS(), new SupportedVM())),
"RTMTotalCountIncrRate", false, true,
TestRTMTotalCountIncrRateOptionOnUnsupportedConfig
.DEFAULT_VALUE,
--- a/hotspot/test/compiler/rtm/cli/TestUseRTMDeoptOptionOnSupportedConfig.java Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/test/compiler/rtm/cli/TestUseRTMDeoptOptionOnSupportedConfig.java Fri Oct 14 11:11:19 2016 -0700
@@ -42,6 +42,7 @@
package compiler.rtm.cli;
import compiler.testlibrary.rtm.predicate.SupportedCPU;
+import compiler.testlibrary.rtm.predicate.SupportedOS;
import compiler.testlibrary.rtm.predicate.SupportedVM;
import jdk.test.lib.process.ExitCode;
import jdk.test.lib.cli.CommandLineOptionTest;
@@ -52,7 +53,7 @@
private static final String DEFAULT_VALUE = "false";
private TestUseRTMDeoptOptionOnSupportedConfig() {
- super(new AndPredicate(new SupportedVM(), new SupportedCPU()));
+ super(new AndPredicate(new SupportedCPU(), new SupportedOS(), new SupportedVM()));
}
@Override
--- a/hotspot/test/compiler/rtm/cli/TestUseRTMDeoptOptionOnUnsupportedConfig.java Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/test/compiler/rtm/cli/TestUseRTMDeoptOptionOnUnsupportedConfig.java Fri Oct 14 11:11:19 2016 -0700
@@ -42,6 +42,7 @@
package compiler.rtm.cli;
import compiler.testlibrary.rtm.predicate.SupportedCPU;
+import compiler.testlibrary.rtm.predicate.SupportedOS;
import compiler.testlibrary.rtm.predicate.SupportedVM;
import jdk.test.lib.cli.CommandLineOptionTest;
import jdk.test.lib.cli.predicate.AndPredicate;
@@ -52,8 +53,8 @@
private static final String DEFAULT_VALUE = "false";
private TestUseRTMDeoptOptionOnUnsupportedConfig() {
- super(new NotPredicate(new AndPredicate(new SupportedCPU(),
- new SupportedVM())),
+ super(new NotPredicate(
+ new AndPredicate(new SupportedCPU(), new SupportedOS(), new SupportedVM())),
"UseRTMDeopt", true, false,
TestUseRTMDeoptOptionOnUnsupportedConfig.DEFAULT_VALUE,
"true");
--- a/hotspot/test/compiler/rtm/cli/TestUseRTMForStackLocksOptionOnSupportedConfig.java Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/test/compiler/rtm/cli/TestUseRTMForStackLocksOptionOnSupportedConfig.java Fri Oct 14 11:11:19 2016 -0700
@@ -42,6 +42,7 @@
package compiler.rtm.cli;
import compiler.testlibrary.rtm.predicate.SupportedCPU;
+import compiler.testlibrary.rtm.predicate.SupportedOS;
import compiler.testlibrary.rtm.predicate.SupportedVM;
import jdk.test.lib.process.ExitCode;
import jdk.test.lib.cli.CommandLineOptionTest;
@@ -52,7 +53,7 @@
private static final String DEFAULT_VALUE = "false";
private TestUseRTMForStackLocksOptionOnSupportedConfig() {
- super(new AndPredicate(new SupportedVM(), new SupportedCPU()));
+ super(new AndPredicate(new SupportedCPU(), new SupportedOS(), new SupportedVM()));
}
@Override
--- a/hotspot/test/compiler/rtm/cli/TestUseRTMForStackLocksOptionOnUnsupportedConfig.java Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/test/compiler/rtm/cli/TestUseRTMForStackLocksOptionOnUnsupportedConfig.java Fri Oct 14 11:11:19 2016 -0700
@@ -42,6 +42,7 @@
package compiler.rtm.cli;
import compiler.testlibrary.rtm.predicate.SupportedCPU;
+import compiler.testlibrary.rtm.predicate.SupportedOS;
import compiler.testlibrary.rtm.predicate.SupportedVM;
import jdk.test.lib.process.ExitCode;
import jdk.test.lib.cli.CommandLineOptionTest;
@@ -53,8 +54,8 @@
private static final String DEFAULT_VALUE = "false";
private TestUseRTMForStackLocksOptionOnUnsupportedConfig() {
- super(new NotPredicate(new AndPredicate(new SupportedCPU(),
- new SupportedVM())),
+ super(new NotPredicate(
+ new AndPredicate(new SupportedCPU(), new SupportedOS(), new SupportedVM())),
"UseRTMForStackLocks", true, true,
TestUseRTMForStackLocksOptionOnUnsupportedConfig.DEFAULT_VALUE,
"true");
--- a/hotspot/test/compiler/rtm/cli/TestUseRTMLockingOptionOnSupportedConfig.java Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/test/compiler/rtm/cli/TestUseRTMLockingOptionOnSupportedConfig.java Fri Oct 14 11:11:19 2016 -0700
@@ -42,6 +42,7 @@
package compiler.rtm.cli;
import compiler.testlibrary.rtm.predicate.SupportedCPU;
+import compiler.testlibrary.rtm.predicate.SupportedOS;
import compiler.testlibrary.rtm.predicate.SupportedVM;
import jdk.test.lib.process.ExitCode;
import jdk.test.lib.cli.CommandLineOptionTest;
@@ -52,7 +53,7 @@
private static final String DEFAULT_VALUE = "false";
private TestUseRTMLockingOptionOnSupportedConfig() {
- super(new AndPredicate(new SupportedVM(), new SupportedCPU()));
+ super(new AndPredicate(new SupportedCPU(), new SupportedOS(), new SupportedVM()));
}
@Override
--- a/hotspot/test/compiler/rtm/cli/TestUseRTMLockingOptionWithBiasedLocking.java Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/test/compiler/rtm/cli/TestUseRTMLockingOptionWithBiasedLocking.java Fri Oct 14 11:11:19 2016 -0700
@@ -42,6 +42,7 @@
package compiler.rtm.cli;
import compiler.testlibrary.rtm.predicate.SupportedCPU;
+import compiler.testlibrary.rtm.predicate.SupportedOS;
import compiler.testlibrary.rtm.predicate.SupportedVM;
import jdk.test.lib.process.ExitCode;
import jdk.test.lib.cli.CommandLineOptionTest;
@@ -50,7 +51,7 @@
public class TestUseRTMLockingOptionWithBiasedLocking
extends CommandLineOptionTest {
private TestUseRTMLockingOptionWithBiasedLocking() {
- super(new AndPredicate(new SupportedCPU(), new SupportedVM()));
+ super(new AndPredicate(new SupportedCPU(), new SupportedOS(), new SupportedVM()));
}
@Override
--- a/hotspot/test/compiler/rtm/locking/TestRTMAbortRatio.java Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/test/compiler/rtm/locking/TestRTMAbortRatio.java Fri Oct 14 11:11:19 2016 -0700
@@ -45,6 +45,7 @@
import compiler.testlibrary.rtm.RTMLockingStatistics;
import compiler.testlibrary.rtm.RTMTestBase;
import compiler.testlibrary.rtm.predicate.SupportedCPU;
+import compiler.testlibrary.rtm.predicate.SupportedOS;
import compiler.testlibrary.rtm.predicate.SupportedVM;
import jdk.internal.misc.Unsafe;
import jdk.test.lib.Asserts;
@@ -60,7 +61,7 @@
*/
public class TestRTMAbortRatio extends CommandLineOptionTest {
private TestRTMAbortRatio() {
- super(new AndPredicate(new SupportedCPU(), new SupportedVM()));
+ super(new AndPredicate(new SupportedCPU(), new SupportedOS(), new SupportedVM()));
}
@Override
--- a/hotspot/test/compiler/rtm/locking/TestRTMAbortThreshold.java Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/test/compiler/rtm/locking/TestRTMAbortThreshold.java Fri Oct 14 11:11:19 2016 -0700
@@ -45,6 +45,7 @@
import compiler.testlibrary.rtm.RTMLockingStatistics;
import compiler.testlibrary.rtm.RTMTestBase;
import compiler.testlibrary.rtm.predicate.SupportedCPU;
+import compiler.testlibrary.rtm.predicate.SupportedOS;
import compiler.testlibrary.rtm.predicate.SupportedVM;
import jdk.test.lib.Asserts;
import jdk.test.lib.process.OutputAnalyzer;
@@ -59,7 +60,7 @@
*/
public class TestRTMAbortThreshold extends CommandLineOptionTest {
private TestRTMAbortThreshold() {
- super(new AndPredicate(new SupportedCPU(), new SupportedVM()));
+ super(new AndPredicate(new SupportedCPU(), new SupportedOS(), new SupportedVM()));
}
@Override
--- a/hotspot/test/compiler/rtm/locking/TestRTMAfterNonRTMDeopt.java Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/test/compiler/rtm/locking/TestRTMAfterNonRTMDeopt.java Fri Oct 14 11:11:19 2016 -0700
@@ -47,6 +47,7 @@
import compiler.testlibrary.rtm.RTMLockingStatistics;
import compiler.testlibrary.rtm.RTMTestBase;
import compiler.testlibrary.rtm.predicate.SupportedCPU;
+import compiler.testlibrary.rtm.predicate.SupportedOS;
import compiler.testlibrary.rtm.predicate.SupportedVM;
import jdk.internal.misc.Unsafe;
import jdk.test.lib.Asserts;
@@ -86,7 +87,7 @@
private static final String RANGE_CHECK = "range_check";
private TestRTMAfterNonRTMDeopt() {
- super(new AndPredicate(new SupportedCPU(), new SupportedVM()));
+ super(new AndPredicate(new SupportedCPU(), new SupportedOS(), new SupportedVM()));
}
@Override
--- a/hotspot/test/compiler/rtm/locking/TestRTMDeoptOnHighAbortRatio.java Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/test/compiler/rtm/locking/TestRTMDeoptOnHighAbortRatio.java Fri Oct 14 11:11:19 2016 -0700
@@ -45,6 +45,7 @@
import compiler.testlibrary.rtm.RTMLockingStatistics;
import compiler.testlibrary.rtm.RTMTestBase;
import compiler.testlibrary.rtm.predicate.SupportedCPU;
+import compiler.testlibrary.rtm.predicate.SupportedOS;
import compiler.testlibrary.rtm.predicate.SupportedVM;
import jdk.test.lib.Asserts;
import jdk.test.lib.process.OutputAnalyzer;
@@ -66,7 +67,7 @@
= AbortProvoker.DEFAULT_ITERATIONS / 2L;
private TestRTMDeoptOnHighAbortRatio() {
- super(new AndPredicate(new SupportedCPU(), new SupportedVM()));
+ super(new AndPredicate(new SupportedCPU(), new SupportedOS(), new SupportedVM()));
}
@Override
--- a/hotspot/test/compiler/rtm/locking/TestRTMDeoptOnLowAbortRatio.java Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/test/compiler/rtm/locking/TestRTMDeoptOnLowAbortRatio.java Fri Oct 14 11:11:19 2016 -0700
@@ -44,6 +44,7 @@
import compiler.testlibrary.rtm.RTMLockingStatistics;
import compiler.testlibrary.rtm.RTMTestBase;
import compiler.testlibrary.rtm.predicate.SupportedCPU;
+import compiler.testlibrary.rtm.predicate.SupportedOS;
import compiler.testlibrary.rtm.predicate.SupportedVM;
import jdk.internal.misc.Unsafe;
import jdk.test.lib.Asserts;
@@ -66,7 +67,7 @@
private static final long ABORT_THRESHOLD = LOCKING_THRESHOLD / 2L;
private TestRTMDeoptOnLowAbortRatio() {
- super(new AndPredicate(new SupportedCPU(), new SupportedVM()));
+ super(new AndPredicate(new SupportedCPU(), new SupportedOS(), new SupportedVM()));
}
@Override
--- a/hotspot/test/compiler/rtm/locking/TestRTMLockingCalculationDelay.java Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/test/compiler/rtm/locking/TestRTMLockingCalculationDelay.java Fri Oct 14 11:11:19 2016 -0700
@@ -44,6 +44,7 @@
import compiler.testlibrary.rtm.AbortType;
import compiler.testlibrary.rtm.RTMTestBase;
import compiler.testlibrary.rtm.predicate.SupportedCPU;
+import compiler.testlibrary.rtm.predicate.SupportedOS;
import compiler.testlibrary.rtm.predicate.SupportedVM;
import jdk.test.lib.Asserts;
import jdk.test.lib.process.OutputAnalyzer;
@@ -58,7 +59,7 @@
private static final boolean INFLATE_MONITOR = true;
private TestRTMLockingCalculationDelay() {
- super(new AndPredicate(new SupportedCPU(), new SupportedVM()));
+ super(new AndPredicate(new SupportedCPU(), new SupportedOS(), new SupportedVM()));
}
@Override
--- a/hotspot/test/compiler/rtm/locking/TestRTMLockingThreshold.java Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/test/compiler/rtm/locking/TestRTMLockingThreshold.java Fri Oct 14 11:11:19 2016 -0700
@@ -45,6 +45,7 @@
import compiler.testlibrary.rtm.RTMLockingStatistics;
import compiler.testlibrary.rtm.RTMTestBase;
import compiler.testlibrary.rtm.predicate.SupportedCPU;
+import compiler.testlibrary.rtm.predicate.SupportedOS;
import compiler.testlibrary.rtm.predicate.SupportedVM;
import jdk.internal.misc.Unsafe;
import jdk.test.lib.Asserts;
@@ -60,7 +61,7 @@
*/
public class TestRTMLockingThreshold extends CommandLineOptionTest {
private TestRTMLockingThreshold() {
- super(new AndPredicate(new SupportedVM(), new SupportedCPU()));
+ super(new AndPredicate(new SupportedCPU(), new SupportedOS(), new SupportedVM()));
}
/**
--- a/hotspot/test/compiler/rtm/locking/TestRTMRetryCount.java Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/test/compiler/rtm/locking/TestRTMRetryCount.java Fri Oct 14 11:11:19 2016 -0700
@@ -44,6 +44,7 @@
import compiler.testlibrary.rtm.RTMLockingStatistics;
import compiler.testlibrary.rtm.RTMTestBase;
import compiler.testlibrary.rtm.predicate.SupportedCPU;
+import compiler.testlibrary.rtm.predicate.SupportedOS;
import compiler.testlibrary.rtm.predicate.SupportedVM;
import jdk.test.lib.Asserts;
import jdk.test.lib.process.OutputAnalyzer;
@@ -64,7 +65,7 @@
private static final boolean INFLATE_MONITOR = true;
private TestRTMRetryCount() {
- super(new AndPredicate(new SupportedCPU(), new SupportedVM()));
+ super(new AndPredicate(new SupportedCPU(), new SupportedOS(), new SupportedVM()));
}
@Override
--- a/hotspot/test/compiler/rtm/locking/TestRTMSpinLoopCount.java Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/test/compiler/rtm/locking/TestRTMSpinLoopCount.java Fri Oct 14 11:11:19 2016 -0700
@@ -45,6 +45,7 @@
import compiler.testlibrary.rtm.RTMLockingStatistics;
import compiler.testlibrary.rtm.RTMTestBase;
import compiler.testlibrary.rtm.predicate.SupportedCPU;
+import compiler.testlibrary.rtm.predicate.SupportedOS;
import compiler.testlibrary.rtm.predicate.SupportedVM;
import jdk.test.lib.Asserts;
import jdk.test.lib.process.OutputAnalyzer;
@@ -66,7 +67,7 @@
= new int[] { 0, 100, 1_000, 1_000_000, 10_000_000 };
private TestRTMSpinLoopCount() {
- super(new AndPredicate(new SupportedVM(), new SupportedCPU()));
+ super(new AndPredicate(new SupportedCPU(), new SupportedOS(), new SupportedVM()));
}
@Override
--- a/hotspot/test/compiler/rtm/locking/TestRTMTotalCountIncrRate.java Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/test/compiler/rtm/locking/TestRTMTotalCountIncrRate.java Fri Oct 14 11:11:19 2016 -0700
@@ -45,6 +45,7 @@
import compiler.testlibrary.rtm.RTMLockingStatistics;
import compiler.testlibrary.rtm.RTMTestBase;
import compiler.testlibrary.rtm.predicate.SupportedCPU;
+import compiler.testlibrary.rtm.predicate.SupportedOS;
import compiler.testlibrary.rtm.predicate.SupportedVM;
import jdk.internal.misc.Unsafe;
import jdk.test.lib.Asserts;
@@ -64,7 +65,7 @@
*/
public class TestRTMTotalCountIncrRate extends CommandLineOptionTest {
private TestRTMTotalCountIncrRate() {
- super(new AndPredicate(new SupportedCPU(), new SupportedVM()));
+ super(new AndPredicate(new SupportedCPU(), new SupportedOS(), new SupportedVM()));
}
@Override
--- a/hotspot/test/compiler/rtm/locking/TestUseRTMAfterLockInflation.java Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/test/compiler/rtm/locking/TestUseRTMAfterLockInflation.java Fri Oct 14 11:11:19 2016 -0700
@@ -45,6 +45,7 @@
import compiler.testlibrary.rtm.RTMLockingStatistics;
import compiler.testlibrary.rtm.RTMTestBase;
import compiler.testlibrary.rtm.predicate.SupportedCPU;
+import compiler.testlibrary.rtm.predicate.SupportedOS;
import compiler.testlibrary.rtm.predicate.SupportedVM;
import jdk.test.lib.Asserts;
import jdk.test.lib.process.OutputAnalyzer;
@@ -73,7 +74,7 @@
= 2L * AbortProvoker.DEFAULT_ITERATIONS;
private TestUseRTMAfterLockInflation() {
- super(new AndPredicate(new SupportedVM(), new SupportedCPU()));
+ super(new AndPredicate(new SupportedCPU(), new SupportedOS(), new SupportedVM()));
}
@Override
--- a/hotspot/test/compiler/rtm/locking/TestUseRTMDeopt.java Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/test/compiler/rtm/locking/TestUseRTMDeopt.java Fri Oct 14 11:11:19 2016 -0700
@@ -44,6 +44,7 @@
import compiler.testlibrary.rtm.AbortType;
import compiler.testlibrary.rtm.RTMTestBase;
import compiler.testlibrary.rtm.predicate.SupportedCPU;
+import compiler.testlibrary.rtm.predicate.SupportedOS;
import compiler.testlibrary.rtm.predicate.SupportedVM;
import jdk.test.lib.Asserts;
import jdk.test.lib.process.OutputAnalyzer;
@@ -56,7 +57,7 @@
*/
public class TestUseRTMDeopt extends CommandLineOptionTest {
private TestUseRTMDeopt() {
- super(new AndPredicate(new SupportedVM(), new SupportedCPU()));
+ super(new AndPredicate(new SupportedCPU(), new SupportedOS(), new SupportedVM()));
}
@Override
--- a/hotspot/test/compiler/rtm/locking/TestUseRTMForInflatedLocks.java Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/test/compiler/rtm/locking/TestUseRTMForInflatedLocks.java Fri Oct 14 11:11:19 2016 -0700
@@ -43,6 +43,7 @@
import compiler.testlibrary.rtm.RTMLockingStatistics;
import compiler.testlibrary.rtm.RTMTestBase;
import compiler.testlibrary.rtm.predicate.SupportedCPU;
+import compiler.testlibrary.rtm.predicate.SupportedOS;
import compiler.testlibrary.rtm.predicate.SupportedVM;
import jdk.test.lib.Asserts;
import jdk.test.lib.process.OutputAnalyzer;
@@ -63,7 +64,7 @@
*/
public class TestUseRTMForInflatedLocks extends CommandLineOptionTest {
private TestUseRTMForInflatedLocks() {
- super(new AndPredicate(new SupportedCPU(), new SupportedVM()));
+ super(new AndPredicate(new SupportedCPU(), new SupportedOS(), new SupportedVM()));
}
@Override
--- a/hotspot/test/compiler/rtm/locking/TestUseRTMForStackLocks.java Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/test/compiler/rtm/locking/TestUseRTMForStackLocks.java Fri Oct 14 11:11:19 2016 -0700
@@ -44,6 +44,7 @@
import compiler.testlibrary.rtm.RTMLockingStatistics;
import compiler.testlibrary.rtm.RTMTestBase;
import compiler.testlibrary.rtm.predicate.SupportedCPU;
+import compiler.testlibrary.rtm.predicate.SupportedOS;
import compiler.testlibrary.rtm.predicate.SupportedVM;
import jdk.test.lib.Asserts;
import jdk.test.lib.process.OutputAnalyzer;
@@ -66,7 +67,7 @@
private static final boolean INFLATE_MONITOR = false;
private TestUseRTMForStackLocks() {
- super(new AndPredicate(new SupportedCPU(), new SupportedVM()));
+ super(new AndPredicate(new SupportedCPU(), new SupportedOS(), new SupportedVM()));
}
@Override
--- a/hotspot/test/compiler/rtm/locking/TestUseRTMXendForLockBusy.java Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/test/compiler/rtm/locking/TestUseRTMXendForLockBusy.java Fri Oct 14 11:11:19 2016 -0700
@@ -46,6 +46,7 @@
import compiler.testlibrary.rtm.RTMLockingStatistics;
import compiler.testlibrary.rtm.RTMTestBase;
import compiler.testlibrary.rtm.predicate.SupportedCPU;
+import compiler.testlibrary.rtm.predicate.SupportedOS;
import compiler.testlibrary.rtm.predicate.SupportedVM;
import jdk.test.lib.Asserts;
import jdk.test.lib.process.OutputAnalyzer;
@@ -62,7 +63,7 @@
private final static int LOCKING_TIME = 5000;
private TestUseRTMXendForLockBusy() {
- super(new AndPredicate(new SupportedVM(), new SupportedCPU()));
+ super(new AndPredicate(new SupportedCPU(), new SupportedOS(), new SupportedVM()));
}
@Override
--- a/hotspot/test/compiler/rtm/method_options/TestNoRTMLockElidingOption.java Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/test/compiler/rtm/method_options/TestNoRTMLockElidingOption.java Fri Oct 14 11:11:19 2016 -0700
@@ -45,6 +45,7 @@
import compiler.testlibrary.rtm.RTMLockingStatistics;
import compiler.testlibrary.rtm.RTMTestBase;
import compiler.testlibrary.rtm.predicate.SupportedCPU;
+import compiler.testlibrary.rtm.predicate.SupportedOS;
import compiler.testlibrary.rtm.predicate.SupportedVM;
import jdk.test.lib.Asserts;
import jdk.test.lib.process.OutputAnalyzer;
@@ -62,7 +63,7 @@
*/
public class TestNoRTMLockElidingOption extends CommandLineOptionTest {
private TestNoRTMLockElidingOption() {
- super(new AndPredicate(new SupportedCPU(), new SupportedVM()));
+ super(new AndPredicate(new SupportedCPU(), new SupportedOS(), new SupportedVM()));
}
@Override
--- a/hotspot/test/compiler/rtm/method_options/TestUseRTMLockElidingOption.java Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/test/compiler/rtm/method_options/TestUseRTMLockElidingOption.java Fri Oct 14 11:11:19 2016 -0700
@@ -46,6 +46,7 @@
import compiler.testlibrary.rtm.RTMLockingStatistics;
import compiler.testlibrary.rtm.RTMTestBase;
import compiler.testlibrary.rtm.predicate.SupportedCPU;
+import compiler.testlibrary.rtm.predicate.SupportedOS;
import compiler.testlibrary.rtm.predicate.SupportedVM;
import jdk.test.lib.Asserts;
import jdk.test.lib.process.OutputAnalyzer;
@@ -68,7 +69,7 @@
*/
public class TestUseRTMLockElidingOption extends CommandLineOptionTest {
private TestUseRTMLockElidingOption() {
- super(new AndPredicate(new SupportedCPU(), new SupportedVM()));
+ super(new AndPredicate(new SupportedCPU(), new SupportedOS(), new SupportedVM()));
}
@Override
--- a/hotspot/test/compiler/rtm/print/TestPrintPreciseRTMLockingStatistics.java Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/test/compiler/rtm/print/TestPrintPreciseRTMLockingStatistics.java Fri Oct 14 11:11:19 2016 -0700
@@ -48,6 +48,7 @@
import compiler.testlibrary.rtm.RTMLockingStatistics;
import compiler.testlibrary.rtm.RTMTestBase;
import compiler.testlibrary.rtm.predicate.SupportedCPU;
+import compiler.testlibrary.rtm.predicate.SupportedOS;
import compiler.testlibrary.rtm.predicate.SupportedVM;
import jdk.test.lib.Asserts;
import jdk.test.lib.process.OutputAnalyzer;
@@ -67,7 +68,7 @@
public class TestPrintPreciseRTMLockingStatistics
extends CommandLineOptionTest {
private TestPrintPreciseRTMLockingStatistics() {
- super(new AndPredicate(new SupportedCPU(), new SupportedVM()));
+ super(new AndPredicate(new SupportedCPU(), new SupportedOS(), new SupportedVM()));
}
@Override
--- a/hotspot/test/compiler/stringopts/TestStringObjectInitialization.java Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/test/compiler/stringopts/TestStringObjectInitialization.java Fri Oct 14 11:11:19 2016 -0700
@@ -67,6 +67,11 @@
add(s + Arrays.toString(sArray) + " const ");
}
+ public void reset() {
+ // Reset string to avoid OOMEs
+ myString = "";
+ }
+
private static class Runner implements Runnable {
private TestStringObjectInitialization test;
@@ -76,8 +81,9 @@
public void run() {
String[] array = {"a", "b", "c"};
- for (int i = 0; i < 10000; ++i) {
+ for (int i = 0; i < 100_000; ++i) {
test.run("a", array);
+ test.reset();
}
}
}
--- a/hotspot/test/compiler/testlibrary/rtm/RTMTestBase.java Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/test/compiler/testlibrary/rtm/RTMTestBase.java Fri Oct 14 11:11:19 2016 -0700
@@ -241,7 +241,8 @@
"-XX:-TieredCompilation", "-XX:+UseRTMLocking",
CommandLineOptionTest.UNLOCK_DIAGNOSTIC_VM_OPTIONS,
CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS,
- "-Xbootclasspath/a:.", "-XX:+WhiteBoxAPI");
+ "-Xbootclasspath/a:.", "-XX:+WhiteBoxAPI",
+ "-XaddExports:java.base/jdk.internal.misc=ALL-UNNAMED");
if (test != null) {
for (String method : test.getMethodsToCompileNames()) {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/testlibrary/rtm/predicate/SupportedOS.java Fri Oct 14 11:11:19 2016 -0700
@@ -0,0 +1,48 @@
+/*
+ * 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 compiler.testlibrary.rtm.predicate;
+
+import jdk.test.lib.Platform;
+
+import java.util.function.BooleanSupplier;
+
+public class SupportedOS implements BooleanSupplier {
+ @Override
+ public boolean getAsBoolean() {
+ if (Platform.isAix()) {
+ // Actually, this works since AIX 7.1.3.30, but os.version property
+ // is set to 7.1.
+ return (Platform.getOsVersionMajor() > 7) ||
+ (Platform.getOsVersionMajor() == 7 && Platform.getOsVersionMinor() > 1);
+
+ } else if (Platform.isLinux()) {
+ if (Platform.isPPC()) {
+ return (Platform.getOsVersionMajor() > 4) ||
+ (Platform.getOsVersionMajor() == 4 && Platform.getOsVersionMinor() > 1);
+ }
+ }
+ return true;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/native/classfile/test_symbolTable.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -0,0 +1,77 @@
+/*
+ * 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/interfaceSupport.hpp"
+#include "classfile/symbolTable.hpp"
+#include "unittest.hpp"
+
+TEST(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();
+ // the thread should be in vm to use locks
+ ThreadInVMfromNative ThreadInVMfromNative(THREAD);
+
+ Symbol* abc = SymbolTable::new_symbol("abc", CATCH);
+ int abccount = abc->refcount();
+ TempNewSymbol ss = abc;
+ ASSERT_EQ(ss->refcount(), abccount) << "only one abc";
+ ASSERT_EQ(ss->refcount(), abc->refcount()) << "should match TempNewSymbol";
+
+ Symbol* efg = SymbolTable::new_symbol("efg", CATCH);
+ Symbol* hij = SymbolTable::new_symbol("hij", CATCH);
+ int efgcount = efg->refcount();
+ int hijcount = hij->refcount();
+
+ TempNewSymbol s1 = efg;
+ TempNewSymbol s2 = hij;
+ ASSERT_EQ(s1->refcount(), efgcount) << "one efg";
+ ASSERT_EQ(s2->refcount(), hijcount) << "one hij";
+
+ // Assignment operator
+ s1 = s2;
+ ASSERT_EQ(hij->refcount(), hijcount + 1) << "should be two hij";
+ ASSERT_EQ(efg->refcount(), efgcount - 1) << "should be no efg";
+
+ s1 = ss; // s1 is abc
+ ASSERT_EQ(s1->refcount(), abccount + 1) << "should be two abc (s1 and ss)";
+ ASSERT_EQ(hij->refcount(), hijcount) << "should only have one hij now (s2)";
+
+ s1 = s1; // self assignment
+ ASSERT_EQ(s1->refcount(), abccount + 1) << "should still be two abc (s1 and ss)";
+
+ TempNewSymbol s3;
+ Symbol* klm = SymbolTable::new_symbol("klm", CATCH);
+ int klmcount = klm->refcount();
+ s3 = klm; // assignment
+ ASSERT_EQ(s3->refcount(), klmcount) << "only one klm now";
+
+ Symbol* xyz = SymbolTable::new_symbol("xyz", CATCH);
+ int xyzcount = xyz->refcount();
+ { // inner scope
+ TempNewSymbol s_inner = xyz;
+ }
+ ASSERT_EQ(xyz->refcount(), xyzcount - 1)
+ << "Should have been decremented by dtor in inner scope";
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/native/gc/g1/test_g1IHOPControl.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -0,0 +1,149 @@
+/*
+ * 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 "gc/g1/g1CollectedHeap.inline.hpp"
+#include "gc/g1/g1IHOPControl.hpp"
+#include "gc/g1/g1Predictions.hpp"
+#include "unittest.hpp"
+
+static void test_update(G1IHOPControl* ctrl, double alloc_time,
+ size_t alloc_amount, size_t young_size,
+ double mark_time) {
+ for (int i = 0; i < 100; i++) {
+ ctrl->update_allocation_info(alloc_time, alloc_amount, young_size);
+ ctrl->update_marking_length(mark_time);
+ }
+}
+
+// @requires UseG1GC
+TEST_VM(G1StaticIHOPControl, simple) {
+ // Test requires G1
+ if (!UseG1GC) {
+ return;
+ }
+
+ const size_t initial_ihop = 45;
+
+ G1StaticIHOPControl ctrl(initial_ihop);
+ ctrl.update_target_occupancy(100);
+
+ size_t threshold = ctrl.get_conc_mark_start_threshold();
+ EXPECT_EQ(initial_ihop, threshold);
+
+ ctrl.update_allocation_info(100.0, 100, 100);
+ threshold = ctrl.get_conc_mark_start_threshold();
+ EXPECT_EQ(initial_ihop, threshold);
+
+ ctrl.update_marking_length(1000.0);
+ threshold = ctrl.get_conc_mark_start_threshold();
+ EXPECT_EQ(initial_ihop, threshold);
+
+ // Whatever we pass, the IHOP value must stay the same.
+ test_update(&ctrl, 2, 10, 10, 3);
+ threshold = ctrl.get_conc_mark_start_threshold();
+
+ EXPECT_EQ(initial_ihop, threshold);
+
+ test_update(&ctrl, 12, 10, 10, 3);
+ threshold = ctrl.get_conc_mark_start_threshold();
+
+ EXPECT_EQ(initial_ihop, threshold);
+}
+
+// @requires UseG1GC
+TEST_VM(G1AdaptiveIHOPControl, simple) {
+ // Test requires G1
+ if (!UseG1GC) {
+ return;
+ }
+
+ const size_t initial_threshold = 45;
+ const size_t young_size = 10;
+ const size_t target_size = 100;
+
+ // The final IHOP value is always
+ // target_size - (young_size + alloc_amount/alloc_time * marking_time)
+
+ G1Predictions pred(0.95);
+ G1AdaptiveIHOPControl ctrl(initial_threshold, &pred, 0, 0);
+ ctrl.update_target_occupancy(target_size);
+
+ // First "load".
+ const size_t alloc_time1 = 2;
+ const size_t alloc_amount1 = 10;
+ const size_t marking_time1 = 2;
+ const size_t settled_ihop1 = target_size
+ - (young_size + alloc_amount1 / alloc_time1 * marking_time1);
+
+ size_t threshold;
+ threshold = ctrl.get_conc_mark_start_threshold();
+
+ EXPECT_EQ(initial_threshold, threshold);
+
+ for (size_t i = 0; i < G1AdaptiveIHOPNumInitialSamples - 1; i++) {
+ ctrl.update_allocation_info(alloc_time1, alloc_amount1, young_size);
+ ctrl.update_marking_length(marking_time1);
+ // Not enough data yet.
+ threshold = ctrl.get_conc_mark_start_threshold();
+
+ ASSERT_EQ(initial_threshold, threshold) << "on step " << i;
+ }
+
+ test_update(&ctrl, alloc_time1, alloc_amount1, young_size, marking_time1);
+
+ threshold = ctrl.get_conc_mark_start_threshold();
+
+ EXPECT_EQ(settled_ihop1, threshold);
+
+ // Second "load". A bit higher allocation rate.
+ const size_t alloc_time2 = 2;
+ const size_t alloc_amount2 = 30;
+ const size_t marking_time2 = 2;
+ const size_t settled_ihop2 = target_size
+ - (young_size + alloc_amount2 / alloc_time2 * marking_time2);
+
+ test_update(&ctrl, alloc_time2, alloc_amount2, young_size, marking_time2);
+
+ threshold = ctrl.get_conc_mark_start_threshold();
+
+ EXPECT_LT(threshold, settled_ihop1);
+
+ // Third "load". Very high (impossible) allocation rate.
+ const size_t alloc_time3 = 1;
+ const size_t alloc_amount3 = 50;
+ const size_t marking_time3 = 2;
+ const size_t settled_ihop3 = 0;
+
+ test_update(&ctrl, alloc_time3, alloc_amount3, young_size, marking_time3);
+ threshold = ctrl.get_conc_mark_start_threshold();
+
+ EXPECT_EQ(settled_ihop3, threshold);
+
+ // And back to some arbitrary value.
+ test_update(&ctrl, alloc_time2, alloc_amount2, young_size, marking_time2);
+
+ threshold = ctrl.get_conc_mark_start_threshold();
+
+ EXPECT_GT(threshold, settled_ihop3);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/native/oops/test_arrayOop.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -0,0 +1,89 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please 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 "oops/arrayOop.hpp"
+#include "oops/oop.inline.hpp"
+#include "unittest.hpp"
+#include "utilities/globalDefinitions.hpp"
+
+class arrayOopDescTest {
+ public:
+
+ static int header_size_in_bytes() {
+ return arrayOopDesc::header_size_in_bytes();
+ }
+};
+
+static bool check_max_length_overflow(BasicType type) {
+ julong length = arrayOopDesc::max_array_length(type);
+ julong bytes_per_element = type2aelembytes(type);
+ julong bytes = length * bytes_per_element
+ + arrayOopDescTest::header_size_in_bytes();
+ return (julong) (size_t) bytes == bytes;
+}
+
+TEST(arrayOopDesc, boolean) {
+ ASSERT_PRED1(check_max_length_overflow, T_BOOLEAN);
+}
+
+TEST(arrayOopDesc, char) {
+ ASSERT_PRED1(check_max_length_overflow, T_CHAR);
+}
+
+TEST(arrayOopDesc, float) {
+ ASSERT_PRED1(check_max_length_overflow, T_FLOAT);
+}
+
+TEST(arrayOopDesc, double) {
+ ASSERT_PRED1(check_max_length_overflow, T_DOUBLE);
+}
+
+TEST(arrayOopDesc, byte) {
+ ASSERT_PRED1(check_max_length_overflow, T_BYTE);
+}
+
+TEST(arrayOopDesc, short) {
+ ASSERT_PRED1(check_max_length_overflow, T_SHORT);
+}
+
+TEST(arrayOopDesc, int) {
+ ASSERT_PRED1(check_max_length_overflow, T_INT);
+}
+
+TEST(arrayOopDesc, long) {
+ ASSERT_PRED1(check_max_length_overflow, T_LONG);
+}
+
+TEST(arrayOopDesc, object) {
+ ASSERT_PRED1(check_max_length_overflow, T_OBJECT);
+}
+
+TEST(arrayOopDesc, array) {
+ ASSERT_PRED1(check_max_length_overflow, T_ARRAY);
+}
+
+TEST(arrayOopDesc, narrowOop) {
+ ASSERT_PRED1(check_max_length_overflow, T_NARROWOOP);
+}
+// T_VOID and T_ADDRESS are not supported by max_array_length()
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/native/oops/test_instanceKlass.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -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.
+ */
+
+#include "precompiled.hpp"
+#include "classfile/symbolTable.hpp"
+#include "classfile/systemDictionary.hpp"
+#include "memory/resourceArea.hpp"
+#include "oops/instanceKlass.hpp"
+#include "unittest.hpp"
+
+// Tests InstanceKlass::package_from_name()
+TEST_VM(InstanceKlass, null_symbol) {
+ ResourceMark rm;
+ TempNewSymbol package_sym = InstanceKlass::package_from_name(NULL, NULL);
+ ASSERT_TRUE(package_sym == NULL) << "Wrong package for NULL symbol";
+}
+
+// Tests for InstanceKlass::is_class_loader_instance_klass() function
+TEST_VM(InstanceKlass, class_loader_class) {
+ InstanceKlass* klass = SystemDictionary::ClassLoader_klass();
+ ASSERT_TRUE(klass->is_class_loader_instance_klass());
+}
+
+TEST_VM(InstanceKlass, string_klass) {
+ InstanceKlass* klass = SystemDictionary::String_klass();
+ ASSERT_TRUE(!klass->is_class_loader_instance_klass());
+}
--- a/hotspot/test/native/runtime/test_instanceKlass.cpp Fri Oct 14 19:12:37 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +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.
- *
- */
-
-#include "precompiled.hpp"
-#include "classfile/symbolTable.hpp"
-#include "memory/resourceArea.hpp"
-#include "oops/instanceKlass.hpp"
-#include "unittest.hpp"
-
-// Tests InstanceKlass::package_from_name()
-TEST_VM(instanceKlass, null_symbol) {
- ResourceMark rm;
- TempNewSymbol package_sym = InstanceKlass::package_from_name(NULL, NULL);
- ASSERT_TRUE(package_sym == NULL) << "Wrong package for NULL symbol";
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/native/utilities/test_chunkedList.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -0,0 +1,130 @@
+/*
+ * 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.
+ */
+
+#include "precompiled.hpp"
+#include "unittest.hpp"
+#include "utilities/chunkedList.hpp"
+
+class Metadata;
+
+template <typename T>
+class TestChunkedList {
+ typedef ChunkedList<T, mtOther> ChunkedListT;
+
+ public:
+
+ static void testEmpty() {
+ ChunkedListT buffer;
+ ASSERT_EQ((size_t) 0, buffer.size());
+ }
+
+ static void testFull() {
+ ChunkedListT buffer;
+ for (uintptr_t i = 0; i < ChunkedListT::BufferSize; i++) {
+ buffer.push((T) i);
+ }
+ ASSERT_EQ((size_t) ChunkedListT::BufferSize, buffer.size());
+ ASSERT_TRUE(buffer.is_full());
+ }
+
+ static void testSize() {
+ ChunkedListT buffer;
+ for (uintptr_t i = 0; i < ChunkedListT::BufferSize; i++) {
+ ASSERT_EQ((size_t) i, buffer.size());
+ buffer.push((T) i);
+ ASSERT_EQ((size_t) (i + 1), buffer.size());
+ }
+ }
+
+ static void testClear() {
+ ChunkedListT buffer;
+
+ buffer.clear();
+ ASSERT_EQ((size_t) 0, buffer.size());
+
+ for (uintptr_t i = 0; i < ChunkedListT::BufferSize / 2; i++) {
+ buffer.push((T) i);
+ }
+ buffer.clear();
+ ASSERT_EQ((size_t) 0, buffer.size());
+
+ for (uintptr_t i = 0; i < ChunkedListT::BufferSize; i++) {
+ buffer.push((T) i);
+ }
+ buffer.clear();
+ ASSERT_EQ((size_t) 0, buffer.size());
+ }
+
+ static void testAt() {
+ ChunkedListT buffer;
+
+ for (uintptr_t i = 0; i < ChunkedListT::BufferSize; i++) {
+ buffer.push((T) i);
+ ASSERT_EQ((T) i, buffer.at(i));
+ }
+
+ for (uintptr_t i = 0; i < ChunkedListT::BufferSize; i++) {
+ ASSERT_EQ((T) i, buffer.at(i));
+ }
+ }
+};
+
+TEST(ChunkedList, metadata_empty) {
+ TestChunkedList<Metadata*>::testEmpty();
+}
+
+TEST(ChunkedList, metadata_full) {
+ TestChunkedList<Metadata*>::testFull();
+}
+
+TEST(ChunkedList, metadata_size) {
+ TestChunkedList<Metadata*>::testSize();
+}
+
+TEST(ChunkedList, metadata_clear) {
+ TestChunkedList<Metadata*>::testSize();
+}
+
+TEST(ChunkedList, metadata_at) {
+ TestChunkedList<Metadata*>::testAt();
+}
+
+TEST(ChunkedList, size_t_empty) {
+ TestChunkedList<size_t>::testEmpty();
+}
+
+TEST(ChunkedList, size_t_full) {
+ TestChunkedList<size_t>::testFull();
+}
+
+TEST(ChunkedList, size_t_size) {
+ TestChunkedList<size_t>::testSize();
+}
+
+TEST(ChunkedList, size_t_clear) {
+ TestChunkedList<size_t>::testSize();
+}
+
+TEST(ChunkedList, size_t_at) {
+ TestChunkedList<size_t>::testAt();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/native/utilities/test_json.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -0,0 +1,515 @@
+/*
+ * 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 "prims/jvm.h"
+#include "utilities/json.hpp"
+#include "unittest.hpp"
+
+class JSON_GTest : public JSON {
+public:
+ static void test(const char* json, bool valid);
+
+private:
+ JSON_GTest(const char* text);
+
+ void log(uint level, const char* format, ...) ATTRIBUTE_PRINTF(3, 4);
+
+ bool callback(JSON_TYPE t, JSON_VAL* v, uint level);
+ JSON_TYPE prev;
+};
+
+void JSON_GTest::test(const char* text, bool should_pass) {
+ JSON_GTest json(text);
+ if (should_pass) {
+ ASSERT_TRUE(json.valid()) << "failed on a valid json string";
+ } else {
+ ASSERT_FALSE(json.valid()) << "succeeded on an invalid json string";
+ }
+}
+
+JSON_GTest::JSON_GTest(const char* text) : JSON(text, false, tty) {
+ prev = JSON_NONE;
+ parse();
+}
+
+TEST(utilities, json_curly_braces) {
+ JSON_GTest::test("{}", true);
+}
+
+TEST(utilities, json_brackets) {
+ JSON_GTest::test("[]", true);
+}
+
+TEST(utilities, json_space_braces) {
+ JSON_GTest::test(" { } ", true);
+}
+
+TEST(utilities, json_space_bracketes) {
+ JSON_GTest::test(" [ ] ", true);
+}
+
+TEST(utilities, json_quoted_error) {
+ JSON_GTest::test("\"error\"", false);
+}
+
+TEST(utilities, json_error_string) {
+ JSON_GTest::test("error", false);
+}
+
+TEST(utilities, json_simple_integer) {
+ JSON_GTest::test("1", false);
+}
+
+TEST(utilities, json_siple_float) {
+ JSON_GTest::test("1.2", false);
+}
+
+TEST(utilities, json_simple_boolean_true) {
+ JSON_GTest::test("true", false);
+}
+
+TEST(utilities, json_simple_boolean_false) {
+ JSON_GTest::test("false", false);
+}
+
+TEST(utilities, json_simple_null) {
+ JSON_GTest::test("null", false);
+}
+
+TEST(utilities, json_one_element_int_array) {
+ JSON_GTest::test("[ 1 ]", true);
+}
+
+TEST(utilities, json_int_array) {
+ JSON_GTest::test("[ 1, ]", true);
+}
+
+TEST(utilities, json_one_element_bool_array) {
+ JSON_GTest::test("[ true ]", true);
+}
+
+TEST(utilities, json_bool_array) {
+ JSON_GTest::test("[ true, ]", true);
+}
+
+TEST(utilities, json_one_element_false_array) {
+ JSON_GTest::test("[ false ]", true);
+}
+
+TEST(utilities, json_false_bool_array) {
+ JSON_GTest::test("[ false, ]", true);
+}
+
+TEST(utilities, json_one_null_array) {
+ JSON_GTest::test("[ null ]", true);
+}
+
+TEST(utilities, json_null_array) {
+ JSON_GTest::test("[ null, ]", true);
+}
+
+TEST(utilities, json_one_empty_string_array) {
+ JSON_GTest::test("[ \"\" ]", true);
+}
+
+TEST(utilities, json_empty_string_array) {
+ JSON_GTest::test("[ \"\", ]", true);
+}
+
+TEST(utilities, json_single_string_array) {
+ JSON_GTest::test("[ \"elem1\" ]", true);
+}
+
+TEST(utilities, json_string_comma_arrray) {
+ JSON_GTest::test("[ \"elem1\", ]", true);
+}
+
+TEST(utilities, json_two_strings_array) {
+ JSON_GTest::test("[ \"elem1\", \"elem2\" ]", true);
+}
+
+TEST(utilities, json_two_strings_comma_array) {
+ JSON_GTest::test("[ \"elem1\", \"elem2\", ]", true);
+}
+
+TEST(utilities, json_curly_braces_outside) {
+ JSON_GTest::test("[ \"elem1\" ] { }", false);
+}
+
+TEST(utilities, json_element_in_array) {
+ JSON_GTest::test("[ elem1, \"elem2\" ]", false);
+}
+
+TEST(utilities, json_incorrect_end_array) {
+ JSON_GTest::test("[ \"elem1\"", false);
+}
+
+TEST(utilities, json_incorrect_string_end) {
+ JSON_GTest::test("[ \"elem1 ]", false);
+}
+
+TEST(utilities, json_incorrect_end_of_two_elements_array) {
+ JSON_GTest::test("[ \"elem1\", \"elem2\"", false);
+}
+
+TEST(utilities, json_incorrect_bool_true_array) {
+ JSON_GTest::test("[ truefoo ]", false);
+}
+
+TEST(utilities, json_incorrect_bool_false_array) {
+ JSON_GTest::test("[ falsefoo ]", false);
+}
+
+TEST(utilities, json_incorrect_null_array) {
+ JSON_GTest::test("[ nullfoo ]", false);
+}
+
+TEST(utilities, json_key_pair) {
+ JSON_GTest::test("{ key : 1 }", true);
+}
+
+TEST(utilities, json_key_pair_comma) {
+ JSON_GTest::test("{ key : 1, }", true);
+}
+
+TEST(utilities, json_bool_true_key) {
+ JSON_GTest::test("{ key : true }", true);
+}
+
+TEST(utilities, json_bool_true_key_comma) {
+ JSON_GTest::test("{ key : true, }", true);
+}
+
+TEST(utilities, json_bool_false_key) {
+ JSON_GTest::test("{ key : false }", true);
+}
+
+TEST(utilities, json_bool_false_key_comma) {
+ JSON_GTest::test("{ key : false, }", true);
+}
+
+TEST(utilities, json_null_key) {
+ JSON_GTest::test("{ key : null }", true);
+}
+
+TEST(utilities, json_null_key_comma) {
+ JSON_GTest::test("{ key : null, }", true);
+}
+
+TEST(utilities, json_pair_of_empty_strings) {
+ JSON_GTest::test("{ \"\" : \"\" }", true);
+}
+
+TEST(utilities, json_pair_of_empty_strings_comma) {
+ JSON_GTest::test("{ \"\" : \"\", }", true);
+}
+
+TEST(utilities, json_pair_of_strings) {
+ JSON_GTest::test("{ \"key1\" : \"val1\" }", true);
+}
+
+TEST(utilities, json_pair_of_strings_comma) {
+ JSON_GTest::test("{ \"key1\" : \"val1\", }", true);
+}
+
+TEST(utilities, json_two_pairs_of_strings) {
+ JSON_GTest::test("{ \"key1\" : \"val1\", \"key2\" : \"val2\" }", true);
+}
+
+TEST(utilities, json_two_pairs_of_strings_comma) {
+ JSON_GTest::test("{ \"key1\" : \"val1\", \"key2\" : \"val2\", }", true);
+}
+
+TEST(utilities, json_array_outside) {
+ JSON_GTest::test("{ \"key\" : \"val\" } [ \"error\" ]", false);
+}
+
+TEST(utilities, json_incorrect_object_end) {
+ JSON_GTest::test("{ \"key\" : \"val\" ", false);
+}
+
+TEST(utilities, json_empty_comment) {
+ JSON_GTest::test("/**/ { }", true);
+}
+
+TEST(utilities, json_space_comment) {
+ JSON_GTest::test("/* */ { }", true);
+}
+
+TEST(utilities, json_comment) {
+ JSON_GTest::test("/*foo*/ { }", true);
+}
+
+TEST(utilities, json_star_comment) {
+ JSON_GTest::test("/* *foo */ { }", true);
+}
+
+TEST(utilities, json_stars_comment) {
+ JSON_GTest::test("/* *foo* */ { }", true);
+}
+
+TEST(utilities, json_special_comment) {
+ JSON_GTest::test("/* /*foo */ { }", true);
+}
+
+TEST(utilities, json_comment_after) {
+ JSON_GTest::test("{ } /* foo */", true);
+}
+
+TEST(utilities, json_comment_after_and_space) {
+ JSON_GTest::test("{ } /* foo */ ", true);
+}
+
+TEST(utilities, json_one_line_empty_comment_after) {
+ JSON_GTest::test("{ } //", true);
+}
+
+TEST(utilities, json_one_line_space_comment_after) {
+ JSON_GTest::test("{ } // ", true);
+}
+
+TEST(utilities, json_one_line_comment_after) {
+ JSON_GTest::test("{ } // foo", true);
+}
+
+TEST(utilities, json_incorrect_multiline_comment) {
+ JSON_GTest::test("/* * / { }", false);
+}
+
+TEST(utilities, json_incorrect_multiline_comment_begin) {
+ JSON_GTest::test("/ * */ { }", false);
+}
+
+TEST(utilities, json_oneline_comment_only) {
+ JSON_GTest::test("// { }", false);
+}
+
+TEST(utilities, json_multiline_comment_only) {
+ JSON_GTest::test("/* { } */", false);
+}
+
+TEST(utilities, json_multiline_comment_2) {
+ JSON_GTest::test("/* { } */ ", false);
+}
+
+TEST(utilities, json_incorrectly_commented_object) {
+ JSON_GTest::test("/* { } ", false);
+}
+
+TEST(utilities, json_missing_multiline_end) {
+ JSON_GTest::test("{ } /* ", false);
+}
+
+TEST(utilities, json_missing_multiline_slash) {
+ JSON_GTest::test("/* { } *", false);
+}
+
+TEST(utilities, json_commented_object_end) {
+ JSON_GTest::test("{ /* } */", false);
+}
+
+TEST(utilities, json_commented_array_end) {
+ JSON_GTest::test("[ /* ] */", false);
+}
+
+TEST(utilities, json_missing_object_end) {
+ JSON_GTest::test("{ key : \"val\", /* } */", false);
+}
+
+TEST(utilities, json_missing_array_end) {
+ JSON_GTest::test("[ \"val\", /* ] */", false);
+}
+
+TEST(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) {
+ 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) {
+ JSON_GTest::test("/*comment*/{\"ff1 fsd\":{\"☃\":{\"☃\":[\"☃\",\"☃\"]},"
+ "\"☃\":true},\"☃\":[\"☃\"],\"foo\":\"☃\",}", true);
+}
+
+TEST(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) {
+ JSON_GTest::test("[\n]", true);
+}
+
+TEST(utilities, json_directives_file) {
+ JSON_GTest::test(
+ "[" "\n"
+ " {"
+ " // pattern to match against class+method+signature" "\n"
+ " // leading and trailing wildcard (*) allowed" "\n"
+ " match: \"foo.bar.*\"," "\n"
+ " " "\n"
+ " // override defaults for specified compiler" "\n"
+ " // we may differentiate between levels too. TBD." "\n"
+ " c1: {" "\n"
+ " //override c1 presets " "\n"
+ " array_bounds_check_removal: false" "\n"
+ " }," "\n"
+ "" "\n"
+ " c2: {" "\n"
+ " // control inlining of method" "\n"
+ " // + force inline, - dont inline" "\n"
+ " inline : [ \"+java.util.*\", \"-com.sun.*\"]," "\n"
+ " }," "\n"
+ "" "\n"
+ " // directives outside a specific preset applies to all compilers" "\n"
+ " inline : [ \"+java.util.*\", \"-com.sun.*\"]," "\n"
+ " print_assembly: true," "\n"
+ " verify_oopmaps: true," "\n"
+ " max_loop_unrolling: 5" "\n"
+ " }," "\n"
+ " {" "\n"
+ " // matching several patterns require an array" "\n"
+ " match: [\"baz.*\",\"frob*\"]," "\n"
+ "" "\n"
+ " // only enable c1 for this directive" "\n"
+ " // all enabled by default. Command disables all not listed" "\n"
+ " enable: \"c1\"," "\n"
+ "" "\n"
+ " // applies to all compilers" "\n"
+ " // + force inline, - dont inline" "\n"
+ " inline : [ \"+java.util.*\", \"-com.sun.*\"]," "\n"
+ " print_inlining: true," "\n"
+ "" "\n"
+ " // force matching compiles to be blocking/syncronous" "\n"
+ " blocking_compile: true" "\n"
+ " }," "\n"
+ "]" "\n", true);
+}
+
+void JSON_GTest::log(uint indent, const char* format, ...) {
+ if (prev != JSON_KEY) {
+ for (uint i = 0; i < indent; i++) {
+ _st->print(" ");
+ }
+ }
+ va_list args;
+ va_start(args, format);
+ _st->vprint(format, args);
+ va_end(args);
+}
+
+bool JSON_GTest::callback(JSON_TYPE t, JSON_VAL* v, uint rlevel) {
+ switch (t) {
+ case JSON_OBJECT_BEGIN:
+ log(rlevel, "{\n");
+ prev = JSON_NONE; // Only care about JSON_KEY, to indent correctly
+ return true;
+
+ case JSON_OBJECT_END:
+ log(rlevel, "},\n");
+ prev = JSON_NONE;
+ return true;
+
+ case JSON_ARRAY_BEGIN:
+ log(rlevel, "[\n");
+ prev = JSON_NONE;
+ return true;
+
+ case JSON_ARRAY_END:
+ log(rlevel, "],\n");
+ prev = JSON_NONE;
+ return true;
+
+ case JSON_KEY:
+ for (uint i = 0; i < rlevel; i++) {
+ _st->print(" ");
+ }
+ _st->print("<key>");
+ for (size_t i = 0; i < v->str.length; i++) {
+ u_char c = v->str.start[i];
+ if (c == 0) {
+ return false;
+ }
+ _st->print("%c", c);
+ }
+ _st->print(" : ");
+ prev = JSON_KEY;
+ return true;
+
+ case JSON_STRING:
+ if (prev != JSON_KEY) {
+ for (uint i = 0; i < rlevel; i++) {
+ _st->print(" ");
+ }
+ }
+ _st->print("<str>");
+ for (size_t i = 0; i < v->str.length; i++) {
+ u_char c = v->str.start[i];
+ if (c == 0) {
+ return false;
+ }
+ _st->print("%c", c);
+ }
+ _st->print(",\n");
+ prev = JSON_NONE;
+ return true;
+
+ case JSON_NUMBER_INT:
+ log(rlevel, "<int>%" PRId64 ",\n", v->int_value);
+ prev = JSON_NONE;
+ return true;
+
+ case JSON_NUMBER_FLOAT:
+ log(rlevel, "<double>%lf,\n", v->double_value);
+ prev = JSON_NONE;
+ return true;
+
+ case JSON_TRUE:
+ log(rlevel, "<true>,\n");
+ prev = JSON_NONE;
+ return true;
+
+ case JSON_FALSE:
+ log(rlevel, "<false>,\n");
+ prev = JSON_NONE;
+ return true;
+
+ case JSON_NULL:
+ log(rlevel, "<null>,\n");
+ prev = JSON_NONE;
+ return true;
+
+ default:
+ error(INTERNAL_ERROR, "unknown JSON type");
+ return false;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/native/utilities/test_linkedlist.cpp Fri Oct 14 11:11:19 2016 -0700
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please 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 "unittest.hpp"
+#include "utilities/linkedlist.hpp"
+
+class Integer : public StackObj {
+ private:
+ int _value;
+ public:
+
+ Integer(int i) : _value(i) {
+ }
+
+ int value() const {
+ return _value;
+ }
+
+ bool equals(const Integer& i) const {
+ return _value == i.value();
+ }
+
+ static int compare(const Integer& i1, const Integer& i2) {
+ return i1.value() - i2.value();
+ }
+};
+
+static void check_list_values(const int* expected, const LinkedList<Integer>* list) {
+ LinkedListNode<Integer>* head = list->head();
+ int index = 0;
+ while (head != NULL) {
+ ASSERT_EQ(expected[index], head->peek()->value())
+ << "Unexpected value at index " << index;
+ head = head->next();
+ index++;
+ }
+}
+
+const Integer one(1), two(2), three(3), four(4), five(5), six(6);
+
+// Test regular linked list
+TEST(LinkedList, simple) {
+ LinkedListImpl<Integer, ResourceObj::C_HEAP, mtTest> ll;
+
+ ASSERT_TRUE(ll.is_empty()) << "Start with empty list";
+
+ ll.add(six);
+ ASSERT_TRUE(!ll.is_empty()) << "Should not be empty";
+
+ Integer* i = ll.find(six);
+ ASSERT_TRUE(i != NULL) << "Should find it";
+ ASSERT_EQ(six.value(), i->value()) << "Should be 6";
+
+ i = ll.find(three);
+ ASSERT_EQ(NULL, i) << "Not in the list";
+
+ LinkedListNode<Integer>* node = ll.find_node(six);
+ ASSERT_TRUE(node != NULL) << "6 is in the list";
+
+ ll.insert_after(three, node);
+ ll.insert_before(one, node);
+ int expected[3] = {1, 6, 3};
+ check_list_values(expected, &ll);
+}
+
+// Test sorted linked list
+TEST(SortedLinkedList, simple) {
+ LinkedListImpl<Integer, ResourceObj::C_HEAP, mtTest> ll;
+ ll.add(one);
+ ll.add(six);
+ ll.add(three);
+ ll.add(two);
+ ll.add(four);
+ ll.add(five);
+
+ SortedLinkedList<Integer, Integer::compare, ResourceObj::C_HEAP, mtTest> sl;
+ ASSERT_TRUE(sl.is_empty()) << "Start with empty list";
+
+ size_t ll_size = ll.size();
+ sl.move(&ll);
+ size_t sl_size = sl.size();
+
+ ASSERT_EQ(ll_size, sl_size) << "Should be the same size";
+ ASSERT_TRUE(ll.is_empty()) << "No more entries";
+
+ // sorted result
+ int sorted_result[] = {1, 2, 3, 4, 5, 6};
+ check_list_values(sorted_result, &sl);
+ if (HasFatalFailure()) {
+ return;
+ }
+
+ LinkedListNode<Integer>* node = sl.find_node(four);
+ ASSERT_TRUE(node != NULL) << "4 is in the list";
+ sl.remove_before(node);
+ sl.remove_after(node);
+ int remains[] = {1, 2, 4, 6};
+ check_list_values(remains, &sl);
+}
--- a/hotspot/test/runtime/SharedArchiveFile/SASymbolTableTest.java Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/test/runtime/SharedArchiveFile/SASymbolTableTest.java Fri Oct 14 11:11:19 2016 -0700
@@ -34,14 +34,17 @@
* jdk.hotspot.agent/sun.jvm.hotspot.runtime
* jdk.hotspot.agent/sun.jvm.hotspot.tools
* java.management
- * @build SASymbolTableTestAgent SASymbolTableTestAttachee
+ * @build SASymbolTableTestAgent
* @run main SASymbolTableTest
*/
+import java.util.Arrays;
+import java.util.List;
import jdk.test.lib.process.ProcessTools;
import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.JDKToolFinder;
import jdk.test.lib.Platform;
+import jdk.test.lib.apps.LingeredApp;
/*
* The purpose of this test is to validate that we can use SA to
@@ -53,6 +56,7 @@
*/
public class SASymbolTableTest {
static String jsaName = "./SASymbolTableTest.jsa";
+ private static LingeredApp theApp = null;
public static void main(String[] args) throws Exception {
if (!Platform.shouldSAAttach()) {
@@ -78,50 +82,44 @@
private static void run(boolean useArchive) throws Exception {
String flag = useArchive ? "auto" : "off";
- // (1) Launch the attachee process
- ProcessBuilder attachee = ProcessTools.createJavaProcessBuilder(
- "-XX:+UnlockDiagnosticVMOptions",
- "-XX:SharedArchiveFile=" + jsaName,
- "-Xshare:" + flag,
- "-showversion", // so we can see "sharing" in the output
- "SASymbolTableTestAttachee");
+ try {
+ // (1) Launch the attachee process
+ System.out.println("Starting LingeredApp");
+ List<String> vmOpts = Arrays.asList(
+ "-XX:+UnlockDiagnosticVMOptions",
+ "-XX:SharedArchiveFile=" + jsaName,
+ "-Xshare:" + flag,
+ "-showversion"); // so we can see "sharing" in the output
- final Process p = attachee.start();
+ theApp = LingeredApp.startApp(vmOpts);
- // (2) Launch the agent process
- long pid = p.getPid();
- System.out.println("Attaching agent " + pid);
- ProcessBuilder tool = ProcessTools.createJavaProcessBuilder(
- "--add-modules=jdk.hotspot.agent",
- "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.oops=ALL-UNNAMED",
- "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.memory=ALL-UNNAMED",
- "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.runtime=ALL-UNNAMED",
- "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.tools=ALL-UNNAMED",
- "SASymbolTableTestAgent",
- Long.toString(pid));
- OutputAnalyzer output = ProcessTools.executeProcess(tool);
- System.out.println(output.getOutput());
- output.shouldHaveExitValue(0);
-
- Thread t = new Thread() {
- public void run() {
- try {
- OutputAnalyzer output = new OutputAnalyzer(p);
- System.out.println("STDOUT[");
- System.out.print(output.getStdout());
- System.out.println("]");
- System.out.println("STDERR[");
- System.out.print(output.getStderr());
- System.out.println("]");
- } catch (Throwable t) {
- t.printStackTrace();
- }
- }
- };
- t.start();
-
- Thread.sleep(2 * 1000);
- p.destroy();
- t.join();
+ // (2) Launch the agent process
+ long pid = theApp.getPid();
+ System.out.println("Attaching agent to " + pid );
+ ProcessBuilder tool = ProcessTools.createJavaProcessBuilder(
+ "--add-modules=jdk.hotspot.agent",
+ "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.oops=ALL-UNNAMED",
+ "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.memory=ALL-UNNAMED",
+ "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.runtime=ALL-UNNAMED",
+ "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.tools=ALL-UNNAMED",
+ "SASymbolTableTestAgent",
+ Long.toString(pid));
+ OutputAnalyzer output = ProcessTools.executeProcess(tool);
+ System.out.println("STDOUT[");
+ System.out.println(output.getOutput());
+ if (output.getStdout().contains("connected too early")) {
+ System.out.println("SymbolTable not created by VM - test skipped");
+ return;
+ }
+ System.out.println("]");
+ System.out.println("STDERR[");
+ System.out.print(output.getStderr());
+ System.out.println("]");
+ output.shouldHaveExitValue(0);
+ } catch (Exception ex) {
+ throw new RuntimeException("Test ERROR " + ex, ex);
+ } finally {
+ LingeredApp.stopApp(theApp);
+ }
}
}
--- a/hotspot/test/runtime/SharedArchiveFile/SASymbolTableTestAgent.java Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/test/runtime/SharedArchiveFile/SASymbolTableTestAgent.java Fri Oct 14 11:11:19 2016 -0700
@@ -112,31 +112,35 @@
public void run() {
System.out.println("SASymbolTableTestAgent: starting");
- VM vm = VM.getVM();
- SymbolTable table = vm.getSymbolTable();
+ try {
+ VM vm = VM.getVM();
+ SymbolTable table = vm.getSymbolTable();
- // (a) These are names that are likely to exist in the symbol table
- // of a JVM after start-up. They were taken from vmSymbols.hpp
- // during the middle of JDK9 development.
- //
- // The purpose is not to check that each name must exist (a future
- // version of JDK may not preload some of the classes).
- //
- // The purpose of this loops is to ensure that we check a lot of symbols,
- // so we will (most likely) hit on both VALUE_ONLY_BUCKET_TYPE and normal bucket type
- // in CompactHashTable.probe().
- for (String n : commonNames) {
- Symbol s = table.probe(n);
- System.out.format("%-40s = %s\n", n, s);
- }
+ // (a) These are names that are likely to exist in the symbol table
+ // of a JVM after start-up. They were taken from vmSymbols.hpp
+ // during the middle of JDK9 development.
+ //
+ // The purpose is not to check that each name must exist (a future
+ // version of JDK may not preload some of the classes).
+ //
+ // The purpose of this loops is to ensure that we check a lot of symbols,
+ // so we will (most likely) hit on both VALUE_ONLY_BUCKET_TYPE and normal bucket type
+ // in CompactHashTable.probe().
+ for (String n : commonNames) {
+ Symbol s = table.probe(n);
+ System.out.format("%-40s = %s\n", n, s);
+ }
- System.out.println("======================================================================");
+ System.out.println("======================================================================");
- // (b) Also test a few strings that are known to not exist in the table. This will
- // both the compact table (if it exists) and the regular table to be walked.
- for (String n : badNames) {
- Symbol s = table.probe(n);
- System.out.format("%-40s = %s\n", n, s);
+ // (b) Also test a few strings that are known to not exist in the table. This will
+ // both the compact table (if it exists) and the regular table to be walked.
+ for (String n : badNames) {
+ Symbol s = table.probe(n);
+ System.out.format("%-40s = %s\n", n, s);
+ }
+ } catch (NullPointerException e) {
+ System.out.println("connected too early -- please try again");
}
}
}
--- a/hotspot/test/runtime/SharedArchiveFile/SASymbolTableTestAttachee.java Fri Oct 14 19:12:37 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,38 +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.
- */
-
-/**
- * This class is launched in a sub-process by the main test,
- * SASymbolTableTest.java.
- *
- * This class does nothing in particular. It just sleeps for 120
- * seconds so SASymbolTableTestAgent can have a chance to examine its
- * SymbolTable. This process should be killed by the parent process
- * after SASymbolTableTestAgent has completed testing.
- */
-public class SASymbolTableTestAttachee {
- public static void main(String args[]) throws Throwable {
- System.out.println("SASymbolTableTestAttachee: sleeping to wait for SA tool to attach ...");
- Thread.sleep(120 * 1000);
- }
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/lambda-features/CyclicInterfaceInit.java Fri Oct 14 11:11:19 2016 -0700
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please 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 8163969
+ * @summary Interface initialization was crashing on this because the wrong class was getting
+ * initialization error.
+ * @run main CyclicInterfaceInit
+ */
+/**
+ * This snippet crashes with
+ * - Java(TM) SE Runtime Environment (8.0_101-b13) (build 1.8.0_101-b13)
+ */
+public class CyclicInterfaceInit {
+
+ interface Base {
+ static final Object CONST = new Target(){}.someMethod();
+
+ default void important() {
+ // Super interfaces with default methods get initialized (JLS 12.4.1)
+ }
+ }
+
+ static boolean out(String c) {
+ System.out.println("initializing " + c);
+ return true;
+ }
+
+ interface Target extends Base {
+ boolean v = CyclicInterfaceInit.out("Target");
+ default Object someMethod() {
+ throw new RuntimeException();
+ }
+ // Target can be fully initialized before initializating Base because Target doesn't
+ // initiate the initialization of Base.
+ }
+
+ static class InnerBad implements Target {}
+
+ public static void main(String[] args) {
+ try {
+ new Target() {}; // Creates inner class that causes initialization of super interfaces
+ } catch (ExceptionInInitializerError e) {
+ System.out.println("ExceptionInInitializerError thrown as expected");
+ }
+ // Try again, InnerBad instantiation should throw NoClassdefFoundError
+ // because Base is marked erroneous due to previous exception during initialization
+ try {
+ InnerBad ig = new InnerBad();
+ throw new RuntimeException("FAILED- initialization of InnerBad should throw NCDFE");
+ } catch (NoClassDefFoundError e) {
+ System.out.println("NoClassDefFoundError thrown as expected");
+ }
+ // Target is already initialized.
+ System.out.println("Target.v is " + Target.v);
+ // shouldn't throw any exceptions.
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/lambda-features/InterfaceInitializationStates.java Fri Oct 14 11:11:19 2016 -0700
@@ -0,0 +1,202 @@
+/*
+ * 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 8163969
+ * @summary Test interface initialization states and when certain interfaces are initialized
+ * in the presence of initialization errors.
+ * @run main InterfaceInitializationStates
+ */
+
+import java.util.List;
+import java.util.Arrays;
+import java.util.ArrayList;
+
+public class InterfaceInitializationStates {
+
+ static List<Class<?>> cInitOrder = new ArrayList<>();
+
+ // K interface with a default method has an initialization error
+ interface K {
+ boolean v = InterfaceInitializationStates.out(K.class);
+ static final Object CONST = InterfaceInitializationStates.someMethod();
+ default int method() { return 2; }
+ }
+
+ // I is initialized when CONST is used, and doesn't trigger initialization of K,
+ // I also doesn't get an initialization error just because K has an initialization error.
+ interface I extends K {
+ boolean v = InterfaceInitializationStates.out(I.class);
+ static final Object CONST = InterfaceInitializationStates.someMethod();
+ }
+
+ // L can be fully initialized even though it extends an interface that has an
+ // initialization error
+ interface L extends K {
+ boolean v = InterfaceInitializationStates.out(L.class);
+ default void lx() {}
+ static void func() {
+ System.out.println("Calling function on interface with bad super interface.");
+ }
+ }
+
+ // Another interface needing initialization.
+ // Initialization of this interface does not occur with ClassLIM because K throws
+ // an initialization error, so the interface initialization is abandoned
+ interface M {
+ boolean v = InterfaceInitializationStates.out(M.class);
+ default void mx() {}
+ }
+
+ static class ClassLIM implements L, I, M {
+ boolean v = InterfaceInitializationStates.out(ClassLIM.class);
+ int callMethodInK() { return method(); }
+ static {
+ // Since interface initialization of K fails, this should never be called
+ System.out.println("Initializing C, but L is still good");
+ L.func();
+ }
+ }
+
+ // Finally initialize M
+ static class ClassM implements M {
+ boolean v = InterfaceInitializationStates.out(ClassM.class);
+ }
+
+ // Iunlinked is testing initialization like interface I, except interface I is linked when
+ // ClassLIM is linked.
+ // Iunlinked is not linked already when K gets an initialization error. Linking Iunlinked
+ // should succeed and not get NoClassDefFoundError because it does not depend on the
+ // initialization state of K for linking. There's bug now where it gets this error.
+ // See: https://bugs.openjdk.java.net/browse/JDK-8166203.
+ interface Iunlinked extends K {
+ boolean v = InterfaceInitializationStates.out(Iunlinked.class);
+ }
+
+ // More tests. What happens if we use K for parameters and return types?
+ // K is a symbolic reference in the constant pool and the initialization error only
+ // matters when it's used.
+ interface Iparams {
+ boolean v = InterfaceInitializationStates.out(Iparams.class);
+ K the_k = null;
+ K m(K k); // abstract
+ default K method() { return new K(){}; }
+ }
+
+ static class ClassIparams implements Iparams {
+ boolean v = InterfaceInitializationStates.out(ClassIparams.class);
+ public K m(K k) { return k; }
+ }
+
+ public static void main(java.lang.String[] unused) {
+ // The rule this tests is the last sentence of JLS 12.4.1:
+
+ // When a class is initialized, its superclasses are initialized (if they have not
+ // been previously initialized), as well as any superinterfaces (s8.1.5) that declare any
+ // default methods (s9.4.3) (if they have not been previously initialized). Initialization
+ // of an interface does not, of itself, cause initialization of any of its superinterfaces.
+
+ // Trigger initialization.
+ // Now L is fully_initialized even though K should
+ // throw an error during initialization.
+ boolean v = L.v;
+ L.func();
+
+ try {
+ ClassLIM c = new ClassLIM(); // is K initialized, with a perfectly good L in the middle
+ // was bug: this used to succeed and be able to callMethodInK().
+ throw new RuntimeException("FAIL exception not thrown for class");
+ } catch (ExceptionInInitializerError e) {
+ System.out.println("ExceptionInInitializerError thrown as expected");
+ }
+
+ // Test that K already has initialization error so gets ClassNotFoundException because
+ // initialization was attempted with ClassLIM.
+ try {
+ Class.forName("InterfaceInitializationStates$K", true, InterfaceInitializationStates.class.getClassLoader());
+ throw new RuntimeException("FAIL exception not thrown for forName(K)");
+ } catch(ClassNotFoundException e) {
+ throw new RuntimeException("ClassNotFoundException should not be thrown");
+ } catch(NoClassDefFoundError e) {
+ System.out.println("NoClassDefFoundError thrown as expected");
+ }
+
+ new ClassM();
+
+ // Initialize I, which doesn't cause K (super interface) to be initialized.
+ // Since the initialization of I does _not_ cause K to be initialized, it does
+ // not get NoClassDefFoundError because K is erroneous.
+ // But the initialization of I throws RuntimeException, so we expect
+ // ExceptionInInitializerError.
+ try {
+ Object ii = I.CONST;
+ throw new RuntimeException("FAIL exception not thrown for I's initialization");
+ } catch (ExceptionInInitializerError e) {
+ System.out.println("ExceptionInInitializerError as expected");
+ }
+
+ // Initialize Iunlinked. This should not get NoClassDefFoundError because K
+ // (its super interface) is in initialization_error state.
+ // This is a bug. It does now.
+ try {
+ boolean bb = Iunlinked.v;
+ throw new RuntimeException("FAIL exception not thrown for Iunlinked initialization");
+ } catch(NoClassDefFoundError e) {
+ System.out.println("NoClassDefFoundError thrown because of bug");
+ }
+
+ // This should be okay
+ boolean value = Iparams.v;
+ System.out.println("value is " + value);
+
+ ClassIparams p = new ClassIparams();
+ try {
+ // Now we get an error because K got an initialization_error
+ K kk = p.method();
+ throw new RuntimeException("FAIL exception not thrown for calling method for K");
+ } catch(NoClassDefFoundError e) {
+ System.out.println("NoClassDefFoundError thrown as expected");
+ }
+
+ // Check expected class initialization order
+ List<Class<?>> expectedCInitOrder = Arrays.asList(L.class, K.class, M.class, ClassM.class,
+ I.class, Iparams.class,
+ ClassIparams.class);
+ if (!cInitOrder.equals(expectedCInitOrder)) {
+ throw new RuntimeException(
+ String.format("Class initialization array %s not equal to expected array %s",
+ cInitOrder, expectedCInitOrder));
+ }
+ }
+
+ static boolean out(Class c) {
+ System.out.println("#: initializing " + c.getName());
+ cInitOrder.add(c);
+ return true;
+ }
+ static Object someMethod() {
+ throw new RuntimeException();
+ }
+}
--- a/hotspot/test/runtime/modules/PatchModule/PatchModuleCDS.java Fri Oct 14 19:12:37 2016 +0300
+++ b/hotspot/test/runtime/modules/PatchModule/PatchModuleCDS.java Fri Oct 14 11:11:19 2016 -0700
@@ -23,41 +23,83 @@
/*
* @test
+ * @summary test that --patch-module works with CDS
* @library /test/lib
* @modules java.base/jdk.internal.misc
+ * jdk.jartool/sun.tools.jar
+ * @build PatchModuleMain
* @run main PatchModuleCDS
*/
import java.io.File;
+import jdk.test.lib.InMemoryJavaCompiler;
import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.process.ProcessTools;
public class PatchModuleCDS {
public static void main(String args[]) throws Throwable {
- System.out.println("Test that --patch-module and -Xshare:dump are incompatibable");
- ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("--patch-module=java.naming=mods/java.naming", "-Xshare:dump");
- OutputAnalyzer output = new OutputAnalyzer(pb.start());
- output.shouldContain("Cannot use the following option when dumping the shared archive: --patch-module");
- System.out.println("Test that --patch-module and -Xshare:on are incompatibable");
+ // Case 1: Test that --patch-module and -Xshare:dump are compatible
String filename = "patch_module.jsa";
- pb = ProcessTools.createJavaProcessBuilder(
+ ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
"-XX:+UnlockDiagnosticVMOptions",
"-XX:SharedArchiveFile=" + filename,
- "-Xshare:dump");
- output = new OutputAnalyzer(pb.start());
- output.shouldContain("ro space:"); // Make sure archive got created.
+ "-Xshare:dump",
+ "--patch-module=java.naming=no/such/directory",
+ "-Xlog:class+path=info",
+ "-version");
+ new OutputAnalyzer(pb.start())
+ .shouldContain("ro space:"); // Make sure archive got created.
+
+ // Case 2: Test that only jar file in --patch-module is supported for CDS dumping
+ // Create a class file in the module java.base.
+ String source = "package javax.naming.spi; " +
+ "public class NamingManager { " +
+ " static { " +
+ " System.out.println(\"I pass!\"); " +
+ " } " +
+ "}";
+
+ ClassFileInstaller.writeClassToDisk("javax/naming/spi/NamingManager",
+ InMemoryJavaCompiler.compile("javax.naming.spi.NamingManager", source, "-Xmodule:java.naming"),
+ System.getProperty("test.classes"));
pb = ProcessTools.createJavaProcessBuilder(
"-XX:+UnlockDiagnosticVMOptions",
"-XX:SharedArchiveFile=" + filename,
- "-Xshare:on",
- "--patch-module=java.naming=mods/java.naming",
+ "-Xshare:dump",
+ "--patch-module=java.base=" + System.getProperty("test.classes"),
+ "-Xlog:class+path=info",
"-version");
- output = new OutputAnalyzer(pb.start());
- output.shouldContain("The shared archive file cannot be used with --patch-module");
+ new OutputAnalyzer(pb.start())
+ .shouldContain("--patch-module requires a regular file during dumping");
- output.shouldHaveExitValue(1);
+ // Case 3a: Test CDS dumping with jar file in --patch-module
+ BasicJarBuilder.build("javanaming", "javax/naming/spi/NamingManager");
+ String moduleJar = BasicJarBuilder.getTestJar("javanaming.jar");
+ pb = ProcessTools.createJavaProcessBuilder(
+ "-XX:+UnlockDiagnosticVMOptions",
+ "-XX:SharedArchiveFile=" + filename,
+ "-Xshare:dump",
+ "--patch-module=java.naming=" + moduleJar,
+ "-Xlog:class+load",
+ "-Xlog:class+path=info",
+ "PatchModuleMain", "javax.naming.spi.NamingManager");
+ new OutputAnalyzer(pb.start())
+ .shouldContain("ro space:"); // Make sure archive got created.
+
+ // Case 3b: Test CDS run with jar file in --patch-module
+ pb = ProcessTools.createJavaProcessBuilder(
+ "-XX:+UnlockDiagnosticVMOptions",
+ "-XX:SharedArchiveFile=" + filename,
+ "-Xshare:auto",
+ "--patch-module=java.naming=" + moduleJar,
+ "-Xlog:class+load",
+ "-Xlog:class+path=info",
+ "PatchModuleMain", "javax.naming.spi.NamingManager");
+ new OutputAnalyzer(pb.start())
+ .shouldContain("I pass!")
+ .shouldHaveExitValue(0);
}
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/serviceability/jvmti/ModuleAwareAgents/ClassFileLoadHook/MAAClassFileLoadHook.java Fri Oct 14 11:11:19 2016 -0700
@@ -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.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please 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
+ * @run main/othervm/native -agentlib:MAAClassFileLoadHook MAAClassFileLoadHook
+ * @run main/othervm/native -agentlib:MAAClassFileLoadHook=with_early_vmstart MAAClassFileLoadHook
+ * @run main/othervm/native -agentlib:MAAClassFileLoadHook=with_early_class_hook MAAClassFileLoadHook
+ * @run main/othervm/native -agentlib:MAAClassFileLoadHook=with_early_vmstart,with_early_class_hook MAAClassFileLoadHook
+ */
+
+public class MAAClassFileLoadHook {
+
+ static {
+ try {
+ System.loadLibrary("MAAClassFileLoadHook");
+ } catch (UnsatisfiedLinkError ule) {
+ System.err.println("Could not load MAAClassFileLoadHook library");
+ System.err.println("java.library.path: "
+ + System.getProperty("java.library.path"));
+ throw ule;
+ }
+ }
+
+ native static int check();
+
+ public static void main(String args[]) {
+ int status = check();
+ if (status != 0) {
+ throw new RuntimeException("Non-zero status returned from the agent: " + status);
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/serviceability/jvmti/ModuleAwareAgents/ClassFileLoadHook/libMAAClassFileLoadHook.c Fri Oct 14 11:11:19 2016 -0700
@@ -0,0 +1,278 @@
+/*
+ * 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 <stdio.h>
+#include <string.h>
+#include "jvmti.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef JNI_ENV_ARG
+
+#ifdef __cplusplus
+#define JNI_ENV_ARG(x, y) y
+#define JNI_ENV_PTR(x) x
+#else
+#define JNI_ENV_ARG(x,y) x, y
+#define JNI_ENV_PTR(x) (*x)
+#endif
+
+#endif
+
+#define TranslateError(err) "JVMTI error"
+
+#define PASSED 0
+#define FAILED 2
+
+static const char *EXPECTED_NAME = "java/util/Collections";
+static const char *EXC_CNAME = "java/lang/Exception";
+
+static jvmtiEnv *jvmti = NULL;
+static jint result = PASSED;
+static jboolean printdump = JNI_FALSE;
+
+static jboolean with_early_vm_start_capability = JNI_FALSE;
+static jboolean with_early_class_hook_capability = JNI_FALSE;
+
+static jboolean found_class_in_vm_start = JNI_FALSE;
+static jboolean found_class_in_primordial = JNI_FALSE;
+static jboolean found_class_in_cflh_events = JNI_FALSE;
+
+static int cflh_events_primordial_count = 0;
+static int cflh_events_vm_start_count = 0;
+
+static jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved);
+
+JNIEXPORT
+jint JNICALL Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) {
+ return Agent_Initialize(jvm, options, reserved);
+}
+
+JNIEXPORT
+jint JNICALL Agent_OnAttach(JavaVM *jvm, char *options, void *reserved) {
+ return Agent_Initialize(jvm, options, reserved);
+}
+
+JNIEXPORT
+jint JNICALL JNI_OnLoad(JavaVM *jvm, void *reserved) {
+ return JNI_VERSION_9;
+}
+
+static
+jint throw_exc(JNIEnv *env, char *msg) {
+ jclass exc_class = JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG(env, EXC_CNAME));
+
+ if (exc_class == NULL) {
+ printf("throw_exc: Error in FindClass(env, %s)\n", EXC_CNAME);
+ return -1;
+ }
+ return JNI_ENV_PTR(env)->ThrowNew(JNI_ENV_ARG(env, exc_class), msg);
+}
+
+static void JNICALL
+Callback_ClassFileLoadHook(jvmtiEnv *jvmti_env, JNIEnv *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) {
+ jvmtiPhase phase;
+ jvmtiError err;
+
+ err = (*jvmti)->GetPhase(jvmti_env, &phase);
+ if (err != JVMTI_ERROR_NONE) {
+ printf("ClassFileLoadHook event: GetPhase error: %s (%d)\n", TranslateError(err), err);
+ result = FAILED;
+ return;
+ }
+
+ if (phase == JVMTI_PHASE_PRIMORDIAL || phase == JVMTI_PHASE_START) {
+ if (phase == JVMTI_PHASE_START) {
+ cflh_events_vm_start_count++;
+ if(strcmp(name, EXPECTED_NAME) == 0) {
+ found_class_in_vm_start = JNI_TRUE;
+ }
+ } else {
+ cflh_events_primordial_count++;
+ if(strcmp(name, EXPECTED_NAME) == 0) {
+ found_class_in_primordial = JNI_TRUE;
+ }
+ }
+ }
+
+ if(strcmp(name, EXPECTED_NAME) == 0) {
+ found_class_in_cflh_events = JNI_TRUE;
+ }
+
+ if (printdump == JNI_TRUE) {
+ printf(">>> ClassFileLoadHook event: phase(%d), class name %s\n", phase, name);
+ }
+}
+
+static
+jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
+ jint res, size;
+ jvmtiCapabilities caps;
+ jvmtiEventCallbacks callbacks;
+ jvmtiError err;
+
+ if (options != NULL) {
+ if (strstr(options, "with_early_vmstart") != NULL) {
+ with_early_vm_start_capability = JNI_TRUE;
+ }
+ if (strstr(options, "with_early_class_hook") != NULL) {
+ with_early_class_hook_capability = JNI_TRUE;
+ }
+ if (strstr(options, "printdump") != NULL) {
+ printdump = JNI_TRUE;
+ }
+ }
+
+ res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
+ JVMTI_VERSION_9);
+ if (res != JNI_OK || jvmti == NULL) {
+ printf(" Error: wrong result of a valid call to GetEnv!\n");
+ return JNI_ERR;
+ }
+
+ printf("Enabling following capabilities: can_generate_all_class_hook_events");
+ memset(&caps, 0, sizeof(caps));
+ caps.can_generate_all_class_hook_events = 1;
+ if (with_early_vm_start_capability == JNI_TRUE) {
+ printf(", can_generate_early_vmstart");
+ caps.can_generate_early_vmstart = 1;
+ }
+ if (with_early_class_hook_capability == JNI_TRUE) {
+ printf(", can_generate_early_class_hook_events");
+ caps.can_generate_early_class_hook_events = 1;
+ }
+ printf("\n");
+
+ err = (*jvmti)->AddCapabilities(jvmti, &caps);
+ if (err != JVMTI_ERROR_NONE) {
+ printf(" Error in AddCapabilites: %s (%d)\n", TranslateError(err), err);
+ return JNI_ERR;
+ }
+
+ size = (jint)sizeof(callbacks);
+
+ memset(&callbacks, 0, sizeof(callbacks));
+ callbacks.ClassFileLoadHook = Callback_ClassFileLoadHook;
+
+ err = (*jvmti)->SetEventCallbacks(jvmti, &callbacks, size);
+ if (err != JVMTI_ERROR_NONE) {
+ printf(" Error in SetEventCallbacks: %s (%d)\n", TranslateError(err), err);
+ return JNI_ERR;
+ }
+
+ err = (*jvmti)->SetEventNotificationMode(jvmti, JVMTI_ENABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, NULL);
+ if (err != JVMTI_ERROR_NONE) {
+ printf(" Error in SetEventNotificationMode: %s (%d)\n", TranslateError(err), err);
+ return JNI_ERR;
+ }
+
+ return JNI_OK;
+}
+
+JNIEXPORT jint JNICALL
+Java_MAAClassFileLoadHook_check(JNIEnv *env, jclass cls) {
+ jobject loader = NULL;
+
+ if (jvmti == NULL) {
+ throw_exc(env, "JVMTI client was not properly loaded!\n");
+ return FAILED;
+ }
+
+ /*
+ * Expecting that we always get ClassFileLoadHook events in the VM Start phase.
+ */
+ if (cflh_events_vm_start_count == 0) {
+ throw_exc(env, "Didn't get ClassFileLoadHook events in start phase!\n");
+ return FAILED;
+ }
+
+ if (with_early_class_hook_capability == JNI_TRUE) {
+ /*
+ * Expecting that we get ClassFileLoadHook events in the Primordial phase
+ * when can_generate_all_class_hook_events and can_generate_early_class_hook_events
+ * capabilities are enabled.
+ */
+ if (cflh_events_primordial_count == 0) {
+ throw_exc(env, "Didn't get ClassFileLoadHook events in primordial phase!\n");
+ return FAILED;
+ }
+ } else {
+ /*
+ * Expecting that we don't get ClassFileLoadHook events in the Primordial phase
+ * when can_generate_early_class_hook_events capability is disabled.
+ */
+ if (cflh_events_primordial_count != 0) {
+ throw_exc(env, "Get ClassFileLoadHook events in primordial phase!\n");
+ return FAILED;
+ }
+ }
+
+
+ if (with_early_vm_start_capability == JNI_TRUE) {
+ /*
+ * Expecting that "java/util/Collections" class from java.base module is present in the
+ * ClassFileLoadHook events during VM Start phase when can_generate_early_vmstart
+ * capability is enabled.
+ */
+ printf("Expecting to find '%s' class in ClassFileLoadHook events during VM early start phase.\n", EXPECTED_NAME);
+ if (found_class_in_vm_start == JNI_FALSE) {
+ throw_exc(env, "Unable to find expected class in ClassLoad events during VM early start phase!\n");
+ return FAILED;
+ }
+ } else if (with_early_class_hook_capability == JNI_TRUE) {
+ /*
+ * Expecting that "java/util/Collections" class from java.base module is present in the
+ * ClassFileLoadHook events during Primordial phase when can_generate_all_class_hook_events
+ * and can_generate_early_class_hook_events capabilities are enabled and can_generate_early_vmstart
+ * capability is disabled.
+ */
+ printf("Expecting to find '%s' class in ClassFileLoadHook events during VM primordial phase.\n", EXPECTED_NAME);
+ if (found_class_in_primordial == JNI_FALSE) {
+ throw_exc(env, "Unable to find expected class in ClassFileLoadHook events during primordial phase!\n");
+ return FAILED;
+ }
+ } else {
+ /*
+ * Expecting that "java/util/Collections" class from java.base module is not present in the
+ * ClassFileLoadHook events when can_generate_all_class_hook_events, can_generate_early_class_hook_events
+ * and can_generate_early_vmstart capabilities are disabled.
+ */
+ printf("Expecting that '%s' class is absent in ClassLoadHook events.\n", EXPECTED_NAME);
+ if (found_class_in_cflh_events == JNI_TRUE) {
+ throw_exc(env, "Class is found in ClassFileLoadHook events!\n");
+ return FAILED;
+ }
+ }
+
+ return result;
+}
+
+#ifdef __cplusplus
+}
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/serviceability/jvmti/ModuleAwareAgents/ClassLoadPrepare/MAAClassLoadPrepare.java Fri Oct 14 11:11:19 2016 -0700
@@ -0,0 +1,54 @@
+/*
+ * 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 8165681
+ * @summary Verify ClassLoad and ClassPrepare JVMTI event with
+ * and without can_generate_early_vmstart capability
+ * @run main/othervm/native -agentlib:MAAClassLoadPrepare MAAClassLoadPrepare
+ * @run main/othervm/native -agentlib:MAAClassLoadPrepare=with_early_vmstart MAAClassLoadPrepare
+ */
+
+public class MAAClassLoadPrepare {
+
+ static {
+ try {
+ System.loadLibrary("MAAClassLoadPrepare");
+ } catch (UnsatisfiedLinkError ule) {
+ System.err.println("Could not load MAAClassLoadPrepare library");
+ System.err.println("java.library.path: "
+ + System.getProperty("java.library.path"));
+ throw ule;
+ }
+ }
+
+ native static int check();
+
+ public static void main(String args[]) {
+ int status = check();
+ if (status != 0) {
+ throw new RuntimeException("Non-zero status returned from the agent: " + status);
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/serviceability/jvmti/ModuleAwareAgents/ClassLoadPrepare/libMAAClassLoadPrepare.c Fri Oct 14 11:11:19 2016 -0700
@@ -0,0 +1,319 @@
+/*
+ * 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 <stdio.h>
+#include <string.h>
+#include "jvmti.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef JNI_ENV_ARG
+
+#ifdef __cplusplus
+#define JNI_ENV_ARG(x, y) y
+#define JNI_ENV_PTR(x) x
+#else
+#define JNI_ENV_ARG(x,y) x, y
+#define JNI_ENV_PTR(x) (*x)
+#endif
+
+#endif
+
+#define TranslateError(err) "JVMTI error"
+
+#define PASSED 0
+#define FAILED 2
+
+static const char *EXPECTED_SIGNATURE = "Ljava/util/Collections;";
+static const char *EXC_CNAME = "java/lang/Exception";
+
+static jvmtiEnv *jvmti = NULL;
+static jint result = PASSED;
+static jboolean printdump = JNI_FALSE;
+
+static jboolean with_early_vm_start_capability = JNI_FALSE;
+
+static jboolean class_in_class_load_events_vm_start = JNI_FALSE;
+static jboolean class_in_class_load_events_vm_live = JNI_FALSE;
+static jboolean class_in_class_prepare_events_vm_start = JNI_FALSE;
+static jboolean class_in_class_prepare_events_vm_live = JNI_FALSE;
+
+static int class_load_events_vm_start_count = 0;
+static int class_prepare_events_vm_start_count = 0;
+
+static jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved);
+
+JNIEXPORT
+jint JNICALL Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) {
+ return Agent_Initialize(jvm, options, reserved);
+}
+
+JNIEXPORT
+jint JNICALL Agent_OnAttach(JavaVM *jvm, char *options, void *reserved) {
+ return Agent_Initialize(jvm, options, reserved);
+}
+
+JNIEXPORT
+jint JNICALL JNI_OnLoad(JavaVM *jvm, void *reserved) {
+ return JNI_VERSION_9;
+}
+
+static
+jint throw_exc(JNIEnv *env, char *msg) {
+ jclass exc_class = JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG(env, EXC_CNAME));
+
+ if (exc_class == NULL) {
+ printf("throw_exc: Error in FindClass(env, %s)\n", EXC_CNAME);
+ return -1;
+ }
+ return JNI_ENV_PTR(env)->ThrowNew(JNI_ENV_ARG(env, exc_class), msg);
+}
+
+static void JNICALL
+Callback_ClassFileLoad(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thread, jclass klass) {
+ jvmtiPhase phase;
+ char *sig, *generic;
+ jvmtiError err;
+
+ err = (*jvmti)->GetPhase(jvmti_env,&phase);
+ if (err != JVMTI_ERROR_NONE) {
+ printf("ClassLoad event: GetPhase error: %s (%d)\n", TranslateError(err), err);
+ result = FAILED;
+ return;
+ }
+
+ if (phase == JVMTI_PHASE_START || phase == JVMTI_PHASE_LIVE) {
+
+ err = (*jvmti)->GetClassSignature(jvmti_env, klass, &sig, &generic);
+
+ if (err != JVMTI_ERROR_NONE) {
+ printf("ClassLoad event: GetClassSignature error: %s (%d)\n", TranslateError(err), err);
+ result = FAILED;
+ return;
+ }
+
+ if (phase == JVMTI_PHASE_START) {
+ class_load_events_vm_start_count++;
+ if(strcmp(sig, EXPECTED_SIGNATURE) == 0) {
+ class_in_class_load_events_vm_start = JNI_TRUE;
+ }
+ } else {
+ if(strcmp(sig, EXPECTED_SIGNATURE) == 0) {
+ class_in_class_load_events_vm_live = JNI_TRUE;
+ }
+ }
+
+ if (printdump == JNI_TRUE) {
+ printf(">>> ClassLoad event: phase(%d), class signature %s\n", phase, sig == NULL ? "null": sig);
+ }
+ } else {
+ printf("ClassLoad event: get event in unexpected phase(%d)\n", phase);
+ result = FAILED;
+ }
+}
+
+static void JNICALL
+Callback_ClassFilePrepare(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thread, jclass klass) {
+ jvmtiPhase phase;
+ char *sig, *generic;
+ jvmtiError err;
+
+ err = (*jvmti)->GetPhase(jvmti_env,&phase);
+ if (err != JVMTI_ERROR_NONE) {
+ printf("ClassPrepare event: GetPhase error: %s (%d)\n", TranslateError(err), err);
+ result = FAILED;
+ return;
+ }
+
+ if (phase == JVMTI_PHASE_START || phase == JVMTI_PHASE_LIVE) {
+
+ err = (*jvmti)->GetClassSignature(jvmti_env, klass, &sig, &generic);
+
+ if (err != JVMTI_ERROR_NONE) {
+ printf("ClassPrepare event: GetClassSignature error: %s (%d)\n", TranslateError(err), err);
+ result = FAILED;
+ return;
+ }
+
+ if (phase == JVMTI_PHASE_START) {
+ class_prepare_events_vm_start_count++;
+ if(strcmp(sig, EXPECTED_SIGNATURE) == 0) {
+ class_in_class_prepare_events_vm_start = JNI_TRUE;
+ }
+ } else {
+ if(strcmp(sig, EXPECTED_SIGNATURE) == 0) {
+ class_in_class_prepare_events_vm_live = JNI_TRUE;
+ }
+ }
+
+ if (printdump == JNI_TRUE) {
+ printf(">>> ClassPrepare event: phase(%d), class signature %s\n", phase, sig == NULL ? "null": sig);
+ }
+ } else {
+ printf("ClassPrepare event: get event in unexpected phase(%d)\n", phase);
+ result = FAILED;
+ }
+}
+
+static
+jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
+ jint res, size;
+ jvmtiCapabilities caps;
+ jvmtiEventCallbacks callbacks;
+ jvmtiError err;
+
+ if (options != NULL) {
+ if (strstr(options, "with_early_vmstart") != NULL) {
+ with_early_vm_start_capability = JNI_TRUE;
+ }
+ if (strstr(options, "printdump") != NULL) {
+ printdump = JNI_TRUE;
+ }
+ }
+
+ res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
+ JVMTI_VERSION_9);
+ if (res != JNI_OK || jvmti == NULL) {
+ printf(" Error: wrong result of a valid call to GetEnv!\n");
+ return JNI_ERR;
+ }
+
+ if (with_early_vm_start_capability == JNI_TRUE) {
+ printf("Enabling following capability: can_generate_early_vmstart\n");
+ memset(&caps, 0, sizeof(caps));
+ caps.can_generate_early_vmstart = 1;
+
+ err = (*jvmti)->AddCapabilities(jvmti, &caps);
+ if (err != JVMTI_ERROR_NONE) {
+ printf(" Error in AddCapabilites: %s (%d)\n", TranslateError(err), err);
+ return JNI_ERR;
+ }
+ }
+
+ size = (jint)sizeof(callbacks);
+
+ memset(&callbacks, 0, sizeof(callbacks));
+ callbacks.ClassLoad = Callback_ClassFileLoad;
+ callbacks.ClassPrepare = Callback_ClassFilePrepare;
+
+ err = (*jvmti)->SetEventCallbacks(jvmti, &callbacks, size);
+ if (err != JVMTI_ERROR_NONE) {
+ printf(" Error in SetEventCallbacks: %s (%d)\n", TranslateError(err), err);
+ return JNI_ERR;
+ }
+
+ err = (*jvmti)->SetEventNotificationMode(jvmti, JVMTI_ENABLE, JVMTI_EVENT_CLASS_LOAD, NULL);
+ if (err != JVMTI_ERROR_NONE) {
+ printf(" Error in SetEventNotificationMode: %s (%d)\n", TranslateError(err), err);
+ return JNI_ERR;
+ }
+
+ err = (*jvmti)->SetEventNotificationMode(jvmti, JVMTI_ENABLE, JVMTI_EVENT_CLASS_PREPARE, NULL);
+
+ if (err != JVMTI_ERROR_NONE) {
+ printf(" Error in SetEventNotificationMode: %s (%d)\n", TranslateError(err), err);
+ return JNI_ERR;
+ }
+
+ return JNI_OK;
+}
+
+JNIEXPORT jint JNICALL
+Java_MAAClassLoadPrepare_check(JNIEnv *env, jclass cls) {
+ jobject loader = NULL;
+
+ if (jvmti == NULL) {
+ throw_exc(env, "JVMTI client was not properly loaded!\n");
+ return FAILED;
+ }
+
+ if (with_early_vm_start_capability == JNI_TRUE) {
+ /*
+ * Expecting that "java/util/Collections" class from java.base module is present in the
+ * ClassLoad and ClassPrepare events during VM Start phase when can_generate_early_vmstart
+ * capability is enabled.
+ * Expecting that ClassLoad and ClassPrepare events are sent in the VM early start phase
+ * when can_generate_early_vmstart is enabled(JDK-8165681).
+ */
+ if (class_load_events_vm_start_count == 0) {
+ throw_exc(env, "Didn't get ClassLoad events in start phase!\n");
+ return FAILED;
+ }
+
+ printf("Expecting to find '%s' class in ClassLoad events during VM early start phase.\n", EXPECTED_SIGNATURE);
+ if (class_in_class_load_events_vm_start == JNI_FALSE) {
+ throw_exc(env, "Unable to find expected class in ClassLoad events during early start phase!\n");
+ return FAILED;
+ }
+
+ if (class_prepare_events_vm_start_count == 0) {
+ throw_exc(env, "Didn't get ClassPrepare events in start phase!\n");
+ return FAILED;
+ }
+
+ printf("Expecting to find '%s' class in ClassPrepare events during VM early start phase.\n", EXPECTED_SIGNATURE);
+ if (class_in_class_prepare_events_vm_start == JNI_FALSE) {
+ throw_exc(env, "Unable to find expected class in ClassPrepare events during early start phase!\n");
+ return FAILED;
+ }
+ } else {
+ /*
+ * Expecting that "java/util/Collections" class from java.base module is not present in the
+ * ClassLoad and ClassPrepare events during VM Start phase when can_generate_early_vmstart
+ * capability is disabled.
+ */
+ printf("Expecting that '%s' class is absent in ClassLoad events during normal VM start phase.\n", EXPECTED_SIGNATURE);
+ if (class_in_class_prepare_events_vm_start == JNI_TRUE) {
+ throw_exc(env, "Class is found in ClassLoad events during normal VM start phase!\n");
+ return FAILED;
+ }
+
+ printf("Expecting that '%s' class is absent in ClassPrepare events during normal VM start phase.\n", EXPECTED_SIGNATURE);
+ if (class_in_class_prepare_events_vm_start == JNI_TRUE) {
+ throw_exc(env, "Class is found in ClassPrepare events during normal VM start phase!\n");
+ return FAILED;
+ }
+ }
+
+ /*
+ * In any case, we not expect to see "java/util/Collections" class from java.base module
+ * in the ClassLoad and ClassPrepare events during VM Live phase.
+ */
+ if (class_in_class_prepare_events_vm_live == JNI_TRUE) {
+ throw_exc(env, "Class is found in ClassLoad events during VM Live phase!\n");
+ return FAILED;
+ }
+
+ if (class_in_class_prepare_events_vm_live == JNI_TRUE) {
+ throw_exc(env, "Class is found in ClassPrepare events during VM Live phase!\n");
+ return FAILED;
+ }
+
+ return result;
+}
+
+#ifdef __cplusplus
+}
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/serviceability/jvmti/ModuleAwareAgents/ThreadStart/MAAThreadStart.java Fri Oct 14 11:11:19 2016 -0700
@@ -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.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please 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 Verify ThreadStart JVMTI event with can_generate_early_vmstart capability
+ * @run main/othervm/native -agentlib:MAAThreadStart MAAThreadStart
+ */
+
+public class MAAThreadStart {
+
+ static {
+ try {
+ System.loadLibrary("MAAThreadStart");
+ } catch (UnsatisfiedLinkError ule) {
+ System.err.println("Could not load MAAThreadStart library");
+ System.err.println("java.library.path: "
+ + System.getProperty("java.library.path"));
+ throw ule;
+ }
+ }
+
+ native static int check();
+
+ public static void main(String args[]) {
+ int status = check();
+ if (status != 0) {
+ throw new RuntimeException("Non-zero status returned from the agent: " + status);
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/serviceability/jvmti/ModuleAwareAgents/ThreadStart/libMAAThreadStart.c Fri Oct 14 11:11:19 2016 -0700
@@ -0,0 +1,177 @@
+/*
+ * 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 <stdio.h>
+#include <string.h>
+#include "jvmti.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef JNI_ENV_ARG
+
+#ifdef __cplusplus
+#define JNI_ENV_ARG(x, y) y
+#define JNI_ENV_PTR(x) x
+#else
+#define JNI_ENV_ARG(x,y) x, y
+#define JNI_ENV_PTR(x) (*x)
+#endif
+
+#endif
+
+#define TranslateError(err) "JVMTI error"
+
+#define PASSED 0
+#define FAILED 2
+
+static const char *EXC_CNAME = "java/lang/Exception";
+
+static jvmtiEnv *jvmti = NULL;
+static jint result = PASSED;
+static jboolean printdump = JNI_FALSE;
+
+static int thread_start_events_vm_start = 0;
+
+static jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved);
+
+JNIEXPORT
+jint JNICALL Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) {
+ return Agent_Initialize(jvm, options, reserved);
+}
+
+JNIEXPORT
+jint JNICALL Agent_OnAttach(JavaVM *jvm, char *options, void *reserved) {
+ return Agent_Initialize(jvm, options, reserved);
+}
+
+JNIEXPORT
+jint JNICALL JNI_OnLoad(JavaVM *jvm, void *reserved) {
+ return JNI_VERSION_9;
+}
+
+static
+jint throw_exc(JNIEnv *env, char *msg) {
+ jclass exc_class = JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG(env, EXC_CNAME));
+
+ if (exc_class == NULL) {
+ printf("throw_exc: Error in FindClass(env, %s)\n", EXC_CNAME);
+ return -1;
+ }
+ return JNI_ENV_PTR(env)->ThrowNew(JNI_ENV_ARG(env, exc_class), msg);
+}
+
+
+void JNICALL Callback_ThreadStart(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thread) {
+ jvmtiError err;
+ jvmtiPhase phase;
+
+ err = (*jvmti)->GetPhase(jvmti_env,&phase);
+ if (err != JVMTI_ERROR_NONE) {
+ printf("ThreadStart event: GetPhase error: %s (%d)\n", TranslateError(err), err);
+ result = FAILED;
+ return;
+ }
+
+ if (phase == JVMTI_PHASE_START) {
+ thread_start_events_vm_start++;
+ }
+
+ if (printdump == JNI_TRUE) {
+ printf(">>> ThreadStart event: phase(%d)\n", phase);
+ }
+}
+
+static
+jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
+ jint res, size;
+ jvmtiCapabilities caps;
+ jvmtiEventCallbacks callbacks;
+ jvmtiError err;
+
+ if (options != NULL && strcmp(options, "printdump") == 0) {
+ printdump = JNI_TRUE;
+ }
+
+ res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
+ JVMTI_VERSION_9);
+ if (res != JNI_OK || jvmti == NULL) {
+ printf(" Error: wrong result of a valid call to GetEnv!\n");
+ return JNI_ERR;
+ }
+
+ printf("Enabling following capability: can_generate_early_vmstart\n");
+ memset(&caps, 0, sizeof(caps));
+ caps.can_generate_early_vmstart = 1;
+
+ err = (*jvmti)->AddCapabilities(jvmti, &caps);
+ if (err != JVMTI_ERROR_NONE) {
+ printf(" Error in AddCapabilites: %s (%d)\n", TranslateError(err), err);
+ return JNI_ERR;
+ }
+
+ size = (jint)sizeof(callbacks);
+
+ memset(&callbacks, 0, sizeof(callbacks));
+ callbacks.ThreadStart = Callback_ThreadStart;
+
+ err = (*jvmti)->SetEventCallbacks(jvmti, &callbacks, size);
+ if (err != JVMTI_ERROR_NONE) {
+ printf(" Error in SetEventCallbacks: %s (%d)\n", TranslateError(err), err);
+ return JNI_ERR;
+ }
+
+ err = (*jvmti)->SetEventNotificationMode(jvmti, JVMTI_ENABLE, JVMTI_EVENT_THREAD_START, NULL);
+ if (err != JVMTI_ERROR_NONE) {
+ printf(" Error in SetEventNotificationMode: %s (%d)\n", TranslateError(err), err);
+ return JNI_ERR;
+ }
+
+ return JNI_OK;
+}
+
+JNIEXPORT jint JNICALL
+Java_MAAThreadStart_check(JNIEnv *env, jclass cls) {
+ jobject loader = NULL;
+
+ if (jvmti == NULL) {
+ throw_exc(env, "JVMTI client was not properly loaded!\n");
+ return FAILED;
+ }
+
+ /*
+ * Expecting that ThreadStart events are sent during VM Start phase when
+ * can_generate_early_vmstart capability is enabled.
+ */
+ if (thread_start_events_vm_start == 0) {
+ throw_exc(env, "Didn't get ThreadStart events in VM early start phase!\n");
+ return FAILED;
+ }
+
+ return result;
+}
+
+#ifdef __cplusplus
+}
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/serviceability/sa/LingeredAppWithDefaultMethods.java Fri Oct 14 11:11:19 2016 -0700
@@ -0,0 +1,55 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please 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.apps.LingeredApp;
+
+interface Language {
+ static final long nbrOfWords = 99999;
+ public abstract long getNbrOfWords();
+ default boolean hasScript() {
+ return true;
+ }
+}
+
+class ParselTongue implements Language {
+ public long getNbrOfWords() {
+ return nbrOfWords * 4;
+ }
+}
+
+class SlytherinSpeak extends ParselTongue {
+ public boolean hasScript() {
+ return false;
+ }
+}
+
+public class LingeredAppWithDefaultMethods extends LingeredApp {
+
+ public static void main(String args[]) {
+ ParselTongue lang = new ParselTongue();
+ SlytherinSpeak slang = new SlytherinSpeak();
+ System.out.println(lang.hasScript() || slang.hasScript());
+
+ LingeredApp.main(args);
+ }
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/serviceability/sa/TestDefaultMethods.java Fri Oct 14 11:11:19 2016 -0700
@@ -0,0 +1,157 @@
+/*
+ * 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.ArrayList;
+import java.util.List;
+
+import sun.jvm.hotspot.HotSpotAgent;
+import sun.jvm.hotspot.utilities.SystemDictionaryHelper;
+import sun.jvm.hotspot.oops.InstanceKlass;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.oops.Method;
+import sun.jvm.hotspot.utilities.MethodArray;
+
+import jdk.test.lib.apps.LingeredApp;
+import jdk.test.lib.JDKToolLauncher;
+import jdk.test.lib.JDKToolFinder;
+import jdk.test.lib.Platform;
+import jdk.test.lib.process.ProcessTools;
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.Utils;
+import jdk.test.lib.Asserts;
+
+/*
+ * @test
+ * @library /test/lib
+ * @requires os.family != "mac"
+ * @modules java.base/jdk.internal.misc
+ * jdk.hotspot.agent/sun.jvm.hotspot
+ * jdk.hotspot.agent/sun.jvm.hotspot.utilities
+ * jdk.hotspot.agent/sun.jvm.hotspot.oops
+ * jdk.hotspot.agent/sun.jvm.hotspot.debugger
+ * @run main/othervm TestDefaultMethods
+ */
+
+public class TestDefaultMethods {
+
+ private static LingeredAppWithDefaultMethods theApp = null;
+
+ private static void printDefaultMethods(String pid,
+ String[] instanceKlassNames) {
+ HotSpotAgent agent = new HotSpotAgent();
+ try {
+ agent.attach(Integer.parseInt(pid));
+ }
+ catch (DebuggerException e) {
+ System.out.println(e.getMessage());
+ System.err.println("Unable to connect to process ID: " + pid);
+
+ agent.detach();
+ e.printStackTrace();
+ }
+
+ for (String instanceKlassName : instanceKlassNames) {
+ InstanceKlass iKlass = SystemDictionaryHelper.findInstanceKlass(instanceKlassName);
+ MethodArray methods = iKlass.getMethods();
+ MethodArray defaultMethods = iKlass.getDefaultMethods();
+ for (int i = 0; i < methods.length(); i++) {
+ Method m = methods.at(i);
+ System.out.println("Method: " + m.getName().asString() +
+ " in instance klass: " + instanceKlassName);
+ }
+ if (defaultMethods != null) {
+ for (int j = 0; j < defaultMethods.length(); j++) {
+ Method dm = defaultMethods.at(j);
+ System.out.println("Default method: " + dm.getName().asString() +
+ " in instance klass: " + instanceKlassName);
+ }
+ } else {
+ System.out.println("No default methods in " + instanceKlassName);
+ }
+
+ }
+ agent.detach();
+ }
+
+ private static void createAnotherToAttach(
+ String[] instanceKlassNames,
+ long lingeredAppPid) throws Exception {
+
+ String[] toolArgs = {
+ "--add-modules=jdk.hotspot.agent",
+ "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot=ALL-UNNAMED",
+ "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.utilities=ALL-UNNAMED",
+ "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.oops=ALL-UNNAMED",
+ "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.debugger=ALL-UNNAMED",
+ "TestDefaultMethods",
+ Long.toString(lingeredAppPid)
+ };
+
+ // Start a new process to attach to the lingered app
+ ProcessBuilder processBuilder = ProcessTools.createJavaProcessBuilder(toolArgs);
+ OutputAnalyzer SAOutput = ProcessTools.executeProcess(processBuilder);
+ SAOutput.shouldHaveExitValue(0);
+ System.out.println(SAOutput.getOutput());
+
+ SAOutput.shouldContain(
+ "Default method: hasScript in instance klass: " + instanceKlassNames[1]);
+ SAOutput.shouldContain(
+ "No default methods in " + instanceKlassNames[0]);
+ SAOutput.shouldContain(
+ "Method: hasScript in instance klass: " + instanceKlassNames[0]);
+ SAOutput.shouldContain(
+ "No default methods in " + instanceKlassNames[2]);
+ }
+
+ public static void main (String... args) throws Exception {
+
+ String[] instanceKlassNames = new String[] {
+ "Language",
+ "ParselTongue",
+ "SlytherinSpeak"
+ };
+
+ if (!Platform.shouldSAAttach()) {
+ System.out.println(
+ "SA attach not expected to work - test skipped.");
+ return;
+ }
+
+ if (args == null || args.length == 0) {
+ try {
+ List<String> vmArgs = new ArrayList<String>();
+ vmArgs.add("-XX:+UsePerfData");
+ vmArgs.addAll(Utils.getVmOptions());
+
+ theApp = new LingeredAppWithDefaultMethods();
+ LingeredApp.startApp(vmArgs, theApp);
+ createAnotherToAttach(instanceKlassNames,
+ theApp.getPid());
+ } finally {
+ LingeredApp.stopApp(theApp);
+ }
+ } else {
+ printDefaultMethods(args[0], instanceKlassNames);
+ }
+ }
+}
--- a/jaxp/.hgtags Fri Oct 14 19:12:37 2016 +0300
+++ b/jaxp/.hgtags Fri Oct 14 11:11:19 2016 -0700
@@ -381,3 +381,4 @@
f1eafcb0eb7182b937bc93f214d8cabd01ec4d59 jdk-9+136
a8d5fe567ae72b4931040e59dd4478363f9004f5 jdk-9+137
69c3b12ba75b2e321dee731ac545e7fbff608451 jdk-9+138
+8991d71c5316bde259e6a417c1199b008ca3cdf0 jdk-9+139
--- a/jaxp/ASSEMBLY_EXCEPTION Fri Oct 14 19:12:37 2016 +0300
+++ b/jaxp/ASSEMBLY_EXCEPTION Fri Oct 14 11:11:19 2016 -0700
@@ -1,27 +1,27 @@
OPENJDK ASSEMBLY EXCEPTION
-The OpenJDK source code made available by Sun at openjdk.java.net and
-openjdk.dev.java.net ("OpenJDK Code") is distributed under the terms of the
-GNU General Public License <http://www.gnu.org/copyleft/gpl.html> version 2
+The OpenJDK source code made available by Oracle America, Inc. (Oracle) at
+openjdk.java.net ("OpenJDK Code") is distributed under the terms of the GNU
+General Public License <http://www.gnu.org/copyleft/gpl.html> version 2
only ("GPL2"), with the following clarification and special exception.
Linking this OpenJDK Code statically or dynamically with other code
is making a combined work based on this library. Thus, the terms
and conditions of GPL2 cover the whole combination.
- As a special exception, Sun gives you permission to link this
- OpenJDK Code with certain code licensed by Sun as indicated at
+ As a special exception, Oracle gives you permission to link this
+ OpenJDK Code with certain code licensed by Oracle as indicated at
http://openjdk.java.net/legal/exception-modules-2007-05-08.html
("Designated Exception Modules") to produce an executable,
regardless of the license terms of the Designated Exception Modules,
and to copy and distribute the resulting executable under GPL2,
provided that the Designated Exception Modules continue to be
- governed by the licenses under which they were offered by Sun.
+ governed by the licenses under which they were offered by Oracle.
-As such, it allows licensees and sublicensees of Sun's GPL2 OpenJDK Code to
-build an executable that includes those portions of necessary code that Sun
-could not provide under GPL2 (or that Sun has provided under GPL2 with the
-Classpath exception). If you modify or add to the OpenJDK code, that new
-GPL2 code may still be combined with Designated Exception Modules if the
-new code is made subject to this exception by its copyright holder.
+As such, it allows licensees and sublicensees of Oracle's GPL2 OpenJDK Code
+to build an executable that includes those portions of necessary code that
+Oracle could not provide under GPL2 (or that Oracle has provided under GPL2
+with the Classpath exception). If you modify or add to the OpenJDK code,
+that new GPL2 code may still be combined with Designated Exception Modules
+if the new code is made subject to this exception by its copyright holder.
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/validation/ValidationState.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/validation/ValidationState.java Fri Oct 14 11:11:19 2016 -0700
@@ -52,7 +52,7 @@
private SymbolTable fSymbolTable = null;
private Locale fLocale = null;
- private ArrayList<String> fIdList;
+ private HashSet<String> fIds;
private ArrayList<String> fIdRefList;
//
@@ -97,7 +97,7 @@
String key;
for (int i = 0; i < fIdRefList.size(); i++) {
key = fIdRefList.get(i);
- if (fIdList == null || !fIdList.contains(key)) {
+ if (fIds == null || !fIds.contains(key)) {
if (missingIDs == null) {
missingIDs = new HashSet();
}
@@ -112,7 +112,7 @@
fExtraChecking = true;
fFacetChecking = true;
fNamespaces = true;
- fIdList = null;
+ fIds = null;
fIdRefList = null;
fEntityState = null;
fNamespaceContext = null;
@@ -126,7 +126,7 @@
* the two tables.
*/
public void resetIDTables() {
- fIdList = null;
+ fIds = null;
fIdRefList = null;
}
@@ -168,12 +168,11 @@
// id
public boolean isIdDeclared(String name) {
- if (fIdList == null) return false;
- return fIdList.contains(name);
+ return fIds != null && fIds.contains(name);
}
public void addId(String name) {
- if (fIdList == null) fIdList = new ArrayList();
- fIdList.add(name);
+ if (fIds == null) fIds = new HashSet<>();
+ fIds.add(name);
}
// idref
--- a/jaxp/src/java.xml/share/classes/com/sun/xml/internal/stream/writers/XMLDOMWriterImpl.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jaxp/src/java.xml/share/classes/com/sun/xml/internal/stream/writers/XMLDOMWriterImpl.java Fri Oct 14 11:11:19 2016 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2006, 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
@@ -25,6 +25,8 @@
package com.sun.xml.internal.stream.writers;
+import com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl;
+import com.sun.org.apache.xerces.internal.dom.DocumentImpl;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import javax.xml.XMLConstants;
@@ -57,7 +59,7 @@
* Change StringBuffer to StringBuilder, when JDK 1.5 will be minimum requirement for SJSXP.
*/
-public class XMLDOMWriterImpl implements XMLStreamWriter {
+public class XMLDOMWriterImpl implements XMLStreamWriterBase {
private Document ownerDoc = null;
@@ -552,7 +554,7 @@
* @throws javax.xml.stream.XMLStreamException {@inheritDoc}
*/
public void writeStartDocument(String version) throws XMLStreamException {
- ownerDoc.setXmlVersion(version);
+ writeStartDocument(null, version, false, false);
}
/**
@@ -563,8 +565,20 @@
* @throws javax.xml.stream.XMLStreamException {@inheritDoc}
*/
public void writeStartDocument(String encoding, String version) throws XMLStreamException {
+ writeStartDocument(encoding, version, false, false);
+ }
+
+ @Override
+ public void writeStartDocument(String encoding, String version, boolean standalone, boolean standaloneSet) throws XMLStreamException {
+ if (encoding != null && ownerDoc.getClass().isAssignableFrom(DocumentImpl.class)) {
+ ((DocumentImpl)ownerDoc).setXmlEncoding(encoding);
+ }
+
ownerDoc.setXmlVersion(version);
- //TODO: What to do with encoding.-Venu
+
+ if (standaloneSet) {
+ ownerDoc.setXmlStandalone(standalone);
+ }
}
/**
--- a/jaxp/src/java.xml/share/classes/com/sun/xml/internal/stream/writers/XMLEventWriterImpl.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jaxp/src/java.xml/share/classes/com/sun/xml/internal/stream/writers/XMLEventWriterImpl.java Fri Oct 14 11:11:19 2016 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2006, 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
@@ -49,14 +49,14 @@
public class XMLEventWriterImpl implements XMLEventWriter{
//delegate everything to XMLStreamWriter..
- private XMLStreamWriter fStreamWriter ;
+ private final XMLStreamWriterBase fStreamWriter ;
private static final boolean DEBUG = false;
/**
*
* @param streamWriter
*/
public XMLEventWriterImpl(XMLStreamWriter streamWriter){
- fStreamWriter = streamWriter;
+ fStreamWriter = (XMLStreamWriterBase)streamWriter;
}
/**
@@ -89,7 +89,8 @@
StartDocument startDocument = (StartDocument)xMLEvent ;
if (DEBUG)System.out.println("Adding StartDocument = " + startDocument.toString());
try {
- fStreamWriter.writeStartDocument(startDocument.getCharacterEncodingScheme(), startDocument.getVersion());
+ fStreamWriter.writeStartDocument(startDocument.getCharacterEncodingScheme(), startDocument.getVersion(),
+ startDocument.isStandalone(), startDocument.standaloneSet());
}catch(XMLStreamException e) {
fStreamWriter.writeStartDocument(startDocument.getVersion());
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/src/java.xml/share/classes/com/sun/xml/internal/stream/writers/XMLStreamWriterBase.java Fri Oct 14 11:11:19 2016 -0700
@@ -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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact 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.xml.internal.stream.writers;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
+/**
+ * Base class for shared methods among XMLStreamWriter implementations.
+ */
+public interface XMLStreamWriterBase extends XMLStreamWriter {
+ /**
+ * Writes the XML declaration.
+ *
+ * @param encoding the specified encoding
+ * @param version the specified version
+ * @param standalone the flag indicating whether it is standalone
+ * @param standaloneSet the flag indicating whether the standalone attribute is set
+ * @throws XMLStreamException in case of an IOException
+ */
+ public void writeStartDocument(String encoding, String version,
+ boolean standalone, boolean standaloneSet)
+ throws XMLStreamException;
+}
--- a/jaxp/src/java.xml/share/classes/com/sun/xml/internal/stream/writers/XMLStreamWriterImpl.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jaxp/src/java.xml/share/classes/com/sun/xml/internal/stream/writers/XMLStreamWriterImpl.java Fri Oct 14 11:11:19 2016 -0700
@@ -71,7 +71,7 @@
* @author Santiago.Pericas-Geertsen@sun.com
* @author Sunitha.Reddy@sun.com
*/
-public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamWriter {
+public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamWriterBase {
public static final String START_COMMENT = "<!--";
public static final String END_COMMENT = "-->";
@@ -1112,90 +1112,55 @@
}
/**
- * @throws XMLStreamException
+ * Writes the XML declaration.
+ *
+ * @throws XMLStreamException in case of an IOException
*/
public void writeStartDocument() throws XMLStreamException {
- try {
- fWriter.write(DEFAULT_XMLDECL);
- } catch (IOException ex) {
- throw new XMLStreamException(ex);
- }
+ writeStartDocument(null, null, false, false);
}
/**
- * @param version
- * @throws XMLStreamException
+ * Writes the XML declaration.
+ *
+ * @param version the specified version
+ * @throws XMLStreamException in case of an IOException
*/
public void writeStartDocument(String version) throws XMLStreamException {
- try {
- if ((version == null) || version.equals("")) {
- writeStartDocument();
-
- return;
- }
-
- fWriter.write("<?xml version=\"");
- fWriter.write(version);
- fWriter.write("\"");
-
- //fWriter.write(DEFAULT_ENCODING);
- fWriter.write("?>");
- } catch (IOException ex) {
- throw new XMLStreamException(ex);
- }
+ writeStartDocument(null, version, false, false);
}
/**
- * @param encoding
- * @param version
- * @throws XMLStreamException
+ * Writes the XML declaration.
+ *
+ * @param encoding the specified encoding
+ * @param version the specified version
+ * @throws XMLStreamException in case of an IOException
*/
+ @Override
public void writeStartDocument(String encoding, String version)
throws XMLStreamException {
- //Revisit : What about standalone ?
- try {
- if ((encoding == null) && (version == null)) {
- writeStartDocument();
+ writeStartDocument(encoding, version, false, false);
+ }
- return;
- }
+ @Override
+ public void writeStartDocument(String encoding, String version,
+ boolean standalone, boolean standaloneSet)
+ throws XMLStreamException {
- if (encoding == null) {
- writeStartDocument(version);
-
+ try {
+ if ((encoding == null || encoding.length() == 0)
+ && (version == null || version.length() == 0)
+ && (!standaloneSet)) {
+ fWriter.write(DEFAULT_XMLDECL);
return;
}
- String streamEncoding = null;
- if (fWriter instanceof OutputStreamWriter) {
- streamEncoding = ((OutputStreamWriter) fWriter).getEncoding();
- }
- else if (fWriter instanceof UTF8OutputStreamWriter) {
- streamEncoding = ((UTF8OutputStreamWriter) fWriter).getEncoding();
- }
- else if (fWriter instanceof XMLWriter) {
- streamEncoding = ((OutputStreamWriter) ((XMLWriter)fWriter).getWriter()).getEncoding();
+ // Verify the encoding before writing anything
+ if (encoding != null && !encoding.equals("")) {
+ verifyEncoding(encoding);
}
- if (streamEncoding != null && !streamEncoding.equalsIgnoreCase(encoding)) {
- // If the equality check failed, check for charset encoding aliases
- boolean foundAlias = false;
- Set aliases = Charset.forName(encoding).aliases();
- for (Iterator it = aliases.iterator(); !foundAlias && it.hasNext(); ) {
- if (streamEncoding.equalsIgnoreCase((String) it.next())) {
- foundAlias = true;
- }
- }
- // If no alias matches the encoding name, then report error
- if (!foundAlias) {
- throw new XMLStreamException("Underlying stream encoding '"
- + streamEncoding
- + "' and input paramter for writeStartDocument() method '"
- + encoding + "' do not match.");
- }
- }
-
-
fWriter.write("<?xml version=\"");
if ((version == null) || version.equals("")) {
@@ -1204,11 +1169,20 @@
fWriter.write(version);
}
- if (!encoding.equals("")) {
+ if (encoding != null && !encoding.equals("")) {
fWriter.write("\" encoding=\"");
fWriter.write(encoding);
}
+ if (standaloneSet) {
+ fWriter.write("\" standalone=\"");
+ if (standalone) {
+ fWriter.write("yes");
+ } else {
+ fWriter.write("no");
+ }
+ }
+
fWriter.write("\"?>");
} catch (IOException ex) {
throw new XMLStreamException(ex);
@@ -1216,6 +1190,45 @@
}
/**
+ * Verifies that the encoding is consistent between the underlying encoding
+ * and that specified.
+ *
+ * @param encoding the specified encoding
+ * @throws XMLStreamException if they do not match
+ */
+ private void verifyEncoding(String encoding) throws XMLStreamException {
+
+ String streamEncoding = null;
+ if (fWriter instanceof OutputStreamWriter) {
+ streamEncoding = ((OutputStreamWriter) fWriter).getEncoding();
+ }
+ else if (fWriter instanceof UTF8OutputStreamWriter) {
+ streamEncoding = ((UTF8OutputStreamWriter) fWriter).getEncoding();
+ }
+ else if (fWriter instanceof XMLWriter) {
+ streamEncoding = ((OutputStreamWriter) ((XMLWriter)fWriter).getWriter()).getEncoding();
+ }
+
+ if (streamEncoding != null && !streamEncoding.equalsIgnoreCase(encoding)) {
+ // If the equality check failed, check for charset encoding aliases
+ boolean foundAlias = false;
+ Set aliases = Charset.forName(encoding).aliases();
+ for (Iterator it = aliases.iterator(); !foundAlias && it.hasNext(); ) {
+ if (streamEncoding.equalsIgnoreCase((String) it.next())) {
+ foundAlias = true;
+ }
+ }
+ // If no alias matches the encoding name, then report error
+ if (!foundAlias) {
+ throw new XMLStreamException("Underlying stream encoding '"
+ + streamEncoding
+ + "' and input paramter for writeStartDocument() method '"
+ + encoding + "' do not match.");
+ }
+ }
+ }
+
+ /**
* @param localName
* @throws XMLStreamException
*/
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/XMLStreamWriterTest.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/XMLStreamWriterTest.java Fri Oct 14 11:11:19 2016 -0700
@@ -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
@@ -20,21 +20,29 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
-
package stream.XMLStreamWriterTest;
import java.io.StringWriter;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.stream.XMLEventFactory;
+import javax.xml.stream.XMLEventWriter;
import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
+import javax.xml.stream.events.XMLEvent;
+import javax.xml.transform.dom.DOMResult;
import org.testng.Assert;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test;
+import org.w3c.dom.Document;
/*
* @test
- * @bug 6347190
+ * @bug 6347190 8139584
* @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
* @run testng/othervm -DrunSecMngr=true stream.XMLStreamWriterTest.XMLStreamWriterTest
* @run testng/othervm stream.XMLStreamWriterTest.XMLStreamWriterTest
@@ -42,6 +50,48 @@
*/
@Listeners({jaxp.library.BasePolicy.class})
public class XMLStreamWriterTest {
+ /**
+ * @bug 8139584
+ * Verifies that the resulting XML contains the standalone setting.
+ */
+ @Test
+ public void testCreateStartDocument() throws XMLStreamException {
+
+ StringWriter stringWriter = new StringWriter();
+ XMLOutputFactory out = XMLOutputFactory.newInstance();
+ XMLEventFactory eventFactory = XMLEventFactory.newInstance();
+
+ XMLEventWriter eventWriter = out.createXMLEventWriter(stringWriter);
+
+ XMLEvent event = eventFactory.createStartDocument("iso-8859-15", "1.0", true);
+ eventWriter.add(event);
+ eventWriter.flush();
+ Assert.assertTrue(stringWriter.toString().contains("encoding=\"iso-8859-15\""));
+ Assert.assertTrue(stringWriter.toString().contains("version=\"1.0\""));
+ Assert.assertTrue(stringWriter.toString().contains("standalone=\"yes\""));
+ }
+
+ /**
+ * @bug 8139584
+ * Verifies that the resulting XML contains the standalone setting.
+ */
+ @Test
+ public void testCreateStartDocument_DOMWriter()
+ throws ParserConfigurationException, XMLStreamException {
+
+ XMLOutputFactory xof = XMLOutputFactory.newInstance();
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ DocumentBuilder db = dbf.newDocumentBuilder();
+ Document doc = db.newDocument();
+ XMLEventWriter eventWriter = xof.createXMLEventWriter(new DOMResult(doc));
+ XMLEventFactory eventFactory = XMLEventFactory.newInstance();
+ XMLEvent event = eventFactory.createStartDocument("iso-8859-15", "1.0", true);
+ eventWriter.add(event);
+ eventWriter.flush();
+ Assert.assertEquals(doc.getXmlEncoding(), "iso-8859-15");
+ Assert.assertEquals(doc.getXmlVersion(), "1.0");
+ Assert.assertTrue(doc.getXmlStandalone());
+ }
/**
* Test of main method, of class TestXMLStreamWriter.
--- a/jaxws/.hgtags Fri Oct 14 19:12:37 2016 +0300
+++ b/jaxws/.hgtags Fri Oct 14 11:11:19 2016 -0700
@@ -384,3 +384,4 @@
09ec13a99f50a4a346180d1e3b0fd8bc1ee399ce jdk-9+136
297c16d401c534cb879809d2a746d21ca99d2954 jdk-9+137
7d3a8f52b124db26ba8425c2931b748dd9d2791b jdk-9+138
+7a7aadf3c4500cc273c889aa1172d4fe3844bb6b jdk-9+139
--- a/jaxws/ASSEMBLY_EXCEPTION Fri Oct 14 19:12:37 2016 +0300
+++ b/jaxws/ASSEMBLY_EXCEPTION Fri Oct 14 11:11:19 2016 -0700
@@ -1,27 +1,27 @@
OPENJDK ASSEMBLY EXCEPTION
-The OpenJDK source code made available by Sun at openjdk.java.net and
-openjdk.dev.java.net ("OpenJDK Code") is distributed under the terms of the
-GNU General Public License <http://www.gnu.org/copyleft/gpl.html> version 2
+The OpenJDK source code made available by Oracle America, Inc. (Oracle) at
+openjdk.java.net ("OpenJDK Code") is distributed under the terms of the GNU
+General Public License <http://www.gnu.org/copyleft/gpl.html> version 2
only ("GPL2"), with the following clarification and special exception.
Linking this OpenJDK Code statically or dynamically with other code
is making a combined work based on this library. Thus, the terms
and conditions of GPL2 cover the whole combination.
- As a special exception, Sun gives you permission to link this
- OpenJDK Code with certain code licensed by Sun as indicated at
+ As a special exception, Oracle gives you permission to link this
+ OpenJDK Code with certain code licensed by Oracle as indicated at
http://openjdk.java.net/legal/exception-modules-2007-05-08.html
("Designated Exception Modules") to produce an executable,
regardless of the license terms of the Designated Exception Modules,
and to copy and distribute the resulting executable under GPL2,
provided that the Designated Exception Modules continue to be
- governed by the licenses under which they were offered by Sun.
+ governed by the licenses under which they were offered by Oracle.
-As such, it allows licensees and sublicensees of Sun's GPL2 OpenJDK Code to
-build an executable that includes those portions of necessary code that Sun
-could not provide under GPL2 (or that Sun has provided under GPL2 with the
-Classpath exception). If you modify or add to the OpenJDK code, that new
-GPL2 code may still be combined with Designated Exception Modules if the
-new code is made subject to this exception by its copyright holder.
+As such, it allows licensees and sublicensees of Oracle's GPL2 OpenJDK Code
+to build an executable that includes those portions of necessary code that
+Oracle could not provide under GPL2 (or that Oracle has provided under GPL2
+with the Classpath exception). If you modify or add to the OpenJDK code,
+that new GPL2 code may still be combined with Designated Exception Modules
+if the new code is made subject to this exception by its copyright holder.
--- a/jdk/.hgtags Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/.hgtags Fri Oct 14 11:11:19 2016 -0700
@@ -382,3 +382,4 @@
e72df94364e3686e7d62059ce0d6b187b82da713 jdk-9+137
665096863382bf23ce891307cf2a7511e77c1c88 jdk-9+138
5518ac2f2ead5e594bd983f2047178136aafdfd0 jdk-9+139
+e93b7ea559759f036c9f69fd2ddaf47bb4e98385 jdk-9+140
--- a/jdk/make/CompileInterimRmic.gmk Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/make/CompileInterimRmic.gmk Fri Oct 14 11:11:19 2016 -0700
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
--- a/jdk/make/CompileTools.gmk Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/make/CompileTools.gmk Fri Oct 14 11:11:19 2016 -0700
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
--- a/jdk/make/GenerateModuleSummary.gmk Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/make/GenerateModuleSummary.gmk Fri Oct 14 11:11:19 2016 -0700
@@ -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
--- a/jdk/make/Tools.gmk Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/make/Tools.gmk Fri Oct 14 11:11:19 2016 -0700
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
--- a/jdk/make/gendata/GendataBreakIterator.gmk Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/make/gendata/GendataBreakIterator.gmk Fri Oct 14 11:11:19 2016 -0700
@@ -1,5 +1,5 @@
-# Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
--- a/jdk/make/gendata/GendataHtml32dtd.gmk Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/make/gendata/GendataHtml32dtd.gmk Fri Oct 14 11:11:19 2016 -0700
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
--- a/jdk/make/gensrc/Gensrc-java.base.gmk Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/make/gensrc/Gensrc-java.base.gmk Fri Oct 14 11:11:19 2016 -0700
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
--- a/jdk/make/gensrc/Gensrc-jdk.jlink.gmk Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/make/gensrc/Gensrc-jdk.jlink.gmk Fri Oct 14 11:11:19 2016 -0700
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2014, 2015, 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
--- a/jdk/make/gensrc/GensrcIcons.gmk Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/make/gensrc/GensrcIcons.gmk Fri Oct 14 11:11:19 2016 -0700
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
--- a/jdk/make/gensrc/GensrcLocaleData.gmk Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/make/gensrc/GensrcLocaleData.gmk Fri Oct 14 11:11:19 2016 -0700
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
--- a/jdk/make/gensrc/GensrcModuleLoaderMap.gmk Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/make/gensrc/GensrcModuleLoaderMap.gmk Fri Oct 14 11:11:19 2016 -0700
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
--- a/jdk/make/gensrc/GensrcVarHandles.gmk Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/make/gensrc/GensrcVarHandles.gmk Fri Oct 14 11:11:19 2016 -0700
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
--- a/jdk/make/launcher/Launcher-java.scripting.gmk Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/make/launcher/Launcher-java.scripting.gmk Fri Oct 14 11:11:19 2016 -0700
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
--- a/jdk/make/launcher/Launcher-jdk.compiler.gmk Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/make/launcher/Launcher-jdk.compiler.gmk Fri Oct 14 11:11:19 2016 -0700
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
--- a/jdk/make/launcher/Launcher-jdk.javadoc.gmk Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/make/launcher/Launcher-jdk.javadoc.gmk Fri Oct 14 11:11:19 2016 -0700
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
--- a/jdk/make/launcher/Launcher-jdk.jdeps.gmk Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/make/launcher/Launcher-jdk.jdeps.gmk Fri Oct 14 11:11:19 2016 -0700
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
--- a/jdk/make/launcher/Launcher-jdk.jlink.gmk Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/make/launcher/Launcher-jdk.jlink.gmk Fri Oct 14 11:11:19 2016 -0700
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
--- a/jdk/make/launcher/Launcher-jdk.jstatd.gmk Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/make/launcher/Launcher-jdk.jstatd.gmk Fri Oct 14 11:11:19 2016 -0700
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
--- a/jdk/make/launcher/Launcher-jdk.pack200.gmk Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/make/launcher/Launcher-jdk.pack200.gmk Fri Oct 14 11:11:19 2016 -0700
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -58,10 +58,6 @@
endif
-ifeq ($(OPENJDK_TARGET_OS), solaris)
- UNPACKEXE_TOOLCHAIN := TOOLCHAIN_LINK_CXX
-endif
-
UNPACK_MAPFILE_DIR := $(JDK_TOPDIR)/make/mapfiles/libunpack
UNPACK_MAPFILE_PLATFORM_FILE := \
$(UNPACK_MAPFILE_DIR)/mapfile-vers-unpack200-$(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU_ARCH)
@@ -79,7 +75,7 @@
$(eval $(call SetupNativeCompilation,BUILD_UNPACKEXE, \
SRC := $(UNPACKEXE_SRC), \
- TOOLCHAIN := $(UNPACKEXE_TOOLCHAIN), \
+ TOOLCHAIN := TOOLCHAIN_LINK_CXX, \
OPTIMIZATION := LOW, \
CFLAGS := $(UNPACKEXE_CFLAGS) $(CXXFLAGS_JDKEXE) -DFULL, \
CFLAGS_release := -DPRODUCT, \
--- a/jdk/make/launcher/Launcher-jdk.scripting.nashorn.shell.gmk Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/make/launcher/Launcher-jdk.scripting.nashorn.shell.gmk Fri Oct 14 11:11:19 2016 -0700
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
--- a/jdk/make/lib/CoreLibraries.gmk Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/make/lib/CoreLibraries.gmk Fri Oct 14 11:11:19 2016 -0700
@@ -255,7 +255,7 @@
CXXFLAGS := $(CXXFLAGS_JDKLIB) $(JIMAGELIB_CPPFLAGS), \
CFLAGS_unix := -UDEBUG, \
MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libjimage/mapfile-vers, \
- LDFLAGS := $(LDFLAGS_JDKLIB) \
+ LDFLAGS := $(LDFLAGS_JDKLIB) $(LDFLAGS_CXX_JDK) \
$(call SET_SHARED_LIBRARY_ORIGIN), \
LDFLAGS_windows := -export:JIMAGE_Open -export:JIMAGE_Close \
-export:JIMAGE_PackageToModule \
--- a/jdk/make/lib/Lib-java.desktop.gmk Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/make/lib/Lib-java.desktop.gmk Fri Oct 14 11:11:19 2016 -0700
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
--- a/jdk/make/rmic/Rmic-java.management.gmk Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/make/rmic/Rmic-java.management.gmk Fri Oct 14 11:11:19 2016 -0700
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
--- a/jdk/make/rmic/RmicCommon.gmk Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/make/rmic/RmicCommon.gmk Fri Oct 14 11:11:19 2016 -0700
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
--- a/jdk/src/java.base/share/classes/java/lang/module/ModuleFinder.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/lang/module/ModuleFinder.java Fri Oct 14 11:11:19 2016 -0700
@@ -33,7 +33,6 @@
import java.security.AccessController;
import java.security.Permission;
import java.security.PrivilegedAction;
-import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
@@ -333,7 +332,7 @@
*
* <p> When locating modules then any exceptions or errors thrown by the
* {@code find} or {@code findAll} methods of the underlying module finders
- * will be propogated to the caller of the resulting module finder's
+ * will be propagated to the caller of the resulting module finder's
* {@code find} or {@code findAll} methods. </p>
*
* @param finders
@@ -342,8 +341,8 @@
* @return A {@code ModuleFinder} that composes a sequence of module finders
*/
static ModuleFinder compose(ModuleFinder... finders) {
- final List<ModuleFinder> finderList = Arrays.asList(finders);
- finderList.forEach(Objects::requireNonNull);
+ // copy the list, also checking for nulls
+ final List<ModuleFinder> finderList = List.of(finders);
return new ModuleFinder() {
private final Map<String, ModuleReference> nameToModule = new HashMap<>();
--- a/jdk/src/java.base/share/classes/java/net/CookieManager.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/net/CookieManager.java Fri Oct 14 11:11:19 2016 -0700
@@ -81,7 +81,7 @@
* <li>
* Currently, only CookieStore.add(URI, HttpCookie) and CookieStore.get(URI)
* are used by CookieManager. Others are for completeness and might be needed
- * by a more sophisticated CookieStore implementation, e.g. a NetscapeCookieSotre.
+ * by a more sophisticated CookieStore implementation, e.g. a NetscapeCookieStore.
* </li>
* </ul>
* </blockquote>
@@ -201,10 +201,9 @@
throw new IllegalArgumentException("Argument is null");
}
- Map<String, List<String>> cookieMap = new java.util.HashMap<>();
// if there's no default CookieStore, no way for us to get any cookie
if (cookieJar == null)
- return Collections.unmodifiableMap(cookieMap);
+ return Map.of();
boolean secureLink = "https".equalsIgnoreCase(uri.getScheme());
List<HttpCookie> cookies = new java.util.ArrayList<>();
@@ -244,8 +243,7 @@
// apply sort rule (RFC 2965 sec. 3.3.4)
List<String> cookieHeader = sortByPath(cookies);
- cookieMap.put("Cookie", cookieHeader);
- return Collections.unmodifiableMap(cookieMap);
+ return Map.of("Cookie", cookieHeader);
}
public void
--- a/jdk/src/java.base/share/classes/java/net/URLPermission.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/net/URLPermission.java Fri Oct 14 11:11:19 2016 -0700
@@ -217,7 +217,7 @@
* where method-names is the list of methods separated by commas
* and header-names is the list of permitted headers separated by commas.
* There is no white space in the returned String. If header-names is empty
- * then the colon separator will not be present.
+ * then the colon separator may not be present.
*/
public String getActions() {
return actions;
--- a/jdk/src/java.base/share/classes/java/nio/file/FileTreeIterator.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/nio/file/FileTreeIterator.java Fri Oct 14 11:11:19 2016 -0700
@@ -31,11 +31,10 @@
import java.util.Arrays;
import java.util.Iterator;
import java.util.NoSuchElementException;
-import java.util.Objects;
import java.nio.file.FileTreeWalker.Event;
/**
- * An {@code Iterator to iterate over the nodes of a file tree.
+ * An {@code Iterator} to iterate over the nodes of a file tree.
*
* <pre>{@code
* try (FileTreeIterator iterator = new FileTreeIterator(start, maxDepth, options)) {
@@ -62,7 +61,7 @@
* @throws SecurityException
* if the security manager denies access to the starting file
* @throws NullPointerException
- * if {@code start} or {@code options} is {@ocde null} or
+ * if {@code start} or {@code options} is {@code null} or
* the options array contains a {@code null} element
*/
FileTreeIterator(Path start, int maxDepth, FileVisitOption... options)
--- a/jdk/src/java.base/share/classes/java/nio/file/FileTreeWalker.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/nio/file/FileTreeWalker.java Fri Oct 14 11:11:19 2016 -0700
@@ -171,7 +171,7 @@
* if {@code options} contains an element that is not a
* {@code FileVisitOption}
* @throws NullPointerException
- * if {@code options} is {@ocde null} or the options
+ * if {@code options} is {@code null} or the options
* array contains a {@code null} element
*/
FileTreeWalker(Collection<FileVisitOption> options, int maxDepth) {
--- a/jdk/src/java.base/share/classes/java/security/KeyStoreSpi.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/security/KeyStoreSpi.java Fri Oct 14 11:11:19 2016 -0700
@@ -479,6 +479,10 @@
} else if (engineIsKeyEntry(alias)) {
KeyStore.PasswordProtection pp =
(KeyStore.PasswordProtection)protParam;
+ if (pp.getProtectionAlgorithm() != null) {
+ throw new KeyStoreException(
+ "unsupported password protection algorithm");
+ }
char[] password = pp.getPassword();
Key key = engineGetKey(alias, password);
@@ -524,6 +528,10 @@
KeyStore.PasswordProtection pProtect = null;
if (protParam != null) {
pProtect = (KeyStore.PasswordProtection)protParam;
+ if (pProtect.getProtectionAlgorithm() != null) {
+ throw new KeyStoreException(
+ "unsupported password protection algorithm");
+ }
}
// set entry
--- a/jdk/src/java.base/share/classes/java/security/MessageDigest.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/security/MessageDigest.java Fri Oct 14 11:11:19 2016 -0700
@@ -32,10 +32,13 @@
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;
+import sun.security.util.MessageDigestSpi2;
+
+import javax.crypto.SecretKey;
/**
* This MessageDigest class provides applications the functionality of a
@@ -548,7 +551,7 @@
* and its original parent (Object).
*/
- static class Delegate extends MessageDigest {
+ static class Delegate extends MessageDigest implements MessageDigestSpi2 {
// The provider implementation (delegate)
private MessageDigestSpi digestSpi;
@@ -601,6 +604,14 @@
digestSpi.engineUpdate(input);
}
+ public void engineUpdate(SecretKey key) throws InvalidKeyException {
+ if (digestSpi instanceof MessageDigestSpi2) {
+ ((MessageDigestSpi2)digestSpi).engineUpdate(key);
+ } else {
+ throw new UnsupportedOperationException
+ ("Digest does not support update of SecretKey object");
+ }
+ }
protected byte[] engineDigest() {
return digestSpi.engineDigest();
}
--- a/jdk/src/java.base/share/classes/java/security/Signature.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/security/Signature.java Fri Oct 14 11:11:19 2016 -0700
@@ -37,7 +37,6 @@
import java.security.Provider.Service;
import javax.crypto.Cipher;
-import javax.crypto.CipherSpi;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.BadPaddingException;
import javax.crypto.NoSuchPaddingException;
@@ -180,15 +179,12 @@
private static final String RSA_CIPHER = "RSA/ECB/PKCS1Padding";
// all the services we need to lookup for compatibility with Cipher
- private static final List<ServiceId> rsaIds = Arrays.asList(
- new ServiceId[] {
- new ServiceId("Signature", "NONEwithRSA"),
- new ServiceId("Cipher", "RSA/ECB/PKCS1Padding"),
- new ServiceId("Cipher", "RSA/ECB"),
- new ServiceId("Cipher", "RSA//PKCS1Padding"),
- new ServiceId("Cipher", "RSA"),
- }
- );
+ private static final List<ServiceId> rsaIds = List.of(
+ new ServiceId("Signature", "NONEwithRSA"),
+ new ServiceId("Cipher", "RSA/ECB/PKCS1Padding"),
+ new ServiceId("Cipher", "RSA/ECB"),
+ new ServiceId("Cipher", "RSA//PKCS1Padding"),
+ new ServiceId("Cipher", "RSA"));
/**
* Returns a Signature object that implements the specified signature
--- a/jdk/src/java.base/share/classes/java/time/Duration.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/time/Duration.java Fri Oct 14 11:11:19 2016 -0700
@@ -88,8 +88,6 @@
import java.time.temporal.TemporalAmount;
import java.time.temporal.TemporalUnit;
import java.time.temporal.UnsupportedTemporalTypeException;
-import java.util.Arrays;
-import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.regex.Matcher;
@@ -578,8 +576,7 @@
* the simple initialization in Duration.
*/
private static class DurationUnits {
- static final List<TemporalUnit> UNITS =
- Collections.unmodifiableList(Arrays.<TemporalUnit>asList(SECONDS, NANOS));
+ static final List<TemporalUnit> UNITS = List.of(SECONDS, NANOS);
}
//-----------------------------------------------------------------------
--- a/jdk/src/java.base/share/classes/java/time/Period.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/time/Period.java Fri Oct 14 11:11:19 2016 -0700
@@ -83,8 +83,6 @@
import java.time.temporal.TemporalQueries;
import java.time.temporal.TemporalUnit;
import java.time.temporal.UnsupportedTemporalTypeException;
-import java.util.Arrays;
-import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.regex.Matcher;
@@ -152,8 +150,7 @@
/**
* The set of supported units.
*/
- private static final List<TemporalUnit> SUPPORTED_UNITS =
- Collections.unmodifiableList(Arrays.<TemporalUnit>asList(YEARS, MONTHS, DAYS));
+ private static final List<TemporalUnit> SUPPORTED_UNITS = List.of(YEARS, MONTHS, DAYS);
/**
* The number of years.
--- a/jdk/src/java.base/share/classes/java/time/ZoneId.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/time/ZoneId.java Fri Oct 14 11:11:19 2016 -0700
@@ -76,14 +76,14 @@
import java.time.zone.ZoneRules;
import java.time.zone.ZoneRulesException;
import java.time.zone.ZoneRulesProvider;
-import java.util.Collections;
-import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.TimeZone;
+import static java.util.Map.entry;
+
/**
* A time-zone ID, such as {@code Europe/Paris}.
* <p>
@@ -220,39 +220,36 @@
* </ul>
* The map is unmodifiable.
*/
- public static final Map<String, String> SHORT_IDS;
- static {
- Map<String, String> map = new HashMap<>(64);
- map.put("ACT", "Australia/Darwin");
- map.put("AET", "Australia/Sydney");
- map.put("AGT", "America/Argentina/Buenos_Aires");
- map.put("ART", "Africa/Cairo");
- map.put("AST", "America/Anchorage");
- map.put("BET", "America/Sao_Paulo");
- map.put("BST", "Asia/Dhaka");
- map.put("CAT", "Africa/Harare");
- map.put("CNT", "America/St_Johns");
- map.put("CST", "America/Chicago");
- map.put("CTT", "Asia/Shanghai");
- map.put("EAT", "Africa/Addis_Ababa");
- map.put("ECT", "Europe/Paris");
- map.put("IET", "America/Indiana/Indianapolis");
- map.put("IST", "Asia/Kolkata");
- map.put("JST", "Asia/Tokyo");
- map.put("MIT", "Pacific/Apia");
- map.put("NET", "Asia/Yerevan");
- map.put("NST", "Pacific/Auckland");
- map.put("PLT", "Asia/Karachi");
- map.put("PNT", "America/Phoenix");
- map.put("PRT", "America/Puerto_Rico");
- map.put("PST", "America/Los_Angeles");
- map.put("SST", "Pacific/Guadalcanal");
- map.put("VST", "Asia/Ho_Chi_Minh");
- map.put("EST", "-05:00");
- map.put("MST", "-07:00");
- map.put("HST", "-10:00");
- SHORT_IDS = Collections.unmodifiableMap(map);
- }
+ public static final Map<String, String> SHORT_IDS = Map.ofEntries(
+ entry("ACT", "Australia/Darwin"),
+ entry("AET", "Australia/Sydney"),
+ entry("AGT", "America/Argentina/Buenos_Aires"),
+ entry("ART", "Africa/Cairo"),
+ entry("AST", "America/Anchorage"),
+ entry("BET", "America/Sao_Paulo"),
+ entry("BST", "Asia/Dhaka"),
+ entry("CAT", "Africa/Harare"),
+ entry("CNT", "America/St_Johns"),
+ entry("CST", "America/Chicago"),
+ entry("CTT", "Asia/Shanghai"),
+ entry("EAT", "Africa/Addis_Ababa"),
+ entry("ECT", "Europe/Paris"),
+ entry("IET", "America/Indiana/Indianapolis"),
+ entry("IST", "Asia/Kolkata"),
+ entry("JST", "Asia/Tokyo"),
+ entry("MIT", "Pacific/Apia"),
+ entry("NET", "Asia/Yerevan"),
+ entry("NST", "Pacific/Auckland"),
+ entry("PLT", "Asia/Karachi"),
+ entry("PNT", "America/Phoenix"),
+ entry("PRT", "America/Puerto_Rico"),
+ entry("PST", "America/Los_Angeles"),
+ entry("SST", "Pacific/Guadalcanal"),
+ entry("VST", "Asia/Ho_Chi_Minh"),
+ entry("EST", "-05:00"),
+ entry("MST", "-07:00"),
+ entry("HST", "-10:00")
+ );
/**
* Serialization version.
*/
--- a/jdk/src/java.base/share/classes/java/time/chrono/ChronoPeriodImpl.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/time/chrono/ChronoPeriodImpl.java Fri Oct 14 11:11:19 2016 -0700
@@ -77,8 +77,6 @@
import java.time.temporal.TemporalUnit;
import java.time.temporal.UnsupportedTemporalTypeException;
import java.time.temporal.ValueRange;
-import java.util.Arrays;
-import java.util.Collections;
import java.util.List;
import java.util.Objects;
@@ -105,8 +103,7 @@
/**
* The set of supported units.
*/
- private static final List<TemporalUnit> SUPPORTED_UNITS =
- Collections.unmodifiableList(Arrays.<TemporalUnit>asList(YEARS, MONTHS, DAYS));
+ private static final List<TemporalUnit> SUPPORTED_UNITS = List.of(YEARS, MONTHS, DAYS);
/**
* The chronology.
--- a/jdk/src/java.base/share/classes/java/time/chrono/HijrahChronology.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/time/chrono/HijrahChronology.java Fri Oct 14 11:11:19 2016 -0700
@@ -59,10 +59,7 @@
import static java.time.temporal.ChronoField.EPOCH_DAY;
-import java.io.File;
-import java.io.FileInputStream;
import java.io.FilePermission;
-import java.io.IOException;
import java.io.InputStream;
import java.io.InvalidObjectException;
import java.io.ObjectInputStream;
@@ -83,7 +80,6 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.Objects;
import java.util.Properties;
import sun.util.logging.PlatformLogger;
@@ -512,7 +508,7 @@
@Override
public List<Era> eras() {
- return Arrays.<Era>asList(HijrahEra.values());
+ return List.of(HijrahEra.values());
}
//-----------------------------------------------------------------------
--- a/jdk/src/java.base/share/classes/java/time/chrono/IsoChronology.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/time/chrono/IsoChronology.java Fri Oct 14 11:11:19 2016 -0700
@@ -90,7 +90,6 @@
import java.time.temporal.TemporalAccessor;
import java.time.temporal.TemporalField;
import java.time.temporal.ValueRange;
-import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@@ -492,7 +491,7 @@
@Override
public List<Era> eras() {
- return Arrays.<Era>asList(IsoEra.values());
+ return List.of(IsoEra.values());
}
//-----------------------------------------------------------------------
--- a/jdk/src/java.base/share/classes/java/time/chrono/JapaneseChronology.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/time/chrono/JapaneseChronology.java Fri Oct 14 11:11:19 2016 -0700
@@ -81,7 +81,6 @@
import java.time.temporal.TemporalField;
import java.time.temporal.UnsupportedTemporalTypeException;
import java.time.temporal.ValueRange;
-import java.util.Arrays;
import java.util.Calendar;
import java.util.List;
import java.util.Locale;
@@ -379,7 +378,7 @@
@Override
public List<Era> eras() {
- return Arrays.<Era>asList(JapaneseEra.values());
+ return List.of(JapaneseEra.values());
}
JapaneseEra getCurrentEra() {
--- a/jdk/src/java.base/share/classes/java/time/chrono/MinguoChronology.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/time/chrono/MinguoChronology.java Fri Oct 14 11:11:19 2016 -0700
@@ -72,7 +72,6 @@
import java.time.temporal.TemporalAccessor;
import java.time.temporal.TemporalField;
import java.time.temporal.ValueRange;
-import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@@ -306,7 +305,7 @@
@Override
public List<Era> eras() {
- return Arrays.<Era>asList(MinguoEra.values());
+ return List.of(MinguoEra.values());
}
//-----------------------------------------------------------------------
--- a/jdk/src/java.base/share/classes/java/time/chrono/ThaiBuddhistChronology.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/time/chrono/ThaiBuddhistChronology.java Fri Oct 14 11:11:19 2016 -0700
@@ -342,7 +342,7 @@
@Override
public List<Era> eras() {
- return Arrays.<Era>asList(ThaiBuddhistEra.values());
+ return List.of(ThaiBuddhistEra.values());
}
//-----------------------------------------------------------------------
--- a/jdk/src/java.base/share/classes/java/time/format/DateTimeFormatter.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/time/format/DateTimeFormatter.java Fri Oct 14 11:11:19 2016 -0700
@@ -1685,6 +1685,7 @@
public DateTimeFormatter withResolverFields(TemporalField... resolverFields) {
Set<TemporalField> fields = null;
if (resolverFields != null) {
+ // Set.of cannot be used because it is hostile to nulls and duplicate elements
fields = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(resolverFields)));
}
if (Objects.equals(this.resolverFields, fields)) {
--- a/jdk/src/java.base/share/classes/java/time/zone/ZoneOffsetTransition.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/time/zone/ZoneOffsetTransition.java Fri Oct 14 11:11:19 2016 -0700
@@ -387,9 +387,9 @@
*/
List<ZoneOffset> getValidOffsets() {
if (isGap()) {
- return Collections.emptyList();
+ return List.of();
}
- return Arrays.asList(getOffsetBefore(), getOffsetAfter());
+ return List.of(getOffsetBefore(), getOffsetAfter());
}
//-----------------------------------------------------------------------
--- a/jdk/src/java.base/share/classes/java/time/zone/ZoneRules.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/time/zone/ZoneRules.java Fri Oct 14 11:11:19 2016 -0700
@@ -303,7 +303,6 @@
* Creates an instance of ZoneRules that has fixed zone rules.
*
* @param offset the offset this fixed zone rules is based on, not null
- * @return the zone rules, not null
* @see #isFixedOffset()
*/
private ZoneRules(ZoneOffset offset) {
@@ -970,7 +969,7 @@
* @return an immutable list of transition rules, not null
*/
public List<ZoneOffsetTransitionRule> getTransitionRules() {
- return Collections.unmodifiableList(Arrays.asList(lastRules));
+ return List.of(lastRules);
}
/**
--- a/jdk/src/java.base/share/classes/java/util/ResourceBundle.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/util/ResourceBundle.java Fri Oct 14 11:11:19 2016 -0700
@@ -2491,34 +2491,29 @@
/**
* The default format <code>List</code>, which contains the strings
* <code>"java.class"</code> and <code>"java.properties"</code>, in
- * this order. This <code>List</code> is {@linkplain
- * Collections#unmodifiableList(List) unmodifiable}.
+ * this order. This <code>List</code> is unmodifiable.
*
* @see #getFormats(String)
*/
public static final List<String> FORMAT_DEFAULT
- = Collections.unmodifiableList(Arrays.asList("java.class",
- "java.properties"));
+ = List.of("java.class", "java.properties");
/**
* The class-only format <code>List</code> containing
- * <code>"java.class"</code>. This <code>List</code> is {@linkplain
- * Collections#unmodifiableList(List) unmodifiable}.
+ * <code>"java.class"</code>. This <code>List</code> is unmodifiable.
*
* @see #getFormats(String)
*/
- public static final List<String> FORMAT_CLASS
- = Collections.unmodifiableList(Arrays.asList("java.class"));
+ public static final List<String> FORMAT_CLASS = List.of("java.class");
/**
* The properties-only format <code>List</code> containing
- * <code>"java.properties"</code>. This <code>List</code> is
- * {@linkplain Collections#unmodifiableList(List) unmodifiable}.
+ * <code>"java.properties"</code>. This <code>List</code> is unmodifiable.
*
* @see #getFormats(String)
*/
public static final List<String> FORMAT_PROPERTIES
- = Collections.unmodifiableList(Arrays.asList("java.properties"));
+ = List.of("java.properties");
/**
* The time-to-live constant for not caching loaded resource bundle
--- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicBoolean.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicBoolean.java Fri Oct 14 11:11:19 2016 -0700
@@ -108,10 +108,18 @@
* if the current value {@code == expectedValue},
* with memory effects as specified by {@link VarHandle#weakCompareAndSetPlain}.
*
+ * @deprecated This method has plain memory effects but the method
+ * name implies volatile memory effects (see methods such as
+ * {@link #compareAndExchange} and {@link #compareAndSet}). To avoid
+ * confusion over plain or volatile memory effects it is recommended that
+ * the method {@link #weakCompareAndSetPlain} be used instead.
+ *
* @param expectedValue the expected value
* @param newValue the new value
* @return {@code true} if successful
+ * @see #weakCompareAndSetPlain
*/
+ @Deprecated(since="9")
public boolean weakCompareAndSet(boolean expectedValue, boolean newValue) {
return VALUE.weakCompareAndSetPlain(this,
(expectedValue ? 1 : 0),
@@ -119,6 +127,22 @@
}
/**
+ * Possibly atomically sets the value to {@code newValue}
+ * if the current value {@code == expectedValue},
+ * with memory effects as specified by {@link VarHandle#weakCompareAndSetPlain}.
+ *
+ * @param expectedValue the expected value
+ * @param newValue the new value
+ * @return {@code true} if successful
+ * @since 9
+ */
+ public boolean weakCompareAndSetPlain(boolean expectedValue, boolean newValue) {
+ return VALUE.weakCompareAndSetPlain(this,
+ (expectedValue ? 1 : 0),
+ (newValue ? 1 : 0));
+ }
+
+ /**
* Sets the value to {@code newValue},
* with memory effects as specified by {@link VarHandle#setVolatile}.
*
--- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicInteger.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicInteger.java Fri Oct 14 11:11:19 2016 -0700
@@ -148,15 +148,37 @@
* if the current value {@code == expectedValue},
* with memory effects as specified by {@link VarHandle#weakCompareAndSetPlain}.
*
+ * @deprecated This method has plain memory effects but the method
+ * name implies volatile memory effects (see methods such as
+ * {@link #compareAndExchange} and {@link #compareAndSet}). To avoid
+ * confusion over plain or volatile memory effects it is recommended that
+ * the method {@link #weakCompareAndSetPlain} be used instead.
+ *
* @param expectedValue the expected value
* @param newValue the new value
* @return {@code true} if successful
+ * @see #weakCompareAndSetPlain
*/
+ @Deprecated(since="9")
public final boolean weakCompareAndSet(int expectedValue, int newValue) {
return U.weakCompareAndSwapInt(this, VALUE, expectedValue, newValue);
}
/**
+ * Possibly atomically sets the value to {@code newValue}
+ * if the current value {@code == expectedValue},
+ * with memory effects as specified by {@link VarHandle#weakCompareAndSetPlain}.
+ *
+ * @param expectedValue the expected value
+ * @param newValue the new value
+ * @return {@code true} if successful
+ * @since 9
+ */
+ public final boolean weakCompareAndSetPlain(int expectedValue, int newValue) {
+ return U.weakCompareAndSwapInt(this, VALUE, expectedValue, newValue);
+ }
+
+ /**
* Atomically increments the current value,
* with memory effects as specified by {@link VarHandle#getAndAdd}.
*
--- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerArray.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerArray.java Fri Oct 14 11:11:19 2016 -0700
@@ -151,16 +151,39 @@
* {@code newValue} if the element's current value {@code == expectedValue},
* with memory effects as specified by {@link VarHandle#weakCompareAndSetPlain}.
*
+ * @deprecated This method has plain memory effects but the method
+ * name implies volatile memory effects (see methods such as
+ * {@link #compareAndExchange} and {@link #compareAndSet}). To avoid
+ * confusion over plain or volatile memory effects it is recommended that
+ * the method {@link #weakCompareAndSetPlain} be used instead.
+ *
* @param i the index
* @param expectedValue the expected value
* @param newValue the new value
* @return {@code true} if successful
+ * @see #weakCompareAndSetPlain
*/
+ @Deprecated(since="9")
public final boolean weakCompareAndSet(int i, int expectedValue, int newValue) {
return AA.weakCompareAndSetPlain(array, i, expectedValue, newValue);
}
/**
+ * Possibly atomically sets the element at index {@code i} to
+ * {@code newValue} if the element's current value {@code == expectedValue},
+ * with memory effects as specified by {@link VarHandle#weakCompareAndSetPlain}.
+ *
+ * @param i the index
+ * @param expectedValue the expected value
+ * @param newValue the new value
+ * @return {@code true} if successful
+ * @since 9
+ */
+ public final boolean weakCompareAndSetPlain(int i, int expectedValue, int newValue) {
+ return AA.weakCompareAndSetPlain(array, i, expectedValue, newValue);
+ }
+
+ /**
* Atomically increments the value of the element at index {@code i},
* with memory effects as specified by {@link VarHandle#getAndAdd}.
*
--- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLong.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLong.java Fri Oct 14 11:11:19 2016 -0700
@@ -164,15 +164,37 @@
* if the current value {@code == expectedValue},
* with memory effects as specified by {@link VarHandle#weakCompareAndSetPlain}.
*
+ * @deprecated This method has plain memory effects but the method
+ * name implies volatile memory effects (see methods such as
+ * {@link #compareAndExchange} and {@link #compareAndSet}). To avoid
+ * confusion over plain or volatile memory effects it is recommended that
+ * the method {@link #weakCompareAndSetPlain} be used instead.
+ *
* @param expectedValue the expected value
* @param newValue the new value
* @return {@code true} if successful
+ * @see #weakCompareAndSetPlain
*/
+ @Deprecated(since="9")
public final boolean weakCompareAndSet(long expectedValue, long newValue) {
return U.weakCompareAndSwapLong(this, VALUE, expectedValue, newValue);
}
/**
+ * Possibly atomically sets the value to {@code newValue}
+ * if the current value {@code == expectedValue},
+ * with memory effects as specified by {@link VarHandle#weakCompareAndSetPlain}.
+ *
+ * @param expectedValue the expected value
+ * @param newValue the new value
+ * @return {@code true} if successful
+ * @since 9
+ */
+ public final boolean weakCompareAndSetPlain(long expectedValue, long newValue) {
+ return U.weakCompareAndSwapLong(this, VALUE, expectedValue, newValue);
+ }
+
+ /**
* Atomically increments the current value,
* with memory effects as specified by {@link VarHandle#getAndAdd}.
*
--- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongArray.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongArray.java Fri Oct 14 11:11:19 2016 -0700
@@ -151,16 +151,39 @@
* {@code newValue} if the element's current value {@code == expectedValue},
* with memory effects as specified by {@link VarHandle#weakCompareAndSetPlain}.
*
+ * @deprecated This method has plain memory effects but the method
+ * name implies volatile memory effects (see methods such as
+ * {@link #compareAndExchange} and {@link #compareAndSet}). To avoid
+ * confusion over plain or volatile memory effects it is recommended that
+ * the method {@link #weakCompareAndSetPlain} be used instead.
+ *
* @param i the index
* @param expectedValue the expected value
* @param newValue the new value
* @return {@code true} if successful
+ * @see #weakCompareAndSetPlain
*/
+ @Deprecated(since="9")
public final boolean weakCompareAndSet(int i, long expectedValue, long newValue) {
return AA.weakCompareAndSetPlain(array, i, expectedValue, newValue);
}
/**
+ * Possibly atomically sets the element at index {@code i} to
+ * {@code newValue} if the element's current value {@code == expectedValue},
+ * with memory effects as specified by {@link VarHandle#weakCompareAndSetPlain}.
+ *
+ * @param i the index
+ * @param expectedValue the expected value
+ * @param newValue the new value
+ * @return {@code true} if successful
+ * @since 9
+ */
+ public final boolean weakCompareAndSetPlain(int i, long expectedValue, long newValue) {
+ return AA.weakCompareAndSetPlain(array, i, expectedValue, newValue);
+ }
+
+ /**
* Atomically increments the value of the element at index {@code i},
* with memory effects as specified by {@link VarHandle#getAndAdd}.
*
--- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReference.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReference.java Fri Oct 14 11:11:19 2016 -0700
@@ -127,15 +127,37 @@
* if the current value {@code == expectedValue},
* with memory effects as specified by {@link VarHandle#weakCompareAndSetPlain}.
*
+ * @deprecated This method has plain memory effects but the method
+ * name implies volatile memory effects (see methods such as
+ * {@link #compareAndExchange} and {@link #compareAndSet}). To avoid
+ * confusion over plain or volatile memory effects it is recommended that
+ * the method {@link #weakCompareAndSetPlain} be used instead.
+ *
* @param expectedValue the expected value
* @param newValue the new value
* @return {@code true} if successful
+ * @see #weakCompareAndSetPlain
*/
+ @Deprecated(since="9")
public final boolean weakCompareAndSet(V expectedValue, V newValue) {
return VALUE.weakCompareAndSetPlain(this, expectedValue, newValue);
}
/**
+ * Possibly atomically sets the value to {@code newValue}
+ * if the current value {@code == expectedValue},
+ * with memory effects as specified by {@link VarHandle#weakCompareAndSetPlain}.
+ *
+ * @param expectedValue the expected value
+ * @param newValue the new value
+ * @return {@code true} if successful
+ * @since 9
+ */
+ public final boolean weakCompareAndSetPlain(V expectedValue, V newValue) {
+ return VALUE.weakCompareAndSetPlain(this, expectedValue, newValue);
+ }
+
+ /**
* Atomically sets the value to {@code newValue} and returns the old value,
* with memory effects as specified by {@link VarHandle#getAndSet}.
*
--- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceArray.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceArray.java Fri Oct 14 11:11:19 2016 -0700
@@ -157,16 +157,39 @@
* {@code newValue} if the element's current value {@code == expectedValue},
* with memory effects as specified by {@link VarHandle#weakCompareAndSetPlain}.
*
+ * @deprecated This method has plain memory effects but the method
+ * name implies volatile memory effects (see methods such as
+ * {@link #compareAndExchange} and {@link #compareAndSet}). To avoid
+ * confusion over plain or volatile memory effects it is recommended that
+ * the method {@link #weakCompareAndSetPlain} be used instead.
+ *
* @param i the index
* @param expectedValue the expected value
* @param newValue the new value
* @return {@code true} if successful
+ * @see #weakCompareAndSetPlain
*/
+ @Deprecated(since="9")
public final boolean weakCompareAndSet(int i, E expectedValue, E newValue) {
return AA.weakCompareAndSetPlain(array, i, expectedValue, newValue);
}
/**
+ * Possibly atomically sets the element at index {@code i} to
+ * {@code newValue} if the element's current value {@code == expectedValue},
+ * with memory effects as specified by {@link VarHandle#weakCompareAndSetPlain}.
+ *
+ * @param i the index
+ * @param expectedValue the expected value
+ * @param newValue the new value
+ * @return {@code true} if successful
+ * @since 9
+ */
+ public final boolean weakCompareAndSetPlain(int i, E expectedValue, E newValue) {
+ return AA.weakCompareAndSetPlain(array, i, expectedValue, newValue);
+ }
+
+ /**
* Atomically updates the element at index {@code i} with the results
* of applying the given function, returning the previous value. The
* function should be side-effect-free, since it may be re-applied
--- a/jdk/src/java.base/share/classes/java/util/spi/ToolProvider.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/util/spi/ToolProvider.java Fri Oct 14 11:11:19 2016 -0700
@@ -56,8 +56,8 @@
/**
* Returns the name of this tool provider.
*
- * @apiNote It is recommended that the name be the same as would be used on
- * the command line: for example, "javac", "jar", "jlink".
+ * @apiNote It is recommended that the name be the same as would be
+ * used on the command line: for example, "javac", "jar", "jlink".
*
* @return the name of this tool provider
*/
@@ -67,12 +67,13 @@
* Runs an instance of the tool, returning zero for a successful run.
* Any non-zero return value indicates a tool-specific error during the
* execution.
+ *
* Two streams should be provided, for "expected" output, and for any
* error messages. If it is not necessary to distinguish the output,
* the same stream may be used for both.
*
* @apiNote The interpretation of the arguments will be specific to
- * each tool.
+ * each tool.
*
* @param out a stream to which "expected" output should be written
*
@@ -81,12 +82,13 @@
* @param args the command-line arguments for the tool
*
* @return the result of executing the tool.
- * A return value of 0 means the tool did not encounter any errors;
- * any other value indicates that at least one error occurred during
- * execution.
+ * A return value of 0 means the tool did not encounter any errors;
+ * any other value indicates that at least one error occurred
+ * during execution.
*
* @throws NullPointerException if any of the arguments are {@code null},
- * or if there are any {@code null} values in the {@code args} array
+ * or if there are any {@code null} values in the {@code args}
+ * array
*/
int run(PrintWriter out, PrintWriter err, String... args);
@@ -94,16 +96,17 @@
* Runs an instance of the tool, returning zero for a successful run.
* Any non-zero return value indicates a tool-specific error during the
* execution.
+ *
* Two streams should be provided, for "expected" output, and for any
* error messages. If it is not necessary to distinguish the output,
* the same stream may be used for both.
*
* @apiNote The interpretation of the arguments will be specific to
- * each tool.
+ * each tool.
*
* @implNote This implementation wraps the {@code out} and {@code err}
- * streams within {@link PrintWriter}s, and then calls
- * {@link run(PrintWriter, PrintWriter, String[])}.
+ * streams within {@link PrintWriter}s, and then calls
+ * {@link #run(PrintWriter, PrintWriter, String[])}.
*
* @param out a stream to which "expected" output should be written
*
@@ -112,12 +115,13 @@
* @param args the command-line arguments for the tool
*
* @return the result of executing the tool.
- * A return value of 0 means the tool did not encounter any errors;
- * any other value indicates that at least one error occurred during
- * execution.
+ * A return value of 0 means the tool did not encounter any errors;
+ * any other value indicates that at least one error occurred
+ * during execution.
*
* @throws NullPointerException if any of the arguments are {@code null},
- * or if there are any {@code null} values in the {@code args} array
+ * or if there are any {@code null} values in the {@code args}
+ * array
*/
default int run(PrintStream out, PrintStream err, String... args) {
Objects.requireNonNull(out);
--- a/jdk/src/java.base/share/classes/java/util/stream/Collectors.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/util/stream/Collectors.java Fri Oct 14 11:11:19 2016 -0700
@@ -27,7 +27,6 @@
import java.util.AbstractMap;
import java.util.AbstractSet;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
@@ -1720,12 +1719,12 @@
@Override
public Set<Map.Entry<Boolean, T>> entrySet() {
- return new AbstractSet<Map.Entry<Boolean, T>>() {
+ return new AbstractSet<>() {
@Override
public Iterator<Map.Entry<Boolean, T>> iterator() {
Map.Entry<Boolean, T> falseEntry = new SimpleImmutableEntry<>(false, forFalse);
Map.Entry<Boolean, T> trueEntry = new SimpleImmutableEntry<>(true, forTrue);
- return Arrays.asList(falseEntry, trueEntry).iterator();
+ return List.of(falseEntry, trueEntry).iterator();
}
@Override
--- a/jdk/src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java Fri Oct 14 11:11:19 2016 -0700
@@ -430,22 +430,23 @@
// the key is $MODULE
String mn = e.getKey();
Optional<Module> om = bootLayer.findModule(mn);
- if (!om.isPresent())
- fail("Unknown module: " + mn);
+ if (!om.isPresent()) {
+ warn("Unknown module: " + mn);
+ continue;
+ }
Module m = om.get();
// the value is the set of other modules (by name)
for (String name : e.getValue()) {
-
- Module other;
if (ALL_UNNAMED.equals(name)) {
Modules.addReadsAllUnnamed(m);
} else {
om = bootLayer.findModule(name);
- if (!om.isPresent())
- fail("Unknown module: " + name);
- other = om.get();
- Modules.addReads(m, other);
+ if (om.isPresent()) {
+ Modules.addReads(m, om.get());
+ } else {
+ warn("Unknown module: " + name);
+ }
}
}
@@ -472,14 +473,24 @@
String mn = s[0];
String pn = s[1];
+ if (mn.isEmpty() || pn.isEmpty())
+ fail("Module and package name must be specified:" + key);
// The exporting module is in the boot layer
Module m;
Optional<Module> om = bootLayer.findModule(mn);
- if (!om.isPresent())
- fail("Unknown module: " + mn);
+ if (!om.isPresent()) {
+ warn("Unknown module: " + mn);
+ continue;
+ }
+
m = om.get();
+ if (!m.getDescriptor().packages().contains(pn)) {
+ warn("package " + pn + " not in " + mn);
+ continue;
+ }
+
// the value is the set of modules to export to (by name)
for (String name : e.getValue()) {
boolean allUnnamed = false;
@@ -491,10 +502,10 @@
if (om.isPresent()) {
other = om.get();
} else {
- fail("Unknown module: " + name);
+ warn("Unknown module: " + name);
+ continue;
}
}
-
if (allUnnamed) {
Modules.addExportsToAllUnnamed(m, pn);
} else {
@@ -534,13 +545,7 @@
if (rhs.isEmpty())
fail("Unable to parse: " + value);
-
- // value is <module>(,<module>)*
- if (map.containsKey(key))
- fail(key + " specified more than once");
-
- Set<String> values = new HashSet<>();
- map.put(key, values);
+ Set<String> values = map.computeIfAbsent(key, k -> new HashSet<>());
for (String s : rhs.split(",")) {
if (s.length() > 0) values.add(s);
}
@@ -566,6 +571,10 @@
throw new RuntimeException(m);
}
+ static void warn(String m) {
+ System.err.println("WARNING: " + m);
+ }
+
static class PerfCounters {
static PerfCounter systemModulesTime
--- a/jdk/src/java.base/share/classes/module-info.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/src/java.base/share/classes/module-info.java Fri Oct 14 11:11:19 2016 -0700
@@ -154,7 +154,6 @@
exports jdk.internal.module to
java.instrument,
java.management,
- jdk.dynalink,
jdk.jartool,
jdk.jlink;
exports jdk.internal.misc to
--- a/jdk/src/java.base/share/classes/sun/nio/cs/HKSCS.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/src/java.base/share/classes/sun/nio/cs/HKSCS.java Fri Oct 14 11:11:19 2016 -0700
@@ -432,6 +432,8 @@
continue;
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
+ if (c == UNMAPPABLE_DECODING)
+ continue;
int hi = c >> 8;
if (c2b[hi] == C2B_UNMAPPABLE) {
c2b[hi] = new char[0x100];
--- a/jdk/src/java.base/share/classes/sun/security/ssl/EllipticCurvesExtension.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/EllipticCurvesExtension.java Fri Oct 14 11:11:19 2016 -0700
@@ -282,7 +282,7 @@
private static int getPreferredCurve(int[] curves,
AlgorithmConstraints constraints) {
for (int curveId : curves) {
- if (constraints.permits(
+ if (isSupported(curveId) && constraints.permits(
EnumSet.of(CryptoPrimitive.KEY_AGREEMENT),
"EC", idToParams.get(curveId))) {
return curveId;
--- a/jdk/src/java.base/share/classes/sun/security/ssl/HandshakeMessage.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/HandshakeMessage.java Fri Oct 14 11:11:19 2016 -0700
@@ -49,6 +49,7 @@
import sun.security.ssl.CipherSuite.*;
import static sun.security.ssl.CipherSuite.PRF.*;
import sun.security.util.KeyUtil;
+import sun.security.util.MessageDigestSpi2;
import sun.security.provider.certpath.OCSPResponse;
/**
@@ -2124,63 +2125,14 @@
md.update(temp);
}
- private static final Class<?> delegate;
- private static final Field spiField;
-
- static {
- try {
- delegate = Class.forName("java.security.MessageDigest$Delegate");
- spiField = delegate.getDeclaredField("digestSpi");
- } catch (Exception e) {
- throw new RuntimeException("Reflection failed", e);
- }
- makeAccessible(spiField);
- }
-
- private static void makeAccessible(final AccessibleObject o) {
- AccessController.doPrivileged(new PrivilegedAction<Object>() {
- @Override
- public Object run() {
- o.setAccessible(true);
- return null;
- }
- });
- }
-
- // ConcurrentHashMap does not allow null values, use this marker object
- private static final Object NULL_OBJECT = new Object();
-
- // cache Method objects per Spi class
- // Note that this will prevent the Spi classes from being GC'd. We assume
- // that is not a problem.
- private static final Map<Class<?>,Object> methodCache =
- new ConcurrentHashMap<>();
-
private static void digestKey(MessageDigest md, SecretKey key) {
try {
- // Verify that md is implemented via MessageDigestSpi, not
- // via JDK 1.1 style MessageDigest subclassing.
- if (md.getClass() != delegate) {
- throw new Exception("Digest is not a MessageDigestSpi");
- }
- MessageDigestSpi spi = (MessageDigestSpi)spiField.get(md);
- Class<?> clazz = spi.getClass();
- Object r = methodCache.get(clazz);
- if (r == null) {
- try {
- r = clazz.getDeclaredMethod("implUpdate", SecretKey.class);
- makeAccessible((Method)r);
- } catch (NoSuchMethodException e) {
- r = NULL_OBJECT;
- }
- methodCache.put(clazz, r);
- }
- if (r == NULL_OBJECT) {
+ if (md instanceof MessageDigestSpi2) {
+ ((MessageDigestSpi2)md).engineUpdate(key);
+ } else {
throw new Exception(
"Digest does not support implUpdate(SecretKey)");
}
- Method update = (Method)r;
- update.invoke(spi, key);
} catch (Exception e) {
throw new RuntimeException(
"Could not obtain encoded key and "
--- a/jdk/src/java.base/share/classes/sun/security/ssl/ServerHandshaker.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/ServerHandshaker.java Fri Oct 14 11:11:19 2016 -0700
@@ -1172,11 +1172,18 @@
if (trySetCipherSuite(suite) == false) {
continue;
}
+
+ if (debug != null && Debug.isOn("handshake")) {
+ System.out.println("Standard ciphersuite chosen: " + suite);
+ }
return;
}
for (CipherSuite suite : legacySuites) {
if (trySetCipherSuite(suite)) {
+ if (debug != null && Debug.isOn("handshake")) {
+ System.out.println("Legacy ciphersuite chosen: " + suite);
+ }
return;
}
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/sun/security/util/MessageDigestSpi2.java Fri Oct 14 11:11:19 2016 -0700
@@ -0,0 +1,44 @@
+/*
+ * 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 sun.security.util;
+
+import java.security.InvalidKeyException;
+import javax.crypto.SecretKey;
+
+/**
+ * Special interface for additional MessageDigestSpi method(s).
+ */
+public interface MessageDigestSpi2 {
+
+ /**
+ * Updates the digest using the specified key.
+ * This is used for SSL 3.0 only, we may deprecate and remove the support
+ * of this in the future
+ *
+ * @param key the key whose value is to be digested.
+ */
+ void engineUpdate(SecretKey key) throws InvalidKeyException;
+}
--- a/jdk/src/java.base/share/lib/security/default.policy Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/src/java.base/share/lib/security/default.policy Fri Oct 14 11:11:19 2016 -0700
@@ -91,7 +91,6 @@
};
grant codeBase "jrt:/jdk.charsets" {
- permission java.io.FilePermission "${java.home}/-", "read";
permission java.util.PropertyPermission "os.name", "read";
permission java.util.PropertyPermission "sun.nio.cs.map", "read";
permission java.lang.RuntimePermission "charsetProvider";
--- a/jdk/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/Base64.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/Base64.java Fri Oct 14 11:11:19 2016 -0700
@@ -376,14 +376,14 @@
return null;
}
- int lengthDataBits = binaryData.length * EIGHTBIT;
- if (lengthDataBits == 0) {
+ long lengthDataBits = ((long) binaryData.length) * ((long) EIGHTBIT);
+ if (lengthDataBits == 0L) {
return "";
}
- int fewerThan24bits = lengthDataBits % TWENTYFOURBITGROUP;
- int numberTriplets = lengthDataBits / TWENTYFOURBITGROUP;
- int numberQuartet = fewerThan24bits != 0 ? numberTriplets + 1 : numberTriplets;
+ long fewerThan24bits = lengthDataBits % TWENTYFOURBITGROUP;
+ int numberTriplets = (int) (lengthDataBits / TWENTYFOURBITGROUP);
+ int numberQuartet = fewerThan24bits != 0L ? numberTriplets + 1 : numberTriplets;
int quartesPerLine = length / 4;
int numberLines = (numberQuartet - 1) / quartesPerLine;
char encodedData[] = null;
--- a/jdk/src/jdk.crypto.pkcs11/share/classes/sun/security/pkcs11/P11Digest.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/src/jdk.crypto.pkcs11/share/classes/sun/security/pkcs11/P11Digest.java Fri Oct 14 11:11:19 2016 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -34,6 +34,8 @@
import sun.nio.ch.DirectBuffer;
+import sun.security.util.MessageDigestSpi2;
+
import sun.security.pkcs11.wrapper.*;
import static sun.security.pkcs11.wrapper.PKCS11Constants.*;
@@ -49,7 +51,8 @@
* @author Andreas Sterbenz
* @since 1.5
*/
-final class P11Digest extends MessageDigestSpi implements Cloneable {
+final class P11Digest extends MessageDigestSpi implements Cloneable,
+ MessageDigestSpi2 {
/* fields initialized, no session acquired */
private final static int S_BLANK = 1;
@@ -233,10 +236,11 @@
}
// Called by SunJSSE via reflection during the SSL 3.0 handshake if
- // the master secret is sensitive. We may want to consider making this
- // method public in a future release.
- protected void implUpdate(SecretKey key) throws InvalidKeyException {
-
+ // the master secret is sensitive.
+ // Note: Change to protected after this method is moved from
+ // sun.security.util.MessageSpi2 interface to
+ // java.security.MessageDigestSpi class
+ public void engineUpdate(SecretKey key) throws InvalidKeyException {
// SunJSSE calls this method only if the key does not have a RAW
// encoding, i.e. if it is sensitive. Therefore, no point in calling
// SecretKeyFactory to try to convert it. Just verify it ourselves.
--- a/jdk/src/jdk.internal.le/share/classes/jdk/internal/jline/console/ConsoleReader.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/src/jdk.internal.le/share/classes/jdk/internal/jline/console/ConsoleReader.java Fri Oct 14 11:11:19 2016 -0700
@@ -2339,7 +2339,7 @@
Stack<Character> pushBackChar = new Stack<Character>();
- if (terminal.isAnsiSupported()) {
+ if (terminal.isAnsiSupported() && System.console() != null) {
//detect the prompt length by reading the cursor position from the terminal
//the real prompt length could differ from the simple prompt length due to
//use of escape sequences:
--- a/jdk/src/jdk.jartool/share/classes/module-info.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/src/jdk.jartool/share/classes/module-info.java Fri Oct 14 11:11:19 2016 -0700
@@ -26,5 +26,7 @@
module jdk.jartool {
exports com.sun.jarsigner;
exports jdk.security.jarsigner;
+
+ provides java.util.spi.ToolProvider with sun.tools.jar.JarToolProvider;
}
--- a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/GNUStyleOptions.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/GNUStyleOptions.java Fri Oct 14 11:11:19 2016 -0700
@@ -27,6 +27,7 @@
import java.io.File;
import java.io.PrintStream;
+import java.io.PrintWriter;
import java.lang.module.ModuleFinder;
import java.lang.module.ModuleDescriptor.Version;
import java.nio.file.Path;
@@ -253,7 +254,8 @@
// process options
for (; count < args.length; count++) {
- if (args[count].charAt(0) != '-' || args[count].equals("-C"))
+ if (args[count].charAt(0) != '-' || args[count].equals("-C")
+ || args[count].equals("--release"))
break;
String name = args[count];
@@ -289,7 +291,7 @@
throw new BadArgs("error.unrecognized.option", name).showUsage(true);
}
- static void printHelp(PrintStream out) {
+ static void printHelp(PrintWriter out) {
out.format("%s%n", Main.getMsg("main.help.preopt"));
for (OptionType type : OptionType.values()) {
boolean typeHeadingWritten = false;
@@ -312,16 +314,16 @@
out.format("%n%s%n%n", Main.getMsg("main.help.postopt"));
}
- static void printCompatHelp(PrintStream out) {
+ static void printCompatHelp(PrintWriter out) {
out.format("%s%n", Main.getMsg("usage.compat"));
}
- static void printUsageSummary(PrintStream out) {
+ static void printUsageSummary(PrintWriter out) {
out.format("%s%n", Main.getMsg("main.usage.summary"));
out.format("%s%n", Main.getMsg("main.usage.summary.try"));
}
- static void printVersion(PrintStream out) {
+ static void printVersion(PrintWriter out) {
out.format("%s %s%n", "jar", System.getProperty("java.version"));
}
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/JarToolProvider.java Fri Oct 14 11:11:19 2016 -0700
@@ -0,0 +1,40 @@
+/*
+ * 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 sun.tools.jar;
+
+import java.io.PrintWriter;
+import java.util.spi.ToolProvider;
+
+public class JarToolProvider implements ToolProvider {
+ public String name() {
+ return "jar";
+ }
+
+ public int run(PrintWriter out, PrintWriter err, String... args) {
+ boolean ok = new Main(out, err, name()).run(args);
+ return ok ? 0 : 1;
+ }
+}
--- a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/Main.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/Main.java Fri Oct 14 11:11:19 2016 -0700
@@ -76,7 +76,7 @@
public
class Main {
String program;
- PrintStream out, err;
+ PrintWriter out, err;
String fname, mname, ename;
String zname = "";
String rootjar = null;
@@ -189,9 +189,9 @@
USAGE_SUMMARY(GNUStyleOptions::printUsageSummary),
VERSION(GNUStyleOptions::printVersion);
- private Consumer<PrintStream> printFunction;
- Info(Consumer<PrintStream> f) { this.printFunction = f; }
- void print(PrintStream out) { printFunction.accept(out); }
+ private Consumer<PrintWriter> printFunction;
+ Info(Consumer<PrintWriter> f) { this.printFunction = f; }
+ void print(PrintWriter out) { printFunction.accept(out); }
};
Info info;
@@ -252,6 +252,12 @@
}
public Main(PrintStream out, PrintStream err, String program) {
+ this.out = new PrintWriter(out, true);
+ this.err = new PrintWriter(err, true);
+ this.program = program;
+ }
+
+ public Main(PrintWriter out, PrintWriter err, String program) {
this.out = out;
this.err = err;
this.program = program;
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JlinkTask.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JlinkTask.java Fri Oct 14 11:11:19 2016 -0700
@@ -153,7 +153,7 @@
= taskHelper.newOptionsHelper(JlinkTask.class, recognizedOptions);
private PrintWriter log;
- void setLog(PrintWriter out) {
+ void setLog(PrintWriter out, PrintWriter err) {
log = out;
taskHelper.setLog(log);
}
@@ -182,7 +182,8 @@
int run(String[] args) {
if (log == null) {
- setLog(new PrintWriter(System.out, true));
+ setLog(new PrintWriter(System.out, true),
+ new PrintWriter(System.err, true));
}
try {
optionsHelper.handleOptions(this, args);
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Main.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Main.java Fri Oct 14 11:11:19 2016 -0700
@@ -26,6 +26,7 @@
package jdk.tools.jlink.internal;
import java.io.*;
+import java.util.spi.ToolProvider;
public class Main {
public static void main(String... args) throws Exception {
@@ -34,17 +35,27 @@
System.exit(rc);
}
-
/**
* Entry point that does <i>not</i> call System.exit.
*
+ * @param out output stream
+ * @param err error output stream
* @param args command line arguments
- * @param out output stream
* @return an exit code. 0 means success, non-zero means an error occurred.
*/
- public static int run(String[] args, PrintWriter out) {
+ public static int run(PrintWriter out, PrintWriter err, String... args) {
JlinkTask t = new JlinkTask();
- t.setLog(out);
+ t.setLog(out, err);
return t.run(args);
}
+
+ public static class JlinkToolProvider implements ToolProvider {
+ public String name() {
+ return "jlink";
+ }
+
+ public int run(PrintWriter out, PrintWriter err, String... args) {
+ return Main.run(out, err, args);
+ }
+ }
}
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/JmodTask.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/JmodTask.java Fri Oct 14 11:11:19 2016 -0700
@@ -32,6 +32,7 @@
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
+import java.io.PrintWriter;
import java.io.UncheckedIOException;
import java.lang.module.Configuration;
import java.lang.module.ModuleReader;
@@ -136,8 +137,8 @@
private static final String MODULE_INFO = "module-info.class";
private Options options;
- private PrintStream out = System.out;
- void setLog(PrintStream out) {
+ private PrintWriter out = new PrintWriter(System.out, true);
+ void setLog(PrintWriter out, PrintWriter err) {
this.out = out;
}
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/Main.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/Main.java Fri Oct 14 11:11:19 2016 -0700
@@ -26,6 +26,7 @@
package jdk.tools.jmod;
import java.io.*;
+import java.util.spi.ToolProvider;
public class Main {
public static void main(String... args) throws Exception {
@@ -37,13 +38,24 @@
/**
* Entry point that does <i>not</i> call System.exit.
*
+ * @param out output stream
+ * @param err error output stream
* @param args command line arguments
- * @param out output stream
* @return an exit code. 0 means success, non-zero means an error occurred.
*/
- public static int run(String[] args, PrintStream out) {
+ public static int run(PrintWriter out, PrintWriter err, String... args) {
JmodTask t = new JmodTask();
- t.setLog(out);
+ t.setLog(out, err);
return t.run(args);
}
+
+ public static class JmodToolProvider implements ToolProvider {
+ public String name() {
+ return "jmod";
+ }
+
+ public int run(PrintWriter out, PrintWriter err, String... args) {
+ return Main.run(out, err, args);
+ }
+ }
}
--- a/jdk/src/jdk.jlink/share/classes/module-info.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/src/jdk.jlink/share/classes/module-info.java Fri Oct 14 11:11:19 2016 -0700
@@ -31,6 +31,9 @@
uses jdk.tools.jlink.plugin.Plugin;
+ provides java.util.spi.ToolProvider with jdk.tools.jmod.Main.JmodToolProvider;
+ provides java.util.spi.ToolProvider with jdk.tools.jlink.internal.Main.JlinkToolProvider;
+
provides jdk.tools.jlink.plugin.Plugin with jdk.tools.jlink.internal.plugins.FileCopierPlugin;
provides jdk.tools.jlink.plugin.Plugin with jdk.tools.jlink.internal.plugins.StripDebugPlugin;
provides jdk.tools.jlink.plugin.Plugin with jdk.tools.jlink.internal.plugins.ExcludePlugin;
--- a/jdk/test/java/lang/module/ModuleReader/ModuleReaderTest.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/test/java/lang/module/ModuleReader/ModuleReaderTest.java Fri Oct 14 11:11:19 2016 -0700
@@ -25,8 +25,8 @@
* @test
* @library /lib/testlibrary
* @modules java.base/jdk.internal.module
- * jdk.jlink/jdk.tools.jmod
* jdk.compiler
+ * jdk.jlink
* @build ModuleReaderTest CompilerUtils JarUtils
* @run testng ModuleReaderTest
* @summary Basic tests for java.lang.module.ModuleReader
@@ -48,6 +48,7 @@
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Optional;
+import java.util.spi.ToolProvider;
import jdk.internal.module.ConfigurableModuleFinder;
import jdk.internal.module.ConfigurableModuleFinder.Phase;
@@ -196,8 +197,11 @@
String cp = MODS_DIR.resolve(TEST_MODULE).toString();
String jmod = dir.resolve("m.jmod").toString();
String[] args = { "create", "--class-path", cp, jmod };
- jdk.tools.jmod.JmodTask task = new jdk.tools.jmod.JmodTask();
- assertEquals(task.run(args), 0);
+ ToolProvider jmodTool = ToolProvider.findFirst("jmod")
+ .orElseThrow(() ->
+ new RuntimeException("jmod tool not found")
+ );
+ assertEquals(jmodTool.run(System.out, System.out, args), 0);
test(dir);
}
--- a/jdk/test/java/security/KeyStore/TestKeyStoreBasic.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/test/java/security/KeyStore/TestKeyStoreBasic.java Fri Oct 14 11:11:19 2016 -0700
@@ -40,7 +40,7 @@
/*
* @test
- * @bug 8048621 8133090
+ * @bug 8048621 8133090 8167371
* @summary Test basic operations with keystores (jks, jceks, pkcs12)
* @author Yu-Ching Valerie PENG
*/
@@ -116,6 +116,8 @@
};
private static final String ALIAS_HEAD = "test";
+ private static final String CRYPTO_ALG = "PBEWithHmacSHA256AndAES_128";
+
public static void main(String args[]) throws Exception {
TestKeyStoreBasic jstest = new TestKeyStoreBasic();
jstest.run();
@@ -125,7 +127,7 @@
for (String provider : PROVIDERS) {
try {
runTest(provider);
- System.out.println("Test with provider " + provider + "passed");
+ System.out.println("Test with provider " + provider + " passed");
} catch (java.security.KeyStoreException e) {
if (provider.equals("SunPKCS11-Solaris")) {
System.out.println("KeyStoreException is expected: "
@@ -236,6 +238,44 @@
// compare the creation date of the 2 key stores for all aliases
compareCreationDate(ks, ks2, numEntries);
+ // check setEntry/getEntry with a password protection algorithm
+ if ("PKCS12".equalsIgnoreCase(ks.getType())) {
+ System.out.println(
+ "Skipping the setEntry/getEntry check for PKCS12 keystore...");
+ return;
+ }
+ String alias = ALIAS_HEAD + ALIAS_HEAD;
+ KeyStore.PasswordProtection pw =
+ new KeyStore.PasswordProtection(PASSWD2, CRYPTO_ALG, null);
+ KeyStore.PrivateKeyEntry entry =
+ new KeyStore.PrivateKeyEntry(privateKey, new Certificate[]{ cert });
+ checkSetEntry(ks, alias, pw, entry);
+ ks.setEntry(alias, entry, new KeyStore.PasswordProtection(PASSWD2));
+ checkGetEntry(ks, alias, pw);
+ }
+
+ // check setEntry with a password protection algorithm
+ private void checkSetEntry(KeyStore ks, String alias,
+ KeyStore.PasswordProtection pw, KeyStore.Entry entry) throws Exception {
+ try {
+ ks.setEntry(alias, entry, pw);
+ throw new Exception(
+ "ERROR: expected KeyStore.setEntry to throw an exception");
+ } catch (KeyStoreException e) {
+ // ignore the expected exception
+ }
+ }
+
+ // check getEntry with a password protection algorithm
+ private void checkGetEntry(KeyStore ks, String alias,
+ KeyStore.PasswordProtection pw) throws Exception {
+ try {
+ ks.getEntry(alias, pw);
+ throw new Exception(
+ "ERROR: expected KeyStore.getEntry to throw an exception");
+ } catch (KeyStoreException e) {
+ // ignore the expected exception
+ }
}
// check key store type
--- a/jdk/test/java/util/concurrent/tck/AtomicBoolean9Test.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/test/java/util/concurrent/tck/AtomicBoolean9Test.java Fri Oct 14 11:11:19 2016 -0700
@@ -162,6 +162,19 @@
}
/**
+ * repeated weakCompareAndSetPlain succeeds in changing value when equal
+ * to expected
+ */
+ public void testWeakCompareAndSetPlain() {
+ AtomicBoolean ai = new AtomicBoolean(true);
+ do {} while (!ai.weakCompareAndSetPlain(true, false));
+ do {} while (!ai.weakCompareAndSetPlain(false, false));
+ assertFalse(ai.get());
+ do {} while (!ai.weakCompareAndSetPlain(false, true));
+ assertTrue(ai.get());
+ }
+
+ /**
* repeated weakCompareAndSetVolatile succeeds in changing value when equal
* to expected
*/
--- a/jdk/test/java/util/concurrent/tck/AtomicInteger9Test.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/test/java/util/concurrent/tck/AtomicInteger9Test.java Fri Oct 14 11:11:19 2016 -0700
@@ -162,6 +162,19 @@
}
/**
+ * repeated weakCompareAndSetPlain succeeds in changing value when equal
+ * to expected
+ */
+ public void testWeakCompareAndSetPlain() {
+ AtomicInteger ai = new AtomicInteger(1);
+ do {} while (!ai.weakCompareAndSetPlain(1, 2));
+ do {} while (!ai.weakCompareAndSetPlain(2, -4));
+ assertEquals(-4, ai.get());
+ do {} while (!ai.weakCompareAndSetPlain(-4, 7));
+ assertEquals(7, ai.get());
+ }
+
+ /**
* repeated weakCompareAndSetVolatile succeeds in changing value when equal
* to expected
*/
--- a/jdk/test/java/util/concurrent/tck/AtomicIntegerArray9Test.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/test/java/util/concurrent/tck/AtomicIntegerArray9Test.java Fri Oct 14 11:11:19 2016 -0700
@@ -62,6 +62,7 @@
() -> aa.compareAndExchange(j, 1, 2),
() -> aa.compareAndExchangeAcquire(j, 1, 2),
() -> aa.compareAndExchangeRelease(j, 1, 2),
+ () -> aa.weakCompareAndSetPlain(j, 1, 2),
() -> aa.weakCompareAndSetVolatile(j, 1, 2),
() -> aa.weakCompareAndSetAcquire(j, 1, 2),
() -> aa.weakCompareAndSetRelease(j, 1, 2),
@@ -216,6 +217,22 @@
}
/**
+ * repeated weakCompareAndSetPlain succeeds in changing value when equal
+ * to expected
+ */
+ public void testWeakCompareAndSetPlain() {
+ AtomicIntegerArray aa = new AtomicIntegerArray(SIZE);
+ for (int i = 0; i < SIZE; i++) {
+ aa.set(i, 1);
+ do {} while (!aa.weakCompareAndSetPlain(i, 1, 2));
+ do {} while (!aa.weakCompareAndSetPlain(i, 2, -4));
+ assertEquals(-4, aa.get(i));
+ do {} while (!aa.weakCompareAndSetPlain(i, -4, 7));
+ assertEquals(7, aa.get(i));
+ }
+ }
+
+ /**
* repeated weakCompareAndSetVolatile succeeds in changing value when equal
* to expected
*/
--- a/jdk/test/java/util/concurrent/tck/AtomicLong9Test.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/test/java/util/concurrent/tck/AtomicLong9Test.java Fri Oct 14 11:11:19 2016 -0700
@@ -162,6 +162,19 @@
}
/**
+ * repeated weakCompareAndSetPlain succeeds in changing value when equal
+ * to expected
+ */
+ public void testWeakCompareAndSetPlain() {
+ AtomicLong ai = new AtomicLong(1);
+ do {} while (!ai.weakCompareAndSetPlain(1, 2));
+ do {} while (!ai.weakCompareAndSetPlain(2, -4));
+ assertEquals(-4, ai.get());
+ do {} while (!ai.weakCompareAndSetPlain(-4, 7));
+ assertEquals(7, ai.get());
+ }
+
+ /**
* repeated weakCompareAndSetVolatile succeeds in changing value when equal
* to expected
*/
--- a/jdk/test/java/util/concurrent/tck/AtomicLongArray9Test.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/test/java/util/concurrent/tck/AtomicLongArray9Test.java Fri Oct 14 11:11:19 2016 -0700
@@ -61,6 +61,7 @@
() -> aa.compareAndExchange(j, 1, 2),
() -> aa.compareAndExchangeAcquire(j, 1, 2),
() -> aa.compareAndExchangeRelease(j, 1, 2),
+ () -> aa.weakCompareAndSetPlain(j, 1, 2),
() -> aa.weakCompareAndSetVolatile(j, 1, 2),
() -> aa.weakCompareAndSetAcquire(j, 1, 2),
() -> aa.weakCompareAndSetRelease(j, 1, 2),
@@ -215,6 +216,22 @@
}
/**
+ * repeated weakCompareAndSetPlain succeeds in changing value when equal
+ * to expected
+ */
+ public void testWeakCompareAndSetPlain() {
+ AtomicLongArray aa = new AtomicLongArray(SIZE);
+ for (int i = 0; i < SIZE; i++) {
+ aa.set(i, 1);
+ do {} while (!aa.weakCompareAndSetPlain(i, 1, 2));
+ do {} while (!aa.weakCompareAndSetPlain(i, 2, -4));
+ assertEquals(-4, aa.get(i));
+ do {} while (!aa.weakCompareAndSetPlain(i, -4, 7));
+ assertEquals(7, aa.get(i));
+ }
+ }
+
+ /**
* repeated weakCompareAndSetVolatile succeeds in changing value when equal
* to expected
*/
--- a/jdk/test/java/util/concurrent/tck/AtomicReference9Test.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/test/java/util/concurrent/tck/AtomicReference9Test.java Fri Oct 14 11:11:19 2016 -0700
@@ -162,6 +162,19 @@
}
/**
+ * repeated weakCompareAndSetPlain succeeds in changing value when equal
+ * to expected
+ */
+ public void testWeakCompareAndSetPlain() {
+ AtomicReference<Integer> ai = new AtomicReference<>(one);
+ do {} while (!ai.weakCompareAndSetPlain(one, two));
+ do {} while (!ai.weakCompareAndSetPlain(two, m4));
+ assertEquals(m4, ai.get());
+ do {} while (!ai.weakCompareAndSetPlain(m4, seven));
+ assertEquals(seven, ai.get());
+ }
+
+ /**
* repeated weakCompareAndSetVolatile succeeds in changing value when equal
* to expected
*/
--- a/jdk/test/java/util/concurrent/tck/AtomicReferenceArray9Test.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/test/java/util/concurrent/tck/AtomicReferenceArray9Test.java Fri Oct 14 11:11:19 2016 -0700
@@ -61,6 +61,7 @@
() -> aa.compareAndExchange(j, null, null),
() -> aa.compareAndExchangeAcquire(j, null, null),
() -> aa.compareAndExchangeRelease(j, null, null),
+ () -> aa.weakCompareAndSetPlain(j, null, null),
() -> aa.weakCompareAndSetVolatile(j, null, null),
() -> aa.weakCompareAndSetAcquire(j, null, null),
() -> aa.weakCompareAndSetRelease(j, null, null),
@@ -215,6 +216,22 @@
}
/**
+ * repeated weakCompareAndSetPlain succeeds in changing value when equal
+ * to expected
+ */
+ public void testWeakCompareAndSetPlain() {
+ AtomicReferenceArray<Integer> aa = new AtomicReferenceArray<>(SIZE);
+ for (int i = 0; i < SIZE; i++) {
+ aa.set(i, one);
+ do {} while (!aa.weakCompareAndSetPlain(i, one, two));
+ do {} while (!aa.weakCompareAndSetPlain(i, two, m4));
+ assertEquals(m4, aa.get(i));
+ do {} while (!aa.weakCompareAndSetPlain(i, m4, seven));
+ assertEquals(seven, aa.get(i));
+ }
+ }
+
+ /**
* repeated weakCompareAndSetVolatile succeeds in changing value when equal
* to expected
*/
--- a/jdk/test/jdk/internal/util/jar/TestVersionedStream.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/test/jdk/internal/util/jar/TestVersionedStream.java Fri Oct 14 11:11:19 2016 -0700
@@ -25,13 +25,14 @@
* @test
* @bug 8163798
* @summary basic tests for multi-release jar versioned streams
+ * @library /lib/testlibrary
* @modules jdk.jartool/sun.tools.jar java.base/jdk.internal.util.jar
+ * @build jdk.testlibrary.FileUtils
* @run testng TestVersionedStream
*/
import org.testng.Assert;
import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
@@ -40,29 +41,31 @@
import java.io.InputStream;
import java.io.UncheckedIOException;
import java.net.URI;
-import java.nio.file.FileVisitResult;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
-import java.nio.file.SimpleFileVisitor;
-import java.nio.file.attribute.BasicFileAttributes;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import java.util.zip.ZipFile;
-public class TestVersionedStream {
- private String userdir;
+import jdk.testlibrary.FileUtils;
- @BeforeClass
- public void initialize() {
- userdir = System.getProperty("user.dir", ".");
+public class TestVersionedStream {
+ private final Path userdir;
+ private final Set<String> unversionedEntryNames;
+
+ public TestVersionedStream() throws IOException {
+ userdir = Paths.get(System.getProperty("user.dir", "."));
// These are not real class files even though they end with .class.
// They are resource files so jar tool validation won't reject them.
@@ -70,91 +73,103 @@
// could be in a concealed package if this was a modular multi-release
// jar.
createFiles(
+ "base/p/Bar.class",
"base/p/Foo.class",
"base/p/Main.class",
"v9/p/Foo.class",
"v10/p/Foo.class",
"v10/q/Bar.class",
+ "v11/p/Bar.class",
"v11/p/Foo.class"
);
- jar("cf mmr.jar -C base . --release 9 -C v9 . --release 10 -C v10 . --release 11 -C v11 .");
+ jar("cf mmr.jar -C base . --release 9 -C v9 . " +
+ "--release 10 -C v10 . --release 11 -C v11 .");
System.out.println("Contents of mmr.jar\n=======");
- jar("tf mmr.jar");
+
+ try(JarFile jf = new JarFile("mmr.jar")) {
+ unversionedEntryNames = jf.stream()
+ .map(je -> je.getName())
+ .peek(System.out::println)
+ .map(nm -> nm.startsWith("META-INF/versions/")
+ ? nm.replaceFirst("META-INF/versions/\\d+/", "")
+ : nm)
+ .collect(Collectors.toCollection(LinkedHashSet::new));
+ }
+
System.out.println("=======");
}
@AfterClass
public void close() throws IOException {
- Path root = Paths.get(userdir);
- Files.walkFileTree(root, new SimpleFileVisitor<>() {
- @Override
- public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
- Files.delete(file);
- return FileVisitResult.CONTINUE;
- }
-
- @Override
- public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
- if (!dir.equals(root)) {
- Files.delete(dir);
- }
- return FileVisitResult.CONTINUE;
- }
- });
+ 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);
+ }
+ });
}
@DataProvider
public Object[][] data() {
- List<String> p = List.of(
- "META-INF/",
- "META-INF/MANIFEST.MF",
- "p/",
- "p/Foo.class",
- "p/Main.class"
- );
- List<String> q = List.of(
- "META-INF/",
- "META-INF/MANIFEST.MF",
- "p/",
- "p/Foo.class",
- "p/Main.class",
- "q/",
- "q/Bar.class"
- );
- Runtime.Version rt = JarFile.runtimeVersion();
return new Object[][] {
- {Runtime.Version.parse("8"), p},
- {Runtime.Version.parse("9"), p},
- {Runtime.Version.parse("10"), q},
- {Runtime.Version.parse("11"), q},
- {JarFile.baseVersion(), p},
- {rt, rt.major() > 9 ? q : p}
+ {Runtime.Version.parse("8")},
+ {Runtime.Version.parse("9")},
+ {Runtime.Version.parse("10")},
+ {Runtime.Version.parse("11")},
+ {JarFile.baseVersion()},
+ {JarFile.runtimeVersion()}
};
}
@Test(dataProvider="data")
- public void test(Runtime.Version version, List<String> names) throws Exception {
+ public void test(Runtime.Version version) throws Exception {
try (JarFile jf = new JarFile(new File("mmr.jar"), false, ZipFile.OPEN_READ, version);
- Stream<JarEntry> jes = jdk.internal.util.jar.VersionedStream.stream(jf))
+ Stream<JarEntry> jes = jdk.internal.util.jar.VersionedStream.stream(jf))
{
Assert.assertNotNull(jes);
- List<JarEntry> entries = jes.collect(Collectors.toList());
+ // put versioned entries in list so we can reuse them
+ List<JarEntry> versionedEntries = jes.collect(Collectors.toList());
+
+ Assert.assertTrue(versionedEntries.size() > 0);
+
+ // also keep the names
+ List<String> versionedNames = new ArrayList<>(versionedEntries.size());
+
+ // verify the correct order while building enames
+ Iterator<String> allIt = unversionedEntryNames.iterator();
+ Iterator<JarEntry> verIt = versionedEntries.iterator();
+ boolean match = false;
- // verify the correct order
- List<String> enames = entries.stream()
- .map(je -> je.getName())
- .collect(Collectors.toList());
- Assert.assertEquals(enames, names);
+ while (verIt.hasNext()) {
+ match = false;
+ if (!allIt.hasNext()) break;
+ String name = verIt.next().getName();
+ versionedNames.add(name);
+ while (allIt.hasNext()) {
+ if (name.equals(allIt.next())) {
+ match = true;
+ break;
+ }
+ }
+ }
+ if (!match) {
+ Assert.fail("versioned entries not in same order as unversioned entries");
+ }
// verify the contents
Map<String,String> contents = new HashMap<>();
+ contents.put("p/Bar.class", "base/p/Bar.class\n");
contents.put("p/Main.class", "base/p/Main.class\n");
- if (version.major() > 9) {
- contents.put("q/Bar.class", "v10/q/Bar.class\n");
- }
switch (version.major()) {
case 8:
contents.put("p/Foo.class", "base/p/Foo.class\n");
@@ -164,9 +179,12 @@
break;
case 10:
contents.put("p/Foo.class", "v10/p/Foo.class\n");
+ contents.put("q/Bar.class", "v10/q/Bar.class\n");
break;
case 11:
+ contents.put("p/Bar.class", "v11/p/Bar.class\n");
contents.put("p/Foo.class", "v11/p/Foo.class\n");
+ contents.put("q/Bar.class", "v10/q/Bar.class\n");
break;
default:
Assert.fail("Test out of date, please add more cases");
@@ -174,9 +192,9 @@
contents.entrySet().stream().forEach(e -> {
String name = e.getKey();
- int i = enames.indexOf(name);
+ int i = versionedNames.indexOf(name);
Assert.assertTrue(i != -1, name + " not in enames");
- JarEntry je = entries.get(i);
+ JarEntry je = versionedEntries.get(i);
try (InputStream is = jf.getInputStream(je)) {
String s = new String(is.readAllBytes());
Assert.assertTrue(s.endsWith(e.getValue()), s);
@@ -210,5 +228,4 @@
new sun.tools.jar.Main(System.out, System.err, "jar")
.run(args.split(" +"));
}
-
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/nio/cs/TestHKSCS.java Fri Oct 14 11:11:19 2016 -0700
@@ -0,0 +1,49 @@
+/*
+ * 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 8166258
+ * @summary Some corner cases for hkscs charsets
+ * @modules jdk.charsets
+ * @run main TestHKSCS
+ */
+
+import java.util.Arrays;
+
+public class TestHKSCS {
+ public static void main(String args[]) throws Exception {
+ String[] charsets = { "x-MS950-HKSCS-XP",
+ "x-MS950-HKSCS",
+ "Big5-HKSCS",
+ "x-Big5-HKSCS-2001"
+ };
+ String s = "\ufffd\ud87f\udffd";
+ byte[] bytes = new byte[] { 0x3f, 0x3f };
+ for (String cs : charsets) {
+ if (!Arrays.equals(bytes, s.getBytes(cs))) {
+ throw new RuntimeException(cs + " failed to decode u+fffd");
+ }
+ }
+ }
+}
--- a/jdk/test/sun/security/pkcs11/PKCS11Test.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/test/sun/security/pkcs11/PKCS11Test.java Fri Oct 14 11:11:19 2016 -0700
@@ -299,11 +299,12 @@
+ props.getProperty("os.arch") + "-" + props.getProperty("sun.arch.data.model");
String[] nssLibDirs = osMap.get(osid);
if (nssLibDirs == null) {
- System.out.println("Unsupported OS, skipping: " + osid);
+ System.out.println("Warning: unsupported OS: " + osid
+ + ", please initialize NSS librarys location firstly, skipping test");
return null;
}
if (nssLibDirs.length == 0) {
- System.out.println("NSS not supported on this platform, skipping test");
+ System.out.println("Warning: NSS not supported on this platform, skipping test");
return null;
}
String nssLibDir = null;
@@ -315,6 +316,10 @@
break;
}
}
+ if (nssLibDir == null) {
+ System.out.println("Warning: can't find NSS librarys on this machine, skipping test");
+ return null;
+ }
return nssLibDir;
}
@@ -624,6 +629,11 @@
PKCS11_BASE + "/nss/lib/windows-amd64/".replace('/', SEP)});
osMap.put("MacOSX-x86_64-64", new String[]{
PKCS11_BASE + "/nss/lib/macosx-x86_64/"});
+ osMap.put("Linux-arm-32", new String[]{
+ "/usr/lib/arm-linux-gnueabi/nss/",
+ "/usr/lib/arm-linux-gnueabihf/nss/"});
+ osMap.put("Linux-aarch64-64", new String[]{
+ "/usr/lib/aarch64-linux-gnu/nss/"});
}
private final static char[] hexDigits = "0123456789abcdef".toCharArray();
--- a/jdk/test/sun/tools/jrunscript/jrunscript-DTest.sh Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/test/sun/tools/jrunscript/jrunscript-DTest.sh Fri Oct 14 11:11:19 2016 -0700
@@ -33,7 +33,7 @@
. ${TESTSRC-.}/common.sh
setup
-${JAVA} -cp ${TESTCLASSES} CheckEngine
+${JAVA} ${TESTVMOPTS} ${TESTJAVAOPTS} -cp ${TESTCLASSES} CheckEngine
if [ $? -eq 2 ]; then
echo "No js engine found and engine not required; test vacuously passes."
exit 0
--- a/jdk/test/sun/tools/jrunscript/jrunscript-argsTest.sh Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/test/sun/tools/jrunscript/jrunscript-argsTest.sh Fri Oct 14 11:11:19 2016 -0700
@@ -33,7 +33,7 @@
. ${TESTSRC-.}/common.sh
setup
-${JAVA} -cp ${TESTCLASSES} CheckEngine
+${JAVA} ${TESTVMOPTS} ${TESTJAVAOPTS} -cp ${TESTCLASSES} CheckEngine
if [ $? -eq 2 ]; then
echo "No js engine found and engine not required; test vacuously passes."
exit 0
--- a/jdk/test/sun/tools/jrunscript/jrunscript-cpTest.sh Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/test/sun/tools/jrunscript/jrunscript-cpTest.sh Fri Oct 14 11:11:19 2016 -0700
@@ -33,14 +33,14 @@
. ${TESTSRC-.}/common.sh
setup
-${JAVA} -cp ${TESTCLASSES} CheckEngine
+${JAVA} ${TESTVMOPTS} ${TESTJAVAOPTS} -cp ${TESTCLASSES} CheckEngine
if [ $? -eq 2 ]; then
echo "No js engine found and engine not required; test vacuously passes."
exit 0
fi
rm -f Hello.class
-${JAVAC} ${TESTSRC}/Hello.java -d .
+${JAVAC} ${TESTTOOLVMOPTS} ${TESTJAVACOPTS} ${TESTSRC}/Hello.java -d .
# we check whether classpath setting for app classes
# work with jrunscript. Script should be able to
--- a/jdk/test/sun/tools/jrunscript/jrunscript-eTest.sh Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/test/sun/tools/jrunscript/jrunscript-eTest.sh Fri Oct 14 11:11:19 2016 -0700
@@ -33,7 +33,7 @@
. ${TESTSRC-.}/common.sh
setup
-${JAVA} -cp ${TESTCLASSES} CheckEngine
+${JAVA} ${TESTVMOPTS} ${TESTJAVAOPTS} -cp ${TESTCLASSES} CheckEngine
if [ $? -eq 2 ]; then
echo "No js engine found and engine not required; test vacuously passes."
exit 0
--- a/jdk/test/sun/tools/jrunscript/jrunscript-fTest.sh Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/test/sun/tools/jrunscript/jrunscript-fTest.sh Fri Oct 14 11:11:19 2016 -0700
@@ -33,7 +33,7 @@
. ${TESTSRC-.}/common.sh
setup
-${JAVA} -cp ${TESTCLASSES} CheckEngine
+${JAVA} ${TESTVMOPTS} ${TESTJAVAOPTS} -cp ${TESTCLASSES} CheckEngine
if [ $? -eq 2 ]; then
echo "No js engine found and engine not required; test vacuously passes."
exit 0
--- a/jdk/test/sun/tools/jrunscript/jrunscriptTest.sh Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/test/sun/tools/jrunscript/jrunscriptTest.sh Fri Oct 14 11:11:19 2016 -0700
@@ -33,7 +33,7 @@
. ${TESTSRC-.}/common.sh
setup
-${JAVA} -cp ${TESTCLASSES} CheckEngine
+${JAVA} ${TESTVMOPTS} ${TESTJAVAOPTS} -cp ${TESTCLASSES} CheckEngine
if [ $? -eq 2 ]; then
echo "No js engine found and engine not required; test vacuously passes."
exit 0
--- a/jdk/test/tools/jar/ChangeDir.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/test/tools/jar/ChangeDir.java Fri Oct 14 11:11:19 2016 -0700
@@ -24,7 +24,7 @@
/**
* @test
* @bug 4806786 8023113
- * @modules jdk.jartool/sun.tools.jar
+ * @modules jdk.jartool
* @summary jar -C doesn't ignore multiple // in path
*/
@@ -32,10 +32,15 @@
import java.nio.file.*;
import java.util.*;
import java.util.jar.*;
+import java.util.spi.ToolProvider;
import java.util.stream.Stream;
-import sun.tools.jar.Main;
public class ChangeDir {
+ private static final ToolProvider JAR_TOOL = ToolProvider.findFirst("jar")
+ .orElseThrow(() ->
+ new RuntimeException("jar tool not found")
+ );
+
private final static String jarName = "test.jar";
private final static String fileName = "hello.txt";
@@ -88,8 +93,9 @@
argList.add(topDir.toString() + sep + "a" + sep + sep + "b"); // Note double 'sep' is intentional
argList.add(fileName);
- Main jarTool = new Main(System.out, System.err, "jar");
- if (!jarTool.run(argList.toArray(new String[argList.size()]))) {
+ int rc = JAR_TOOL.run(System.out, System.err,
+ argList.toArray(new String[argList.size()]));
+ if (rc != 0) {
fail("Could not create jar file.");
}
--- a/jdk/test/tools/jar/InputFilesTest.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/test/tools/jar/InputFilesTest.java Fri Oct 14 11:11:19 2016 -0700
@@ -29,7 +29,7 @@
* duplicates that sometimes cause exceptions and other times do not,
* demonstrating identical behavior to JDK 8 jar tool.
* @library /lib/testlibrary
- * @modules jdk.jartool/sun.tools.jar
+ * @modules jdk.jartool
* @build jdk.testlibrary.FileUtils
* @run testng InputFilesTest
*/
@@ -47,12 +47,18 @@
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
+import java.util.spi.ToolProvider;
import java.util.stream.Stream;
import java.util.zip.ZipException;
import jdk.testlibrary.FileUtils;
public class InputFilesTest {
+ private static final ToolProvider JAR_TOOL = ToolProvider.findFirst("jar")
+ .orElseThrow(() ->
+ new RuntimeException("jar tool not found")
+ );
+
private final String nl = System.lineSeparator();
private final ByteArrayOutputStream baos = new ByteArrayOutputStream();
private final PrintStream out = new PrintStream(baos);
@@ -195,9 +201,9 @@
PrintStream err = new PrintStream(baes);
PrintStream saveErr = System.err;
System.setErr(err);
- boolean ok = new sun.tools.jar.Main(out, err, "jar").run(cmdline.split(" +"));
+ int rc = JAR_TOOL.run(out, err, cmdline.split(" +"));
System.setErr(saveErr);
- if (!ok) {
+ if (rc != 0) {
String s = baes.toString();
if (s.startsWith("java.util.zip.ZipException: duplicate entry: ")) {
throw new ZipException(s);
--- a/jdk/test/tools/jar/JarBackSlash.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/test/tools/jar/JarBackSlash.java Fri Oct 14 11:11:19 2016 -0700
@@ -28,7 +28,7 @@
/*
* @test
* @bug 7201156
- * @modules jdk.jartool/sun.tools.jar
+ * @modules jdk.jartool
* @summary jar tool fails to convert file separation characters for list and extract
* @author Sean Chou
*/
@@ -43,10 +43,13 @@
import java.util.List;
import java.util.jar.JarEntry;
import java.util.jar.JarOutputStream;
-
-import sun.tools.jar.Main;
+import java.util.spi.ToolProvider;
public class JarBackSlash {
+ private static final ToolProvider JAR_TOOL = ToolProvider.findFirst("jar")
+ .orElseThrow(() ->
+ new RuntimeException("jar tool not found")
+ );
// used construct an entry JarBackSlash/dir/file.txt
private static String JARBACKSLASH = "JarBackSlash";
@@ -78,8 +81,8 @@
PipedInputStream pipedInput = new PipedInputStream(pipedOutput);
PrintStream out = new PrintStream(pipedOutput);
- Main jarTool = new Main(out, System.err, "jar");
- if (!jarTool.run(jarArgs)) {
+ int rc = JAR_TOOL.run(out, System.err, jarArgs);
+ if (rc != 0) {
fail("Could not list jar file.");
}
@@ -101,8 +104,8 @@
PipedInputStream pipedInput = new PipedInputStream(pipedOutput);
PrintStream out = new PrintStream(pipedOutput);
- Main jarTool = new Main(out, System.err, "jar");
- if (!jarTool.run(jarArgs)) {
+ int rc = JAR_TOOL.run(out, System.err, jarArgs);
+ if (rc != 0) {
fail("Could not list jar file.");
}
--- a/jdk/test/tools/jar/JarEntryTime.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/test/tools/jar/JarEntryTime.java Fri Oct 14 11:11:19 2016 -0700
@@ -24,7 +24,7 @@
/**
* @test
* @bug 4225317 6969651
- * @modules jdk.jartool/sun.tools.jar
+ * @modules jdk.jartool
* @summary Check extracted files have date as per those in the .jar file
*/
@@ -33,9 +33,14 @@
import java.nio.file.attribute.FileTime;
import java.util.Date;
import java.util.TimeZone;
-import sun.tools.jar.Main;
+import java.util.spi.ToolProvider;
public class JarEntryTime {
+ static final ToolProvider JAR_TOOL = ToolProvider.findFirst("jar")
+ .orElseThrow(() ->
+ new RuntimeException("jar tool not found")
+ );
+
// ZipEntry's mod date has 2 seconds precision: give extra time to
// allow for e.g. rounding/truncation and networked/samba drives.
@@ -114,10 +119,8 @@
check(fileInner.setLastModified(earlier));
// Make a jar file from that directory structure
- Main jartool = new Main(System.out, System.err, "jar");
- check(jartool.run(new String[] {
- "cf",
- jarFile.getName(), dirOuter.getName() } ));
+ check(JAR_TOOL.run(System.out, System.err,
+ "cf", jarFile.getName(), dirOuter.getName()) == 0);
check(jarFile.exists());
check(cleanup(dirInner));
@@ -142,7 +145,6 @@
final long start = testFile.lastModified();
// Extract and check the last modified values are the current times.
- // See sun.tools.jar.Main
extractJar(jarFile, true);
try (PrintWriter pw = new PrintWriter(testFile)) {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/jar/ReleaseBeforeFiles.java Fri Oct 14 11:11:19 2016 -0700
@@ -0,0 +1,165 @@
+/*
+ * 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 8167237
+ * @summary test that both old style command line options and new gnu style
+ * command line options work with the --release option whether or
+ * not the --release option is preceded by a file name.
+ * @library /lib/testlibrary
+ * @modules jdk.jartool/sun.tools.jar
+ * @build jdk.testlibrary.FileUtils
+ * @run testng ReleaseBeforeFiles
+ */
+
+import org.testng.Assert;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import java.io.IOException;
+import java.io.UncheckedIOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Arrays;
+import java.util.stream.Stream;
+
+import jdk.testlibrary.FileUtils;
+
+public class ReleaseBeforeFiles {
+ private Runnable onCompletion;
+
+ @BeforeMethod
+ public void reset() {
+ onCompletion = null;
+ }
+
+ @AfterMethod
+ public void run() {
+ if (onCompletion != null) {
+ onCompletion.run();
+ }
+ }
+
+ @Test // passes before bug fix
+ public void test1() throws IOException {
+ mkdir("test1");
+ touch("test1/testfile1");
+ jar("cf test.jar --release 9 test1");
+ jar("tf test.jar");
+ rm("test.jar test1");
+ }
+
+ @Test // fails before bug fix
+ public void test2() throws IOException {
+ System.out.println("=====");
+ mkdir("test1");
+ touch("test1/testfile1");
+ onCompletion = () -> rm("test.jar test1");
+ jar("--create --file=test.jar --release 9 test1");
+ jar("tf test.jar");
+ }
+
+ @Test // passes before bug fix
+ public void test3() throws IOException {
+ System.out.println("=====");
+ mkdir("test1");
+ touch("test1/testfile1");
+ jar("-cf test.jar -C test1 .");
+ jar("-uf test.jar --release 9 -C test1 .");
+ jar("tf test.jar");
+ rm("test.jar test1");
+ }
+
+ @Test // fails before bug fix
+ public void test4() throws IOException {
+ System.out.println("=====");
+ mkdir("test1");
+ touch("test1/testfile1");
+ onCompletion = () -> rm("test.jar test1");
+ jar("--create --file=test.jar -C test1 .");
+ jar("--update --file=test.jar --release 9 -C test1 .");
+ jar("tf test.jar");
+ }
+
+ @Test // passes before bug fix since test2 precedes --release 9
+ public void test5() throws IOException {
+ System.out.println("=====");
+ mkdir("test1 test2");
+ touch("test1/testfile1 test2/testfile2");
+ jar("--create --file=test.jar -C test1 .");
+ jar("--update --file=test.jar test2 --release 9 -C test1 .");
+ jar("tf test.jar");
+ rm("test.jar test1 test2");
+ }
+
+ private Stream<Path> mkpath(String... args) {
+ return Arrays.stream(args).map(d -> Paths.get(".", d.split("/")));
+ }
+
+ private void mkdir(String cmdline) {
+ System.out.println("mkdir -p " + cmdline);
+ mkpath(cmdline.split(" +")).forEach(p -> {
+ try {
+ Files.createDirectories(p);
+ } catch (IOException x) {
+ throw new UncheckedIOException(x);
+ }
+ });
+ }
+
+ private void touch(String cmdline) {
+ System.out.println("touch " + cmdline);
+ mkpath(cmdline.split(" +")).forEach(p -> {
+ try {
+ Files.createFile(p);
+ } catch (IOException x) {
+ throw new UncheckedIOException(x);
+ }
+ });
+ }
+
+ private void rm(String cmdline) {
+ System.out.println("rm -rf " + cmdline);
+ mkpath(cmdline.split(" +")).forEach(p -> {
+ try {
+ if (Files.isDirectory(p)) {
+ FileUtils.deleteFileTreeWithRetry(p);
+ } else {
+ FileUtils.deleteFileIfExistsWithRetry(p);
+ }
+ } catch (IOException x) {
+ throw new UncheckedIOException(x);
+ }
+ });
+ }
+
+ private void jar(String cmdline) throws IOException {
+ System.out.println("jar " + cmdline);
+ boolean ok = new sun.tools.jar.Main(System.out, System.err, "jar")
+ .run(cmdline.split(" +"));
+ Assert.assertTrue(ok);
+ }
+}
--- a/jdk/test/tools/jar/UpdateJar.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/test/tools/jar/UpdateJar.java Fri Oct 14 11:11:19 2016 -0700
@@ -24,7 +24,7 @@
/**
* @test
* @bug 7175845
- * @modules jdk.jartool/sun.tools.jar
+ * @modules jdk.jartool
* @summary jar -uf should not change file permission
*/
@@ -32,9 +32,13 @@
import java.nio.file.*;
import java.nio.file.attribute.*;
import java.util.Set;
-import sun.tools.jar.Main;
+import java.util.spi.ToolProvider;
public class UpdateJar {
+ private static final ToolProvider JAR_TOOL = ToolProvider.findFirst("jar")
+ .orElseThrow(() ->
+ new RuntimeException("jar tool not found")
+ );
private static void cleanup(String... fnames) throws Throwable {
for (String fname : fnames) {
@@ -55,12 +59,12 @@
fos1.write(0);
}
String[] jarArgs = new String[] {"cfM0", jar, e0};
- if (!new Main(System.out, System.err, "jar").run(jarArgs)) {
+ if (JAR_TOOL.run(System.out, System.err, jarArgs) != 0) {
fail("Could not create jar file.");
}
Set<PosixFilePermission> pm = Files.getPosixFilePermissions(Paths.get(jar));
jarArgs = new String[] {"uf", jar, e1};
- if (!new Main(System.out, System.err, "jar").run(jarArgs)) {
+ if (JAR_TOOL.run(System.out, System.err, jarArgs) != 0) {
fail("Could not create jar file.");
}
equal(pm, Files.getPosixFilePermissions(Paths.get(jar)));
--- a/jdk/test/tools/jar/UpdateManifest.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/test/tools/jar/UpdateManifest.java Fri Oct 14 11:11:19 2016 -0700
@@ -24,7 +24,7 @@
/**
* @test
* @bug 6434207 6442687 6984046
- * @modules jdk.jartool/sun.tools.jar
+ * @modules jdk.jartool
* @summary Ensure that jar ufm actually updates the
* existing jar file's manifest with contents of the
* manifest file.
@@ -32,14 +32,19 @@
import java.io.*;
import java.util.logging.*;
+import java.util.spi.ToolProvider;
import java.util.zip.*;
-import sun.tools.jar.Main;
public class UpdateManifest {
static PrintStream out = System.out;
static PrintStream err = System.err;
static boolean debug = true;
+ static final ToolProvider JAR_TOOL = ToolProvider.findFirst("jar")
+ .orElseThrow(() ->
+ new RuntimeException("jar tool not found")
+ );
+
static final Logger JAR_LOGGER = Logger.getLogger("java.util.jar");
public static void realMain(String[] args) throws Throwable {
@@ -64,17 +69,14 @@
// Create a jar file, specifying a Main-Class
final String jarFileName = "um-existence.jar";
new File(jarFileName).delete(); // remove pre-existing first!
- Main jartool = new Main(out, err, "jar");
- boolean status = jartool.run(
- new String[] { "cfe", jarFileName, "Hello", existence.getPath() });
- check(status);
+ int status = JAR_TOOL.run(out, err, "cfe", jarFileName,
+ "Hello", existence.getPath());
+ check(status == 0);
checkManifest(jarFileName, "Hello");
// Update that jar file by changing the Main-Class
- jartool = new Main(out, err, "jar");
- status = jartool.run(
- new String[] { "ufe", jarFileName, "Bye" });
- check(status);
+ status = JAR_TOOL.run(out, err, "ufe", jarFileName, "Bye");
+ check(status == 0);
checkManifest(jarFileName, "Bye");
}
@@ -101,11 +103,9 @@
// Create a jar file
final String jarFileName = "um-test.jar";
new File(jarFileName).delete(); // remove pre-existing first!
- Main jartool = new Main(out, err, "jar");
- boolean status = jartool.run(
- new String[] {"cfm", jarFileName,
- manifestOrig.getPath(), hello.getPath() });
- check(status);
+ int status = JAR_TOOL.run(out, err, "cfm", jarFileName,
+ manifestOrig.getPath(), hello.getPath());
+ check(status == 0);
// Create a new manifest, to use in updating the jar file.
File manifestUpdate = File.createTempFile("manifestUpdate", ".txt");
@@ -122,10 +122,9 @@
pw.close();
// Update jar file with manifest
- jartool = new Main(out, err, "jar");
- status = jartool.run(
- new String[] { "ufm", jarFileName, manifestUpdate.getPath() });
- check(status);
+ status = JAR_TOOL.run(out, err, "ufm",
+ jarFileName, manifestUpdate.getPath());
+ check(status == 0);
// Extract jar, and verify contents of manifest file
File f = new File(jarFileName);
--- a/jdk/test/tools/jar/index/MetaInf.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/test/tools/jar/index/MetaInf.java Fri Oct 14 11:11:19 2016 -0700
@@ -24,17 +24,21 @@
/*
* @test
* @bug 4408526 6854795
- * @modules jdk.jartool/sun.tools.jar
+ * @modules jdk.jartool
* @summary Index the non-meta files in META-INF, such as META-INF/services.
*/
import java.io.*;
import java.util.Arrays;
import java.util.jar.*;
-import sun.tools.jar.Main;
+import java.util.spi.ToolProvider;
import java.util.zip.ZipFile;
public class MetaInf {
+ static final ToolProvider JAR_TOOL = ToolProvider.findFirst("jar")
+ .orElseThrow(() ->
+ new RuntimeException("jar tool not found")
+ );
static String jarName = "a.jar";
static String INDEX = "META-INF/INDEX.LIST";
@@ -43,7 +47,7 @@
System.getProperty("test.src") + File.separatorChar + "jarcontents";
static void run(String ... args) {
- if (! new Main(System.out, System.err, "jar").run(args))
+ if (JAR_TOOL.run(System.out, System.err, args) != 0)
throw new Error("jar failed: args=" + Arrays.toString(args));
}
--- a/jdk/test/tools/jlink/JLinkTest.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/test/tools/jlink/JLinkTest.java Fri Oct 14 11:11:19 2016 -0700
@@ -32,13 +32,13 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import java.util.spi.ToolProvider;
import java.util.stream.Stream;
import jdk.tools.jlink.plugin.Plugin;
import jdk.tools.jlink.internal.PluginRepository;
import tests.Helper;
import tests.JImageGenerator;
-import tests.JImageGenerator.InMemoryFile;
/*
* @test
@@ -48,13 +48,17 @@
* @modules java.base/jdk.internal.jimage
* jdk.jdeps/com.sun.tools.classfile
* jdk.jlink/jdk.tools.jlink.internal
- * jdk.jlink/jdk.tools.jmod
* jdk.jlink/jdk.tools.jimage
* jdk.compiler
* @build tests.*
* @run main/othervm -Xmx1g JLinkTest
*/
public class JLinkTest {
+ static final ToolProvider JLINK_TOOL = ToolProvider.findFirst("jlink")
+ .orElseThrow(() ->
+ new RuntimeException("jlink tool not found")
+ );
+
// number of built-in plugins from jdk.jlink module
private static int getNumJlinkPlugins() {
ModuleDescriptor desc = Plugin.class.getModule().getDescriptor();
@@ -180,7 +184,8 @@
{
// Help
StringWriter writer = new StringWriter();
- jdk.tools.jlink.internal.Main.run(new String[]{"--help"}, new PrintWriter(writer));
+ PrintWriter pw = new PrintWriter(writer);
+ JLINK_TOOL.run(pw, pw, "--help");
String output = writer.toString();
if (output.split("\n").length < 10) {
System.err.println(output);
@@ -202,7 +207,9 @@
{
// List plugins
StringWriter writer = new StringWriter();
- jdk.tools.jlink.internal.Main.run(new String[]{"--list-plugins"}, new PrintWriter(writer));
+ PrintWriter pw = new PrintWriter(writer);
+
+ JLINK_TOOL.run(pw, pw, "--list-plugins");
String output = writer.toString();
long number = Stream.of(output.split("\\R"))
.filter((s) -> s.matches("Plugin Name:.*"))
--- a/jdk/test/tools/jlink/basic/BasicTest.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/test/tools/jlink/basic/BasicTest.java Fri Oct 14 11:11:19 2016 -0700
@@ -27,8 +27,7 @@
* @author Andrei Eremeev
* @library /lib/testlibrary
* @modules java.base/jdk.internal.module
- * jdk.jlink/jdk.tools.jlink.internal
- * jdk.jlink/jdk.tools.jmod
+ * jdk.jlink
* jdk.compiler
* @build jdk.testlibrary.ProcessTools
* jdk.testlibrary.OutputAnalyzer
@@ -44,11 +43,21 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import java.util.spi.ToolProvider;
import jdk.testlibrary.OutputAnalyzer;
import jdk.testlibrary.ProcessTools;
public class BasicTest {
+ static final ToolProvider JMOD_TOOL = ToolProvider.findFirst("jmod")
+ .orElseThrow(() ->
+ new RuntimeException("jmod tool not found")
+ );
+
+ static final ToolProvider JLINK_TOOL = ToolProvider.findFirst("jlink")
+ .orElseThrow(() ->
+ new RuntimeException("jlink tool not found")
+ );
private final Path jdkHome = Paths.get(System.getProperty("test.jdk"));
private final Path jdkMods = jdkHome.resolve("jmods");
@@ -110,20 +119,22 @@
"--add-modules", modName,
"--output", image.toString());
Collections.addAll(args, options);
- int rc = jdk.tools.jlink.internal.Main.run(args.toArray(new String[args.size()]), new PrintWriter(System.out));
+
+ PrintWriter pw = new PrintWriter(System.out);
+ int rc = JLINK_TOOL.run(pw, pw, args.toArray(new String[args.size()]));
if (rc != 0) {
throw new AssertionError("Jlink failed: rc = " + rc);
}
}
private void runJmod(String cp, String modName) {
- int rc = jdk.tools.jmod.Main.run(new String[] {
+ int rc = JMOD_TOOL.run(System.out, System.out, new String[] {
"create",
"--class-path", cp,
"--module-version", "1.0",
"--main-class", "jdk.test.Test",
jmods.resolve(modName + ".jmod").toString(),
- }, System.out);
+ });
if (rc != 0) {
throw new AssertionError("Jmod failed: rc = " + rc);
}
--- a/jdk/test/tools/jmod/JmodNegativeTest.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/test/tools/jmod/JmodNegativeTest.java Fri Oct 14 11:11:19 2016 -0700
@@ -24,8 +24,8 @@
/*
* @test
* @library /lib/testlibrary
- * @modules jdk.jlink/jdk.tools.jmod
- * jdk.compiler
+ * @modules jdk.compiler
+ * jdk.jlink
* @build jdk.testlibrary.FileUtils CompilerUtils
* @run testng JmodNegativeTest
* @summary Negative tests for jmod
@@ -39,6 +39,7 @@
import java.util.List;
import java.util.function.Consumer;
import java.util.function.Supplier;
+import java.util.spi.ToolProvider;
import java.util.zip.ZipOutputStream;
import jdk.testlibrary.FileUtils;
import org.testng.annotations.BeforeTest;
@@ -51,6 +52,11 @@
public class JmodNegativeTest {
+ static final ToolProvider JMOD_TOOL = ToolProvider.findFirst("jmod")
+ .orElseThrow(() ->
+ new RuntimeException("jmod tool not found")
+ );
+
static final String TEST_SRC = System.getProperty("test.src", ".");
static final Path SRC_DIR = Paths.get(TEST_SRC, "src");
static final Path EXPLODED_DIR = Paths.get("build");
@@ -515,7 +521,7 @@
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(baos);
System.out.println("jmod " + Arrays.asList(args));
- int ec = jdk.tools.jmod.Main.run(args, ps);
+ int ec = JMOD_TOOL.run(ps, ps, args);
return new JmodResult(ec, new String(baos.toByteArray(), UTF_8));
}
--- a/jdk/test/tools/jmod/JmodTest.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/test/tools/jmod/JmodTest.java Fri Oct 14 11:11:19 2016 -0700
@@ -24,8 +24,8 @@
/*
* @test
* @library /lib/testlibrary
- * @modules jdk.jlink/jdk.tools.jmod
- * jdk.compiler
+ * @modules jdk.compiler
+ * jdk.jlink
* @build jdk.testlibrary.FileUtils CompilerUtils
* @run testng JmodTest
* @summary Basic test for jmod
@@ -38,6 +38,7 @@
import java.util.*;
import java.util.function.Consumer;
import java.util.regex.Pattern;
+import java.util.spi.ToolProvider;
import java.util.stream.Stream;
import jdk.testlibrary.FileUtils;
import org.testng.annotations.BeforeTest;
@@ -51,6 +52,11 @@
public class JmodTest {
+ static final ToolProvider JMOD_TOOL = ToolProvider.findFirst("jmod")
+ .orElseThrow(() ->
+ new RuntimeException("jmod tool not found")
+ );
+
static final String TEST_SRC = System.getProperty("test.src", ".");
static final Path SRC_DIR = Paths.get(TEST_SRC, "src");
static final Path EXPLODED_DIR = Paths.get("build");
@@ -479,7 +485,7 @@
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(baos);
System.out.println("jmod " + Arrays.asList(args));
- int ec = jdk.tools.jmod.Main.run(args, ps);
+ int ec = JMOD_TOOL.run(ps, ps, args);
return new JmodResult(ec, new String(baos.toByteArray(), UTF_8));
}
--- a/jdk/test/tools/jmod/hashes/HashesTest.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/test/tools/jmod/hashes/HashesTest.java Fri Oct 14 11:11:19 2016 -0700
@@ -27,8 +27,7 @@
* @author Andrei Eremeev
* @library /lib/testlibrary
* @modules java.base/jdk.internal.module
- * jdk.jlink/jdk.tools.jlink.internal
- * jdk.jlink/jdk.tools.jmod
+ * jdk.jlink
* jdk.compiler
* @build CompilerUtils
* @run testng HashesTest
@@ -53,6 +52,7 @@
import java.util.List;
import java.util.Optional;
import java.util.Set;
+import java.util.spi.ToolProvider;
import java.util.stream.Collectors;
import jdk.internal.module.ConfigurableModuleFinder;
@@ -63,6 +63,10 @@
import static org.testng.Assert.*;
public class HashesTest {
+ static final ToolProvider JMOD_TOOL = ToolProvider.findFirst("jmod")
+ .orElseThrow(() ->
+ new RuntimeException("jmod tool not found")
+ );
private final Path testSrc = Paths.get(System.getProperty("test.src"));
private final Path modSrc = testSrc.resolve("src");
@@ -204,7 +208,7 @@
}
private void runJmod(List<String> args) {
- int rc = jdk.tools.jmod.Main.run(args.toArray(new String[args.size()]), System.out);
+ int rc = JMOD_TOOL.run(System.out, System.out, args.toArray(new String[args.size()]));
System.out.println("jmod options: " + args.stream().collect(Collectors.joining(" ")));
if (rc != 0) {
throw new AssertionError("Jmod failed: rc = " + rc);
--- a/jdk/test/tools/launcher/modules/addexports/AddExportsTest.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/test/tools/launcher/modules/addexports/AddExportsTest.java Fri Oct 14 11:11:19 2016 -0700
@@ -202,7 +202,7 @@
/**
- * --add-exports can only be specified once
+ * --add-exports allows duplicates
*/
public void testWithDuplicateOption() throws Exception {
@@ -212,10 +212,40 @@
"-version")
.outputTo(System.out)
.errorTo(System.out)
- .shouldContain("specified more than once")
.getExitValue();
- assertTrue(exitValue != 0);
+ assertTrue(exitValue == 0);
+ }
+
+
+ /**
+ * Exercise --add-exports with unknown values. Warning is emitted.
+ */
+ @Test(dataProvider = "unknownvalues")
+ public void testWithUnknownValue(String value, String ignore) throws Exception {
+
+ // --add-exports $VALUE -version
+ int exitValue =
+ executeTestJava("--add-exports", value,
+ "-version")
+ .stderrShouldMatch("WARNING: .*.monkey.*")
+ .outputTo(System.out)
+ .errorTo(System.out)
+ .getExitValue();
+
+ assertTrue(exitValue == 0);
+ }
+
+ @DataProvider(name = "unknownvalues")
+ public Object[][] unknownValues() {
+ return new Object[][]{
+
+ { "java.base/jdk.internal.misc=sun.monkey", null }, // unknown target
+ { "java.monkey/sun.monkey=ALL-UNNAMED", null }, // unknown module
+ { "java.base/sun.monkey=ALL-UNNAMED", null }, // unknown package
+ { "java.monkey/sun.monkey=ALL-UNNAMED", null }, // unknown module/package
+
+ };
}
@@ -241,10 +271,6 @@
return new Object[][]{
{ "java.base/jdk.internal.misc", null }, // missing target
- { "java.base/jdk.internal.misc=sun.monkey", null }, // unknown target
- { "java.monkey/sun.monkey=ALL-UNNAMED", null }, // unknown module
- { "java.base/sun.monkey=ALL-UNNAMED", null }, // unknown package
- { "java.monkey/sun.monkey=ALL-UNNAMED", null }, // unknown module/package
{ "java.base=ALL-UNNAMED", null }, // missing package
{ "java.base/=ALL-UNNAMED", null } // missing package
--- a/jdk/test/tools/launcher/modules/addreads/AddReadsTest.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/test/tools/launcher/modules/addreads/AddReadsTest.java Fri Oct 14 11:11:19 2016 -0700
@@ -182,28 +182,43 @@
"--add-reads", "m1=java.xml",
"--add-reads", "m1=junit",
"-m", MAIN)
- .shouldContain("specified more than once")
.getExitValue();
- assertTrue(exitValue != 0);
+ assertTrue(exitValue == 0);
}
/**
- * Exercise --add-reads with bad values
+ * Exercise --add-reads with missing source
+ */
+ public void testWithMissingSource() throws Exception {
+
+ // --add-exports $VALUE -version
+ assertTrue(run("--add-reads", "java.base", "-version").getExitValue() != 0);
+ }
+
+
+ /**
+ * Exercise --add-reads with unknown source/target module.
+ * Warning is emitted.
*/
@Test(dataProvider = "badvalues")
public void testWithBadValue(String value, String ignore) throws Exception {
// --add-exports $VALUE -version
- assertTrue(run("--add-reads", value, "-version").getExitValue() != 0);
+ int exitValue = run("--add-reads", value, "-version")
+ .stderrShouldMatch("WARNING: Unknown module: .*.monkey")
+ .outputTo(System.out)
+ .errorTo(System.out)
+ .getExitValue();
+
+ assertTrue(exitValue == 0);
}
@DataProvider(name = "badvalues")
public Object[][] badValues() {
return new Object[][]{
- { "java.base", null }, // missing source
{ "java.monkey=java.base", null }, // unknown module
{ "java.base=sun.monkey", null }, // unknown source
--- a/jdk/test/tools/launcher/modules/basic/BasicTest.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/test/tools/launcher/modules/basic/BasicTest.java Fri Oct 14 11:11:19 2016 -0700
@@ -24,9 +24,9 @@
/**
* @test
* @library /lib/testlibrary
- * @modules jdk.jartool/sun.tools.jar
- * jdk.jlink/jdk.tools.jmod
- * jdk.compiler
+ * @modules jdk.compiler
+ * jdk.jartool
+ * jdk.jlink
* @build BasicTest CompilerUtils jdk.testlibrary.*
* @run testng BasicTest
* @summary Basic test of starting an application as a module
@@ -36,6 +36,7 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
+import java.util.spi.ToolProvider;
import jdk.testlibrary.ProcessTools;
@@ -46,6 +47,14 @@
@Test
public class BasicTest {
+ private static final ToolProvider JAR_TOOL = ToolProvider.findFirst("jar")
+ .orElseThrow(() ->
+ new RuntimeException("jar tool not found")
+ );
+ private static final ToolProvider JMOD_TOOL = ToolProvider.findFirst("jmod")
+ .orElseThrow(() ->
+ new RuntimeException("jmod tool not found")
+ );
private static final Path USER_DIR = Paths.get(System.getProperty("user.dir"));
@@ -132,10 +141,8 @@
"--main-class=" + MAIN_CLASS,
"-C", classes, "."
};
- boolean success
- = new sun.tools.jar.Main(System.out, System.out, "jar")
- .run(args);
- assertTrue(success);
+ int rc = JAR_TOOL.run(System.out, System.out, args);
+ assertTrue(rc == 0);
// java --module-path mlib -module $TESTMODULE
int exitValue = exec("--module-path", dir.toString(),
@@ -164,8 +171,8 @@
"--main-class", MAIN_CLASS,
jmod
};
- jdk.tools.jmod.JmodTask task = new jdk.tools.jmod.JmodTask();
- assertEquals(task.run(args), 0);
+
+ assertEquals(JMOD_TOOL.run(System.out, System.out, args), 0);
// java --module-path mods --module $TESTMODULE
int exitValue = exec("--module-path", dir.toString(),
@@ -229,10 +236,8 @@
"--file=" + jar,
"-C", classes, "."
};
- boolean success
- = new sun.tools.jar.Main(System.out, System.out, "jar")
- .run(args);
- assertTrue(success);
+ int rc = JAR_TOOL.run(System.out, System.out, args);
+ assertTrue(rc == 0);
// java --module-path mods -m $TESTMODULE
int exitValue = exec("--module-path", dir.toString(), "-m", TEST_MODULE);
--- a/jdk/test/tools/launcher/modules/dryrun/DryRunTest.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/test/tools/launcher/modules/dryrun/DryRunTest.java Fri Oct 14 11:11:19 2016 -0700
@@ -26,7 +26,7 @@
* @bug 8159596
* @library /lib/testlibrary
* @modules jdk.compiler
- * jdk.jartool/sun.tools.jar
+ * jdk.jartool
* @build DryRunTest CompilerUtils jdk.testlibrary.ProcessTools
* @run testng DryRunTest
* @summary Test java --dry-run
@@ -37,6 +37,7 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
+import java.util.spi.ToolProvider;
import jdk.testlibrary.ProcessTools;
@@ -78,8 +79,8 @@
Files.createDirectories(LIBS_DIR);
// create JAR files with no module-info.class
- assertTrue(jar(M_MODULE, "p/Lib.class"));
- assertTrue(jar(TEST_MODULE, "jdk/test/Main.class"));
+ assertTrue(jar(M_MODULE, "p/Lib.class") == 0);
+ assertTrue(jar(TEST_MODULE, "jdk/test/Main.class") == 0);
}
/**
@@ -197,7 +198,12 @@
assertTrue(exitValue != 0);
}
- private static boolean jar(String name, String entries) throws IOException {
+ private static final ToolProvider JAR_TOOL = ToolProvider.findFirst("jar")
+ .orElseThrow(() ->
+ new RuntimeException("jar tool not found")
+ );
+
+ private static int jar(String name, String entries) throws IOException {
Path jar = LIBS_DIR.resolve(name + ".jar");
// jar --create ...
@@ -207,8 +213,6 @@
"--file=" + jar,
"-C", classes, entries
};
- boolean success
- = new sun.tools.jar.Main(System.out, System.out, "jar").run(args);
- return success;
+ return JAR_TOOL.run(System.out, System.out, args);
}
}
--- a/jdk/test/tools/lib/tests/JImageGenerator.java Fri Oct 14 19:12:37 2016 +0300
+++ b/jdk/test/tools/lib/tests/JImageGenerator.java Fri Oct 14 11:11:19 2016 -0700
@@ -338,6 +338,10 @@
}
public static class JModTask {
+ static final java.util.spi.ToolProvider JMOD_TOOL =
+ java.util.spi.ToolProvider.findFirst("jmod").orElseThrow(() ->
+ new RuntimeException("jmod tool not found")
+ );
private final List<Path> classpath = new ArrayList<>();
private final List<Path> libs = new ArrayList<>();
@@ -477,7 +481,8 @@
String[] args = optionsJMod(cmd);
System.err.println("jmod options: " + optionsPrettyPrint(args));
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- int exitCode = jdk.tools.jmod.Main.run(args, new PrintStream(baos));
+ PrintStream ps = new PrintStream(baos);
+ int exitCode = JMOD_TOOL.run(ps, ps, args);
String msg = new String(baos.toByteArray());
return new Result(exitCode, msg, output);
}
@@ -556,6 +561,10 @@
}
public static class JLinkTask {
+ static final java.util.spi.ToolProvider JLINK_TOOL =
+ java.util.spi.ToolProvider.findFirst("jlink").orElseThrow(() ->
+ new RuntimeException("jlink tool not found")
+ );
private final List<Path> jars = new ArrayList<>();
private final List<Path> jmods = new ArrayList<>();
@@ -691,7 +700,8 @@
String[] args = optionsJLink();
System.err.println("jlink options: " + optionsPrettyPrint(args));
StringWriter writer = new StringWriter();
- int exitCode = jdk.tools.jlink.internal.Main.run(args, new PrintWriter(writer));
+ PrintWriter pw = new PrintWriter(writer);
+ int exitCode = JLINK_TOOL.run(pw, pw, args);
return new Result(exitCode, writer.toString(), output);
}
@@ -699,7 +709,8 @@
String[] args = optionsPostProcessJLink();
System.err.println("jlink options: " + optionsPrettyPrint(args));
StringWriter writer = new StringWriter();
- int exitCode = jdk.tools.jlink.internal.Main.run(args, new PrintWriter(writer));
+ PrintWriter pw = new PrintWriter(writer);
+ int exitCode = JLINK_TOOL.run(pw, pw, args);
return new Result(exitCode, writer.toString(), output);
}
}
--- a/langtools/.hgtags Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/.hgtags Fri Oct 14 11:11:19 2016 -0700
@@ -381,3 +381,4 @@
c8f02f0ecbd7cd6700f47416e4b7e9d5ec20ad77 jdk-9+136
dd56c243c199a540c9f1fbff4855f0934b32a9d0 jdk-9+137
90dd93e668a521642382561c47abe96ee2e065b7 jdk-9+138
+17a82cb0e4b480e97021691d39917f15e3f7b653 jdk-9+139
--- a/langtools/ASSEMBLY_EXCEPTION Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/ASSEMBLY_EXCEPTION Fri Oct 14 11:11:19 2016 -0700
@@ -1,27 +1,27 @@
OPENJDK ASSEMBLY EXCEPTION
-The OpenJDK source code made available by Sun at openjdk.java.net and
-openjdk.dev.java.net ("OpenJDK Code") is distributed under the terms of the
-GNU General Public License <http://www.gnu.org/copyleft/gpl.html> version 2
+The OpenJDK source code made available by Oracle America, Inc. (Oracle) at
+openjdk.java.net ("OpenJDK Code") is distributed under the terms of the GNU
+General Public License <http://www.gnu.org/copyleft/gpl.html> version 2
only ("GPL2"), with the following clarification and special exception.
Linking this OpenJDK Code statically or dynamically with other code
is making a combined work based on this library. Thus, the terms
and conditions of GPL2 cover the whole combination.
- As a special exception, Sun gives you permission to link this
- OpenJDK Code with certain code licensed by Sun as indicated at
+ As a special exception, Oracle gives you permission to link this
+ OpenJDK Code with certain code licensed by Oracle as indicated at
http://openjdk.java.net/legal/exception-modules-2007-05-08.html
("Designated Exception Modules") to produce an executable,
regardless of the license terms of the Designated Exception Modules,
and to copy and distribute the resulting executable under GPL2,
provided that the Designated Exception Modules continue to be
- governed by the licenses under which they were offered by Sun.
+ governed by the licenses under which they were offered by Oracle.
-As such, it allows licensees and sublicensees of Sun's GPL2 OpenJDK Code to
-build an executable that includes those portions of necessary code that Sun
-could not provide under GPL2 (or that Sun has provided under GPL2 with the
-Classpath exception). If you modify or add to the OpenJDK code, that new
-GPL2 code may still be combined with Designated Exception Modules if the
-new code is made subject to this exception by its copyright holder.
+As such, it allows licensees and sublicensees of Oracle's GPL2 OpenJDK Code
+to build an executable that includes those portions of necessary code that
+Oracle could not provide under GPL2 (or that Oracle has provided under GPL2
+with the Classpath exception). If you modify or add to the OpenJDK code,
+that new GPL2 code may still be combined with Designated Exception Modules
+if the new code is made subject to this exception by its copyright holder.
--- a/langtools/make/CompileInterim.gmk Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/make/CompileInterim.gmk Fri Oct 14 11:11:19 2016 -0700
@@ -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
@@ -47,7 +47,7 @@
$$(wildcard $(SUPPORT_OUTPUTDIR)/gensrc/$(strip $1)), \
EXCLUDES := sun com/sun/tools/jdeps com/sun/tools/javap \
com/sun/tools/jdeprscan, \
- EXCLUDE_FILES := module-info.java, \
+ EXCLUDE_FILES := module-info.java JavacToolProvider.java JavadocToolProvider.java, \
COPY := .gif .png .xml .css .js javax.tools.JavaCompilerTool, \
BIN := $(BUILDTOOLS_OUTPUTDIR)/override_modules/$(strip $1), \
ADD_JAVAC_FLAGS := -Xbootclasspath/p:$$(call PathList, \
--- a/langtools/make/tools/crules/MutableFieldsAnalyzer.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/make/tools/crules/MutableFieldsAnalyzer.java Fri Oct 14 11:11:19 2016 -0700
@@ -111,6 +111,8 @@
"loadMethod");
ignoreFields("com.sun.tools.javac.util.JDK9Wrappers$VMHelper",
"vmClass", "getRuntimeArgumentsMethod");
+ ignoreFields("com.sun.tools.javac.util.JDK9Wrappers$JmodFile",
+ "jmodFileClass", "checkMagicMethod");
}
}
--- a/langtools/src/jdk.compiler/share/classes/com/sun/source/util/DocTreeFactory.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/source/util/DocTreeFactory.java Fri Oct 14 11:11:19 2016 -0700
@@ -112,12 +112,11 @@
/**
* Create a new {@code DocCommentTree} object, to represent a complete doc comment.
- * @param firstSentence the first sentence of the doc comment
- * @param body the body of the doc comment following the first sentence
+ * @param fullBody the entire body of the doc comment
* @param tags the block tags in the doc comment
* @return a {@code DocCommentTree} object
*/
- DocCommentTree newDocCommentTree(List<? extends DocTree> firstSentence, List<? extends DocTree> body, List<? extends DocTree> tags);
+ DocCommentTree newDocCommentTree(List<? extends DocTree> fullBody, List<? extends DocTree> tags);
/**
* Create a new {@code DocRootTree} object, to represent an {@code {@docroot} } tag.
--- a/langtools/src/jdk.compiler/share/classes/com/sun/source/util/TreePathScanner.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/source/util/TreePathScanner.java Fri Oct 14 11:11:19 2016 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2014, 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,6 +35,10 @@
* Inside your method, call super.visitXYZ to visit descendant
* nodes.
*
+ * @apiNote
+ * In order to initialize the "current path", the scan must be
+ * started by calling one of the {@code scan} methods.
+ *
* @author Jonathan Gibbons
* @since 1.6
*/
@@ -58,6 +62,13 @@
/**
* Scans a single node.
* The current path is updated for the duration of the scan.
+ *
+ * @apiNote This method should normally only be called by the
+ * scanner's {@code visit} methods, as part of an ongoing scan
+ * initiated by {@link #scan(TreePath,Object) scan(TreePath, P)}.
+ * The one exception is that it may also be called to initiate
+ * a full scan of a {@link CompilationUnitTree}.
+ *
* @return the result value from the visit method
*/
@Override
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java Fri Oct 14 11:11:19 2016 -0700
@@ -4415,6 +4415,7 @@
chk.checkDeprecatedAnnotation(env.tree.pos(), c);
chk.checkClassOverrideEqualsAndHashIfNeeded(env.tree.pos(), c);
chk.checkFunctionalInterface((JCClassDecl) env.tree, c);
+ chk.checkLeaksNotAccessible(env, (JCClassDecl) env.tree);
} finally {
env.info.returnResult = prevReturnRes;
log.useSource(prev);
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java Fri Oct 14 11:11:19 2016 -0700
@@ -31,10 +31,13 @@
import com.sun.tools.javac.code.*;
import com.sun.tools.javac.code.Attribute.Compound;
+import com.sun.tools.javac.code.Directive.ExportsDirective;
+import com.sun.tools.javac.code.Directive.RequiresDirective;
import com.sun.tools.javac.comp.Annotate.AnnotationTypeMetadata;
import com.sun.tools.javac.jvm.*;
import com.sun.tools.javac.resources.CompilerProperties.Errors;
import com.sun.tools.javac.resources.CompilerProperties.Fragments;
+import com.sun.tools.javac.resources.CompilerProperties.Warnings;
import com.sun.tools.javac.tree.*;
import com.sun.tools.javac.util.*;
import com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag;
@@ -3661,4 +3664,178 @@
}
}
+ public void checkLeaksNotAccessible(Env<AttrContext> env, JCClassDecl check) {
+ JCCompilationUnit toplevel = env.toplevel;
+
+ if ( toplevel.modle == syms.unnamedModule
+ || toplevel.modle == syms.noModule
+ || (check.sym.flags() & COMPOUND) != 0) {
+ return ;
+ }
+
+ ExportsDirective currentExport = findExport(toplevel.packge);
+
+ if ( currentExport == null //not exported
+ || currentExport.modules != null) //don't check classes in qualified export
+ return ;
+
+ new TreeScanner() {
+ Lint lint = env.info.lint;
+ boolean inSuperType;
+
+ @Override
+ public void visitBlock(JCBlock tree) {
+ }
+ @Override
+ public void visitMethodDef(JCMethodDecl tree) {
+ if (!isAPISymbol(tree.sym))
+ return;
+ Lint prevLint = lint;
+ try {
+ lint = lint.augment(tree.sym);
+ if (lint.isEnabled(LintCategory.EXPORTS)) {
+ super.visitMethodDef(tree);
+ }
+ } finally {
+ lint = prevLint;
+ }
+ }
+ @Override
+ public void visitVarDef(JCVariableDecl tree) {
+ if (!isAPISymbol(tree.sym) && tree.sym.owner.kind != MTH)
+ return;
+ Lint prevLint = lint;
+ try {
+ lint = lint.augment(tree.sym);
+ if (lint.isEnabled(LintCategory.EXPORTS)) {
+ scan(tree.mods);
+ scan(tree.vartype);
+ }
+ } finally {
+ lint = prevLint;
+ }
+ }
+ @Override
+ public void visitClassDef(JCClassDecl tree) {
+ if (tree != check)
+ return ;
+
+ if (!isAPISymbol(tree.sym))
+ return ;
+
+ Lint prevLint = lint;
+ try {
+ lint = lint.augment(tree.sym);
+ if (lint.isEnabled(LintCategory.EXPORTS)) {
+ scan(tree.mods);
+ scan(tree.typarams);
+ try {
+ inSuperType = true;
+ scan(tree.extending);
+ scan(tree.implementing);
+ } finally {
+ inSuperType = false;
+ }
+ scan(tree.defs);
+ }
+ } finally {
+ lint = prevLint;
+ }
+ }
+ @Override
+ public void visitTypeApply(JCTypeApply tree) {
+ scan(tree.clazz);
+ boolean oldInSuperType = inSuperType;
+ try {
+ inSuperType = false;
+ scan(tree.arguments);
+ } finally {
+ inSuperType = oldInSuperType;
+ }
+ }
+ @Override
+ public void visitIdent(JCIdent tree) {
+ Symbol sym = TreeInfo.symbol(tree);
+ if (sym.kind == TYP && !sym.type.hasTag(TYPEVAR)) {
+ checkVisible(tree.pos(), sym, toplevel.packge, inSuperType);
+ }
+ }
+
+ @Override
+ public void visitSelect(JCFieldAccess tree) {
+ Symbol sym = TreeInfo.symbol(tree);
+ Symbol sitesym = TreeInfo.symbol(tree.selected);
+ if (sym.kind == TYP && sitesym.kind == PCK) {
+ checkVisible(tree.pos(), sym, toplevel.packge, inSuperType);
+ } else {
+ super.visitSelect(tree);
+ }
+ }
+
+ @Override
+ public void visitAnnotation(JCAnnotation tree) {
+ if (tree.attribute.type.tsym.getAnnotation(java.lang.annotation.Documented.class) != null)
+ super.visitAnnotation(tree);
+ }
+
+ }.scan(check);
+ }
+ //where:
+ private ExportsDirective findExport(PackageSymbol pack) {
+ for (ExportsDirective d : pack.modle.exports) {
+ if (d.packge == pack)
+ return d;
+ }
+
+ return null;
+ }
+ private boolean isAPISymbol(Symbol sym) {
+ while (sym.kind != PCK) {
+ if ((sym.flags() & Flags.PUBLIC) == 0 && (sym.flags() & Flags.PROTECTED) == 0) {
+ return false;
+ }
+ sym = sym.owner;
+ }
+ return true;
+ }
+ private void checkVisible(DiagnosticPosition pos, Symbol what, PackageSymbol inPackage, boolean inSuperType) {
+ if (!isAPISymbol(what) && !inSuperType) { //package private/private element
+ log.warning(LintCategory.EXPORTS, pos, Warnings.LeaksNotAccessible(kindName(what), what, what.packge().modle));
+ return ;
+ }
+
+ PackageSymbol whatPackage = what.packge();
+ ExportsDirective whatExport = findExport(whatPackage);
+ ExportsDirective inExport = findExport(inPackage);
+
+ if (whatExport == null) { //package not exported:
+ log.warning(LintCategory.EXPORTS, pos, Warnings.LeaksNotAccessibleUnexported(kindName(what), what, what.packge().modle));
+ return ;
+ }
+
+ if (whatExport.modules != null) {
+ if (inExport.modules == null || !whatExport.modules.containsAll(inExport.modules)) {
+ log.warning(LintCategory.EXPORTS, pos, Warnings.LeaksNotAccessibleUnexportedQualified(kindName(what), what, what.packge().modle));
+ }
+ }
+
+ if (whatPackage.modle != inPackage.modle && whatPackage.modle != syms.java_base) {
+ //check that relativeTo.modle requires public what.modle, somehow:
+ List<ModuleSymbol> todo = List.of(inPackage.modle);
+
+ while (todo.nonEmpty()) {
+ ModuleSymbol current = todo.head;
+ todo = todo.tail;
+ if (current == whatPackage.modle)
+ return ; //OK
+ for (RequiresDirective req : current.requires) {
+ if (req.isPublic()) {
+ todo = todo.prepend(req.module);
+ }
+ }
+ }
+
+ log.warning(LintCategory.EXPORTS, pos, Warnings.LeaksNotAccessibleNotRequiredPublic(kindName(what), what, what.packge().modle));
+ }
+ }
}
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java Fri Oct 14 11:11:19 2016 -0700
@@ -78,6 +78,7 @@
import com.sun.tools.javac.resources.CompilerProperties.Warnings;
import com.sun.tools.javac.util.DefinedBy;
import com.sun.tools.javac.util.DefinedBy.Api;
+import com.sun.tools.javac.util.JDK9Wrappers;
import com.sun.tools.javac.util.ListBuffer;
import com.sun.tools.javac.util.Log;
import com.sun.tools.javac.jvm.ModuleNameReader;
@@ -1103,6 +1104,11 @@
if (p.getFileName().toString().endsWith(".jmod")) {
try {
+ // check if the JMOD file is valid
+ JDK9Wrappers.JmodFile.checkMagic(p);
+
+ // No JMOD file system. Use JarFileSystem to
+ // workaround for now
FileSystem fs = fileSystems.get(p);
if (fs == null) {
URI uri = URI.create("jar:" + p.toUri());
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/CommandLine.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/CommandLine.java Fri Oct 14 11:11:19 2016 -0700
@@ -27,7 +27,6 @@
import java.io.IOException;
import java.io.Reader;
-import java.io.StreamTokenizer;
import java.nio.file.Files;
import java.nio.file.Paths;
@@ -51,10 +50,11 @@
* '@file' argument replaced with the resulting tokens. Recursive command
* files are not supported. The '@' character itself can be quoted with
* the sequence '@@'.
+ * @param args the arguments that may contain @files
+ * @return the arguments, with @files expanded
+ * @throws IOException if there is a problem reading any of the @files
*/
- public static String[] parse(String[] args)
- throws IOException
- {
+ public static String[] parse(String[] args) throws IOException {
ListBuffer<String> newArgs = new ListBuffer<>();
for (String arg : args) {
if (arg.length() > 1 && arg.charAt(0) == '@') {
@@ -71,19 +71,120 @@
return newArgs.toList().toArray(new String[newArgs.length()]);
}
- private static void loadCmdFile(String name, ListBuffer<String> args)
- throws IOException
- {
+ private static void loadCmdFile(String name, ListBuffer<String> args) throws IOException {
try (Reader r = Files.newBufferedReader(Paths.get(name))) {
- StreamTokenizer st = new StreamTokenizer(r);
- st.resetSyntax();
- st.wordChars(' ', 255);
- st.whitespaceChars(0, ' ');
- st.commentChar('#');
- st.quoteChar('"');
- st.quoteChar('\'');
- while (st.nextToken() != StreamTokenizer.TT_EOF) {
- args.append(st.sval);
+ Tokenizer t = new Tokenizer(r);
+ String s;
+ while ((s = t.nextToken()) != null) {
+ args.append(s);
+ }
+ }
+ }
+
+ public static class Tokenizer {
+ private final Reader in;
+ private int ch;
+
+ public Tokenizer(Reader in) throws IOException {
+ this.in = in;
+ ch = in.read();
+ }
+
+ public String nextToken() throws IOException {
+ skipWhite();
+ if (ch == -1) {
+ return null;
+ }
+
+ StringBuilder sb = new StringBuilder();
+ char quoteChar = 0;
+
+ while (ch != -1) {
+ switch (ch) {
+ case ' ':
+ case '\t':
+ case '\f':
+ if (quoteChar == 0) {
+ return sb.toString();
+ }
+ sb.append((char) ch);
+ break;
+
+ case '\n':
+ case '\r':
+ return sb.toString();
+
+ case '\'':
+ case '"':
+ if (quoteChar == 0) {
+ quoteChar = (char) ch;
+ } else if (quoteChar == ch) {
+ quoteChar = 0;
+ } else {
+ sb.append((char) ch);
+ }
+ break;
+
+ case '\\':
+ if (quoteChar != 0) {
+ ch = in.read();
+ switch (ch) {
+ case '\n':
+ case '\r':
+ while (ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t' || ch == '\f') {
+ ch = in.read();
+ }
+ continue;
+
+ case 'n':
+ ch = '\n';
+ break;
+ case 'r':
+ ch = '\r';
+ break;
+ case 't':
+ ch = '\t';
+ break;
+ case 'f':
+ ch = '\f';
+ break;
+ }
+ }
+ sb.append((char) ch);
+ break;
+
+ default:
+ sb.append((char) ch);
+ }
+
+ ch = in.read();
+ }
+
+ return sb.toString();
+ }
+
+ void skipWhite() throws IOException {
+ while (ch != -1) {
+ switch (ch) {
+ case ' ':
+ case '\t':
+ case '\n':
+ case '\r':
+ case '\f':
+ break;
+
+ case '#':
+ ch = in.read();
+ while (ch != '\n' && ch != '\r' && ch != -1) {
+ ch = in.read();
+ }
+ break;
+
+ default:
+ return;
+ }
+
+ ch = in.read();
}
}
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavacToolProvider.java Fri Oct 14 11:11:19 2016 -0700
@@ -0,0 +1,48 @@
+/*
+ * 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.javac.main;
+
+import java.io.PrintWriter;
+import java.util.spi.ToolProvider;
+
+/**
+ * An implementation of the {@link java.util.spi.ToolProvider ToolProvider} SPI,
+ * providing access to JDK Java compiler, javac.
+ *
+ * @since 9
+ */
+// This is currently a stand-alone top-level class so that it can easily be excluded
+// from interims builds of javac, used while building JDK.
+public class JavacToolProvider implements ToolProvider {
+ public String name() {
+ return "javac";
+ }
+
+ public int run(PrintWriter out, PrintWriter err, String... args) {
+ Main compiler = new Main("javac", out, err);
+ return compiler.compile(args).exitCode;
+ }
+}
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Main.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Main.java Fri Oct 14 11:11:19 2016 -0700
@@ -119,6 +119,18 @@
this.stdOut = this.stdErr = out;
}
+ /**
+ * Construct a compiler instance.
+ * @param name the name of this tool
+ * @param out a stream to which to write expected output
+ * @param err a stream to which to write diagnostic output
+ */
+ public Main(String name, PrintWriter out, PrintWriter err) {
+ this.ownName = name;
+ this.stdOut = out;
+ this.stdErr = err;
+ }
+
/** Report a usage error.
*/
void error(String key, Object... args) {
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties Fri Oct 14 11:11:19 2016 -0700
@@ -2865,6 +2865,19 @@
compiler.warn.service.provided.but.not.exported.or.used=\
service interface provided but not exported or used
+# 0: kind name, 1: symbol, 2: symbol
+compiler.warn.leaks.not.accessible=\
+ {0} {1} in module {2} is not accessible to clients that require this module
+# 0: kind name, 1: symbol, 2: symbol
+compiler.warn.leaks.not.accessible.unexported=\
+ {0} {1} in module {2} is not exported
+# 0: kind name, 1: symbol, 2: symbol
+compiler.warn.leaks.not.accessible.not.required.public=\
+ {0} {1} in module {2} is not indirectly exported using 'requires public'
+# 0: kind name, 1: symbol, 2: symbol
+compiler.warn.leaks.not.accessible.unexported.qualified=\
+ {0} {1} in module {2} may not be visible to all clients that require this module
+
###
# errors related to options
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/DocTreeMaker.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/DocTreeMaker.java Fri Oct 14 11:11:19 2016 -0700
@@ -203,11 +203,10 @@
* where the trees are being synthesized by a tool.
*/
@Override @DefinedBy(Api.COMPILER_TREE)
- public DCDocComment newDocCommentTree(List<? extends DocTree> firstSentence, List<? extends DocTree> body, List<? extends DocTree> tags) {
+ public DCDocComment newDocCommentTree(List<? extends DocTree> fullBody, List<? extends DocTree> tags) {
ListBuffer<DCTree> lb = new ListBuffer<>();
- lb.addAll(cast(firstSentence));
- lb.addAll(cast(body));
- List<DCTree> fullBody = lb.toList();
+ lb.addAll(cast(fullBody));
+ List<DCTree> fBody = lb.toList();
// A dummy comment to keep the diagnostics logic happy.
Comment c = new Comment() {
@@ -231,8 +230,8 @@
return false;
}
};
-
- DCDocComment tree = new DCDocComment(c, fullBody, cast(firstSentence), cast(body), cast(tags));
+ Pair<List<DCTree>, List<DCTree>> pair = splitBody(fullBody);
+ DCDocComment tree = new DCDocComment(c, fBody, pair.fst, pair.snd, cast(tags));
return tree;
}
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Iterators.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Iterators.java Fri Oct 14 11:11:19 2016 -0700
@@ -46,7 +46,8 @@
private final Iterator<I> inputs;
private final Function<I, Iterator<O>> convertor;
- private Iterator<O> currentIterator;
+ @SuppressWarnings("unchecked")
+ private Iterator<O> currentIterator = EMPTY;
public CompoundIterator(Iterable<I> inputs, Function<I, Iterator<O>> convertor) {
this.inputs = inputs.iterator();
@@ -54,10 +55,10 @@
}
public boolean hasNext() {
- while (inputs.hasNext() && (currentIterator == null || !currentIterator.hasNext())) {
- currentIterator = convertor.apply(inputs.next());
+ if (currentIterator != null && !currentIterator.hasNext()) {
+ update();
}
- return currentIterator != null && currentIterator.hasNext();
+ return currentIterator != null;
}
public O next() {
@@ -70,5 +71,25 @@
public void remove() {
throw new UnsupportedOperationException();
}
+
+ private void update() {
+ while (inputs.hasNext()) {
+ currentIterator = convertor.apply(inputs.next());
+ if (currentIterator.hasNext()) return;
+ }
+ currentIterator = null;
+ }
}
+
+ @SuppressWarnings("rawtypes")
+ private final static Iterator EMPTY = new Iterator() {
+ public boolean hasNext() {
+ return false;
+ }
+
+ @Override
+ public Object next() {
+ return null;
+ }
+ };
}
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/JDK9Wrappers.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/JDK9Wrappers.java Fri Oct 14 11:11:19 2016 -0700
@@ -25,6 +25,7 @@
package com.sun.tools.javac.util;
+import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.nio.file.Path;
@@ -367,4 +368,41 @@
}
}
}
+
+ /**
+ * Helper class for new method in jdk.internal.jmod.JmodFile
+ */
+ public static final class JmodFile {
+ public static final String JMOD_FILE_CLASSNAME = "jdk.internal.jmod.JmodFile";
+
+ public static void checkMagic(Path file) throws IOException {
+ try {
+ init();
+ checkMagicMethod.invoke(null, file);
+ } catch (InvocationTargetException ex) {
+ if (ex.getCause() instanceof IOException) {
+ throw IOException.class.cast(ex.getCause());
+ }
+ throw new Abort(ex);
+ } catch (IllegalAccessException | IllegalArgumentException | SecurityException ex) {
+ throw new Abort(ex);
+ }
+ }
+
+ // -----------------------------------------------------------------------------------------
+
+ private static Class<?> jmodFileClass = null;
+ private static Method checkMagicMethod = null;
+
+ private static void init() {
+ if (jmodFileClass == null) {
+ try {
+ jmodFileClass = Class.forName(JMOD_FILE_CLASSNAME, false, null);
+ checkMagicMethod = jmodFileClass.getDeclaredMethod("checkMagic", Path.class);
+ } catch (ClassNotFoundException | NoSuchMethodException | SecurityException ex) {
+ throw new Abort(ex);
+ }
+ }
+ }
+ }
}
--- a/langtools/src/jdk.compiler/share/classes/module-info.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/src/jdk.compiler/share/classes/module-info.java Fri Oct 14 11:11:19 2016 -0700
@@ -70,6 +70,9 @@
uses com.sun.source.util.Plugin;
uses com.sun.tools.javac.platform.PlatformProvider;
+ provides java.util.spi.ToolProvider
+ with com.sun.tools.javac.main.JavacToolProvider;
+
provides com.sun.tools.javac.platform.PlatformProvider
with com.sun.tools.javac.platform.JDKPlatformProvider;
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractMemberWriter.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractMemberWriter.java Fri Oct 14 11:11:19 2016 -0700
@@ -368,7 +368,7 @@
* @param htmltree the content tree to which the comment will be added.
*/
protected void addComment(Element member, Content htmltree) {
- if (!utils.getBody(member).isEmpty()) {
+ if (!utils.getFullBody(member).isEmpty()) {
writer.addInlineComment(member, htmltree);
}
}
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeWriterImpl.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeWriterImpl.java Fri Oct 14 11:11:19 2016 -0700
@@ -290,8 +290,8 @@
*/
@Override
public void addAnnotationTypeDescription(Content annotationInfoTree) {
- if(!configuration.nocomment) {
- if (!utils.getBody(annotationType).isEmpty()) {
+ if (!configuration.nocomment) {
+ if (!utils.getFullBody(annotationType).isEmpty()) {
addInlineComment(annotationType, annotationInfoTree);
}
}
@@ -302,7 +302,7 @@
*/
@Override
public void addAnnotationTypeTagInfo(Content annotationInfoTree) {
- if(!configuration.nocomment) {
+ if (!configuration.nocomment) {
addTagsInfo(annotationType, annotationInfoTree);
}
}
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriterImpl.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriterImpl.java Fri Oct 14 11:11:19 2016 -0700
@@ -353,7 +353,7 @@
public void addClassDescription(Content classInfoTree) {
if(!configuration.nocomment) {
// generate documentation for the class.
- if (!utils.getBody(typeElement).isEmpty()) {
+ if (!utils.getFullBody(typeElement).isEmpty()) {
addInlineComment(typeElement, classInfoTree);
}
}
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/FieldWriterImpl.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/FieldWriterImpl.java Fri Oct 14 11:11:19 2016 -0700
@@ -146,7 +146,7 @@
*/
@Override
public void addComments(VariableElement field, Content fieldTree) {
- if (!utils.getBody(field).isEmpty()) {
+ if (!utils.getFullBody(field).isEmpty()) {
writer.addInlineComment(field, fieldTree);
}
}
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java Fri Oct 14 11:11:19 2016 -0700
@@ -1704,7 +1704,7 @@
* @param htmltree the documentation tree to which the inline comments will be added
*/
public void addInlineComment(Element element, Content htmltree) {
- addCommentTags(element, utils.getBody(element), false, false, htmltree);
+ addCommentTags(element, utils.getFullBody(element), false, false, htmltree);
}
/**
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlSerialFieldWriter.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlSerialFieldWriter.java Fri Oct 14 11:11:19 2016 -0700
@@ -159,7 +159,7 @@
* @param contentTree the tree to which the deprecated info will be added
*/
public void addMemberDescription(VariableElement field, Content contentTree) {
- if (!utils.getBody(field).isEmpty()) {
+ if (!utils.getFullBody(field).isEmpty()) {
writer.addInlineComment(field, contentTree);
}
List<? extends DocTree> tags = utils.getBlockTags(field, DocTree.Kind.SERIAL);
@@ -210,7 +210,7 @@
*/
public boolean shouldPrintOverview(VariableElement field) {
if (!configuration.nocomment) {
- if(!utils.getBody(field).isEmpty() ||
+ if(!utils.getFullBody(field).isEmpty() ||
writer.hasSerializationOverviewTags(field))
return true;
}
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/MethodWriterImpl.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/MethodWriterImpl.java Fri Oct 14 11:11:19 2016 -0700
@@ -172,7 +172,7 @@
@Override
public void addComments(TypeMirror holderType, ExecutableElement method, Content methodDocTree) {
TypeElement holder = utils.asTypeElement(holderType);
- if (!utils.getBody(method).isEmpty()) {
+ if (!utils.getFullBody(method).isEmpty()) {
if (holder.equals(typeElement) ||
!(utils.isPublic(holder) ||
utils.isLinkable(holder))) {
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexWriter.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexWriter.java Fri Oct 14 11:11:19 2016 -0700
@@ -182,7 +182,7 @@
@Override
protected void addOverviewHeader(Content body) {
addConfigurationTitle(body);
- if (!utils.getBody(configuration.overviewElement).isEmpty()) {
+ if (!utils.getFullBody(configuration.overviewElement).isEmpty()) {
HtmlTree subTitleDiv = new HtmlTree(HtmlTag.DIV);
subTitleDiv.addStyle(HtmlStyle.subTitle);
addSummaryComment(configuration.overviewElement, subTitleDiv);
@@ -212,7 +212,7 @@
* be added
*/
protected void addOverviewComment(Content htmltree) {
- if (!utils.getBody(configuration.overviewElement).isEmpty()) {
+ if (!utils.getFullBody(configuration.overviewElement).isEmpty()) {
htmltree.addContent(getMarkerAnchor(SectionName.OVERVIEW_DESCRIPTION));
addInlineComment(configuration.overviewElement, htmltree);
}
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java Fri Oct 14 11:11:19 2016 -0700
@@ -484,7 +484,7 @@
* {@inheritDoc}
*/
public void addModuleDescription(Content moduleContentTree) {
- if (!utils.getBody(mdle).isEmpty()) {
+ if (!utils.getFullBody(mdle).isEmpty()) {
Content tree = configuration.allowTag(HtmlTag.SECTION) ? HtmlTree.SECTION() : moduleContentTree;
tree.addContent(HtmlConstants.START_OF_MODULE_DESCRIPTION);
tree.addContent(getMarkerAnchor(SectionName.MODULE_DESCRIPTION));
@@ -528,7 +528,7 @@
li.addContent(Contents.SPACE);
Content ulNav = HtmlTree.UL(HtmlStyle.subNavList, li);
Content liNav = new HtmlTree(HtmlTag.LI);
- liNav.addContent(!utils.getBody(mdle).isEmpty() && !configuration.nocomment
+ liNav.addContent(!utils.getFullBody(mdle).isEmpty() && !configuration.nocomment
? getHyperLink(SectionName.MODULE_DESCRIPTION, contents.navModuleDescription)
: contents.navModuleDescription);
addNavGap(liNav);
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexWriter.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexWriter.java Fri Oct 14 11:11:19 2016 -0700
@@ -175,7 +175,7 @@
@Override
protected void addOverviewHeader(Content body) {
addConfigurationTitle(body);
- if (!utils.getBody(configuration.overviewElement).isEmpty()) {
+ if (!utils.getFullBody(configuration.overviewElement).isEmpty()) {
HtmlTree subTitleDiv = new HtmlTree(HtmlTag.DIV);
subTitleDiv.addStyle(HtmlStyle.subTitle);
addSummaryComment(configuration.overviewElement, subTitleDiv);
@@ -205,7 +205,7 @@
* be added
*/
protected void addOverviewComment(Content htmltree) {
- if (!utils.getBody(configuration.overviewElement).isEmpty()) {
+ if (!utils.getFullBody(configuration.overviewElement).isEmpty()) {
htmltree.addContent(getMarkerAnchor(SectionName.OVERVIEW_DESCRIPTION));
addInlineComment(configuration.overviewElement, htmltree);
}
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageWriterImpl.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageWriterImpl.java Fri Oct 14 11:11:19 2016 -0700
@@ -143,19 +143,6 @@
Content packageHead = new StringContent(heading);
tHeading.addContent(packageHead);
div.addContent(tHeading);
- addDeprecationInfo(div);
- if (!utils.getBody(packageElement).isEmpty() && !configuration.nocomment) {
- HtmlTree docSummaryDiv = new HtmlTree(HtmlTag.DIV);
- docSummaryDiv.addStyle(HtmlStyle.docSummary);
- addSummaryComment(packageElement, docSummaryDiv);
- div.addContent(docSummaryDiv);
- Content space = Contents.SPACE;
- Content descLink = getHyperLink(getDocLink(
- SectionName.PACKAGE_DESCRIPTION),
- contents.descriptionLabel, "", "");
- Content descPara = new HtmlTree(HtmlTag.P, contents.seeLabel, space, descLink);
- div.addContent(descPara);
- }
if (configuration.allowTag(HtmlTag.MAIN)) {
mainTree.addContent(div);
} else {
@@ -259,19 +246,9 @@
@Override
public void addPackageDescription(Content packageContentTree) {
if (!utils.getBody(packageElement).isEmpty()) {
- packageContentTree.addContent(
- getMarkerAnchor(SectionName.PACKAGE_DESCRIPTION));
- Content h2Content = new StringContent(
- configuration.getText("doclet.Package_Description",
- packageElement.isUnnamed() ? "" : utils.getPackageName(packageElement)));
- Content heading = HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, true, h2Content);
- if (configuration.allowTag(HtmlTag.SECTION)) {
- sectionTree.addContent(heading);
- addInlineComment(packageElement, sectionTree);
- } else {
- packageContentTree.addContent(heading);
- addInlineComment(packageElement, packageContentTree);
- }
+ Content tree = configuration.allowTag(HtmlTag.SECTION) ? sectionTree : packageContentTree;
+ addDeprecationInfo(tree);
+ addInlineComment(packageElement, tree);
}
}
@@ -284,6 +261,9 @@
? sectionTree
: packageContentTree;
addTagsInfo(packageElement, htmlTree);
+ if (configuration.allowTag(HtmlTag.SECTION)) {
+ packageContentTree.addContent(sectionTree);
+ }
}
/**
@@ -292,7 +272,6 @@
@Override
public void addPackageContent(Content contentTree, Content packageContentTree) {
if (configuration.allowTag(HtmlTag.MAIN)) {
- packageContentTree.addContent(sectionTree);
mainTree.addContent(packageContentTree);
contentTree.addContent(mainTree);
} else {
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PropertyWriterImpl.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PropertyWriterImpl.java Fri Oct 14 11:11:19 2016 -0700
@@ -147,7 +147,7 @@
@Override
public void addComments(ExecutableElement property, Content propertyDocTree) {
TypeElement holder = (TypeElement)property.getEnclosingElement();
- if (!utils.getBody(property).isEmpty()) {
+ if (!utils.getFullBody(property).isEmpty()) {
if (holder.equals(typeElement) ||
(!utils.isPublic(holder) || utils.isLinkable(holder))) {
writer.addInlineComment(property, propertyDocTree);
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/standard.properties Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/standard.properties Fri Oct 14 11:11:19 2016 -0700
@@ -97,7 +97,6 @@
doclet.deprecated_annotation_type_members=deprecated annotation type elements
doclet.Generated_Docs_Untitled=Generated Documentation (Untitled)
doclet.Other_Packages=Other Packages
-doclet.Package_Description=Package {0} Description
doclet.Description=Description
doclet.Specified_By=Specified by:
doclet.in_interface=in interface
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/AbstractDoclet.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/AbstractDoclet.java Fri Oct 14 11:11:19 2016 -0700
@@ -40,7 +40,6 @@
import jdk.javadoc.internal.doclets.toolkit.builders.BuilderFactory;
import jdk.javadoc.internal.doclets.toolkit.util.ClassTree;
import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
-import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
import jdk.javadoc.internal.doclets.toolkit.util.InternalException;
import jdk.javadoc.internal.doclets.toolkit.util.PackageListWriter;
import jdk.javadoc.internal.doclets.toolkit.util.ResourceIOException;
@@ -112,8 +111,6 @@
return false;
}
- boolean dumpOnError = false; // set true to always show stack traces
-
try {
startGeneration(docEnv);
return true;
@@ -128,16 +125,16 @@
messages.error("doclet.exception.write.file",
e.fileName.getPath(), e.getCause());
}
- dumpStack(dumpOnError, e);
+ dumpStack(configuration.dumpOnError, e);
} catch (ResourceIOException e) {
messages.error("doclet.exception.read.resource",
e.resource.getPath(), e.getCause());
- dumpStack(dumpOnError, e);
+ dumpStack(configuration.dumpOnError, e);
} catch (SimpleDocletException e) {
configuration.reporter.print(ERROR, e.getMessage());
- dumpStack(dumpOnError, e);
+ dumpStack(configuration.dumpOnError, e);
} catch (InternalException e) {
configuration.reporter.print(ERROR, e.getMessage());
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/CommentUtils.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/CommentUtils.java Fri Oct 14 11:11:19 2016 -0700
@@ -108,27 +108,22 @@
Utils utils = config.utils;
String klassName = utils.getSimpleName(utils.getEnclosingTypeElement(e));
- List<DocTree> fs = new ArrayList<>();
- fs.add(treeFactory.newTextTree(config.getText("doclet.enum_values_doc.firstsentence")));
-
- List<DocTree> body = new ArrayList<>();
- body.add(treeFactory.newTextTree(config.getText("doclet.enum_values_doc.body", klassName)));
+ List<DocTree> fullBody = new ArrayList<>();
+ fullBody.add(treeFactory.newTextTree(config.getText("doclet.enum_values_doc.fullbody", klassName)));
List<DocTree> descriptions = new ArrayList<>();
descriptions.add(treeFactory.newTextTree(config.getText("doclet.enum_values_doc.return")));
List<DocTree> tags = new ArrayList<>();
tags.add(treeFactory.newReturnTree(descriptions));
- DocCommentTree docTree = treeFactory.newDocCommentTree(fs, body, tags);
+ DocCommentTree docTree = treeFactory.newDocCommentTree(fullBody, tags);
dcTreesMap.put(e, new DocCommentDuo(null, docTree));
}
public void setEnumValueOfTree(Configuration config, Element e) {
- List<DocTree> fs = new ArrayList<>();
- fs.add(treeFactory.newTextTree(config.getText("doclet.enum_valueof_doc.firstsentence")));
- List<DocTree> body = new ArrayList<>();
- body.add(treeFactory.newTextTree(config.getText("doclet.enum_valueof_doc.body")));
+ List<DocTree> fullBody = new ArrayList<>();
+ fullBody.add(treeFactory.newTextTree(config.getText("doclet.enum_valueof_doc.fullbody")));
List<DocTree> tags = new ArrayList<>();
@@ -156,7 +151,7 @@
ref = treeFactory.newReferenceTree("java.lang.NullPointerException");
tags.add(treeFactory.newThrowsTree(ref, throwsDescs));
- DocCommentTree docTree = treeFactory.newDocCommentTree(fs, body, tags);
+ DocCommentTree docTree = treeFactory.newDocCommentTree(fullBody, tags);
dcTreesMap.put(e, new DocCommentDuo(null, docTree));
}
@@ -190,11 +185,9 @@
return new DocCommentDuo(treePath.getTreePath(), dcTree);
}
- public void setDocCommentTree(Element element, List<DocTree> firstSentence,
- List<DocTree> bodyTags, List<DocTree> blockTags, Utils utils) {
- DocCommentTree docTree = treeFactory.newDocCommentTree(firstSentence,
- bodyTags,
- blockTags);
+ public void setDocCommentTree(Element element, List<DocTree> fullBody,
+ List<DocTree> blockTags, Utils utils) {
+ DocCommentTree docTree = treeFactory.newDocCommentTree(fullBody, blockTags);
dcTreesMap.put(element, new DocCommentDuo(null, docTree));
// There maybe an entry with the original comments usually null,
// therefore remove that entry if it exists, and allow a new one
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/Configuration.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/Configuration.java Fri Oct 14 11:11:19 2016 -0700
@@ -281,6 +281,8 @@
private String pkglistUrlForLinkOffline;
+ public boolean dumpOnError = false;
+
private List<GroupContainer> groups;
public abstract Messages getMessages();
@@ -616,6 +618,13 @@
showversion = true;
return true;
}
+ },
+ new Hidden(resources, "--dump-on-error") {
+ @Override
+ public boolean process(String opt, ListIterator<String> args) {
+ dumpOnError = true;
+ return true;
+ }
}
};
Set<Doclet.Option> set = new TreeSet<>();
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/MemberSummaryBuilder.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/MemberSummaryBuilder.java Fri Oct 14 11:11:19 2016 -0700
@@ -386,8 +386,8 @@
CommentUtils cmtutils = configuration.cmtUtils;
final boolean isSetter = isSetter(member);
final boolean isGetter = isGetter(member);
- List<DocTree> firstSentence = new ArrayList<>();
- List<DocTree> bodyTags = new ArrayList<>();
+
+ List<DocTree> fullBody = new ArrayList<>();
List<DocTree> blockTags = new ArrayList<>();
if (isGetter || isSetter) {
//add "[GS]ets the value of the property PROPERTY_NAME."
@@ -395,21 +395,21 @@
String text = MessageFormat.format(
configuration.getText("doclet.PropertySetterWithName"),
utils.propertyName((ExecutableElement)member));
- firstSentence.addAll(cmtutils.makeFirstSentenceTree(text));
+ fullBody.addAll(cmtutils.makeFirstSentenceTree(text));
}
if (isGetter) {
String text = MessageFormat.format(
configuration.getText("doclet.PropertyGetterWithName"),
utils.propertyName((ExecutableElement) member));
- firstSentence.addAll(cmtutils.makeFirstSentenceTree(text));
+ fullBody.addAll(cmtutils.makeFirstSentenceTree(text));
}
List<? extends DocTree> propertyTags = utils.getBlockTags(property, "propertyDescription");
if (propertyTags.isEmpty()) {
- List<? extends DocTree> comment = utils.getBody(property);
+ List<? extends DocTree> comment = utils.getFullBody(property);
blockTags.addAll(cmtutils.makePropertyDescriptionTree(comment));
}
} else {
- firstSentence.addAll(utils.getBody(property));
+ fullBody.addAll(utils.getFullBody(property));
}
// copy certain tags
@@ -452,7 +452,7 @@
blockTags.add(cmtutils.makeSeeTree(sb.toString(), setter));
}
}
- cmtutils.setDocCommentTree(member, firstSentence, bodyTags, blockTags, utils);
+ cmtutils.setDocCommentTree(member, fullBody, blockTags, utils);
}
/**
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/MethodBuilder.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/MethodBuilder.java Fri Oct 14 11:11:19 2016 -0700
@@ -210,7 +210,7 @@
public void buildMethodComments(XMLNode node, Content methodDocTree) {
if (!configuration.nocomment) {
ExecutableElement method = currentMethod;
- if (utils.getBody(currentMethod).isEmpty()) {
+ if (utils.getFullBody(currentMethod).isEmpty()) {
DocFinder.Output docs = DocFinder.search(configuration,
new DocFinder.Input(utils, currentMethod));
if (docs.inlineTags != null && !docs.inlineTags.isEmpty())
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/doclet.xml Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/doclet.xml Fri Oct 14 11:11:19 2016 -0700
@@ -42,6 +42,8 @@
<PackageDoc>
<Content>
+ <PackageDescription/>
+ <PackageTags/>
<Summary>
<InterfaceSummary/>
<ClassSummary/>
@@ -50,8 +52,6 @@
<ErrorSummary/>
<AnnotationTypeSummary/>
</Summary>
- <PackageDescription/>
- <PackageTags/>
</Content>
</PackageDoc>
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/doclets.properties Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/doclets.properties Fri Oct 14 11:11:19 2016 -0700
@@ -207,22 +207,21 @@
doclet.0_and_1={0} and {1}
#Documentation for Enums
-doclet.enum_values_doc.firstsentence=\
-Returns an array containing the constants of this enum type, in\n\
-the order they are declared.
-doclet.enum_values_doc.body=\ This method may be used to iterate\n\
+doclet.enum_values_doc.fullbody=\
+ Returns an array containing the constants of this enum type, in\n\
+ the order they are declared. This method may be used to iterate\n\
over the constants as follows:\n\
<pre>\n\
for ({0} c : {0}.values())\n\
System.out.println(c);\n\
</pre>
+
doclet.enum_values_doc.return=\
an array containing the constants of this enum type, in the order they are declared
-doclet.enum_valueof_doc.firstsentence=\
-Returns the enum constant of this type with the specified name.
-doclet.enum_valueof_doc.body=\n\
-The string must match <i>exactly</i> an identifier used to declare an\n\
+doclet.enum_valueof_doc.fullbody=\
+ Returns the enum constant of this type with the specified name.\n\
+ The string must match <i>exactly</i> an identifier used to declare an\n\
enum constant in this type. (Extraneous whitespace characters are \n\
not permitted.)
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/TagletWriter.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/TagletWriter.java Fri Oct 14 11:11:19 2016 -0700
@@ -221,7 +221,7 @@
List<Taglet> taglets, TagletWriter writer, Content output) {
Utils utils = writer.configuration().utils;
tagletManager.checkTags(utils, element, utils.getBlockTags(element), false);
- tagletManager.checkTags(utils, element, utils.getBody(element), true);
+ tagletManager.checkTags(utils, element, utils.getFullBody(element), true);
for (Taglet taglet : taglets) {
if (utils.isTypeElement(element) && taglet instanceof ParamTaglet) {
//The type parameters are documented in a special section away
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/DocFinder.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/DocFinder.java Fri Oct 14 11:11:19 2016 -0700
@@ -251,7 +251,7 @@
//We want overall documentation.
output.inlineTags = input.isFirstSentence
? utils.getFirstSentenceTrees(input.element)
- : utils.getBody(input.element);
+ : utils.getFullBody(input.element);
output.holder = input.element;
} else {
input.taglet.inherit(input, output);
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java Fri Oct 14 11:11:19 2016 -0700
@@ -1453,7 +1453,7 @@
public void setEnumDocumentation(TypeElement elem) {
for (Element e : getMethods(elem)) {
ExecutableElement ee = (ExecutableElement)e;
- if (!getBody(e).isEmpty()) // if already set skip it please
+ if (!getFullBody(e).isEmpty()) // ignore if already set
continue;
if (ee.getSimpleName().contentEquals("values") && ee.getParameters().isEmpty()) {
configuration.cmtUtils.setEnumValuesTree(configuration, e);
@@ -2939,12 +2939,18 @@
return dcTree;
}
+ public List<? extends DocTree> getFullBody(Element element) {
+ DocCommentTree docCommentTree = getDocCommentTree(element);
+ return (docCommentTree == null)
+ ? Collections.emptyList()
+ : docCommentTree.getFullBody();
+ }
+
public List<? extends DocTree> getBody(Element element) {
DocCommentTree docCommentTree = getDocCommentTree(element);
- if (docCommentTree == null)
- return Collections.emptyList();
-
- return docCommentTree.getFullBody();
+ return (docCommentTree == null)
+ ? Collections.emptyList()
+ : docCommentTree.getFullBody();
}
public List<? extends DocTree> getDeprecatedTrees(Element element) {
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ElementsTable.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ElementsTable.java Fri Oct 14 11:11:19 2016 -0700
@@ -75,6 +75,7 @@
import jdk.javadoc.doclet.DocletEnvironment.ModuleMode;
import static com.sun.tools.javac.code.Scope.LookupKind.NON_RECURSIVE;
+import static jdk.javadoc.internal.tool.Main.Result.*;
import static jdk.javadoc.internal.tool.JavadocTool.isValidClassName;
/**
@@ -158,6 +159,7 @@
private final Location location;
private final Modules modules;
private final Map<ToolOption, Object> opts;
+ private final Messager messager;
private final Map<String, Entry> entries = new LinkedHashMap<>();
@@ -201,6 +203,8 @@
this.fm = toolEnv.fileManager;
this.modules = Modules.instance(context);
this.opts = opts;
+ this.messager = Messager.instance0(context);
+
this.location = modules.multiModuleMode
? StandardLocation.MODULE_SOURCE_PATH
: toolEnv.fileManager.hasLocation(StandardLocation.SOURCE_PATH)
@@ -339,9 +343,9 @@
* This is a terminal operation, thus no further modifications
* are allowed to the specified data sets.
*
- * @throws IOException if an error occurs
+ * @throws ToolException if an error occurs
*/
- void analyze() throws IOException {
+ void analyze() throws ToolException {
// compute the specified element, by expanding module dependencies
computeSpecifiedModules();
@@ -354,7 +358,6 @@
// compute the packages belonging to all the specified modules
Set<PackageElement> expandedModulePackages = computeModulePackages();
initializeIncludedSets(expandedModulePackages);
-
}
ElementsTable classTrees(com.sun.tools.javac.util.List<JCCompilationUnit> classTrees) {
@@ -363,16 +366,17 @@
}
@SuppressWarnings("unchecked")
- ElementsTable scanSpecifiedItems() throws IOException {
+ ElementsTable scanSpecifiedItems() throws ToolException {
// scan modules specified on the command line
List<String> moduleNames = (List<String>) opts.computeIfAbsent(ToolOption.MODULE,
s -> Collections.EMPTY_LIST);
List<String> mlist = new ArrayList<>();
for (String m : moduleNames) {
- Location moduleLoc = fm.getModuleLocation(location, m);
+ Location moduleLoc = getModuleLocation(location, m);
if (moduleLoc == null) {
- toolEnv.error("main.module_not_found", m);
+ String text = messager.getText("main.module_not_found", m);
+ throw new ToolException(CMDERR, text);
} else {
mlist.add(m);
ModuleSymbol msym = syms.enterModule(names.fromString(m));
@@ -457,7 +461,7 @@
}
@SuppressWarnings("unchecked")
- private void computeSubpackages() throws IOException {
+ private void computeSubpackages() throws ToolException {
((List<String>) opts.computeIfAbsent(ToolOption.EXCLUDE, v -> Collections.EMPTY_LIST))
.stream()
.map((packageName) -> new ModulePackage(packageName))
@@ -469,7 +473,14 @@
for (ModulePackage modpkg : subPackages) {
Location packageLocn = getLocation(modpkg);
- for (JavaFileObject fo : fm.list(packageLocn, modpkg.packageName, sourceKinds, true)) {
+ Iterable<JavaFileObject> list = null;
+ try {
+ list = fm.list(packageLocn, modpkg.packageName, sourceKinds, true);
+ } catch (IOException ioe) {
+ String text = messager.getText("main.file.manager.list", modpkg.packageName);
+ throw new ToolException(SYSERR, text, ioe);
+ }
+ for (JavaFileObject fo : list) {
String binaryName = fm.inferBinaryName(packageLocn, fo);
String pn = getPackageName(binaryName);
String simpleName = getSimpleName(binaryName);
@@ -554,22 +565,28 @@
specifiedModuleElements = Collections.unmodifiableSet(result);
}
- private Set<PackageElement> getAllModulePackages(ModuleElement mdle) throws IOException {
+ private Set<PackageElement> getAllModulePackages(ModuleElement mdle) throws ToolException {
Set<PackageElement> result = new HashSet<>();
- ModuleSymbol msym = (ModuleSymbol)mdle;
- Location msymloc = fm.getModuleLocation(location, msym.name.toString());
- for (JavaFileObject fo : fm.list(msymloc, "", sourceKinds, true)) {
- if (fo.getName().endsWith("module-info.java"))
- continue;
- String binaryName = fm.inferBinaryName(msymloc, fo);
- String pn = getPackageName(binaryName);
- PackageSymbol psym = syms.enterPackage(msym, names.fromString(pn));
- result.add((PackageElement)psym);
+ ModuleSymbol msym = (ModuleSymbol) mdle;
+ Location msymloc = getModuleLocation(location, msym.name.toString());
+ try {
+ for (JavaFileObject fo : fm.list(msymloc, "", sourceKinds, true)) {
+ if (fo.getName().endsWith("module-info.java"))
+ continue;
+ String binaryName = fm.inferBinaryName(msymloc, fo);
+ String pn = getPackageName(binaryName);
+ PackageSymbol psym = syms.enterPackage(msym, names.fromString(pn));
+ result.add((PackageElement) psym);
+ }
+
+ } catch (IOException ioe) {
+ String text = messager.getText("main.file.manager.list", msymloc.getName());
+ throw new ToolException(SYSERR, text, ioe);
}
return result;
}
- private Set<PackageElement> computeModulePackages() throws IOException {
+ private Set<PackageElement> computeModulePackages() throws ToolException {
final AccessKind accessValue = accessFilter.getAccessValue(ElementKind.PACKAGE);
final boolean documentAllModulePackages = (accessValue == AccessKind.PACKAGE ||
accessValue == AccessKind.PRIVATE);
@@ -662,10 +679,10 @@
includedTypeElements = Collections.unmodifiableSet(iclasses);
}
- /**
+ /*
* Computes the included packages and freezes the specified packages list.
*/
- private void computeSpecifiedPackages() throws IOException {
+ private void computeSpecifiedPackages() throws ToolException {
computeSubpackages();
@@ -683,7 +700,7 @@
if (pkg != null) {
packlist.add(pkg);
} else {
- toolEnv.warning("main.package_not_found", modpkg.toString());
+ messager.printWarningUsingKey("main.package_not_found", modpkg.toString());
}
});
specifiedPackageElements = Collections.unmodifiableSet(packlist);
@@ -693,7 +710,7 @@
* Adds all classes as well as inner classes, to the specified
* list.
*/
- private void computeSpecifiedTypes() {
+ private void computeSpecifiedTypes() throws ToolException {
Set<TypeElement> classes = new LinkedHashSet<>();
classDecList.stream().filter((def) -> (shouldDocument(def.sym))).forEach((def) -> {
TypeElement te = (TypeElement) def.sym;
@@ -701,24 +718,28 @@
addAllClasses(classes, te, true);
}
});
- classArgList.forEach((className) -> {
+ for (String className : classArgList) {
TypeElement te = toolEnv.loadClass(className);
if (te == null) {
- toolEnv.error("javadoc.class_not_found", className);
+ String text = messager.getText("javadoc.class_not_found", className);
+ throw new ToolException(CMDERR, text);
} else {
addAllClasses(classes, te, true);
}
- });
+ }
specifiedTypeElements = Collections.unmodifiableSet(classes);
}
private void addFilesForParser(Collection<JavaFileObject> result,
- Collection<ModulePackage> collection, boolean recurse) throws IOException {
+ Collection<ModulePackage> collection,
+ boolean recurse) throws ToolException {
for (ModulePackage modpkg : collection) {
toolEnv.notice("main.Loading_source_files_for_package", modpkg.toString());
List<JavaFileObject> files = getFiles(modpkg, recurse);
if (files.isEmpty()) {
- toolEnv.error("main.no_source_files_for_package", modpkg.toString());
+ String text = messager.getText("main.no_source_files_for_package",
+ modpkg.toString());
+ throw new ToolException(CMDERR, text);
} else {
result.addAll(files);
}
@@ -732,7 +753,7 @@
* @return a list of java file objects
* @throws IOException if an error occurs
*/
- List<JavaFileObject> getFilesToParse() throws IOException {
+ List<JavaFileObject> getFilesToParse() throws ToolException {
List<JavaFileObject> result = new ArrayList<>();
addFilesForParser(result, cmdLinePackages, false);
addFilesForParser(result, subPackages, true);
@@ -744,9 +765,10 @@
*
* @param packageName the specified package
* @return the set of file objects for the specified package
- * @throws IOException if an error occurs while accessing the files
+ * @throws ToolException if an error occurs while accessing the files
*/
- private List<JavaFileObject> getFiles(ModulePackage modpkg, boolean recurse) throws IOException {
+ private List<JavaFileObject> getFiles(ModulePackage modpkg,
+ boolean recurse) throws ToolException {
Entry e = getEntry(modpkg);
// The files may have been found as a side effect of searching for subpackages
if (e.files != null) {
@@ -759,12 +781,18 @@
return Collections.emptyList();
}
String pname = modpkg.packageName;
- for (JavaFileObject fo : fm.list(packageLocn, pname, sourceKinds, recurse)) {
- String binaryName = fm.inferBinaryName(packageLocn, fo);
- String simpleName = getSimpleName(binaryName);
- if (isValidClassName(simpleName)) {
- lb.append(fo);
+
+ try {
+ for (JavaFileObject fo : fm.list(packageLocn, pname, sourceKinds, recurse)) {
+ String binaryName = fm.inferBinaryName(packageLocn, fo);
+ String simpleName = getSimpleName(binaryName);
+ if (isValidClassName(simpleName)) {
+ lb.append(fo);
+ }
}
+ } catch (IOException ioe) {
+ String text = messager.getText("main.file.manager.list", pname);
+ throw new ToolException(SYSERR, text, ioe);
}
return lb.toList();
@@ -781,20 +809,30 @@
return null;
}
- private Location getLocation(ModulePackage modpkg) throws IOException {
+ private Location getLocation(ModulePackage modpkg) throws ToolException {
if (location != StandardLocation.MODULE_SOURCE_PATH) {
return location;
}
if (modpkg.hasModule()) {
- return fm.getModuleLocation(location, modpkg.moduleName);
+ return getModuleLocation(location, modpkg.moduleName);
}
// TODO: handle invalid results better.
ModuleSymbol msym = findModuleOfPackageName(modpkg.packageName);
if (msym == null) {
return null;
}
- return fm.getModuleLocation(location, msym.name.toString());
+ return getModuleLocation(location, msym.name.toString());
+ }
+
+ private Location getModuleLocation(Location location, String msymName)
+ throws ToolException {
+ try {
+ return fm.getModuleLocation(location, msymName);
+ } catch (IOException ioe) {
+ String text = messager.getText("main.doclet_could_not_get_location", msymName);
+ throw new ToolException(ERROR, text, ioe);
+ }
}
private Entry getEntry(String name) {
@@ -841,7 +879,10 @@
}
}
} catch (CompletionFailure e) {
- // quietly ignore completion failures
+ if (e.getMessage() != null)
+ messager.printWarning(e.getMessage());
+ else
+ messager.printWarningUsingKey("main.unexpected.exception", e);
}
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/IllegalOptionValue.java Fri Oct 14 11:11:19 2016 -0700
@@ -0,0 +1,52 @@
+/*
+ * 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.javadoc.internal.tool;
+
+import static jdk.javadoc.internal.tool.Main.Result.CMDERR;
+
+/**
+ * Provides a mechanism for the javadoc tool to indicate an option
+ * decoding issue, arising from command line error.
+ *
+ * <p><b>This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.</b>
+ */
+
+class IllegalOptionValue extends OptionException {
+
+ private static final long serialVersionUID = 0;
+
+ /**
+ * Constructs an object containing a runnable and a message.
+ * @param method a method to display suitable usage text
+ * @param message the detailed message
+ */
+ IllegalOptionValue(Runnable method, String message) {
+ super(CMDERR, method, message);
+ }
+}
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/JavadocTool.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/JavadocTool.java Fri Oct 14 11:11:19 2016 -0700
@@ -27,7 +27,6 @@
import java.io.File;
-import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedHashSet;
@@ -51,6 +50,8 @@
import com.sun.tools.javac.util.Position;
import jdk.javadoc.doclet.DocletEnvironment;
+import static jdk.javadoc.internal.tool.Main.Result.*;
+
/**
* This class could be the main entry point for Javadoc when Javadoc is used as a
* component in a larger software system. It provides operations to
@@ -120,9 +121,10 @@
}
}
- public DocletEnvironment getEnvironment(Map<ToolOption, Object> jdtoolOpts,
- List<String> javaNames,
- Iterable<? extends JavaFileObject> fileObjects) throws IOException {
+ public DocletEnvironment getEnvironment(Map<ToolOption,
+ Object> jdtoolOpts,
+ List<String> javaNames,
+ Iterable<? extends JavaFileObject> fileObjects) throws ToolException {
toolEnv = ToolEnvironment.instance(context);
toolEnv.initialize(jdtoolOpts);
ElementsTable etable = new ElementsTable(context, jdtoolOpts);
@@ -133,10 +135,12 @@
if (etable.xclasses) {
// If -Xclasses is set, the args should be a list of class names
for (String arg: javaNames) {
- if (!isValidPackageName(arg)) // checks
- toolEnv.error("main.illegal_class_name", arg);
+ if (!isValidPackageName(arg)) { // checks
+ String text = messager.getText("main.illegal_class_name", arg);
+ throw new ToolException(CMDERR, text);
+ }
}
- if (messager.nerrors() != 0) {
+ if (messager.hasErrors()) {
return null;
}
etable.setClassArgList(javaNames);
@@ -157,19 +161,23 @@
for (String arg: javaNames) {
if (fm != null && arg.endsWith(".java") && new File(arg).exists()) {
if (new File(arg).getName().equals("module-info.java")) {
- toolEnv.warning("main.file_ignored", arg);
+ messager.printWarningUsingKey("main.file_ignored", arg);
} else {
parse(fm.getJavaFileObjects(arg), classTrees, true);
}
} else if (isValidPackageName(arg)) {
packageNames.add(arg);
} else if (arg.endsWith(".java")) {
- if (fm == null)
- throw new IllegalArgumentException();
- else
- toolEnv.error("main.file_not_found", arg);
+ if (fm == null) {
+ String text = messager.getText("main.assertion.error", "fm == null");
+ throw new ToolException(ABNORMAL, text);
+ } else {
+ String text = messager.getText("main.file_not_found", arg);
+ throw new ToolException(ERROR, text);
+ }
} else {
- toolEnv.error("main.illegal_package_name", arg);
+ String text = messager.getText("main.illegal_package_name", arg);
+ throw new ToolException(CMDERR, text);
}
}
@@ -185,7 +193,7 @@
parse(etable.getFilesToParse(), packageTrees, false);
modules.enter(packageTrees.toList(), null);
- if (messager.nerrors() != 0) {
+ if (messager.hasErrors()) {
return null;
}
@@ -197,10 +205,19 @@
enterDone = true;
etable.analyze();
} catch (CompletionFailure cf) {
- toolEnv.printError(cf.getMessage());
- } catch (Abort ex) {}
+ throw new ToolException(ABNORMAL, cf.getMessage(), cf);
+ } catch (Abort abort) {
+ if (messager.hasErrors()) {
+ // presumably a message has been emitted, keep silent
+ throw new ToolException(ABNORMAL, "", abort);
+ } else {
+ String text = messager.getText("main.internal.error");
+ Throwable t = abort.getCause() == null ? abort : abort.getCause();
+ throw new ToolException(ABNORMAL, text, t);
+ }
+ }
- if (messager.nerrors() != 0)
+ if (messager.hasErrors())
return null;
toolEnv.docEnv = new DocEnvImpl(toolEnv, etable);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/JavadocToolProvider.java Fri Oct 14 11:11:19 2016 -0700
@@ -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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact 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.javadoc.internal.tool;
+
+import java.io.PrintWriter;
+import java.util.spi.ToolProvider;
+
+/**
+ * An implementation of the {@link java.util.spi.ToolProvider ToolProvider} SPI,
+ * providing access to JDK documentation tool, javadoc.
+ *
+ * @since 9
+ */
+// This is currently a stand-alone top-level class so that it can easily be excluded
+// from interims builds of javadoc, used while building JDK.
+public class JavadocToolProvider implements ToolProvider {
+ public String name() {
+ return "javadoc";
+ }
+
+ public int run(PrintWriter out, PrintWriter err, String... args) {
+ return Main.execute(args, out, err);
+ }
+}
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Main.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Main.java Fri Oct 14 11:11:19 2016 -0700
@@ -60,18 +60,61 @@
*/
public static int execute(String... args) {
Start jdoc = new Start();
- return jdoc.begin(args);
+ return jdoc.begin(args).exitCode;
+ }
+
+ /**
+ * Programmatic interface.
+ *
+ * @param writer a stream for all output
+ * @param args The command line parameters.
+ * @return The return code.
+ */
+ public static int execute(String[] args, PrintWriter writer) {
+ Start jdoc = new Start(writer, writer);
+ return jdoc.begin(args).exitCode;
}
/**
* Programmatic interface.
*
- * @param writer PrintWriter to receive notice messages.
+ * @param outWriter a stream for expected output
+ * @param errWriter a stream for diagnostic output
* @param args The command line parameters.
* @return The return code.
*/
- public static int execute(String[] args, PrintWriter writer) {
- Start jdoc = new Start(writer);
- return jdoc.begin(args);
+ public static int execute(String[] args, PrintWriter outWriter, PrintWriter errWriter) {
+ Start jdoc = new Start(outWriter, errWriter);
+ return jdoc.begin(args).exitCode;
+ }
+
+ public static enum Result {
+ /** completed with no errors */
+ OK(0),
+ /** Completed with reported errors */
+ ERROR(1),
+ /** Bad command-line arguments */
+ CMDERR(2),
+ /** System error or resource exhaustion */
+ SYSERR(3),
+ /** Terminated abnormally */
+ ABNORMAL(4);
+
+ private static final long serialVersionUID = 1L;
+
+ Result(int exitCode) {
+ this.exitCode = exitCode;
+ }
+
+ public boolean isOK() {
+ return (exitCode == 0);
+ }
+
+ public final int exitCode;
+
+ @Override
+ public String toString() {
+ return name() + '(' + exitCode + ')';
+ }
}
}
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Messager.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Messager.java Fri Oct 14 11:11:19 2016 -0700
@@ -48,10 +48,8 @@
/**
* Utility for integrating with javadoc tools and for localization.
- * Handle Resources. Access to error and warning counts.
- * Message formatting.
- * <br>
- * Also provides implementation for DocErrorReporter.
+ * Handle resources, access to error and warning counts and
+ * message formatting.
*
* <p><b>This is NOT part of any supported API.
* If you write code that depends on this, you do so at your own risk.
@@ -139,10 +137,6 @@
}
}
- public static class ExitJavadoc extends Error {
- private static final long serialVersionUID = 0;
- }
-
final String programName;
private Locale locale;
@@ -165,8 +159,8 @@
/**
* Constructor
* @param programName Name of the program (for error messages).
- * @param stdOut Stream for notices etc.
- * @param stdErr Stream for errors and warnings
+ * @param outWriter Stream for notices etc.
+ * @param errWriter Stream for errors and warnings
*/
@SuppressWarnings("deprecation")
public Messager(Context context, String programName, PrintWriter outWriter, PrintWriter errWriter) {
@@ -240,7 +234,7 @@
report(DiagnosticType.ERROR, prefix, msg);
return;
}
- incrementErrorCount(prefix, msg);
+ printError(prefix, msg);
}
public void printError(Element e, String msg) {
@@ -249,10 +243,15 @@
report(DiagnosticType.ERROR, prefix, msg);
return;
}
- incrementErrorCount(prefix, msg);
+ printError(prefix, msg);
}
- private void incrementErrorCount(String prefix, String msg) {
+ public void printErrorUsingKey(String key, Object... args) {
+ printError((Element)null, getText(key, args));
+ }
+
+ // print the error and increment count
+ private void printError(String prefix, String msg) {
if (nerrors < MaxErrors) {
PrintWriter errWriter = getWriter(WriterKind.ERROR);
printRawLines(errWriter, prefix + ": " + getText("javadoc.error") + " - " + msg);
@@ -272,13 +271,21 @@
printWarning((DocTreePath)null, msg);
}
+ public void printWarningUsingKey(String key, Object... args) {
+ printWarning((Element)null, getText(key, args));
+ }
+
+ public void printWarning(Element e, String key, Object... args) {
+ printWarning(getText(key, args));
+ }
+
public void printWarning(DocTreePath path, String msg) {
String prefix = getDiagSource(path);
if (diagListener != null) {
report(DiagnosticType.WARNING, prefix, msg);
return;
}
- incrementWarningCount(prefix, msg);
+ printWarning(prefix, msg);
}
public void printWarning(Element e, String msg) {
@@ -287,10 +294,11 @@
report(DiagnosticType.WARNING, prefix, msg);
return;
}
- incrementWarningCount(prefix, msg);
+ printWarning(prefix, msg);
}
- private void incrementWarningCount(String prefix, String msg) {
+ // print the warning and increment count
+ private void printWarning(String prefix, String msg) {
if (nwarnings < MaxWarnings) {
PrintWriter warnWriter = getWriter(WriterKind.WARNING);
printRawLines(warnWriter, prefix + ": " + getText("javadoc.warning") + " - " + msg);
@@ -342,50 +350,6 @@
}
/**
- * Print error message, increment error count.
- *
- * @param key selects message from resource
- */
- public void error(Element e, String key, Object... args) {
- printError(e, getText(key, args));
- }
-
- /**
- * Print error message, increment error count.
- *
- * @param key selects message from resource
- */
- public void error(DocTreePath path, String key, Object... args) {
- printError(path, getText(key, args));
- }
-
- public void error(String key, Object... args) {
- printError((Element)null, getText(key, args));
- }
-
- public void warning(String key, Object... args) {
- printWarning((Element)null, getText(key, args));
- }
-
- /**
- * Print warning message, increment warning count.
- *
- * @param key selects message from resource
- */
- public void warning(Element e, String key, Object... args) {
- printWarning(e, getText(key, args));
- }
-
- /**
- * Print warning message, increment warning count.
- *
- * @param key selects message from resource
- */
- public void warning(DocTreePath path, String key, Object... args) {
- printWarning(path, getText(key, args));
- }
-
- /**
* Print a message.
*
* @param key selects message from resource
@@ -395,21 +359,23 @@
}
/**
- * Return total number of errors, including those recorded
- * in the compilation log.
+ * Returns true if errors have been recorded.
*/
- public int nerrors() { return nerrors; }
+ public boolean hasErrors() {
+ return nerrors != 0;
+ }
/**
- * Return total number of warnings, including those recorded
- * in the compilation log.
+ * Returns true if warnings have been recorded.
*/
- public int nwarnings() { return nwarnings; }
+ public boolean hasWarnings() {
+ return nwarnings != 0;
+ }
/**
* Print exit message.
*/
- public void exitNotice() {
+ public void printErrorWarningCounts() {
if (nerrors > 0) {
notice((nerrors > 1) ? "main.errors" : "main.error",
"" + nerrors);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/OptionException.java Fri Oct 14 11:11:19 2016 -0700
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.javadoc.internal.tool;
+
+import jdk.javadoc.internal.tool.Main.Result;
+
+/**
+ * Provides a general mechanism for the javadoc tool to indicate an option
+ * decoding issue.
+ *
+ * <p><b>This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.</b>
+ */
+
+class OptionException extends Exception {
+
+ private static final long serialVersionUID = 0;
+
+ public final Result result;
+ public final String message;
+ public final Runnable m;
+
+ /**
+ * Constructs an object with a result, runnable and a message
+ * to be printed out by the catcher. The runnable can be invoked
+ * by the catcher to display the usage text.
+ * @param result the exit code
+ * @param method the method to invoke
+ * @param message the detailed message
+ */
+ public OptionException(Result result, Runnable method, String message) {
+ this.result = result;
+ this.m = method;
+ this.message = message;
+ if (result == null || result.isOK() || method == null || message == null) {
+ throw new AssertionError("result == null || result.isOK() || " +
+ "method == null || message == null");
+ }
+ }
+
+ /**
+ * Constructs an object with a result and a runnable.
+ * The runnable can be invoked by the catcher to display the usage text.
+ * @param result the exit code
+ * @param method the method to invoke
+ */
+ public OptionException(Result result, Runnable method) {
+ this.result = result;
+ this.m = method;
+ this.message = null;
+ if (result == null || method == null) {
+ throw new AssertionError("result == null || method == null");
+ }
+ }
+}
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Start.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Start.java Fri Oct 14 11:11:19 2016 -0700
@@ -26,7 +26,6 @@
package jdk.javadoc.internal.tool;
import java.io.File;
-import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.PrintWriter;
import java.nio.file.Path;
@@ -65,11 +64,12 @@
import jdk.javadoc.doclet.Doclet;
import jdk.javadoc.doclet.Doclet.Option;
import jdk.javadoc.doclet.DocletEnvironment;
-import jdk.javadoc.internal.doclets.toolkit.Resources;
+import jdk.javadoc.internal.tool.Main.Result;
import static javax.tools.DocumentationTool.Location.*;
import static com.sun.tools.javac.main.Option.*;
+import static jdk.javadoc.internal.tool.Main.Result.*;
/**
* Main program of Javadoc.
@@ -119,20 +119,21 @@
private JavaFileManager fileManager;
Start() {
- this(null, null, null, null, null);
+ this(null, null, null, null, null, null);
}
- Start(PrintWriter writer) {
- this(null, null, writer, null, null);
+ Start(PrintWriter outWriter, PrintWriter errWriter) {
+ this(null, null, outWriter, errWriter, null, null);
}
- Start(Context context, String programName, PrintWriter writer,
+ Start(Context context, String programName,
+ PrintWriter outWriter, PrintWriter errWriter,
String docletName, ClassLoader classLoader) {
this.context = context == null ? new Context() : context;
String pname = programName == null ? ProgramName : programName;
- this.messager = writer == null
+ this.messager = (outWriter == null && errWriter == null)
? new Messager(this.context, pname)
- : new Messager(this.context, pname, writer, writer);
+ : new Messager(this.context, pname, outWriter, errWriter);
this.docletName = docletName;
this.classLoader = classLoader;
this.docletClass = null;
@@ -169,41 +170,28 @@
*/
@Override
void usage() {
- usage(true);
- }
-
- void usage(boolean exit) {
- usage("main.usage", "-help", "main.usage.foot");
-
- if (exit)
- throw new Messager.ExitJavadoc();
+ usage("main.usage", OptionKind.STANDARD, "main.usage.foot");
}
@Override
void Xusage() {
- Xusage(true);
+ usage("main.Xusage", OptionKind.EXTENDED, "main.Xusage.foot");
}
- void Xusage(boolean exit) {
- usage("main.Xusage", "-X", "main.Xusage.foot");
-
- if (exit)
- throw new Messager.ExitJavadoc();
- }
-
- private void usage(String header, String option, String footer) {
- messager.notice(header);
- showToolOptions(option.equals("-X") ? OptionKind.EXTENDED : OptionKind.STANDARD);
+ private void usage(String headerKey, OptionKind kind, String footerKey) {
+ messager.notice(headerKey);
+ showToolOptions(kind);
// let doclet print usage information
if (docletClass != null) {
String name = doclet.getName();
messager.notice("main.doclet.usage.header", name);
- showDocletOptions(option.equals("-X") ? Option.Kind.EXTENDED : Option.Kind.STANDARD);
+ showDocletOptions(kind == OptionKind.EXTENDED
+ ? Option.Kind.EXTENDED
+ : Option.Kind.STANDARD);
}
-
- if (footer != null)
- messager.notice(footer);
+ if (footerKey != null)
+ messager.notice(footerKey);
}
void showToolOptions(OptionKind kind) {
@@ -325,25 +313,23 @@
* of class loader creation, needed to detect the doclet/taglet class variants.
*/
@SuppressWarnings("deprecation")
- int begin(String... argv) {
+ Result begin(String... argv) {
// Preprocess @file arguments
try {
argv = CommandLine.parse(argv);
- } catch (FileNotFoundException e) {
- messager.error("main.cant.read", e.getMessage());
- throw new Messager.ExitJavadoc();
} catch (IOException e) {
- e.printStackTrace(System.err);
- throw new Messager.ExitJavadoc();
+ error("main.cant.read", e.getMessage());
+ return ERROR;
}
if (argv.length > 0 && "-Xold".equals(argv[0])) {
- messager.warning("main.legacy_api");
+ warn("main.legacy_api");
String[] nargv = Arrays.copyOfRange(argv, 1, argv.length);
- return com.sun.tools.javadoc.Main.execute(nargv);
+ return com.sun.tools.javadoc.Main.execute(nargv) == 0
+ ? OK
+ : ERROR;
}
- boolean ok = begin(Arrays.asList(argv), Collections.<JavaFileObject> emptySet());
- return ok ? 0 : 1;
+ return begin(Arrays.asList(argv), Collections.<JavaFileObject> emptySet());
}
// Called by 199 API.
@@ -355,11 +341,11 @@
for (String opt: options)
opts.add(opt);
- return begin(opts, fileObjects);
+ return begin(opts, fileObjects).isOK();
}
@SuppressWarnings("deprecation")
- private boolean begin(List<String> options, Iterable<? extends JavaFileObject> fileObjects) {
+ private Result begin(List<String> options, Iterable<? extends JavaFileObject> fileObjects) {
fileManager = context.get(JavaFileManager.class);
if (fileManager == null) {
JavacFileManager.preRegister(context);
@@ -368,8 +354,28 @@
((BaseFileManager) fileManager).autoClose = true;
}
}
+
// locale, doclet and maybe taglet, needs to be determined first
- docletClass = preProcess(fileManager, options);
+ try {
+ docletClass = preprocess(fileManager, options);
+ } catch (ToolException te) {
+ if (!te.result.isOK()) {
+ if (te.message != null) {
+ messager.printError(te.message);
+ }
+ Throwable t = te.getCause();
+ dumpStack(t == null ? te : t);
+ }
+ return te.result;
+ } catch (OptionException oe) {
+ if (oe.message != null) {
+ messager.printError(oe.message);
+ }
+ oe.m.run();
+ Throwable t = oe.getCause();
+ dumpStack(t == null ? oe : t);
+ return oe.result;
+ }
if (jdk.javadoc.doclet.Doclet.class.isAssignableFrom(docletClass)) {
// no need to dispatch to old, safe to init now
initMessager();
@@ -378,43 +384,62 @@
Object o = docletClass.getConstructor().newInstance();
doclet = (Doclet) o;
} catch (ReflectiveOperationException exc) {
- exc.printStackTrace();
- if (!apiMode) {
- error("main.could_not_instantiate_class", docletClass);
- throw new Messager.ExitJavadoc();
+ if (apiMode) {
+ throw new ClientCodeException(exc);
}
- throw new ClientCodeException(exc);
+ error("main.could_not_instantiate_class", docletClass);
+ return ERROR;
}
} else {
- if (this.apiMode) {
+ if (apiMode) {
com.sun.tools.javadoc.main.Start ostart
= new com.sun.tools.javadoc.main.Start(context);
- return ostart.begin(docletClass, options, fileObjects);
+ return ostart.begin(docletClass, options, fileObjects)
+ ? OK
+ : ERROR;
}
warn("main.legacy_api");
String[] array = options.toArray(new String[options.size()]);
- return com.sun.tools.javadoc.Main.execute(array) == 0;
+ return com.sun.tools.javadoc.Main.execute(array) == 0
+ ? OK
+ : ERROR;
}
- boolean failed = false;
+ Result result = OK;
try {
- failed = !parseAndExecute(options, fileObjects);
- } catch (Messager.ExitJavadoc exc) {
- // ignore, we just exit this way
+ result = parseAndExecute(options, fileObjects)
+ ? OK
+ : ERROR;
+ } catch (OptionException toe) {
+ if (toe.message != null)
+ messager.printError(toe.message);
+
+ toe.m.run();
+ Throwable t = toe.getCause();
+ dumpStack(t == null ? toe : t);
+ return toe.result;
+ } catch (ToolException exc) {
+ if (exc.message != null) {
+ messager.printError(exc.message);
+ }
+ Throwable t = exc.getCause();
+ if (result == ABNORMAL) {
+ reportInternalError(t == null ? exc : t);
+ } else {
+ dumpStack(t == null ? exc : t);
+ }
+ return exc.result;
} catch (OutOfMemoryError ee) {
- messager.error("main.out.of.memory");
- failed = true;
+ error("main.out.of.memory");
+ result = SYSERR;
+ dumpStack(ee);
} catch (ClientCodeException e) {
// simply rethrow these exceptions, to be caught and handled by JavadocTaskImpl
throw e;
- } catch (Error ee) {
- ee.printStackTrace(System.err);
- messager.error("main.fatal.error");
- failed = true;
- } catch (Exception ee) {
- ee.printStackTrace(System.err);
- messager.error("main.fatal.exception");
- failed = true;
+ } catch (Error | Exception ee) {
+ error("main.fatal.error", ee);
+ reportInternalError(ee);
+ result = ABNORMAL;
} finally {
if (fileManager != null
&& fileManager instanceof BaseFileManager
@@ -423,17 +448,34 @@
fileManager.close();
} catch (IOException ignore) {}
}
- boolean haveErrorWarnings = messager.nerrors() > 0 ||
- (rejectWarnings && messager.nwarnings() > 0);
- if (failed && !haveErrorWarnings) {
+ boolean haveErrorWarnings = messager.hasErrors()
+ || (rejectWarnings && messager.hasWarnings());
+ if (!result.isOK() && !haveErrorWarnings) {
// the doclet failed, but nothing reported, flag it!.
- messager.error("main.unknown.error");
+ error("main.unknown.error");
}
- failed |= haveErrorWarnings;
- messager.exitNotice();
+ if (haveErrorWarnings && result.isOK()) {
+ result = ERROR;
+ }
+ messager.printErrorWarningCounts();
messager.flush();
}
- return !failed;
+ return result;
+ }
+
+ private void reportInternalError(Throwable t) {
+ messager.printErrorUsingKey("doclet.internal.report.bug");
+ dumpStack(true, t);
+ }
+
+ private void dumpStack(Throwable t) {
+ dumpStack(false, t);
+ }
+
+ private void dumpStack(boolean enabled, Throwable t) {
+ if (t != null && (enabled || dumpOnError)) {
+ t.printStackTrace(System.err);
+ }
}
/**
@@ -441,7 +483,7 @@
*/
@SuppressWarnings("unchecked")
private boolean parseAndExecute(List<String> argList,
- Iterable<? extends JavaFileObject> fileObjects) throws IOException {
+ Iterable<? extends JavaFileObject> fileObjects) throws ToolException, OptionException {
long tm = System.currentTimeMillis();
List<String> javaNames = new ArrayList<>();
@@ -462,17 +504,21 @@
if (platformString != null) {
if (compOpts.isSet("-source")) {
- usageError("main.release.bootclasspath.conflict", "-source");
+ String text = messager.getText("main.release.bootclasspath.conflict", "-source");
+ throw new ToolException(CMDERR, text);
}
if (fileManagerOpts.containsKey(BOOT_CLASS_PATH)) {
- usageError("main.release.bootclasspath.conflict", BOOT_CLASS_PATH.getPrimaryName());
+ String text = messager.getText("main.release.bootclasspath.conflict",
+ BOOT_CLASS_PATH.getPrimaryName());
+ throw new ToolException(CMDERR, text);
}
PlatformDescription platformDescription =
PlatformUtils.lookupPlatformDescription(platformString);
if (platformDescription == null) {
- usageError("main.unsupported.release.version", platformString);
+ String text = messager.getText("main.unsupported.release.version", platformString);
+ throw new IllegalArgumentException(text);
}
compOpts.put(SOURCE, platformDescription.getSourceVersion());
@@ -484,10 +530,15 @@
if (platformCP != null) {
if (fileManager instanceof StandardJavaFileManager) {
StandardJavaFileManager sfm = (StandardJavaFileManager) fileManager;
-
- sfm.setLocationFromPaths(StandardLocation.PLATFORM_CLASS_PATH, platformCP);
+ try {
+ sfm.setLocationFromPaths(StandardLocation.PLATFORM_CLASS_PATH, platformCP);
+ } catch (IOException ioe) {
+ throw new ToolException(SYSERR, ioe.getMessage(), ioe);
+ }
} else {
- usageError("main.release.not.standard.file.manager", platformString);
+ String text = messager.getText("main.release.not.standard.file.manager",
+ platformString);
+ throw new ToolException(ABNORMAL, text);
}
}
}
@@ -501,7 +552,8 @@
s -> Collections.EMPTY_LIST);
if (subpkgs.isEmpty()) {
if (javaNames.isEmpty() && isEmpty(fileObjects)) {
- usageError("main.No_modules_packages_or_classes_specified");
+ String text = messager.getText("main.No_modules_packages_or_classes_specified");
+ throw new ToolException(CMDERR, text);
}
}
}
@@ -534,7 +586,8 @@
}
Set<Doclet.Option> docletOptions = null;
- int handleDocletOptions(int idx, List<String> args, boolean isToolOption) {
+ int handleDocletOptions(int idx, List<String> args, boolean isToolOption)
+ throws OptionException {
if (docletOptions == null) {
docletOptions = doclet.getSupportedOptions();
}
@@ -548,24 +601,25 @@
argBase = arg;
argVal = null;
}
-
+ String text = null;
for (Doclet.Option opt : docletOptions) {
if (opt.matches(argBase)) {
if (argVal != null) {
switch (opt.getArgumentCount()) {
case 0:
- usageError("main.unnecessary_arg_provided", argBase);
- break;
+ text = messager.getText("main.unnecessary_arg_provided", argBase);
+ throw new OptionException(ERROR, this::usage, text);
case 1:
opt.process(arg, Arrays.asList(argVal).listIterator());
break;
default:
- usageError("main.only_one_argument_with_equals", argBase);
- break;
+ text = messager.getText("main.only_one_argument_with_equals", argBase);
+ throw new OptionException(ERROR, this::usage, text);
}
} else {
if (args.size() - idx -1 < opt.getArgumentCount()) {
- usageError("main.requires_argument", arg);
+ text = messager.getText("main.requires_argument", arg);
+ throw new OptionException(ERROR, this::usage, text);
}
opt.process(arg, args.listIterator(idx + 1));
idx += opt.getArgumentCount();
@@ -574,12 +628,15 @@
}
}
// check if arg is accepted by the tool before emitting error
- if (!isToolOption)
- usageError("main.invalid_flag", arg);
+ if (!isToolOption) {
+ text = messager.getText("main.invalid_flag", arg);
+ throw new OptionException(ERROR, this::usage, text);
+ }
return idx;
}
- private Class<?> preProcess(JavaFileManager jfm, List<String> argv) {
+ private Class<?> preprocess(JavaFileManager jfm,
+ List<String> argv) throws ToolException, OptionException {
// doclet specifying arguments
String userDocletPath = null;
String userDocletName = null;
@@ -592,19 +649,31 @@
// Step 1: loop through the args, set locale early on, if found.
for (int i = 0 ; i < argv.size() ; i++) {
String arg = argv.get(i);
- if (arg.equals(ToolOption.LOCALE.primaryName)) {
+ if (arg.equals(ToolOption.DUMPONERROR.primaryName)) {
+ dumpOnError = true;
+ } else if (arg.equals(ToolOption.LOCALE.primaryName)) {
checkOneArg(argv, i++);
String lname = argv.get(i);
locale = getLocale(lname);
} else if (arg.equals(ToolOption.DOCLET.primaryName)) {
checkOneArg(argv, i++);
if (userDocletName != null) {
- usageError("main.more_than_one_doclet_specified_0_and_1",
+ if (apiMode) {
+ throw new IllegalArgumentException("More than one doclet specified (" +
+ userDocletName + " and " + argv.get(i) + ").");
+ }
+ String text = messager.getText("main.more_than_one_doclet_specified_0_and_1",
userDocletName, argv.get(i));
+ throw new ToolException(CMDERR, text);
}
if (docletName != null) {
- usageError("main.more_than_one_doclet_specified_0_and_1",
+ if (apiMode) {
+ throw new IllegalArgumentException("More than one doclet specified (" +
+ docletName + " and " + argv.get(i) + ").");
+ }
+ String text = messager.getText("main.more_than_one_doclet_specified_0_and_1",
docletName, argv.get(i));
+ throw new ToolException(CMDERR, text);
}
userDocletName = argv.get(i);
} else if (arg.equals(ToolOption.DOCLETPATH.primaryName)) {
@@ -643,23 +712,37 @@
try {
((StandardJavaFileManager)fileManager).setLocation(DOCLET_PATH, paths);
} catch (IOException ioe) {
- error("main.doclet_could_not_set_location", paths);
- throw new Messager.ExitJavadoc();
+ if (apiMode) {
+ throw new IllegalArgumentException("Could not set location for " +
+ userDocletPath, ioe);
+ }
+ String text = messager.getText("main.doclet_could_not_set_location",
+ userDocletPath);
+ throw new ToolException(CMDERR, text, ioe);
}
}
cl = fileManager.getClassLoader(DOCLET_PATH);
if (cl == null) {
// despite doclet specified on cmdline no classloader found!
- error("main.doclet_no_classloader_found", userDocletName);
- throw new Messager.ExitJavadoc();
+ if (apiMode) {
+ throw new IllegalArgumentException("Could not obtain classloader to load "
+ + userDocletPath);
+ }
+ String text = messager.getText("main.doclet_no_classloader_found",
+ userDocletName);
+ throw new ToolException(CMDERR, text);
}
}
try {
Class<?> klass = cl.loadClass(userDocletName);
return klass;
} catch (ClassNotFoundException cnfe) {
- error("main.doclet_class_not_found", userDocletName);
- throw new Messager.ExitJavadoc();
+ if (apiMode) {
+ throw new IllegalArgumentException("Cannot find doclet class " + userDocletName,
+ cnfe);
+ }
+ String text = messager.getText("main.doclet_class_not_found", userDocletName);
+ throw new ToolException(CMDERR, text, cnfe);
}
}
@@ -668,8 +751,11 @@
try {
return Class.forName(docletName, true, getClass().getClassLoader());
} catch (ClassNotFoundException cnfe) {
- error("main.doclet_class_not_found", userDocletName);
- throw new Messager.ExitJavadoc();
+ if (apiMode) {
+ throw new IllegalArgumentException("Cannot find doclet class " + userDocletName);
+ }
+ String text = messager.getText("main.doclet_class_not_found", userDocletName);
+ throw new ToolException(CMDERR, text, cnfe);
}
}
@@ -689,20 +775,20 @@
* nature to take its own course.
*/
@SuppressWarnings("deprecation")
- private boolean hasOldTaglet(List<String> tagletNames, List<File> tagletPaths) {
+ private boolean hasOldTaglet(List<String> tagletNames, List<File> tagletPaths) throws ToolException {
if (!fileManager.hasLocation(TAGLET_PATH)) {
try {
((StandardJavaFileManager) fileManager).setLocation(TAGLET_PATH, tagletPaths);
} catch (IOException ioe) {
- error("main.doclet_could_not_set_location", tagletPaths);
- throw new Messager.ExitJavadoc();
+ String text = messager.getText("main.doclet_could_not_set_location", tagletPaths);
+ throw new ToolException(CMDERR, text, ioe);
}
}
ClassLoader cl = fileManager.getClassLoader(TAGLET_PATH);
if (cl == null) {
// no classloader found!
- error("main.doclet_no_classloader_found", tagletNames.get(0));
- throw new Messager.ExitJavadoc();
+ String text = messager.getText("main.doclet_no_classloader_found", tagletNames.get(0));
+ throw new ToolException(CMDERR, text);
}
for (String tagletName : tagletNames) {
try {
@@ -711,14 +797,15 @@
return true;
}
} catch (ClassNotFoundException cnfe) {
- error("main.doclet_class_not_found", tagletName);
- throw new Messager.ExitJavadoc();
+ String text = messager.getText("main.doclet_class_not_found", tagletName);
+ throw new ToolException(CMDERR, text, cnfe);
}
}
return false;
}
- private void parseArgs(List<String> args, List<String> javaNames) {
+ private void parseArgs(List<String> args, List<String> javaNames) throws ToolException,
+ OptionException {
for (int i = 0 ; i < args.size() ; i++) {
String arg = args.get(i);
ToolOption o = ToolOption.get(arg);
@@ -726,7 +813,6 @@
// handle a doclet argument that may be needed however
// don't increment the index, and allow the tool to consume args
handleDocletOptions(i, args, true);
-
if (o.hasArg) {
if (arg.startsWith("--") && arg.contains("=")) {
o.process(this, arg.substring(arg.indexOf('=') + 1));
@@ -762,24 +848,19 @@
* Check the one arg option.
* Error and exit if one argument is not provided.
*/
- private void checkOneArg(List<String> args, int index) {
+ private void checkOneArg(List<String> args, int index) throws OptionException {
if ((index + 1) >= args.size() || args.get(index + 1).startsWith("-d")) {
- usageError("main.requires_argument", args.get(index));
+ String text = messager.getText("main.requires_argument", args.get(index));
+ throw new OptionException(CMDERR, this::usage, text);
}
}
- @Override
- void usageError(String key, Object... args) {
- error(key, args);
- usage(true);
- }
-
void error(String key, Object... args) {
- messager.error(key, args);
+ messager.printErrorUsingKey(key, args);
}
void warn(String key, Object... args) {
- messager.warning(key, args);
+ messager.printWarningUsingKey(key, args);
}
/**
@@ -787,7 +868,7 @@
* else return null and if locale option is not used
* then return default locale.
*/
- private Locale getLocale(String localeName) {
+ private Locale getLocale(String localeName) throws ToolException {
Locale userlocale = null;
if (localeName == null || localeName.isEmpty()) {
return Locale.getDefault();
@@ -803,8 +884,8 @@
if (seconduscore > 0) {
if (seconduscore != firstuscore + 3
|| localeName.length() <= seconduscore + 1) {
- usageError("main.malformed_locale_name", localeName);
- return null;
+ String text = messager.getText("main.malformed_locale_name", localeName);
+ throw new ToolException(CMDERR, text);
}
country = localeName.substring(firstuscore + 1,
seconduscore);
@@ -812,19 +893,19 @@
} else if (localeName.length() == firstuscore + 3) {
country = localeName.substring(firstuscore + 1);
} else {
- usageError("main.malformed_locale_name", localeName);
- return null;
+ String text = messager.getText("main.malformed_locale_name", localeName);
+ throw new ToolException(CMDERR, text);
}
} else if (firstuscore == -1 && localeName.length() == 2) {
language = localeName;
} else {
- usageError("main.malformed_locale_name", localeName);
- return null;
+ String text = messager.getText("main.malformed_locale_name", localeName);
+ throw new ToolException(CMDERR, text);
}
userlocale = searchLocale(language, country, variant);
if (userlocale == null) {
- usageError("main.illegal_locale_name", localeName);
- return null;
+ String text = messager.getText("main.illegal_locale_name", localeName);
+ throw new ToolException(CMDERR, text);
} else {
return userlocale;
}
@@ -860,4 +941,9 @@
}
};
}
+
+ @Override
+ String getLocalizedMessage(String msg, Object... args) {
+ return messager.getText(msg, args);
+ }
}
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ToolEnvironment.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ToolEnvironment.java Fri Oct 14 11:11:19 2016 -0700
@@ -87,7 +87,7 @@
return instance;
}
- private final Messager messager;
+ final Messager messager;
/** Predefined symbols known to the compiler. */
public final Symtab syms;
@@ -204,182 +204,8 @@
return path != null;
}
- //---------------- print forwarders ----------------//
-
- // ERRORS
/**
- * Print error message, increment error count.
- *
- * @param msg message to print.
- */
- public void printError(String msg) {
- messager.printError(msg);
- }
-
-// /**
-// * Print error message, increment error count.
-// *
-// * @param key selects message from resource
-// */
-// public void error(Element element, String key) {
-// if (element == null)
-// messager.error(key);
-// else
-// messager.error(element, key);
-// }
-//
-// public void error(String prefix, String key) {
-// printError(prefix + ":" + messager.getText(key));
-// }
-//
-// /**
-// * Print error message, increment error count.
-// *
-// * @param path the path to the source
-// * @param key selects message from resource
-// */
-// public void error(DocTreePath path, String key) {
-// messager.error(path, key);
-// }
-//
-// /**
-// * Print error message, increment error count.
-// *
-// * @param path the path to the source
-// * @param msg message to print.
-// */
-// public void printError(DocTreePath path, String msg) {
-// messager.printError(path, msg);
-// }
-//
-// /**
-// * Print error message, increment error count.
-// * @param e the target element
-// * @param msg message to print.
-// */
-// public void printError(Element e, String msg) {
-// messager.printError(e, msg);
-// }
-
- /**
- * Print error message, increment error count.
- * @param key selects message from resource
- * @param args replacement arguments
- */
- public void error(String key, String... args) {
- error(null, key, args);
- }
-
- /**
- * Print error message, increment error count.
- *
- * @param element the source element
- * @param key selects message from resource
- * @param args replacement arguments
- */
- public void error(Element element, String key, String... args) {
- if (element == null)
- messager.error(key, (Object[]) args);
- else
- messager.error(element, key, (Object[]) args);
- }
-
- // WARNINGS
-
-// /**
-// * Print warning message, increment warning count.
-// *
-// * @param msg message to print.
-// */
-// public void printWarning(String msg) {
-// messager.printWarning(msg);
-// }
-//
-// public void warning(String key) {
-// warning((Element)null, key);
-// }
-
- public void warning(String key, String... args) {
- warning((Element)null, key, args);
- }
-
-// /**
-// * Print warning message, increment warning count.
-// *
-// * @param element the source element
-// * @param key selects message from resource
-// */
-// public void warning(Element element, String key) {
-// if (element == null)
-// messager.warning(key);
-// else
-// messager.warning(element, key);
-// }
-//
-// /**
-// * Print warning message, increment warning count.
-// *
-// * @param path the path to the source
-// * @param msg message to print.
-// */
-// public void printWarning(DocTreePath path, String msg) {
-// messager.printWarning(path, msg);
-// }
-//
-// /**
-// * Print warning message, increment warning count.
-// *
-// * @param e the source element
-// * @param msg message to print.
-// */
-// public void printWarning(Element e, String msg) {
-// messager.printWarning(e, msg);
-// }
-
- /**
- * Print warning message, increment warning count.
- *
- * @param e the source element
- * @param key selects message from resource
- * @param args the replace arguments
- */
- public void warning(Element e, String key, String... args) {
- if (e == null)
- messager.warning(key, (Object[]) args);
- else
- messager.warning(e, key, (Object[]) args);
- }
-
-// Note: no longer required
-// /**
-// * Print a message.
-// *
-// * @param msg message to print.
-// */
-// public void printNotice(String msg) {
-// if (quiet) {
-// return;
-// }
-// messager.printNotice(msg);
-// }
-
-// Note: no longer required
-// /**
-// * Print a message.
-// *
-// * @param e the source element
-// * @param msg message to print.
-// */
-// public void printNotice(Element e, String msg) {
-// if (quiet) {
-// return;
-// }
-// messager.printNotice(e, msg);
-// }
-
- // NOTICES
- /**
- * Print a message.
+ * Print a notice, iff <em>quiet</em> is not specified.
*
* @param key selects message from resource
*/
@@ -390,22 +216,8 @@
messager.notice(key);
}
-// Note: not used anymore
-// /**
-// * Print a message.
-// *
-// * @param path the path to the source
-// * @param msg message to print.
-// */
-// public void printNotice(DocTreePath path, String msg) {
-// if (quiet) {
-// return;
-// }
-// messager.printNotice(path, msg);
-// }
-
/**
- * Print a message.
+ * Print a notice, iff <em>quiet</em> is not specified.
*
* @param key selects message from resource
* @param a1 first argument
@@ -417,48 +229,6 @@
messager.notice(key, a1);
}
-// Note: not used anymore
-// /**
-// * Print a message.
-// *
-// * @param key selects message from resource
-// * @param a1 first argument
-// * @param a2 second argument
-// */
-// public void notice(String key, String a1, String a2) {
-// if (quiet) {
-// return;
-// }
-// messager.notice(key, a1, a2);
-// }
-//
-
-// Note: not used anymore
-// /**
-// * Print a message.
-// *
-// * @param key selects message from resource
-// * @param a1 first argument
-// * @param a2 second argument
-// * @param a3 third argument
-// */
-// public void notice(String key, String a1, String a2, String a3) {
-// if (quiet) {
-// return;
-// }
-// messager.notice(key, a1, a2, a3);
-// }
-
- /**
- * Exit, reporting errors and warnings.
- */
- public void exit() {
- // Messager should be replaced by a more general
- // compilation environment. This can probably
- // subsume DocEnv as well.
- throw new Messager.ExitJavadoc();
- }
-
TreePath getTreePath(JCCompilationUnit tree) {
TreePath p = treePaths.get(tree);
if (p == null)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ToolException.java Fri Oct 14 11:11:19 2016 -0700
@@ -0,0 +1,79 @@
+/*
+ * 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.javadoc.internal.tool;
+
+import jdk.javadoc.internal.tool.Main.Result;
+
+/**
+ * Provides a mechanism for the javadoc tool to terminate execution.
+ * This class is constructed with a result and an error message,
+ * that can be printed out before termination, a cause can also
+ * be wrapped to supply extended information about the exception.
+ *
+ * <p><b>This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.</b>
+ */
+
+class ToolException extends Exception {
+
+ private static final long serialVersionUID = 0;
+
+ final String message;
+
+ final Result result;
+
+ /**
+ * Constructs an object containing a result and a message to be
+ * printed out by the catcher.
+ * @param result the exit code
+ * @param message the detailed message
+ */
+ ToolException(Result result, String message) {
+ this.message = message;
+ this.result = result;
+ if (result == null || result.isOK() || message == null) {
+ throw new AssertionError("result == null || result.isOK() || message == null");
+ }
+ }
+
+ /**
+ * Constructs an object containing a result, a messages and an underlying cause.
+ * @param result the exit code
+ * @param message the detailed message
+ * @param cause the underlying cause
+ */
+ ToolException(Result result, String message, Throwable cause) {
+ super(cause);
+ this.message = message;
+ this.result = result;
+ if (result == null || message == null || cause == null || result.isOK()) {
+ throw new AssertionError("result == null || message == null"
+ + " || cause == null || result.isOK()");
+ }
+ }
+}
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ToolOption.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ToolOption.java Fri Oct 14 11:11:19 2016 -0700
@@ -40,6 +40,7 @@
import com.sun.tools.javac.util.Options;
import static com.sun.tools.javac.main.Option.OptionKind.*;
+import static jdk.javadoc.internal.tool.Main.Result.*;
/**
* javadoc tool options.
@@ -226,63 +227,63 @@
PACKAGE("-package", STANDARD) {
@Override
- public void process(Helper helper) {
+ public void process(Helper helper) throws OptionException {
helper.setSimpleFilter("package");
}
},
PRIVATE("-private", STANDARD) {
@Override
- public void process(Helper helper) {
+ public void process(Helper helper) throws OptionException {
helper.setSimpleFilter("private");
}
},
PROTECTED("-protected", STANDARD) {
@Override
- public void process(Helper helper) {
+ public void process(Helper helper) throws OptionException {
helper.setSimpleFilter("protected");
}
},
PUBLIC("-public", STANDARD) {
@Override
- public void process(Helper helper) {
+ public void process(Helper helper) throws OptionException {
helper.setSimpleFilter("public");
}
},
SHOW_MEMBERS("--show-members", STANDARD, true) {
@Override
- public void process(Helper helper, String arg) {
+ public void process(Helper helper, String arg) throws OptionException {
helper.setFilter(this, arg);
}
},
SHOW_TYPES("--show-types", STANDARD, true) {
@Override
- public void process(Helper helper, String arg) {
+ public void process(Helper helper, String arg) throws OptionException {
helper.setFilter(this, arg);
}
},
SHOW_PACKAGES("--show-packages", STANDARD, true) {
@Override
- public void process(Helper helper, String arg) {
+ public void process(Helper helper, String arg) throws OptionException {
helper.setShowPackageAccess(SHOW_PACKAGES, arg);
}
},
SHOW_MODULE_CONTENTS("--show-module-contents", STANDARD, true) {
@Override
- public void process(Helper helper, String arg) {
+ public void process(Helper helper, String arg) throws OptionException {
helper.setShowModuleContents(SHOW_MODULE_CONTENTS, arg);
}
},
EXPAND_REQUIRES("--expand-requires", STANDARD, true) {
@Override
- public void process(Helper helper, String arg) {
+ public void process(Helper helper, String arg) throws OptionException {
helper.setExpandRequires(EXPAND_REQUIRES, arg);
}
},
@@ -342,19 +343,26 @@
}
},
+ DUMPONERROR("--dump-on-error", HIDDEN) {
+ @Override
+ public void process(Helper helper) {
+ helper.dumpOnError = true;
+ }
+ },
+
// ----- help options -----
HELP("--help -help", STANDARD) {
@Override
- public void process(Helper helper) {
- helper.usage();
+ public void process(Helper helper) throws OptionException {
+ throw new OptionException(OK, helper::usage);
}
},
X("-X", STANDARD) {
@Override
- public void process(Helper helper) {
- helper.Xusage();
+ public void process(Helper helper) throws OptionException {
+ throw new OptionException(OK, helper::Xusage);
}
},
@@ -395,9 +403,9 @@
this.hasSuffix = lastChar == ':' || lastChar == '=';
}
- void process(Helper helper, String arg) { }
+ void process(Helper helper, String arg) throws OptionException { }
- void process(Helper helper) { }
+ void process(Helper helper) throws OptionException { }
List<String> getNames() {
return names;
@@ -451,6 +459,9 @@
/** Javadoc tool options */
final Map<ToolOption, Object> jdtoolOpts = new EnumMap<>(ToolOption.class);
+ /** dump stack traces for debugging etc.*/
+ boolean dumpOnError = false;
+
/** Set by -breakiterator. */
boolean breakiterator = false;
@@ -470,7 +481,8 @@
abstract void usage();
abstract void Xusage();
- abstract void usageError(String msg, Object... args);
+ abstract String getLocalizedMessage(String msg, Object... args);
+
abstract OptionHelper getOptionHelper();
@SuppressWarnings("unchecked")
@@ -480,7 +492,7 @@
jdtoolOpts.put(opt, list);
}
- void setExpandRequires(ToolOption opt, String arg) {
+ void setExpandRequires(ToolOption opt, String arg) throws OptionException {
switch (arg) {
case "public":
jdtoolOpts.put(opt, AccessKind.PUBLIC);
@@ -489,11 +501,12 @@
jdtoolOpts.put(opt, AccessKind.PRIVATE);
break;
default:
- usageError("main.illegal_option_value", arg);
+ String text = getLocalizedMessage("main.illegal_option_value", arg);
+ throw new IllegalOptionValue(this::usage, text);
}
}
- void setShowModuleContents(ToolOption opt, String arg) {
+ void setShowModuleContents(ToolOption opt, String arg) throws OptionException {
switch (arg) {
case "api":
jdtoolOpts.put(opt, AccessKind.PUBLIC);
@@ -502,11 +515,12 @@
jdtoolOpts.put(opt, AccessKind.PRIVATE);
break;
default:
- usageError("main.illegal_option_value", arg);
+ String text = getLocalizedMessage("main.illegal_option_value", arg);
+ throw new IllegalOptionValue(this::usage, text);
}
}
- void setShowPackageAccess(ToolOption opt, String arg) {
+ void setShowPackageAccess(ToolOption opt, String arg) throws OptionException {
switch (arg) {
case "exported":
jdtoolOpts.put(opt, AccessKind.PUBLIC);
@@ -515,16 +529,17 @@
jdtoolOpts.put(opt, AccessKind.PRIVATE);
break;
default:
- usageError("main.illegal_option_value", arg);
+ String text = getLocalizedMessage("main.illegal_option_value", arg);
+ throw new IllegalOptionValue(this::usage, text);
}
}
- void setFilter(ToolOption opt, String arg) {
+ void setFilter(ToolOption opt, String arg) throws OptionException {
jdtoolOpts.put(opt, getAccessValue(arg));
}
- void setSimpleFilter(String arg) {
+ void setSimpleFilter(String arg) throws OptionException {
handleSimpleOption(arg);
}
@@ -532,7 +547,7 @@
fileManagerOpts.put(opt, arg);
}
- void handleSimpleOption(String arg) {
+ void handleSimpleOption(String arg) throws OptionException {
populateSimpleAccessMap(getAccessValue(arg));
}
@@ -541,7 +556,7 @@
* -private, so on, in addition to the new ones such as
* --show-types:public and so on.
*/
- private AccessKind getAccessValue(String arg) {
+ private AccessKind getAccessValue(String arg) throws OptionException {
int colon = arg.indexOf(':');
String value = (colon > 0)
? arg.substring(colon + 1)
@@ -556,8 +571,8 @@
case "private":
return AccessKind.PRIVATE;
default:
- usageError("main.illegal_option_value", value);
- return null;
+ String text = getLocalizedMessage("main.illegal_option_value", value);
+ throw new IllegalOptionValue(this::usage, text);
}
}
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/resources/javadoc.properties Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/resources/javadoc.properties Fri Oct 14 11:11:19 2016 -0700
@@ -265,13 +265,13 @@
main.Building_tree=Constructing Javadoc information...
main.no_source_files_for_package=No source files for package {0}
main.package_not_found=Package {0} not found
-main.fatal.error=fatal error
-main.fatal.exception=fatal exception
+main.fatal.error=fatal error encountered: {0}
main.out.of.memory=java.lang.OutOfMemoryError: Please increase memory.\n\
For example, on the JDK Classic or HotSpot VMs, add the option -J-Xmx\n\
such as -J-Xmx32m.
main.done_in=[done in {0} ms]
main.more_than_one_doclet_specified_0_and_1=More than one doclet specified ({0} and {1}).
+main.doclet_could_not_get_location=Could not get location for {0}
main.doclet_could_not_set_location=Could not set location for {0}
main.doclet_no_classloader_found=Could not obtain classloader to load {0}
main.could_not_instantiate_class=Could not instantiate class {0}
@@ -286,7 +286,15 @@
main.release.bootclasspath.conflict=option {0} cannot be used together with -release
main.unsupported.release.version=release version {0} not supported
main.release.not.standard.file.manager=-release option specified, but the provided JavaFileManager is not a StandardJavaFileManager.
+main.file.manager.list=FileManager error listing files: "{0}"
+main.assertion.error=assertion failed: "{0}}"
main.unknown.error=an unknown error has occurred
+main.internal.error=an internal error has occurred
+main.unexpected.exception=an unexpected exception was caught: {0}
+doclet.internal.report.bug=\
+Please file a bug against the javadoc tool via the Java bug reporting page\n\
+(http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com)\n\
+for duplicates. Include error messages and the following diagnostic in your report. Thank you.
main.legacy_api=The old Doclet and Taglet APIs in the packages\n\
com.sun.javadoc, com.sun.tools.doclets and their implementations\n\
are planned to be removed in a future JDK release. These\n\
--- a/langtools/src/jdk.javadoc/share/classes/module-info.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/src/jdk.javadoc/share/classes/module-info.java Fri Oct 14 11:11:19 2016 -0700
@@ -41,6 +41,9 @@
exports jdk.javadoc.doclet.taglet;
exports jdk.javadoc.doclets;
+ provides java.util.spi.ToolProvider
+ with jdk.javadoc.internal.tool.JavadocToolProvider;
+
provides javax.tools.DocumentationTool
with jdk.javadoc.internal.api.JavadocTool;
}
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/javap/Main.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/javap/Main.java Fri Oct 14 11:11:19 2016 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,7 @@
package com.sun.tools.javap;
import java.io.PrintWriter;
+import java.util.spi.ToolProvider;
/**
* Main entry point.
@@ -58,4 +59,14 @@
t.setLog(out);
return t.run(args);
}
+
+ public static class JavapToolProvider implements ToolProvider {
+ public String name() {
+ return "javap";
+ }
+
+ public int run(PrintWriter out, PrintWriter err, String... args) {
+ return Main.run(args, out);
+ }
+ }
}
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/Main.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/Main.java Fri Oct 14 11:11:19 2016 -0700
@@ -89,8 +89,6 @@
* - multi-version jar
*/
public class Main implements DiagnosticListener<JavaFileObject> {
- public static Main instance;
-
final PrintStream out;
final PrintStream err;
final List<File> bootClassPath = new ArrayList<>();
@@ -415,13 +413,6 @@
}
/**
- * Prints a usage message to the err stream.
- */
- void usage() {
-
- }
-
- /**
* An enum denoting the mode in which the tool is running.
* Different modes correspond to the different process* methods.
* The exception is UNKNOWN, which indicates that a mode wasn't
@@ -504,7 +495,6 @@
args.remove();
switch (a) {
case "--class-path":
- case "-cp":
classPath.clear();
Arrays.stream(args.remove().split(File.pathSeparator))
.map(File::new)
@@ -699,12 +689,7 @@
* @return true on success, false otherwise
*/
public static boolean call(PrintStream out, PrintStream err, String... args) {
- try {
- instance = new Main(out, err);
- return instance.run(args);
- } finally {
- instance = null;
- }
+ return new Main(out, err).run(args);
}
/**
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/readme.md Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/readme.md Fri Oct 14 11:11:19 2016 -0700
@@ -39,7 +39,6 @@
**OPTIONS**
- -cp PATH
--class-path PATH
Sets the classpath to PATH.
@@ -103,7 +102,7 @@
java.lang.Thread$State
-The `--class-path` and `-cp` options specify the classpath used for
+The `--class-path` option specifies the classpath used for
class searching. The classpath is used for classes named on the
command line, as well as for dependencies of the classes in jar file
or directory hierarchy to be scanned.
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/resources/jdeprscan.properties Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/resources/jdeprscan.properties Fri Oct 14 11:11:19 2016 -0700
@@ -2,7 +2,7 @@
Usage: jdeprscan [options] '{dir|jar|class}' ...\n\
\n\
options:\n\
-\ -cp --class-path PATH\n\
+\ --class-path PATH\n\
\ --for-removal\n\
\ --full-version\n\
\ -h --help\n\
@@ -20,7 +20,7 @@
\n\
\ java.lang.Thread$State\n\
\n\
-The --class-path (-cp) option provides a search path for resolution\n\
+The --class-path option provides a search path for resolution\n\
of dependent classes.\n\
\n\
The --for-removal option limits scanning or listing to APIs that are\n\
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ClassFileReader.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ClassFileReader.java Fri Oct 14 11:11:19 2016 -0700
@@ -63,7 +63,7 @@
* Returns a ClassFileReader instance of a given path.
*/
public static ClassFileReader newInstance(Path path) throws IOException {
- return newInstance(path, JarFile.baseVersion());
+ return newInstance(path, null);
}
/**
@@ -438,7 +438,10 @@
cf = reader.readClassFile(jf, nextEntry);
return true;
} catch (ClassFileError | IOException ex) {
- skippedEntries.add(nextEntry.getName());
+ skippedEntries.add(String.format("%s: %s (%s)",
+ ex.getMessage(),
+ nextEntry.getName(),
+ jf.getName()));
}
nextEntry = nextEntry();
}
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsTask.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsTask.java Fri Oct 14 11:11:19 2016 -0700
@@ -483,6 +483,7 @@
}
if (options.checkModuleDeps != null && !inputArgs.isEmpty()) {
reportError("err.invalid.module.option", inputArgs, "--check");
+ return EXIT_CMDERR;
}
boolean ok = run();
@@ -604,11 +605,12 @@
boolean ok = analyzer.run(options.compileTimeView, options.depth);
// print skipped entries, if any
- analyzer.archives()
- .forEach(archive -> archive.reader()
- .skippedEntries().stream()
- .forEach(name -> warning("warn.skipped.entry",
- name, archive.getPathName())));
+ if (!options.nowarning) {
+ analyzer.archives()
+ .forEach(archive -> archive.reader()
+ .skippedEntries().stream()
+ .forEach(name -> warning("warn.skipped.entry", name)));
+ }
if (options.findJDKInternals && !options.nowarning) {
Map<String, String> jdkInternals = new TreeMap<>();
@@ -676,17 +678,29 @@
}
private boolean genModuleInfo(JdepsConfiguration config) throws IOException {
+ // check if any JAR file contains unnamed package
+ for (String arg : inputArgs) {
+ Optional<String> classInUnnamedPackage =
+ ClassFileReader.newInstance(Paths.get(arg))
+ .entries().stream()
+ .filter(n -> n.endsWith(".class"))
+ .filter(cn -> toPackageName(cn).isEmpty())
+ .findFirst();
+
+ if (classInUnnamedPackage.isPresent()) {
+ if (classInUnnamedPackage.get().equals("module-info.class")) {
+ reportError("err.genmoduleinfo.not.jarfile", arg);
+ } else {
+ reportError("err.genmoduleinfo.unnamed.package", arg);
+ }
+ return false;
+ }
+ }
+
ModuleInfoBuilder builder
= new ModuleInfoBuilder(config, inputArgs, options.genModuleInfo);
boolean ok = builder.run();
- builder.modules().forEach(module -> {
- if (module.packages().contains("")) {
- reportError("ERROR: %s contains unnamed package. " +
- "module-info.java not generated%n", module.getPathName());
- }
- });
-
if (!ok && !options.nowarning) {
log.println("ERROR: missing dependencies");
builder.visitMissingDeps(
@@ -703,6 +717,11 @@
return ok;
}
+ private String toPackageName(String name) {
+ int i = name.lastIndexOf('/');
+ return i > 0 ? name.replace('/', '.').substring(0, i) : "";
+ }
+
/**
* Returns a filter used during dependency analysis
*/
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Main.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Main.java Fri Oct 14 11:11:19 2016 -0700
@@ -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
@@ -26,6 +26,7 @@
package com.sun.tools.jdeps;
import java.io.*;
+import java.util.spi.ToolProvider;
/**
*
@@ -62,4 +63,14 @@
t.setLog(out);
return t.run(args);
}
+
+ public static class JDepsToolProvider implements ToolProvider {
+ public String name() {
+ return "jdeps";
+ }
+
+ public int run(PrintWriter out, PrintWriter err, String... args) {
+ return Main.run(args, out);
+ }
+ }
}
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/resources/jdeps.properties Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/resources/jdeps.properties Fri Oct 14 11:11:19 2016 -0700
@@ -166,7 +166,8 @@
err.missing.arg=no value given for {0}
err.invalid.arg.for.option=invalid argument for option: {0}
err.option.after.class=option must be specified before classes: {0}
-err.genmoduleinfo.not.jarfile={0} not valid for --generate-module-info option (must be non-modular JAR file)
+err.genmoduleinfo.not.jarfile={0} is a modular JAR file that cannot be specified with the --generate-module-info option
+err.genmoduleinfo.unnamed.package={0} contains an unnamed package that is not allowed in a module
err.profiles.msg=No profile information
err.exception.message={0}
err.invalid.path=invalid path: {0}
@@ -180,6 +181,7 @@
err.multirelease.version.associated=class {0} already associated with version {1}, trying to add version {2}
err.multirelease.jar.malformed=malformed multi-release jar, {0}, bad entry: {1}
warn.invalid.arg=Path does not exist: {0}
+warn.skipped.entry={0}
warn.split.package=package {0} defined in {1} {2}
warn.replace.useJDKInternals=\
JDK internal APIs are unsupported and private to JDK implementation that are\n\
--- a/langtools/src/jdk.jdeps/share/classes/module-info.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/src/jdk.jdeps/share/classes/module-info.java Fri Oct 14 11:11:19 2016 -0700
@@ -32,4 +32,10 @@
requires jdk.compiler;
exports com.sun.tools.classfile to
jdk.jlink;
+
+ provides java.util.spi.ToolProvider
+ with com.sun.tools.javap.Main.JavapToolProvider;
+
+ provides java.util.spi.ToolProvider
+ with com.sun.tools.jdeps.Main.JDepsToolProvider;
}
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/CompletenessAnalyzer.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/CompletenessAnalyzer.java Fri Oct 14 11:11:19 2016 -0700
@@ -166,6 +166,7 @@
private static final int XTERM = 0b100000000; // Can terminate (last before EOF)
private static final int XSTART = 0b1000000000; // Boundary, must be XTERM before
private static final int XERRO = 0b10000000000; // Is an error
+ private static final int XBRACESNEEDED = 0b100000000000; // Expect {ANY} LBRACE
/**
* An extension of the compiler's TokenKind which adds our combined/processed
@@ -190,7 +191,7 @@
ERROR(TokenKind.ERROR, XERRO), //
IDENTIFIER(TokenKind.IDENTIFIER, XEXPR1|XDECL1|XTERM), //
UNDERSCORE(TokenKind.UNDERSCORE, XERRO), // _
- CLASS(TokenKind.CLASS, XEXPR|XDECL1), // class decl (MAPPED: DOTCLASS)
+ CLASS(TokenKind.CLASS, XEXPR|XDECL1|XBRACESNEEDED), // class decl (MAPPED: DOTCLASS)
MONKEYS_AT(TokenKind.MONKEYS_AT, XEXPR|XDECL1), // @
IMPORT(TokenKind.IMPORT, XDECL1|XSTART), // import -- consider declaration
SEMI(TokenKind.SEMI, XSTMT1|XTERM|XSTART), // ;
@@ -202,10 +203,10 @@
CUSTOM(TokenKind.CUSTOM, XERRO), // No uses
// Declarations
- ENUM(TokenKind.ENUM, XDECL1), // enum
+ ENUM(TokenKind.ENUM, XDECL1|XBRACESNEEDED), // enum
IMPLEMENTS(TokenKind.IMPLEMENTS, XDECL), // implements
- INTERFACE(TokenKind.INTERFACE, XDECL1), // interface
- THROWS(TokenKind.THROWS, XDECL), // throws
+ INTERFACE(TokenKind.INTERFACE, XDECL1|XBRACESNEEDED), // interface
+ THROWS(TokenKind.THROWS, XDECL|XBRACESNEEDED), // throws
// Primarive type names
BOOLEAN(TokenKind.BOOLEAN, XEXPR1|XDECL1), // boolean
@@ -381,6 +382,10 @@
return (belongs & XSTART) != 0;
}
+ boolean isBracesNeeded() {
+ return (belongs & XBRACESNEEDED) != 0;
+ }
+
/**
* After construction, check that all compiler TokenKind values have
* corresponding TK values.
@@ -641,7 +646,9 @@
public Completeness parseDeclaration() {
boolean isImport = token.kind == IMPORT;
+ boolean isBracesNeeded = false;
while (token.kind.isDeclaration()) {
+ isBracesNeeded |= token.kind.isBracesNeeded();
nextToken();
}
switch (token.kind) {
@@ -666,6 +673,9 @@
case SEMI:
return Completeness.COMPLETE;
case IDENTIFIER:
+ return isBracesNeeded
+ ? Completeness.DEFINITELY_INCOMPLETE
+ : Completeness.COMPLETE_WITH_SEMI;
case BRACKETS:
return Completeness.COMPLETE_WITH_SEMI;
case DOTSTAR:
--- a/langtools/test/Makefile Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/test/Makefile Fri Oct 14 11:11:19 2016 -0700
@@ -157,6 +157,15 @@
-refvmoptions:-Xbootclasspath/p:$(TESTBOOTCLASSPATH)
endif
+ifeq ($(ARCH_DATA_MODEL),32)
+ # Set the GC options for test vms
+ JTREG_GC_OPTION = -vmoption:-XX:+UseSerialGC
+ JTREG_OPTIONS += $(JTREG_GC_OPTION)
+endif
+# Set the max memory for jtreg target test JVMs
+JTREG_TESTVM_MEMORY_OPTION = -vmoption:-Xmx768m
+JTREG_OPTIONS += $(JTREG_TESTVM_MEMORY_OPTION)
+
ifdef EXTRA_JTREG_OPTIONS
JTREG_OPTIONS += $(EXTRA_JTREG_OPTIONS)
endif
@@ -304,8 +313,6 @@
$(JTREG_OUTPUT_DIR)/diff.html $(JTREG_OUTPUT_DIR)/status.txt
@mkdir -p $(JTREG_OUTPUT_DIR)
JT_JAVA=$(JT_JAVA) $(JTREG) \
- -J-Xmx512m \
- -vmoption:-Xmx768m \
-a -ignore:quiet $(if $(JTREG_VERBOSE),-v:$(JTREG_VERBOSE)) \
-r:$(JTREG_OUTPUT_DIR)/JTreport \
-w:$(JTREG_OUTPUT_DIR)/JTwork \
--- a/langtools/test/jdk/javadoc/doclet/T6735320/T6735320.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/test/jdk/javadoc/doclet/T6735320/T6735320.java Fri Oct 14 11:11:19 2016 -0700
@@ -42,7 +42,7 @@
void test() {
javadoc("-d", "out",
testSrc("SerialFieldTest.java"));
- checkExit(Exit.FAILED);
+ checkExit(Exit.ERROR);
checkOutput(Output.STDERR, false,
"OutOfBoundsException");
}
--- a/langtools/test/jdk/javadoc/doclet/dupThrowsTags/TestDupThrowsTags.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/test/jdk/javadoc/doclet/dupThrowsTags/TestDupThrowsTags.java Fri Oct 14 11:11:19 2016 -0700
@@ -42,7 +42,7 @@
void test() {
javadoc("-d", "out",
testSrc("TestDupThrowsTags.java"));
- checkExit(Exit.FAILED);
+ checkExit(Exit.ERROR);
checkOutput("TestDupThrowsTags.html", true,
"Test 1 passes",
--- a/langtools/test/jdk/javadoc/doclet/lib/JavadocTester.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/test/jdk/javadoc/doclet/lib/JavadocTester.java Fri Oct 14 11:11:19 2016 -0700
@@ -327,15 +327,27 @@
outputDirectoryCheck = c;
}
+ /**
+ * The exit codes returned by the javadoc tool.
+ * @see jdk.javadoc.internal.tool.Main.Result
+ */
public enum Exit {
- OK(0),
- FAILED(1);
+ OK(0), // Javadoc completed with no errors.
+ ERROR(1), // Completed but reported errors.
+ CMDERR(2), // Bad command-line arguments
+ SYSERR(3), // System error or resource exhaustion.
+ ABNORMAL(4); // Javadoc terminated abnormally
Exit(int code) {
this.code = code;
}
final int code;
+
+ @Override
+ public String toString() {
+ return name() + '(' + code + ')';
+ }
}
/**
@@ -349,7 +361,7 @@
if (exitCode == expected.code) {
passed("return code " + exitCode);
} else {
- failed("return code " + exitCode +"; expected " + expected.code + " (" + expected + ")");
+ failed("return code " + exitCode +"; expected " + expected);
}
}
--- a/langtools/test/jdk/javadoc/doclet/testBadSourceFile/TestBadSourceFile.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/test/jdk/javadoc/doclet/testBadSourceFile/TestBadSourceFile.java Fri Oct 14 11:11:19 2016 -0700
@@ -50,6 +50,6 @@
javadoc("-Xdoclint:none",
"-d", "out",
testSrc("C2.java"));
- checkExit(Exit.FAILED);
+ checkExit(Exit.ERROR);
}
}
--- a/langtools/test/jdk/javadoc/doclet/testConstantValuesPage/TestConstantValuesPage.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/test/jdk/javadoc/doclet/testConstantValuesPage/TestConstantValuesPage.java Fri Oct 14 11:11:19 2016 -0700
@@ -45,7 +45,7 @@
javadoc("-d", "out",
"-sourcepath", testSrc,
"foo");
- checkExit(Exit.FAILED);
+ checkExit(Exit.CMDERR);
checkOutput(Output.OUT, false,
"constant-values.html...");
--- a/langtools/test/jdk/javadoc/doclet/testDocErrorReporter/TestDocErrorReporter.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/test/jdk/javadoc/doclet/testDocErrorReporter/TestDocErrorReporter.java Fri Oct 14 11:11:19 2016 -0700
@@ -52,6 +52,8 @@
"-encoding", "xyz",
testSrc("TestDocErrorReporter.java"));
- checkExit(Exit.FAILED);
+ checkExit(Exit.ERROR);
+
+ checkOutput(Output.OUT, true, "error: unsupported encoding: xyz");
}
}
--- a/langtools/test/jdk/javadoc/doclet/testHelpOption/TestHelpOption.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/test/jdk/javadoc/doclet/testHelpOption/TestHelpOption.java Fri Oct 14 11:11:19 2016 -0700
@@ -111,7 +111,7 @@
"-helpfile", testSrc("test-help.html"),
"-helpfile", testSrc("test-help.html"),
testSrc("Sample.java"));
- checkExit(Exit.FAILED);
+ checkExit(Exit.ERROR);
}
@Test
@@ -121,7 +121,7 @@
"-helpfile", testSrc("test-help.html"),
"-nohelp",
testSrc("Sample.java"));
- checkExit(Exit.FAILED);
+ checkExit(Exit.ERROR);
}
private void checkOutput(boolean withOption) {
--- a/langtools/test/jdk/javadoc/doclet/testHtmlTag/TestHtmlTag.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/test/jdk/javadoc/doclet/testHtmlTag/TestHtmlTag.java Fri Oct 14 11:11:19 2016 -0700
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 6786682
+ * @bug 6786682 4649116
* @summary This test verifies the use of lang attribute by <HTML>.
* @author Bhavesh Patel
* @library ../lib
@@ -106,7 +106,7 @@
checkExit(Exit.OK);
checkOutput("pkg3/package-summary.html", true,
- "<h2 title=\"Package pkg3 Description\">Package pkg3 Description</h2>\n"
+ "<div class=\"contentContainer\">\n"
+ "<div class=\"block\"><p>This is the first line."
+ " Note the newlines before the <p> is relevant.</div>");
--- a/langtools/test/jdk/javadoc/doclet/testHtmlVersion/TestHtmlVersion.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/test/jdk/javadoc/doclet/testHtmlVersion/TestHtmlVersion.java Fri Oct 14 11:11:19 2016 -0700
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 8072945 8081854 8141492 8148985 8150188
+ * @bug 8072945 8081854 8141492 8148985 8150188 4649116
* @summary Test the version of HTML generated by the javadoc tool.
* @author bpatel
* @library ../lib
@@ -162,10 +162,17 @@
"<main role=\"main\">\n"
+ "<div class=\"header\">",
"<section role=\"region\">\n"
- + "<h2 title=\"Package pkg Description\">Package pkg Description</h2>\n",
+ + "<div class=\"block\">Test package.</div>",
"<footer role=\"contentinfo\">\n"
+ "<nav role=\"navigation\">\n"
+ "<!-- ======= START OF BOTTOM NAVBAR ====== -->");
+ // No package description
+ checkOutput("pkg1/package-summary.html", true,
+ "<div class=\"contentContainer\">\n"
+ + "<ul class=\"blockList\">\n"
+ + "<li class=\"blockList\">\n"
+ + "<table class=\"typeSummary\">\n"
+ + "<caption><span>Class Summary</span><span class=\"tabEnd\"> </span></caption>");
// Test for package-tree page
checkOutput("pkg/package-tree.html", true,
@@ -662,6 +669,8 @@
"<a name=\"navbar.top.firstrow\">\n"
+ "<!-- -->\n"
+ "</a>",
+ "<section role=\"region\">\n"
+ + "<h2 title=\"Package pkg Description\">Package pkg Description</h2>\n",
"<table class=\"typeSummary\" summary=\"Interface Summary table, listing interfaces, and an explanation\">",
"<table class=\"typeSummary\" summary=\"Class Summary table, listing classes, and an explanation\">",
"<table class=\"typeSummary\" summary=\"Enum Summary table, listing enums, and an explanation\">",
@@ -1060,12 +1069,21 @@
"<a name=\"navbar.top.firstrow\">\n"
+ "<!-- -->\n"
+ "</a>",
+ "<div class=\"contentContainer\">\n"
+ + "<div class=\"block\">Test package.</div>",
"<table class=\"typeSummary\" summary=\"Interface Summary table, listing interfaces, and an explanation\">",
"<table class=\"typeSummary\" summary=\"Class Summary table, listing classes, and an explanation\">",
"<table class=\"typeSummary\" summary=\"Enum Summary table, listing enums, and an explanation\">",
"<table class=\"typeSummary\" summary=\"Exception Summary table, listing exceptions, and an explanation\">",
"<table class=\"typeSummary\" summary=\"Error Summary table, listing errors, and an explanation\">",
"<table class=\"typeSummary\" summary=\"Annotation Types Summary table, listing annotation types, and an explanation\">");
+ // No Package description
+ checkOutput("pkg1/package-summary.html", true,
+ "<div class=\"contentContainer\">\n"
+ + "<ul class=\"blockList\">\n"
+ + "<li class=\"blockList\">\n"
+ + "<table class=\"typeSummary\" summary=\"Class Summary table, listing classes, and an explanation\">\n"
+ + "<caption><span>Class Summary</span><span class=\"tabEnd\"> </span></caption>");
// Test for package-tree page
checkOutput("pkg/package-tree.html", true,
@@ -1485,8 +1503,7 @@
+ "<!-- ========= START OF TOP NAVBAR ======= -->",
"<main role=\"main\">\n"
+ "<div class=\"header\">",
- "<section role=\"region\">\n"
- + "<h2 title=\"Package pkg Description\">Package pkg Description</h2>\n",
+ "<h2 title=\"Package pkg Description\">Package pkg Description</h2>\n",
"<footer role=\"contentinfo\">\n"
+ "<nav role=\"navigation\">\n"
+ "<!-- ======= START OF BOTTOM NAVBAR ====== -->");
--- a/langtools/test/jdk/javadoc/doclet/testIOException/TestIOException.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/test/jdk/javadoc/doclet/testIOException/TestIOException.java Fri Oct 14 11:11:19 2016 -0700
@@ -57,7 +57,7 @@
try {
javadoc("-d", outDir.toString(),
new File(testSrc, "TestIOException.java").getPath());
- checkExit(Exit.FAILED);
+ checkExit(Exit.ERROR);
checkOutput(Output.OUT, true,
"Destination directory not writable: " + outDir);
} finally {
@@ -85,7 +85,7 @@
javadoc("-d", outDir.toString(),
new File(testSrc, "TestIOException.java").getPath());
- checkExit(Exit.FAILED);
+ checkExit(Exit.ERROR);
checkOutput(Output.OUT, true,
"Error writing file: " + index);
} finally {
@@ -123,7 +123,7 @@
setOutputDirectoryCheck(DirectoryCheck.NONE);
javadoc("-d", outDir.toString(),
src_p_C.getPath());
- checkExit(Exit.FAILED);
+ checkExit(Exit.ERROR);
checkOutput(Output.OUT, true,
"Error writing file: " + new File(pkgOutDir, "C.html"));
} finally {
@@ -167,7 +167,7 @@
javadoc("-d", outDir.toString(),
"-sourcepath", srcDir.getPath(),
"p");
- checkExit(Exit.FAILED);
+ checkExit(Exit.ERROR);
checkOutput(Output.OUT, true,
"Error writing file: " + new File(docFilesOutDir, "info.txt"));
} finally {
--- a/langtools/test/jdk/javadoc/doclet/testJavaFX/TestJavaFX.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/test/jdk/javadoc/doclet/testJavaFX/TestJavaFX.java Fri Oct 14 11:11:19 2016 -0700
@@ -61,8 +61,14 @@
+ "<div class=\"block\">Gets the value of the property rate.</div>\n"
+ "<dl>\n"
+ "<dt><span class=\"simpleTagLabel\">Property description:</span></dt>",
- "<th class=\"colSecond\" scope=\"row\"><code><span class=\"memberNameLink\">"
- + "<a href=\"../pkg1/C.html#rateProperty\">rate</a></span></code>",
+ "<td class=\"colFirst\"><code><a href=\"../pkg1/C.DoubleProperty.html\" "
+ + "title=\"class in pkg1\">C.DoubleProperty</a></code></td>\n"
+ + "<th class=\"colSecond\" scope=\"row\"><code><span class=\"memberNameLink\">"
+ + "<a href=\"../pkg1/C.html#rateProperty\">rate</a></span></code></th>\n"
+ + "<td class=\"colLast\">\n"
+ + "<div class=\"block\">Defines the direction/speed at which the "
+ + "<code>Timeline</code> is expected to\n"
+ + " be played.</div>\n</td>",
"<span class=\"simpleTagLabel\">Default value:</span>",
"<span class=\"simpleTagLabel\">Since:</span></dt>\n"
+ "<dd>JavaFX 8.0</dd>",
@@ -72,13 +78,70 @@
"<th class=\"colSecond\" scope=\"row\"><code><span class=\"memberNameLink\">"
+ "<a href=\"../pkg1/C.html#setTestMethodProperty--\">"
+ "setTestMethodProperty</a></span>()</code></th>",
+ "<th class=\"colSecond\" scope=\"row\"><code><span class=\"memberNameLink\">"
+ + "<a href=\"../pkg1/C.html#pausedProperty\">paused</a></span></code></th>\n"
+ + "<td class=\"colLast\">\n"
+ + "<div class=\"block\">Defines if paused.</div>",
+ "<h4>paused</h4>\n"
+ + "<pre>public final <a href=\"../pkg1/C.BooleanProperty.html\" "
+ + "title=\"class in pkg1\">C.BooleanProperty</a> pausedProperty</pre>\n"
+ + "<div class=\"block\">Defines if paused. The second line.</div>",
+ "<h4>isPaused</h4>\n"
+ + "<pre>public final double isPaused()</pre>\n"
+ + "<div class=\"block\">Gets the value of the property paused.</div>",
+ "<h4>setPaused</h4>\n"
+ + "<pre>public final void setPaused(boolean value)</pre>\n"
+ + "<div class=\"block\">Sets the value of the property paused.</div>\n"
+ + "<dl>\n"
+ + "<dt><span class=\"simpleTagLabel\">Property description:</span></dt>\n"
+ + "<dd>Defines if paused. The second line.</dd>\n"
+ + "<dt><span class=\"simpleTagLabel\">Default value:</span></dt>\n"
+ + "<dd>false</dd>",
"<h4>isPaused</h4>\n"
+ "<pre>public final double isPaused()</pre>\n"
- + "<div class=\"block\">Gets the value of the property paused.</div>");
+ + "<div class=\"block\">Gets the value of the property paused.</div>\n"
+ + "<dl>\n"
+ + "<dt><span class=\"simpleTagLabel\">Property description:</span></dt>\n"
+ + "<dd>Defines if paused. The second line.</dd>\n"
+ + "<dt><span class=\"simpleTagLabel\">Default value:</span></dt>\n"
+ + "<dd>false</dd>",
+ "<h4>rate</h4>\n"
+ + "<pre>public final <a href=\"../pkg1/C.DoubleProperty.html\" "
+ + "title=\"class in pkg1\">C.DoubleProperty</a> rateProperty</pre>\n"
+ + "<div class=\"block\">Defines the direction/speed at which the "
+ + "<code>Timeline</code> is expected to\n"
+ + " be played. This is the second line.</div>",
+ "<h4>setRate</h4>\n"
+ + "<pre>public final void setRate(double value)</pre>\n"
+ + "<div class=\"block\">Sets the value of the property rate.</div>\n"
+ + "<dl>\n"
+ + "<dt><span class=\"simpleTagLabel\">Property description:</span></dt>\n"
+ + "<dd>Defines the direction/speed at which the <code>Timeline</code> is expected to\n"
+ + " be played. This is the second line.</dd>\n"
+ + "<dt><span class=\"simpleTagLabel\">Default value:</span></dt>\n"
+ + "<dd>11</dd>\n"
+ + "<dt><span class=\"simpleTagLabel\">Since:</span></dt>\n"
+ + "<dd>JavaFX 8.0</dd>",
+ "<h4>getRate</h4>\n"
+ + "<pre>public final double getRate()</pre>\n"
+ + "<div class=\"block\">Gets the value of the property rate.</div>\n"
+ + "<dl>\n"
+ + "<dt><span class=\"simpleTagLabel\">Property description:</span></dt>\n"
+ + "<dd>Defines the direction/speed at which the <code>Timeline</code> is expected to\n"
+ + " be played. This is the second line.</dd>\n"
+ + "<dt><span class=\"simpleTagLabel\">Default value:</span></dt>\n"
+ + "<dd>11</dd>\n"
+ + "<dt><span class=\"simpleTagLabel\">Since:</span></dt>\n"
+ + "<dd>JavaFX 8.0</dd>",
+ "");
checkOutput("pkg1/C.html", false,
"A()");
+ checkOutput("index-all.html", true,
+ "<div class=\"block\">Gets the value of the property paused.</div>",
+ "<div class=\"block\">Defines if paused.</div>");
+
checkOutput("pkg1/D.html", true,
"<h3>Properties inherited from class pkg1."
+ "<a href=\"../pkg1/C.html\" title=\"class in pkg1\">C</a></h3>\n"
--- a/langtools/test/jdk/javadoc/doclet/testJavaFX/pkg1/C.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/test/jdk/javadoc/doclet/testJavaFX/pkg1/C.java Fri Oct 14 11:11:19 2016 -0700
@@ -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
@@ -52,7 +52,7 @@
/**
* Defines the direction/speed at which the {@code Timeline} is expected to
- * be played.
+ * be played. This is the second line.
* @defaultValue 11
* @since JavaFX 8.0
*/
@@ -71,7 +71,7 @@
public final double isPaused() {}
/**
- * Defines if paused
+ * Defines if paused. The second line.
* @defaultValue false
*/
public final BooleanProperty pausedProperty() {}
@@ -87,7 +87,7 @@
/**
* Defines the direction/speed at which the {@code Timeline} is expected to
- * be played.
+ * be played. This is the second line.
* @defaultValue 11
*/
private DoubleProperty rate;
--- a/langtools/test/jdk/javadoc/doclet/testPackageHtml/TestPackageHtml.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/test/jdk/javadoc/doclet/testPackageHtml/TestPackageHtml.java Fri Oct 14 11:11:19 2016 -0700
@@ -42,7 +42,7 @@
javadoc("-d", "out-pkg-html",
"-sourcepath", testSrc,
"pkg1");
- checkExit(Exit.FAILED);
+ checkExit(Exit.ERROR);
checkOutput(Output.OUT, true, "package.html:10: error: bad use of '>'");
}
}
--- a/langtools/test/jdk/javadoc/doclet/testParamTaglet/TestParamTaglet.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/test/jdk/javadoc/doclet/testParamTaglet/TestParamTaglet.java Fri Oct 14 11:11:19 2016 -0700
@@ -46,7 +46,7 @@
javadoc("-d", "out",
"-sourcepath", testSrc,
"pkg");
- checkExit(Exit.FAILED);
+ checkExit(Exit.ERROR);
checkOutput("pkg/C.html", true,
//Regular param tags.
--- a/langtools/test/jdk/javadoc/doclet/testSearch/TestSearch.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/test/jdk/javadoc/doclet/testSearch/TestSearch.java Fri Oct 14 11:11:19 2016 -0700
@@ -73,7 +73,7 @@
void test2a() {
javadoc("-d", "out-2a", "-Xdoclint:all", "-sourcepath", testSrc,
"-use", "pkg", "pkg1", "pkg2", "pkg3");
- checkExit(Exit.FAILED);
+ checkExit(Exit.ERROR);
checkDocLintErrors();
checkSearchOutput(true);
checkSingleIndex(true);
--- a/langtools/test/jdk/javadoc/doclet/testSerializedFormDeprecationInfo/TestSerializedFormDeprecationInfo.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/test/jdk/javadoc/doclet/testSerializedFormDeprecationInfo/TestSerializedFormDeprecationInfo.java Fri Oct 14 11:11:19 2016 -0700
@@ -44,7 +44,7 @@
javadoc("-d", "out-default",
"-sourcepath", testSrc,
"pkg1");
- checkExit(Exit.FAILED); // TODO: should be OK
+ checkExit(Exit.OK);
checkCommentDeprecated(true);
checkNoComment(false);
@@ -56,7 +56,7 @@
"-nocomment",
"-sourcepath", testSrc,
"pkg1");
- checkExit(Exit.FAILED); // TODO: should be OK
+ checkExit(Exit.OK);
checkNoComment(true);
checkCommentDeprecated(false);
@@ -68,7 +68,7 @@
"-nodeprecated",
"-sourcepath", testSrc,
"pkg1");
- checkExit(Exit.FAILED); // TODO: should be OK
+ checkExit(Exit.OK);
checkNoDeprecated(true);
checkNoCommentNoDeprecated(false);
@@ -81,7 +81,7 @@
"-nodeprecated",
"-sourcepath", testSrc,
"pkg1");
- checkExit(Exit.FAILED); // TODO: should be OK
+ checkExit(Exit.OK);
checkNoCommentNoDeprecated(true);
checkNoDeprecated(false);
}
@@ -93,7 +93,7 @@
"<dl>\n"
+ "<dt><span class=\"throwsLabel\">Throws:</span></dt>\n"
+ "<dd><code>"
- + "java.io.IOException</code></dd>\n"
+ + "java.io.IOException</code> - on error</dd>\n"
+ "<dt><span class=\"seeLabel\">See Also:</span>"
+ "</dt>\n"
+ "<dd><a href=\"pkg1/C1.html#setUndecorated-boolean-\">"
@@ -121,7 +121,7 @@
+ "<div class=\"block\">Reads the object stream.</div>\n"
+ "<dl>\n"
+ "<dt><span class=\"throwsLabel\">Throws:</span></dt>\n"
- + "<dd><code>java.io.IOException</code></dd>\n"
+ + "<dd><code>java.io.IOException</code> - on error</dd>\n"
+ "</dl>",
"<span class=\"deprecatedLabel\">Deprecated.</span>"
+ " </div>\n"
--- a/langtools/test/jdk/javadoc/doclet/testSerializedFormDeprecationInfo/pkg1/C1.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/test/jdk/javadoc/doclet/testSerializedFormDeprecationInfo/pkg1/C1.java Fri Oct 14 11:11:19 2016 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -75,7 +75,6 @@
* @param test boolean value
* @exception IllegalArgumentException if the <code>owner</code>'s
* <code>GraphicsConfiguration</code> is not from a screen device
- * @exception HeadlessException
*/
public C1(String title, boolean test) {
@@ -98,6 +97,7 @@
}
/**
+ * @throws java.io.IOException on error
* @see #setUndecorated(boolean)
*/
public void readObject() throws IOException {
--- a/langtools/test/jdk/javadoc/doclet/testSerializedFormDeprecationInfo/pkg1/C2.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/test/jdk/javadoc/doclet/testSerializedFormDeprecationInfo/pkg1/C2.java Fri Oct 14 11:11:19 2016 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -74,7 +74,7 @@
* Reads the object stream.
*
* @param s ObjectInputStream
- * @throws IOException
+ * @throws IOException on error
* @deprecated As of JDK version 1.5, replaced by
* {@link C1#setUndecorated(boolean) setUndecorated(boolean)}.
*/
--- a/langtools/test/jdk/javadoc/doclet/testSinceTag/TestSinceTag.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/test/jdk/javadoc/doclet/testSinceTag/TestSinceTag.java Fri Oct 14 11:11:19 2016 -0700
@@ -45,7 +45,7 @@
javadoc("-d", "out-since",
"-sourcepath", testSrc,
"pkg1");
- checkExit(Exit.FAILED); // TODO: investigate
+ checkExit(Exit.OK);
checkSince(true);
}
@@ -56,7 +56,7 @@
"-sourcepath", testSrc,
"-nosince",
"pkg1");
- checkExit(Exit.FAILED); // TODO: investigate
+ checkExit(Exit.OK);
checkSince(false);
}
--- a/langtools/test/jdk/javadoc/doclet/testSinceTag/pkg1/C1.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/test/jdk/javadoc/doclet/testSinceTag/pkg1/C1.java Fri Oct 14 11:11:19 2016 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -72,7 +72,6 @@
* @param test boolean value
* @exception IllegalArgumentException if the <code>owner</code>'s
* <code>GraphicsConfiguration</code> is not from a screen device
- * @exception HeadlessException
*/
public C1(String title, boolean test) {
}
@@ -93,6 +92,7 @@
}
/**
+ * @throws java.io.IOException on error
* @see #setUndecorated(boolean)
*/
public void readObject() throws IOException {
--- a/langtools/test/jdk/javadoc/doclet/testSupplementary/TestSupplementary.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/test/jdk/javadoc/doclet/testSupplementary/TestSupplementary.java Fri Oct 14 11:11:19 2016 -0700
@@ -52,7 +52,7 @@
javadoc("-locale", "en_US",
"-d", "out",
testSrc("C.java"));
- checkExit(Exit.FAILED);
+ checkExit(Exit.ERROR);
checkOutput(Output.OUT, true,
"C.java:36: error: unexpected text",
--- a/langtools/test/jdk/javadoc/doclet/testThrowsTag/TestThrowsTag.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/test/jdk/javadoc/doclet/testThrowsTag/TestThrowsTag.java Fri Oct 14 11:11:19 2016 -0700
@@ -45,7 +45,7 @@
javadoc("-d", "out",
"-sourcepath", testSrc,
"pkg");
- checkExit(Exit.FAILED); // TODO: investigate why failed
+ checkExit(Exit.OK);
checkOutput("pkg/C.html", true,
"<dd><code><a href=\"../pkg/T1.html\" title=\"class in pkg\">T1</a></code> - the first throws tag.</dd>\n" +
--- a/langtools/test/jdk/javadoc/doclet/testThrowsTag/pkg/T1.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/test/jdk/javadoc/doclet/testThrowsTag/pkg/T1.java Fri Oct 14 11:11:19 2016 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,4 +23,4 @@
package pkg;
-public class T1 extends Exception {}
+public class T1 extends RuntimeException {}
--- a/langtools/test/jdk/javadoc/doclet/testThrowsTag/pkg/T2.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/test/jdk/javadoc/doclet/testThrowsTag/pkg/T2.java Fri Oct 14 11:11:19 2016 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,4 +23,4 @@
package pkg;
-public class T2 extends Exception {}
+public class T2 extends RuntimeException {}
--- a/langtools/test/jdk/javadoc/doclet/testThrowsTag/pkg/T3.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/test/jdk/javadoc/doclet/testThrowsTag/pkg/T3.java Fri Oct 14 11:11:19 2016 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,4 +23,4 @@
package pkg;
-public class T3 extends Exception {}
+public class T3 extends RuntimeException {}
--- a/langtools/test/jdk/javadoc/doclet/testThrowsTag/pkg/T4.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/test/jdk/javadoc/doclet/testThrowsTag/pkg/T4.java Fri Oct 14 11:11:19 2016 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,4 +23,4 @@
package pkg;
-public class T4 extends Exception {}
+public class T4 extends RuntimeException {}
--- a/langtools/test/jdk/javadoc/doclet/testValueTag/TestValueTag.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/test/jdk/javadoc/doclet/testValueTag/TestValueTag.java Fri Oct 14 11:11:19 2016 -0700
@@ -46,7 +46,7 @@
"-sourcepath", testSrc,
"-tag", "todo",
"pkg1", "pkg2");
- checkExit(Exit.FAILED);
+ checkExit(Exit.ERROR);
checkOutput("pkg1/Class1.html", true,
// Base case: using @value on a constant.
--- a/langtools/test/jdk/javadoc/doclet/testWarnings/TestWarnings.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/test/jdk/javadoc/doclet/testWarnings/TestWarnings.java Fri Oct 14 11:11:19 2016 -0700
@@ -47,7 +47,7 @@
javadoc("-d", "out-default",
"-sourcepath", testSrc,
"pkg");
- checkExit(Exit.FAILED);
+ checkExit(Exit.ERROR);
checkOutput(Output.OUT, true,
"X.java:23: error: self-closing element not allowed");
@@ -75,7 +75,7 @@
"-private",
"-sourcepath", testSrc,
"pkg");
- checkExit(Exit.FAILED);
+ checkExit(Exit.ERROR);
checkOutput("pkg/X.html", true,
"<a href=\"../pkg/X.html#m--\"><code>m()</code></a><br/>",
--- a/langtools/test/jdk/javadoc/tool/ReleaseOption.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/test/jdk/javadoc/tool/ReleaseOption.java Fri Oct 14 11:11:19 2016 -0700
@@ -28,7 +28,11 @@
import java.util.Arrays;
import java.util.List;
import java.util.function.Predicate;
+
import jdk.javadoc.internal.tool.Main;
+import jdk.javadoc.internal.tool.Main.Result;
+
+import static jdk.javadoc.internal.tool.Main.Result.*;
/**
* @test
@@ -43,13 +47,13 @@
}
void run() {
- doRunTest(0, out -> out.contains("compiler.err.doesnt.exist: java.util.stream"), "--release", "7");
- doRunTest(0, out -> !out.contains("compiler.err.doesnt.exist: java.util.stream"), "--release", "8");
- doRunTest(1, out -> true, "--release", "7", "-source", "7");
- doRunTest(1, out -> true, "--release", "7", "-bootclasspath", "any");
+ doRunTest(OK, out -> out.contains("compiler.err.doesnt.exist: java.util.stream"), "--release", "7");
+ doRunTest(OK, out -> !out.contains("compiler.err.doesnt.exist: java.util.stream"), "--release", "8");
+ doRunTest(CMDERR, out -> true, "--release", "7", "-source", "7");
+ doRunTest(CMDERR, out -> true, "--release", "7", "-bootclasspath", "any");
}
- void doRunTest(int expectedResult, Predicate<String> validate, String... args) {
+ void doRunTest(Result expectedResult, Predicate<String> validate, String... args) {
System.err.println("running with args: " + Arrays.asList(args));
List<String> options = new ArrayList<>();
options.addAll(Arrays.asList(args));
@@ -60,7 +64,7 @@
int actualResult = Main.execute(options.toArray(new String[0]), pw);
System.err.println("actual result=" + actualResult);
System.err.println("actual output=" + out.toString());
- if (actualResult != expectedResult)
+ if (actualResult != expectedResult.exitCode)
throw new Error("Exit code not as expected");
if (!validate.test(out.toString())) {
throw new Error("Output not as expected");
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/tool/ToolProviderTest.java Fri Oct 14 11:11:19 2016 -0700
@@ -0,0 +1,133 @@
+/*
+ * 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 8159855
+ * @summary test javadoc's ToolProvider
+ * @library /tools/lib
+ * @build toolbox.TestRunner toolbox.ToolBox
+ * @run main ToolProviderTest
+ */
+
+import java.io.*;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.*;
+import java.util.spi.ToolProvider;
+
+import toolbox.TestRunner;
+import toolbox.ToolBox;
+
+public class ToolProviderTest extends TestRunner {
+ public static void main(String... args) throws Exception {
+ new ToolProviderTest().runTests();
+ }
+
+ ToolBox tb = new ToolBox();
+ ToolProvider javadoc;
+
+ ToolProviderTest() {
+ super(System.err);
+ javadoc = ToolProvider.findFirst("javadoc").get();
+ }
+
+ @Test
+ public void testProviders() throws Exception {
+ Map<String, ToolProvider> providers = new LinkedHashMap<>();
+ for (ToolProvider tp : ServiceLoader.load(ToolProvider.class,
+ ClassLoader.getSystemClassLoader())) {
+ System.out.println("Provider: " + tp.name() + ": " + tp.getClass().getName());
+ providers.put(tp.name(), tp);
+ }
+ if (!providers.containsKey("javadoc")) {
+ error("javadoc ToolProvider not found");
+ }
+ }
+
+ @Test
+ public void testOneStream() throws Exception {
+ StringWriter sw = new StringWriter();
+ try (PrintWriter pw = new PrintWriter(sw)) {
+ int rc = javadoc.run(pw, pw, "-help");
+ if (rc != 0) {
+ error("unexpected exit code: " + rc);
+ }
+ }
+ String out = sw.toString();
+ if (!out.contains("Usage:")) {
+ error("expected output not found");
+ }
+ }
+
+ @Test
+ public void testTwoStreamsOut() throws Exception {
+ StringWriter swOut = new StringWriter();
+ StringWriter swErr = new StringWriter();
+ try (PrintWriter pwOut = new PrintWriter(swOut);
+ PrintWriter pwErr = new PrintWriter(swErr)) {
+ int rc = javadoc.run(pwOut, pwErr, "-help");
+ if (rc != 0) {
+ error("unexpected exit code: " + rc);
+ }
+ }
+ String out = swOut.toString();
+ String err = swErr.toString();
+ if (!out.contains("Usage:")) {
+ error("stdout: expected output not found");
+ }
+ if (!err.isEmpty()) {
+ error("stderr: unexpected output");
+ }
+ }
+
+ @Test
+ public void testTwoStreamsErr() throws Exception {
+ Path src = Paths.get("src");
+ Path classes = Paths.get("classes");
+ tb.writeJavaFiles(src,
+ "import java.util.*; class C { # }");
+
+ StringWriter swOut = new StringWriter();
+ StringWriter swErr = new StringWriter();
+ try (PrintWriter pwOut = new PrintWriter(swOut);
+ PrintWriter pwErr = new PrintWriter(swErr)) {
+ int rc = javadoc.run(pwOut, pwErr,
+ "-d", classes.toString(),
+ src.resolve("C.java").toString());
+ if (rc != 1) {
+ error("unexpected exit code: " + rc);
+ }
+ }
+
+ String out = swOut.toString();
+ String err = swErr.toString();
+
+ if (!out.contains("Loading")) {
+ error("stdout: unexpected output");
+ }
+ if (!err.contains("illegal character")) {
+ error("stderr: expected output not found");
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/tool/exceptionHandling/TestExceptionHandling.java Fri Oct 14 11:11:19 2016 -0700
@@ -0,0 +1,146 @@
+/*
+ * 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 8151102
+ * @summary verify that option --dump-on-error functions correctly
+ * @library /tools/lib
+ * @modules
+ * jdk.javadoc/jdk.javadoc.internal.api
+ * jdk.javadoc/jdk.javadoc.internal.tool
+ * jdk.compiler/com.sun.tools.javac.api
+ * jdk.compiler/com.sun.tools.javac.main
+ * @build toolbox.ToolBox toolbox.TestRunner
+ * @run main TestExceptionHandling
+ */
+
+import java.io.File;
+import java.io.PrintStream;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.List;
+
+import toolbox.*;
+
+/**
+ * This class tests if stack traces printed when
+ * --dump-on-error. The standard doclet is used,
+ * to test the doclet as well as the tool.
+ */
+public class TestExceptionHandling extends TestRunner {
+
+ final ToolBox tb;
+ final File testSrcFile;
+ final PrintStream ostream;
+ final JavadocTask cmdTask;
+ final JavadocTask apiTask;
+
+ public static void main(String... args) throws Exception {
+ TestExceptionHandling tester = new TestExceptionHandling();
+ tester.runTests();
+ }
+
+ TestExceptionHandling() {
+ super(System.err);
+ tb = new ToolBox();
+ ostream = System.err;
+ testSrcFile = new File(System.getProperty("test.src"), "TestExceptionHandling.java");
+ cmdTask = new JavadocTask(tb, Task.Mode.CMDLINE);
+ apiTask = new JavadocTask(tb, Task.Mode.API);
+ }
+
+ @Test
+ public void testDocletTrace() throws Exception {
+ Path out = Paths.get("out");
+ // create a file with the same name as the output
+ out.toFile().createNewFile();
+ cmdTask.outdir(out);
+ cmdTask.options("--dump-on-error");
+ cmdTask.files(testSrcFile.getAbsolutePath());
+ Task.Result tr = cmdTask.run(Task.Expect.FAIL);
+
+ String errString = "Destination directory is not a directory: " + out.toString();
+ // check the regular message
+ assertPresent("javadoc: error - " + errString, tr.getOutputLines(Task.OutputKind.DIRECT));
+ // check that first line of the stack trace is present
+ assertPresent("jdk.javadoc.internal.doclets.toolkit.util.SimpleDocletException: " +
+ errString, tr.getOutputLines(Task.OutputKind.STDERR));
+
+ }
+
+ @Test
+ public void testToolTrace() throws Exception {
+ Path out = Paths.get("out.dir");
+ cmdTask.options("--dump-on-error", "-doclet", "NonExistentDoclet");
+ cmdTask.outdir(out);
+ cmdTask.files(testSrcFile.getAbsolutePath());
+ Task.Result tr = cmdTask.run(Task.Expect.FAIL);
+
+ // check the regular message
+ assertPresent("javadoc: error - Cannot find doclet class NonExistentDoclet",
+ tr.getOutputLines(Task.OutputKind.DIRECT));
+
+ // check that first line of the stack trace is present
+ assertPresent("java.lang.ClassNotFoundException: NonExistentDoclet",
+ tr.getOutputLines(Task.OutputKind.STDERR));
+
+ }
+
+ @Test
+ public void testApiModeMissingDoclet() throws Exception {
+ apiTask.options("-doclet", "MissingDoclet");
+ try {
+ Task.Result result = apiTask.run(Task.Expect.FAIL);
+ } catch (IllegalArgumentException iae) {
+ // ok got the right exception
+ return;
+ }
+ throw new Exception("expected exception/error not found");
+ }
+
+ @Test
+ public void testApiModeMultipleDoclets() throws Exception {
+ apiTask.options("-doclet", "MissingDoclet",
+ "-doclet", "SomeDoclet");
+ try {
+ Task.Result result = apiTask.run(Task.Expect.FAIL);
+ } catch (IllegalArgumentException iae) {
+ // ok got the right exception
+ return;
+ }
+ throw new Exception("expected exception/error not found");
+ }
+
+ void assertPresent(String regex, List<String> output) throws Exception {
+ List<String> gresult = tb.grep(regex, output);
+ if (gresult.isEmpty()) {
+ ostream.println("Expected: " + regex);
+ ostream.println("Output: ");
+ output.forEach(s -> {
+ ostream.println(s);
+ });
+ throw new Exception("Test fails expected output not found: " + regex);
+ }
+ }
+}
--- a/langtools/test/jdk/jshell/CompletenessTest.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/test/jdk/jshell/CompletenessTest.java Fri Oct 14 11:11:19 2016 -0700
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 8149524 8131024 8165211 8080071 8130454
+ * @bug 8149524 8131024 8165211 8080071 8130454 8167343
* @summary Test SourceCodeAnalysis
* @build KullaTesting TestingInputStream
* @run testng CompletenessTest
@@ -117,6 +117,7 @@
"bar: g()",
"baz: while (true) if (t()) printf('-'); else break baz",
"java.util.function.IntFunction<int[]> ggg = int[]::new",
+ "List<? extends Object> l",
};
static final String[] considered_incomplete = new String[] {
@@ -162,7 +163,19 @@
"enum TK { EOF(TokenKind.EOF, 0),",
"enum TK { EOF(TokenKind.EOF, 0), NEW_MIDDLE(XEXPR1|XTERM)",
"enum TK { EOF(TokenKind.EOF, 0), NEW_MIDDLE(XEXPR1|XTERM); ",
- "enum Tt { FOO, BAR, BAZ,;"
+ "enum Tt { FOO, BAR, BAZ,;",
+ "class C",
+ "class C extends D",
+ "class C implements D",
+ "class C implements D, E",
+ "interface I extends D",
+ "interface I extends D, E",
+ "enum E",
+ "enum E implements I1",
+ "enum E implements I1, I2",
+ "@interface Anno",
+ "void f()",
+ "void f() throws E",
};
static final String[] unknown = new String[] {
--- a/langtools/test/tools/javac/T8003967/DetectMutableStaticFields.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/test/tools/javac/T8003967/DetectMutableStaticFields.java Fri Oct 14 11:11:19 2016 -0700
@@ -118,6 +118,8 @@
"loadMethod");
ignore("com/sun/tools/javac/util/JDK9Wrappers$VMHelper",
"vmClass", "getRuntimeArgumentsMethod");
+ ignore("com/sun/tools/javac/util/JDK9Wrappers$JmodFile",
+ "jmodFileClass", "checkMagicMethod");
}
private final List<String> errors = new ArrayList<>();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/LeaksNotAccessible/LeaksNotAccessible.java Fri Oct 14 11:11:19 2016 -0700
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.warn.leaks.not.accessible
+// options: -Xlint:exports
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/LeaksNotAccessible/modulesourcepath/m1/api/Api.java Fri Oct 14 11:11:19 2016 -0700
@@ -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 api;
+
+public class Api {
+ public Impl getImpl() {
+ return null;
+ }
+}
+
+class Impl {}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/LeaksNotAccessible/modulesourcepath/m1/module-info.java Fri Oct 14 11:11:19 2016 -0700
@@ -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 api;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/LeaksNotAccessibleNotRequiredPublic/LeaksNotAccessibleNotRequiredPublic.java Fri Oct 14 11:11:19 2016 -0700
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.warn.leaks.not.accessible.not.required.public
+// options: -Xlint:exports
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/LeaksNotAccessibleNotRequiredPublic/modulesourcepath/m1/api1/Api1.java Fri Oct 14 11:11:19 2016 -0700
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package api1;
+
+public class Api1 {
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/LeaksNotAccessibleNotRequiredPublic/modulesourcepath/m1/module-info.java Fri Oct 14 11:11:19 2016 -0700
@@ -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 api1;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/LeaksNotAccessibleNotRequiredPublic/modulesourcepath/m2/api2/Api2.java Fri Oct 14 11:11:19 2016 -0700
@@ -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 api2;
+
+public class Api2 {
+ public api1.Api1 getApi1() {
+ return null;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/LeaksNotAccessibleNotRequiredPublic/modulesourcepath/m2/module-info.java Fri Oct 14 11:11:19 2016 -0700
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+module m2 {
+ requires m1;
+ exports api2;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/LeaksNotAccessibleUnexported/LeaksNotAccessibleUnexported.java Fri Oct 14 11:11:19 2016 -0700
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.warn.leaks.not.accessible.unexported
+// options: -Xlint:exports
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/LeaksNotAccessibleUnexported/modulesourcepath/m1/api/Api.java Fri Oct 14 11:11:19 2016 -0700
@@ -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 api;
+
+public class Api {
+ public impl.Impl getImpl() {
+ return null;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/LeaksNotAccessibleUnexported/modulesourcepath/m1/impl/Impl.java Fri Oct 14 11:11:19 2016 -0700
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package impl;
+
+public class Impl {
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/LeaksNotAccessibleUnexported/modulesourcepath/m1/module-info.java Fri Oct 14 11:11:19 2016 -0700
@@ -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 api;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/LeaksNotAccessibleUnexportedQualified/LeaksNotAccessibleUnexportedQualified.java Fri Oct 14 11:11:19 2016 -0700
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.warn.leaks.not.accessible.unexported.qualified
+// options: -Xlint:exports
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/LeaksNotAccessibleUnexportedQualified/modulesourcepath/m1/api/Api.java Fri Oct 14 11:11:19 2016 -0700
@@ -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 api;
+
+public class Api {
+ public qapi.QApi get() {
+ return null;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/LeaksNotAccessibleUnexportedQualified/modulesourcepath/m1/module-info.java Fri Oct 14 11:11:19 2016 -0700
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+module m1 {
+ exports api;
+ exports qapi to m2;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/LeaksNotAccessibleUnexportedQualified/modulesourcepath/m1/qapi/QApi.java Fri Oct 14 11:11:19 2016 -0700
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package qapi;
+
+public class QApi {
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/LeaksNotAccessibleUnexportedQualified/modulesourcepath/m2/module-info.java Fri Oct 14 11:11:19 2016 -0700
@@ -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 m2 {
+ requires m1;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/main/AtFileTest.java Fri Oct 14 11:11:19 2016 -0700
@@ -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
+ * @bug 8166472 8162810
+ * @summary Align javac support for at-files with launcher support
+ * @modules jdk.compiler/com.sun.tools.javac.main
+ */
+
+import java.io.IOException;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import com.sun.tools.javac.main.CommandLine.Tokenizer;
+
+public class AtFileTest {
+
+ public static void main(String... args) throws IOException {
+ AtFileTest t = new AtFileTest();
+ if (args.length > 0) {
+ System.out.println(String.join(" ", args));
+ } else {
+ t.run();
+ }
+ }
+
+ void run() throws IOException {
+ test("-version -cp \"c:\\\\java libs\\\\one.jar\" \n",
+ "-version", "-cp", "c:\\java libs\\one.jar");
+
+ // note the open quote at the end
+ test("com.foo.Panda \"Furious 5\"\fand\t'Shi Fu' \"escape\tprison",
+ "com.foo.Panda", "Furious 5", "and", "Shi Fu", "escape\tprison");
+
+ test("escaped chars testing \"\\a\\b\\c\\f\\n\\r\\t\\v\\9\\6\\23\\82\\28\\377\\477\\278\\287\"",
+ "escaped", "chars", "testing", "abc\f\n\r\tv96238228377477278287");
+
+ test("\"mix 'single quote' in double\" 'mix \"double quote\" in single' partial\"quote me\"this",
+ "mix 'single quote' in double", "mix \"double quote\" in single", "partialquote methis");
+
+ test("line one #comment\n'line #2' #rest are comment\r\n#comment on line 3\nline 4 #comment to eof",
+ "line", "one", "line #2", "line", "4");
+
+ test("This is an \"open quote \n across line\n\t, note for WS.",
+ "This", "is", "an", "open quote ", "across", "line", ",", "note", "for", "WS.");
+
+ test("Try \"this \\\\\\\\ escape\\n double quote \\\" in open quote",
+ "Try", "this \\\\ escape\n double quote \" in open quote");
+
+ test("'-Dmy.quote.single'='Property in single quote. Here a double quote\" Add some slashes \\\\/'",
+ "-Dmy.quote.single=Property in single quote. Here a double quote\" Add some slashes \\/");
+
+ test("\"Open quote to \n new \"line \\\n\r third\\\n\r\\\tand\ffourth\"",
+ "Open quote to ", "new", "line third\tand\ffourth");
+
+ test("c:\\\"partial quote\"\\lib",
+ "c:\\partial quote\\lib");
+ }
+
+ void test(String full, String... expect) throws IOException {
+ System.out.println("test: >>>" + full + "<<<");
+ List<String> found = expand(full);
+ if (found.equals(Arrays.asList(expect))) {
+ System.out.println("OK");
+ } else {
+ for (int i = 0; i < Math.max(found.size(), expect.length); i++) {
+ if (i < found.size()) {
+ System.out.println("found[" + i + "]: >>>" + found.get(i) + "<<<");
+ }
+ if (i < expect.length) {
+ System.out.println("expect[" + i + "]: >>>" + expect[i] + "<<<");
+ }
+ }
+ }
+ System.out.println();
+ }
+
+ List<String> expand(String full) throws IOException {
+ Tokenizer t = new Tokenizer(new StringReader(full));
+ List<String> result = new ArrayList<>();
+ String s;
+ while ((s = t.nextToken()) != null) {
+// System.err.println("token: " + s);
+ result.add(s);
+ }
+ return result;
+
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/main/ToolProviderTest.java Fri Oct 14 11:11:19 2016 -0700
@@ -0,0 +1,132 @@
+/*
+ * 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 8159855
+ * @summary test javac's ToolProvider
+ * @library /tools/lib
+ * @build toolbox.TestRunner toolbox.ToolBox
+ * @run main ToolProviderTest
+ */
+
+import java.io.*;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.*;
+import java.util.spi.ToolProvider;
+
+import toolbox.TestRunner;
+import toolbox.ToolBox;
+
+public class ToolProviderTest extends TestRunner {
+ public static void main(String... args) throws Exception {
+ new ToolProviderTest().runTests();
+ }
+
+ ToolBox tb = new ToolBox();
+ ToolProvider javac;
+
+ ToolProviderTest() {
+ super(System.err);
+ javac = ToolProvider.findFirst("javac").get();
+ }
+
+ @Test
+ public void testProviders() throws Exception {
+ Map<String, ToolProvider> providers = new LinkedHashMap<>();
+ for (ToolProvider tp : ServiceLoader.load(ToolProvider.class,
+ ClassLoader.getSystemClassLoader())) {
+ System.out.println("Provider: " + tp.name() + ": " + tp.getClass().getName());
+ providers.put(tp.name(), tp);
+ }
+ if (!providers.containsKey("javac")) {
+ error("javac ToolProvider not found");
+ }
+ }
+
+ @Test
+ public void testOneStream() throws Exception {
+ StringWriter sw = new StringWriter();
+ try (PrintWriter pw = new PrintWriter(sw)) {
+ int rc = javac.run(pw, pw, "-help");
+ if (rc != 0) {
+ error("unexpected exit code: " + rc);
+ }
+ }
+ String out = sw.toString();
+ if (!out.contains("Usage:")) {
+ error("expected output not found");
+ }
+ }
+
+ @Test
+ public void testTwoStreamsOut() throws Exception {
+ StringWriter swOut = new StringWriter();
+ StringWriter swErr = new StringWriter();
+ try (PrintWriter pwOut = new PrintWriter(swOut);
+ PrintWriter pwErr = new PrintWriter(swErr)) {
+ int rc = javac.run(pwOut, pwErr, "-help");
+ if (rc != 0) {
+ error("unexpected exit code: " + rc);
+ }
+ }
+ String out = swOut.toString();
+ String err = swErr.toString();
+ if (!out.contains("Usage:")) {
+ error("stdout: expected output not found");
+ }
+ if (!err.isEmpty()) {
+ error("stderr: unexpected output");
+ }
+ }
+
+ @Test
+ public void testTwoStreamsErr() throws Exception {
+ Path src = Paths.get("src");
+ Path classes = Paths.get("classes");
+ tb.writeJavaFiles(src,
+ "import java.util.*; class C { # }");
+
+ StringWriter swOut = new StringWriter();
+ StringWriter swErr = new StringWriter();
+ try (PrintWriter pwOut = new PrintWriter(swOut);
+ PrintWriter pwErr = new PrintWriter(swErr)) {
+ int rc = javac.run(pwOut, pwErr,
+ "-d", classes.toString(),
+ src.resolve("C.java").toString());
+ if (rc != 1) {
+ error("unexpected exit code: " + rc);
+ }
+ }
+
+ String out = swOut.toString();
+ String err = swErr.toString();
+ if (!out.isEmpty()) {
+ error("stdout: unexpected output");
+ }
+ if (!err.contains("illegal character")) {
+ error("stderr: expected output not found");
+ }
+ }
+}
--- a/langtools/test/tools/javac/modules/AddLimitMods.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/test/tools/javac/modules/AddLimitMods.java Fri Oct 14 11:11:19 2016 -0700
@@ -345,6 +345,7 @@
Files.createDirectories(classpathOut);
+ System.err.println("Compiling classpath-src files:");
new JavacTask(tb)
.outdir(classpathOut)
.files(findJavaFiles(classpathSrc))
@@ -360,6 +361,7 @@
Files.createDirectories(automaticOut);
+ System.err.println("Compiling automatic-src files:");
new JavacTask(tb)
.outdir(automaticOut)
.files(findJavaFiles(automaticSrc))
@@ -373,6 +375,7 @@
Path automaticJar = modulePath.resolve("automatic.jar");
+ System.err.println("Creating automatic.jar:");
new JarTask(tb, automaticJar)
.baseDir(automaticOut)
.files("automatic/Automatic.class")
@@ -385,6 +388,7 @@
"module m1 { exports api; }",
"package api; public class Api { public void test() { } }");
+ System.err.println("Compiling module-src files:");
new JavacTask(tb)
.options("--module-source-path", moduleSrc.toString())
.outdir(modulePath)
@@ -399,7 +403,7 @@
for (String[] options : OPTIONS_VARIANTS) {
index++;
- System.err.println("running check: " + moduleInfo + "; " + Arrays.asList(options));
+ System.err.println("Running check: " + moduleInfo + "; " + Arrays.asList(options));
Path m2Runtime = base.resolve(index + "-runtime").resolve("m2");
Path out = base.resolve(index + "-runtime").resolve("out").resolve("m2");
@@ -427,6 +431,7 @@
tb.writeJavaFiles(m2Runtime, moduleInfo, testClassNamed.toString());
+ System.err.println("Compiling " + m2Runtime + " files:");
new JavacTask(tb)
.options("--module-path", modulePath.toString())
.outdir(out)
@@ -438,6 +443,7 @@
String output;
try {
+ System.err.println("Running m2/test.Test:");
output = new JavaTask(tb)
.vmOptions(augmentOptions(options,
Collections.emptyList(),
@@ -468,6 +474,8 @@
"-Aoutput=" + output,
"-XDaccessInternalAPI=true"
) : Collections.emptyList();
+
+ System.err.println("Compiling/processing m2 files:");
new JavacTask(tb)
.options(augmentOptions(options,
auxOptions,
@@ -510,8 +518,6 @@
MODULES_TO_CHECK_TO_SAMPLE_CLASS.put("m1", "api.Api");
MODULES_TO_CHECK_TO_SAMPLE_CLASS.put("m2", "test.Test");
MODULES_TO_CHECK_TO_SAMPLE_CLASS.put("java.base", "java.lang.Object");
- MODULES_TO_CHECK_TO_SAMPLE_CLASS.put("java.compiler", "javax.tools.ToolProvider");
- MODULES_TO_CHECK_TO_SAMPLE_CLASS.put("jdk.compiler", "com.sun.tools.javac.Main");
};
@SupportedAnnotationTypes("*")
@@ -573,8 +579,7 @@
private static final String[] MODULE_INFO_VARIANTS = {
"module m2 { exports test; }",
- "module m2 { requires m1; exports test; }",
- "module m2 { requires jdk.compiler; exports test; }",
+ "module m2 { requires m1; exports test; }"
};
private static final String[][] OPTIONS_VARIANTS = {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/modules/ExportsUnexported.java Fri Oct 14 11:11:19 2016 -0700
@@ -0,0 +1,375 @@
+/*
+ * 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 tests for module declarations
+ * @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 ExportsUnexported
+ */
+
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import toolbox.JavacTask;
+import toolbox.Task;
+
+public class ExportsUnexported extends ModuleTestBase {
+
+ public static void main(String... args) throws Exception {
+ ExportsUnexported t = new ExportsUnexported();
+ t.runTests();
+ }
+
+ @Test
+ public void testLocations(Path base) throws Exception {
+ String warningsTest = "package api;\n" +
+ "import impl.impl.*;\n" +
+ "@impl.impl^.DocAnn\n" +
+ "public abstract class Api<T extends impl.impl^.Cls&impl.impl^.Intf> extends impl.impl^.Cls implements impl.impl^.Intf, impl.impl^.NonDocAnn, impl.impl^.DocAnn {\n" +
+ " public static <E extends impl.impl^.Cls&impl.impl^.Intf> impl.impl^.Cls m(impl.impl^.Intf i, impl.impl^.Cls c) throws impl.impl^.Exc { return null; }\n" +
+ " public static impl.impl^.Cls f;\n" +
+ "}";
+ String noWarningsTest = "package api;\n" +
+ "import impl.impl.*;\n" +
+ "@impl.impl.NonDocAnn\n" +
+ "public abstract class Api {\n" +
+ " private static abstract class I <T extends impl.impl.Cls&impl.impl.Intf> extends impl.impl.Cls implements impl.impl.Intf, impl.impl.NonDocAnn, impl.impl.DocAnn {\n" +
+ " public static abstract class II <T extends impl.impl.Cls&impl.impl.Intf> extends impl.impl.Cls implements impl.impl.Intf, impl.impl.NonDocAnn, impl.impl.DocAnn { }\n" +
+ " public static <E extends impl.impl.Cls&impl.impl.Intf> impl.impl.Cls m(impl.impl.Intf i, impl.impl.Cls c) throws impl.impl.Exc { return null; }\n" +
+ " public static impl.impl.Cls f;\n" +
+ " }\n" +
+ " private static <E extends impl.impl.Cls&impl.impl.Intf> impl.impl.Cls m(impl.impl.Intf i, impl.impl.Cls c) throws impl.impl.Exc { return null; }\n" +
+ " private static impl.impl.Cls f1;\n" +
+ " public static void m() { new impl.impl.Cls(); }\n" +
+ " public static Object f2 = new impl.impl.Cls();\n" +
+ "}";
+ for (String genericTest : new String[] {warningsTest, noWarningsTest}) {
+ for (String test : new String[] {genericTest, genericTest.replaceAll("impl\\.impl\\^.([A-Za-z])", "^$1").replaceAll("impl\\.impl\\.([A-Za-z])", "$1")}) {
+ System.err.println("testing: " + test);
+
+ Path src = base.resolve("src");
+ Path src_m1 = src.resolve("m1");
+ StringBuilder testCode = new StringBuilder();
+ List<String> expectedLog = new ArrayList<>();
+ int line = 1;
+ int col = 1;
+
+ for (int i = 0; i < test.length(); i++) {
+ char c = test.charAt(i);
+
+ if (c == '^') {
+ StringBuilder typeName = new StringBuilder();
+ for (int j = i + 1 + (test.charAt(i + 1) == '.' ? 1 : 0);
+ j < test.length() && Character.isJavaIdentifierPart(test.charAt(j));
+ j++) {
+ typeName.append(test.charAt(j));
+ }
+ String kindName;
+ switch (typeName.toString()) {
+ case "Exc": case "DocAnn": case "NonDocAnn":
+ case "Cls": kindName = "kindname.class"; break;
+ case "Intf": kindName = "kindname.interface"; break;
+ default:
+ throw new AssertionError(typeName.toString());
+ }
+ expectedLog.add("Api.java:" + line + ":" + col + ": compiler.warn.leaks.not.accessible.unexported: " + kindName + ", impl.impl." + typeName + ", m1");
+ continue;
+ }
+
+ if (c == '\n') {
+ line++;
+ col = 0;
+ }
+
+ testCode.append(c);
+ col++;
+ }
+
+ if (!expectedLog.isEmpty()) {
+ expectedLog.add("" + expectedLog.size() + " warning" + (expectedLog.size() == 1 ? "" : "s"));
+ expectedLog.add("- compiler.err.warnings.and.werror");
+ expectedLog.add("1 error");
+ }
+
+ Collections.sort(expectedLog);
+
+ tb.writeJavaFiles(src_m1,
+ "module m1 { exports api; }",
+ testCode.toString(),
+ "package impl.impl; public class Cls { }",
+ "package impl.impl; public class Exc extends Exception { }",
+ "package impl.impl; public interface Intf { }",
+ "package impl.impl; @java.lang.annotation.Documented public @interface DocAnn { }",
+ "package impl.impl; public @interface NonDocAnn { }");
+ Path classes = base.resolve("classes");
+ tb.createDirectories(classes);
+
+ List<String> log = new JavacTask(tb)
+ .options("-XDrawDiagnostics",
+ "-Werror",
+ "--module-source-path", src.toString(),
+ "-Xlint:exports")
+ .outdir(classes)
+ .files(findJavaFiles(src))
+ .run(expectedLog.isEmpty() ? Task.Expect.SUCCESS : Task.Expect.FAIL)
+ .writeAll()
+ .getOutputLines(Task.OutputKind.DIRECT);
+
+ log = new ArrayList<>(log);
+ Collections.sort(log);
+
+ if (expectedLog.isEmpty() ? !log.equals(Arrays.asList("")) : !log.equals(expectedLog)) {
+ throw new Exception("expected output not found in: " + log + "; " + expectedLog);
+ }
+ }
+ }
+ }
+
+ @Test
+ public void testAccessibleToSpecificOrAll(Path base) throws Exception {
+ Path src = base.resolve("src");
+ Path src_lib1 = src.resolve("lib1");
+ tb.writeJavaFiles(src_lib1,
+ "module lib1 { exports lib1; }",
+ "package lib1; public class Lib1 {}");
+ Path src_lib2 = src.resolve("lib2");
+ tb.writeJavaFiles(src_lib2,
+ "module lib2 { exports lib2; }",
+ "package lib2; public class Lib2 {}");
+ Path src_api = src.resolve("api");
+ tb.writeJavaFiles(src_api,
+ "module api {\n" +
+ " exports api;\n" +
+ " exports qapi1 to qual1;\n" +
+ " exports qapi2 to qual1, qual2;\n" +
+ " requires public lib1;\n" +
+ " requires lib2;\n" +
+ "}\n",
+ "package api;\n" +
+ "public class Api {\n" +
+ " public lib1.Lib1 lib1;\n" +
+ " public lib2.Lib2 lib2;\n" +
+ " public qapi1.QApi1 qapi1;\n" +
+ " public impl.Impl impl;\n" +
+ "}",
+ "package qapi1;\n" +
+ "public class QApi1 {\n" +
+ " public qapi2.QApi2 qapi2;\n" +
+ "}",
+ "package qapi2;\n" +
+ "public class QApi2 {\n" +
+ " public qapi1.QApi1 qapi1;\n" +
+ "}",
+ "package impl;\n" +
+ "public class Impl {\n" +
+ "}");
+ Path src_qual1 = src.resolve("qual1");
+ tb.writeJavaFiles(src_qual1, "module qual1 { }");
+ Path src_qual2 = src.resolve("qual2");
+ tb.writeJavaFiles(src_qual2, "module qual2 { }");
+ Path classes = base.resolve("classes");
+ tb.createDirectories(classes);
+
+ List<String> log = new JavacTask(tb)
+ .options("-XDrawDiagnostics",
+ "-Werror",
+ "--module-source-path", src.toString(),
+ "-Xlint:exports")
+ .outdir(classes)
+ .files(findJavaFiles(src))
+ .run(Task.Expect.FAIL)
+ .writeAll()
+ .getOutputLines(Task.OutputKind.DIRECT);
+
+ List<String> expected = Arrays.asList(
+ "Api.java:4:16: compiler.warn.leaks.not.accessible.not.required.public: kindname.class, lib2.Lib2, lib2",
+ "Api.java:5:17: compiler.warn.leaks.not.accessible.unexported.qualified: kindname.class, qapi1.QApi1, api",
+ "Api.java:6:16: compiler.warn.leaks.not.accessible.unexported: kindname.class, impl.Impl, api",
+ "- compiler.err.warnings.and.werror",
+ "1 error",
+ "3 warnings"
+ );
+
+ if (!log.equals(expected))
+ throw new Exception("expected output not found");
+ }
+
+ @Test
+ public void testNestedClasses(Path base) throws Exception {
+ Path src = base.resolve("src");
+ Path src_api = src.resolve("api");
+ tb.writeJavaFiles(src_api,
+ "module api {\n" +
+ " exports api;\n" +
+ "}\n",
+ "package api;\n" +
+ "import impl.Impl.Nested;\n" +
+ "public class Api {\n" +
+ " public impl.Impl impl1;\n" +
+ " public impl.Impl.Nested impl2;\n" +
+ " public Nested impl3;\n" +
+ "}",
+ "package impl;\n" +
+ "public class Impl {\n" +
+ " public static class Nested {\n" +
+ " }\n" +
+ "}");
+ Path classes = base.resolve("classes");
+ tb.createDirectories(classes);
+
+ List<String> log = new JavacTask(tb)
+ .options("-XDrawDiagnostics",
+ "-Werror",
+ "--module-source-path", src.toString(),
+ "-Xlint:exports")
+ .outdir(classes)
+ .files(findJavaFiles(src))
+ .run(Task.Expect.FAIL)
+ .writeAll()
+ .getOutputLines(Task.OutputKind.DIRECT);
+
+ List<String> expected = Arrays.asList(
+ "Api.java:4:16: compiler.warn.leaks.not.accessible.unexported: kindname.class, impl.Impl, api",
+ "Api.java:5:16: compiler.warn.leaks.not.accessible.unexported: kindname.class, impl.Impl, api",
+ "Api.java:6:12: compiler.warn.leaks.not.accessible.unexported: kindname.class, impl.Impl.Nested, api",
+ "- compiler.err.warnings.and.werror",
+ "1 error",
+ "3 warnings"
+ );
+
+ if (!log.equals(expected))
+ throw new Exception("expected output not found");
+ }
+
+ @Test
+ public void testProtectedAndInaccessible(Path base) throws Exception {
+ Path src = base.resolve("src");
+ Path src_api = src.resolve("api");
+ tb.writeJavaFiles(src_api,
+ "module api {\n" +
+ " exports api;\n" +
+ "}\n",
+ "package api;\n" +
+ "public class Api extends PackagePrivateClass<PackagePrivateInterface> implements PackagePrivateInterface<PackagePrivateClass> {\n" +
+ " protected PackagePrivateClass<?> f1;\n" +
+ " protected PackagePrivateInterface<?> f2;\n" +
+ " protected Inner f3;\n" +
+ " protected PrivateInner f4;\n" +
+ " protected impl.Impl f5;\n" +
+ " public static class InnerClass extends PrivateInner {}\n" +
+ " protected static class Inner {}\n" +
+ " private static class PrivateInner {}\n" +
+ "}\n" +
+ "class PackagePrivateClass<T> {}\n" +
+ "interface PackagePrivateInterface<T> {}",
+ "package impl;\n" +
+ "public class Impl {\n" +
+ "}");
+ Path classes = base.resolve("classes");
+ tb.createDirectories(classes);
+
+ List<String> log = new JavacTask(tb)
+ .options("-XDrawDiagnostics",
+ "-Werror",
+ "--module-source-path", src.toString(),
+ "-Xlint:exports")
+ .outdir(classes)
+ .files(findJavaFiles(src))
+ .run(Task.Expect.FAIL)
+ .writeAll()
+ .getOutputLines(Task.OutputKind.DIRECT);
+
+ List<String> expected = Arrays.asList(
+ "Api.java:2:46: compiler.warn.leaks.not.accessible: kindname.interface, api.PackagePrivateInterface, api",
+ "Api.java:2:106: compiler.warn.leaks.not.accessible: kindname.class, api.PackagePrivateClass, api",
+ "Api.java:3:15: compiler.warn.leaks.not.accessible: kindname.class, api.PackagePrivateClass, api",
+ "Api.java:4:15: compiler.warn.leaks.not.accessible: kindname.interface, api.PackagePrivateInterface, api",
+ "Api.java:6:15: compiler.warn.leaks.not.accessible: kindname.class, api.Api.PrivateInner, api",
+ "Api.java:7:19: compiler.warn.leaks.not.accessible.unexported: kindname.class, impl.Impl, api",
+ "- compiler.err.warnings.and.werror",
+ "1 error",
+ "6 warnings"
+ );
+
+ if (!log.equals(expected))
+ throw new Exception("expected output not found");
+ }
+
+ @Test
+ public void testSuppressResetProperly(Path base) throws Exception {
+ Path src = base.resolve("src");
+ Path src_api = src.resolve("api");
+ tb.writeJavaFiles(src_api,
+ "module api {\n" +
+ " exports api;\n" +
+ "}\n",
+ "package api;\n" +
+ "public class Api {\n" +
+ " @SuppressWarnings(\"exports\")\n" +
+ " public PackagePrivateClass f1;\n" +
+ " public PackagePrivateClass f2;\n" +
+ " @SuppressWarnings(\"exports\")\n" +
+ " public void t() {}\n" +
+ " public PackagePrivateClass f3;\n" +
+ " @SuppressWarnings(\"exports\")\n" +
+ " public static class C {\n" +
+ " public PackagePrivateClass f4;\n" +
+ " }\n" +
+ " public PackagePrivateClass f5;\n" +
+ "}\n" +
+ "class PackagePrivateClass<T> {}\n");
+ Path classes = base.resolve("classes");
+ tb.createDirectories(classes);
+
+ List<String> log = new JavacTask(tb)
+ .options("-XDrawDiagnostics",
+ "-Werror",
+ "--module-source-path", src.toString(),
+ "-Xlint:exports")
+ .outdir(classes)
+ .files(findJavaFiles(src))
+ .run(Task.Expect.FAIL)
+ .writeAll()
+ .getOutputLines(Task.OutputKind.DIRECT);
+
+ List<String> expected = Arrays.asList(
+ "Api.java:5:12: compiler.warn.leaks.not.accessible: kindname.class, api.PackagePrivateClass, api",
+ "Api.java:8:12: compiler.warn.leaks.not.accessible: kindname.class, api.PackagePrivateClass, api",
+ "Api.java:13:12: compiler.warn.leaks.not.accessible: kindname.class, api.PackagePrivateClass, api",
+ "- compiler.err.warnings.and.werror",
+ "1 error",
+ "3 warnings"
+ );
+
+ if (!log.equals(expected))
+ throw new Exception("expected output not found");
+ }
+
+}
--- a/langtools/test/tools/jdeprscan/tests/jdk/jdeprscan/TestScan.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/test/tools/jdeprscan/tests/jdk/jdeprscan/TestScan.java Fri Oct 14 11:11:19 2016 -0700
@@ -74,7 +74,7 @@
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try (PrintStream out = new PrintStream(baos, false, "UTF-8")) {
boolean r = Main.call(out, System.err,
- "-cp", deprcases, "--Xload-dir", deprcases, deprusage);
+ "--class-path", deprcases, "--Xload-dir", deprcases, deprusage);
assertTrue(r);
}
byte[] bytes = baos.toByteArray();
--- a/langtools/test/tools/jdeps/jdkinternals/RemovedJDKInternals.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/test/tools/jdeps/jdkinternals/RemovedJDKInternals.java Fri Oct 14 11:11:19 2016 -0700
@@ -26,7 +26,7 @@
* @bug 8153042
* @summary Tests JDK internal APIs that have been removed.
* @library ../lib
- * @build CompilerUtils JdepsUtil ModuleMetaData
+ * @build CompilerUtils JdepsRunner JdepsUtil ModuleMetaData
* @modules jdk.jdeps/com.sun.tools.jdeps
* @run testng RemovedJDKInternals
*/
@@ -123,7 +123,8 @@
@Test
public void checkReplacement() {
- String[] output = JdepsUtil.jdeps("-jdkinternals", CLASSES_DIR.toString());
+ JdepsRunner jdeps = JdepsRunner.run("-jdkinternals", CLASSES_DIR.toString());
+ String[] output = jdeps.output();
int i = 0;
while (!output[i].contains("Suggested Replacement")) {
i++;
--- a/langtools/test/tools/jdeps/jdkinternals/ShowReplacement.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/test/tools/jdeps/jdkinternals/ShowReplacement.java Fri Oct 14 11:11:19 2016 -0700
@@ -70,7 +70,8 @@
@Test
public void withReplacement() {
Path file = Paths.get("q", "WithRepl.class");
- String[] output = JdepsUtil.jdeps("-jdkinternals", CLASSES_DIR.resolve(file).toString());
+ JdepsRunner jdeps = JdepsRunner.run("-jdkinternals", CLASSES_DIR.resolve(file).toString());
+ String[] output = jdeps.output();
int i = 0;
while (!output[i].contains("Suggested Replacement")) {
i++;
@@ -99,7 +100,8 @@
@Test
public void noReplacement() {
Path file = Paths.get("q", "NoRepl.class");
- String[] output = JdepsUtil.jdeps("-jdkinternals", CLASSES_DIR.resolve(file).toString());
+ JdepsRunner jdeps = JdepsRunner.run("-jdkinternals", CLASSES_DIR.resolve(file).toString());
+ String[] output = jdeps.output();
int i = 0;
// expect no replacement
while (i < output.length && !output[i].contains("Suggested Replacement")) {
@@ -116,7 +118,8 @@
@Test
public void removedPackage() {
Path file = Paths.get("q", "RemovedPackage.class");
- String[] output = JdepsUtil.jdeps("--jdk-internals", CLASSES_DIR.resolve(file).toString());
+ JdepsRunner jdeps = JdepsRunner.run("--jdk-internals", CLASSES_DIR.resolve(file).toString());
+ String[] output = jdeps.output();
int i = 0;
// expect no replacement
while (i < output.length && !output[i].contains("Suggested Replacement")) {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/jdeps/lib/JdepsRunner.java Fri Oct 14 11:11:19 2016 -0700
@@ -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.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please 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.io.PrintStream;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * JdepsRunner class to invoke jdeps with the given command line argument
+ */
+public class JdepsRunner {
+ public static JdepsRunner run(String... args) {
+ JdepsRunner jdeps = new JdepsRunner(args);
+ int rc = jdeps.run();
+ jdeps.printStdout(System.err);
+ if (rc != 0)
+ throw new Error("jdeps failed: rc=" + rc);
+ return jdeps;
+ }
+
+ final StringWriter stdout = new StringWriter();
+ final StringWriter stderr = new StringWriter();
+ final String[] args;
+ public JdepsRunner(String... args) {
+ System.err.println("jdeps " + Arrays.stream(args)
+ .collect(Collectors.joining(" ")));
+ this.args = args;
+ }
+
+ public JdepsRunner(List<String> args) {
+ this(args.toArray(new String[0]));
+ }
+
+ public int run() {
+ return run(false);
+ }
+
+ public int run(boolean showOutput) {
+ try (PrintWriter pw = new PrintWriter(stdout)) {
+ int rc = com.sun.tools.jdeps.Main.run(args, pw);
+ if (showOutput) {
+ System.err.println(stdout.toString());
+ }
+ return rc;
+ }
+ }
+
+ public boolean outputContains(String s) {
+ return stdout.toString().contains(s);
+ }
+
+ public void printStdout(PrintStream stream) {
+ stream.println(stdout.toString());
+ }
+
+ public void printStderr(PrintStream stream) {
+ stream.println(stderr.toString());
+ }
+
+ public String[] output() {
+ String lineSep = System.getProperty("line.separator");
+ return stdout.toString().split(lineSep);
+ }
+}
--- a/langtools/test/tools/jdeps/lib/JdepsUtil.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/test/tools/jdeps/lib/JdepsUtil.java Fri Oct 14 11:11:19 2016 -0700
@@ -39,37 +39,17 @@
import java.lang.module.ModuleDescriptor;
import java.nio.file.Files;
import java.nio.file.Path;
-import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.jar.JarEntry;
import java.util.jar.JarOutputStream;
import java.util.regex.Pattern;
-import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* Utilities to run jdeps command
*/
public final class JdepsUtil {
- /*
- * Runs jdeps with the given arguments
- */
- public static String[] jdeps(String... args) {
- String lineSep = System.getProperty("line.separator");
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
- System.err.println("jdeps " + Arrays.stream(args).collect(Collectors.joining(" ")));
- int rc = com.sun.tools.jdeps.Main.run(args, pw);
- pw.close();
- String out = sw.toString();
- if (!out.isEmpty())
- System.err.println(out);
- if (rc != 0)
- throw new Error("jdeps failed: rc=" + rc);
- return out.split(lineSep);
- }
-
public static Command newCommand(String cmd) {
return new Command(cmd);
}
--- a/langtools/test/tools/jdeps/modules/GenModuleInfo.java Fri Oct 14 19:12:37 2016 +0300
+++ b/langtools/test/tools/jdeps/modules/GenModuleInfo.java Fri Oct 14 11:11:19 2016 -0700
@@ -25,7 +25,7 @@
* @test
* @summary Tests jdeps --generate-module-info option
* @library ../lib
- * @build CompilerUtils JdepsUtil
+ * @build CompilerUtils JdepsUtil JdepsRunner
* @modules jdk.jdeps/com.sun.tools.jdeps
* @run testng GenModuleInfo
*/
@@ -97,7 +97,7 @@
Stream<String> files = Arrays.stream(modules)
.map(mn -> LIBS_DIR.resolve(mn + ".jar"))
.map(Path::toString);
- JdepsUtil.jdeps(Stream.concat(Stream.of("-cp"), files).toArray(String[]::new));
+ JdepsRunner.run(Stream.concat(Stream.of("-cp"), files).toArray(String[]::new));
}
@Test
@@ -106,7 +106,7 @@
.map(mn -> LIBS_DIR.resolve(mn + ".jar"))
.map(Path::toString);
- JdepsUtil.jdeps(Stream.concat(Stream.of("--generate-module-info", DEST_DIR.toString()),
+ JdepsRunner.run(Stream.concat(Stream.of("--generate-module-info", DEST_DIR.toString()),
files).toArray(String[]::new));
// check file exists
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/jdeps/modules/UnnamedPackage.java Fri Oct 14 11:11:19 2016 -0700
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8166846
+ * @summary Tests --generate-module-info on invalid JAR file
+ * @modules jdk.jdeps/com.sun.tools.jdeps
+ * @library ../lib
+ * @build JdepsRunner JdepsUtil
+ * @run main UnnamedPackage
+ */
+
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.stream.Stream;
+
+public class UnnamedPackage {
+ private static final Path TEST_CLASSES = Paths.get(System.getProperty("test.classes"));
+ private static final Path FOO_JAR_FILE = Paths.get("foo.jar");
+
+ public static void main(String... args) throws Exception {
+ // create foo.jar with unnamed package
+ Path name = TEST_CLASSES.resolve("UnnamedPackage.class");
+ JdepsUtil.createJar(FOO_JAR_FILE, TEST_CLASSES, Stream.of(name));
+
+ // run jdeps --generate-module-info
+ JdepsRunner jdeps = new JdepsRunner("--generate-module-info",
+ "tmp", FOO_JAR_FILE.toString());
+ // should fail to generate module-info.java
+ int exitValue = jdeps.run();
+ if (exitValue == 0) {
+ throw new RuntimeException("expected non-zero exitValue");
+ }
+ if (!jdeps.outputContains("foo.jar contains an unnamed package")) {
+ jdeps.printStdout(System.out);
+ throw new RuntimeException("expected error message not found");
+ }
+ }
+}
--- a/make/CompileJavaModules.gmk Fri Oct 14 19:12:37 2016 +0300
+++ b/make/CompileJavaModules.gmk Fri Oct 14 11:11:19 2016 -0700
@@ -95,7 +95,7 @@
################################################################################
java.desktop_ADD_JAVAC_FLAGS := -Xdoclint:all/protected,-reference \
- '-Xdoclint/package:java.*,javax.*' -Xlint:-deprecation
+ '-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
@@ -316,7 +316,7 @@
################################################################################
-java.naming_ADD_JAVAC_FLAGS := -Xdoclint:all/protected '-Xdoclint/package:java.*,javax.*'
+java.naming_ADD_JAVAC_FLAGS := -Xdoclint:all/protected '-Xdoclint/package:java.*,javax.*' -Xlint:-exports
java.naming_CLEAN := jndiprovider.properties
################################################################################
@@ -344,6 +344,10 @@
################################################################################
+jdk.accessibility_ADD_JAVAC_FLAGS := -Xlint:-exports
+
+################################################################################
+
jdk.compiler_ADD_JAVAC_FLAGS := -Xdoclint:all/protected '-Xdoclint/package:-com.sun.tools.*' \
-XDstringConcat=inline
jdk.compiler_CLEAN_FILES := $(wildcard \
@@ -352,6 +356,10 @@
################################################################################
+jdk.jshell_ADD_JAVAC_FLAGS := -Xlint:-exports
+
+################################################################################
+
jdk.hotspot.agent_ADD_JAVAC_FLAGS := $(DISABLE_WARNINGS),-overrides
jdk.hotspot.agent_COPY := .gif .png sa.js .properties
@@ -428,6 +436,10 @@
################################################################################
+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))
@@ -440,6 +452,10 @@
################################################################################
+jdk.vm.ci_ADD_JAVAC_FLAGS := -Xlint:-exports
+
+################################################################################
+
jdk.xml.bind_SETUP := GENERATE_JDKBYTECODE_NOWARNINGS
jdk.xml.bind_CLEAN := .properties
jdk.xml.bind_COPY := .xsd JAXBContextFactory.java ZeroOneBooleanAdapter.java
--- a/make/CopyImportModules.gmk Fri Oct 14 19:12:37 2016 +0300
+++ b/make/CopyImportModules.gmk Fri Oct 14 11:11:19 2016 -0700
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -59,9 +59,24 @@
$(eval $(call SetupCopyFiles, COPY_LIBS, \
SRC := $(LIBS_DIR), \
DEST := $(JDK_OUTPUTDIR)/lib, \
- FILES := $(call CacheFind, $(LIBS_DIR)), \
+ FILES := $(filter %$(SHARED_LIBRARY_SUFFIX), $(call CacheFind, $(LIBS_DIR))), \
))
- TARGETS += $(COPY_LIBS)
+
+ # Use relative links if the import dir is inside the OUTPUT_ROOT, otherwise
+ # copy to avoid having automated systems following symlinks when deleting files,
+ # or risk invalidating the build output from external changes.
+ ifeq ($(filter $(OUTPUT_ROOT)/%, $(LIBS_DIR)), )
+ LINK_MACRO := install-file
+ else
+ LINK_MACRO := link-file-relative
+ endif
+ $(eval $(call SetupCopyFiles, LINK_LIBS, \
+ SRC := $(LIBS_DIR), \
+ DEST := $(JDK_OUTPUTDIR)/lib, \
+ FILES := $(filter-out %$(SHARED_LIBRARY_SUFFIX), $(call CacheFind, $(LIBS_DIR))), \
+ MACRO := $(LINK_MACRO), \
+ ))
+ TARGETS += $(COPY_LIBS) $(LINK_LIBS)
endif
endif
--- a/make/CreateJmods.gmk Fri Oct 14 19:12:37 2016 +0300
+++ b/make/CreateJmods.gmk Fri Oct 14 11:11:19 2016 -0700
@@ -38,9 +38,9 @@
JMODS_DIR := $(IMAGES_OUTPUTDIR)/jmods
LIBS_DIR := $(firstword $(wildcard $(addsuffix /$(MODULE), \
- $(SUPPORT_OUTPUTDIR)/modules_libs-stripped $(IMPORT_MODULES_LIBS))))
+ $(SUPPORT_OUTPUTDIR)/modules_libs $(IMPORT_MODULES_LIBS))))
CMDS_DIR := $(firstword $(wildcard $(addsuffix /$(MODULE), \
- $(SUPPORT_OUTPUTDIR)/modules_cmds-stripped $(IMPORT_MODULES_CMDS))))
+ $(SUPPORT_OUTPUTDIR)/modules_cmds $(IMPORT_MODULES_CMDS))))
CONF_DIR := $(firstword $(wildcard $(addsuffix /$(MODULE), \
$(SUPPORT_OUTPUTDIR)/modules_conf $(IMPORT_MODULES_CONF))))
CLASSES_DIR := $(wildcard $(JDK_OUTPUTDIR)/modules/$(MODULE))
@@ -103,7 +103,7 @@
--os-arch $(OPENJDK_TARGET_CPU_LEGACY) \
--os-version $(REQUIRED_OS_VERSION) \
--module-path $(JMODS_DIR) \
- --exclude '**{_the.*,*.diz,*.debuginfo,*.dSYM/**,*.pdb,*.map}' \
+ --exclude '**{_the.*,*.diz,*.debuginfo,*.dSYM/**,*.dSYM,*.pdb,*.map}' \
$(JMOD_FLAGS) $(SUPPORT_OUTPUTDIR)/jmods/$(notdir $@)
$(MV) $(SUPPORT_OUTPUTDIR)/jmods/$(notdir $@) $@
--- a/make/Help.gmk Fri Oct 14 19:12:37 2016 +0300
+++ b/make/Help.gmk Fri Oct 14 11:11:19 2016 -0700
@@ -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
@@ -39,7 +39,8 @@
$(info $(_) make [default] # Compile all modules in langtools, hotspot, jdk, jaxws,)
$(info $(_) # jaxp and corba, and create a runnable "exploded" image)
$(info $(_) make all # Compile everything, all repos, docs and images)
- $(info $(_) make images # Create complete jdk and jre images)
+ $(info $(_) make images # Create complete jdk and jre images (alias for product-images))
+ $(info $(_) make <name>-image # Build just the image (jdk, jre, test, docs etc))
$(info $(_) make <phase> # Build the specified phase and everything it depends on)
$(info $(_) # (gensrc, java, copy, libs, launchers, gendata, rmic))
$(info $(_) make *-only # Applies to most targets and disables compling the)
--- a/make/Images.gmk Fri Oct 14 19:12:37 2016 +0300
+++ b/make/Images.gmk Fri Oct 14 11:11:19 2016 -0700
@@ -382,14 +382,28 @@
################################################################################
# /demo dir
-ifneq ($(findstring images, $(MAKECMDGOALS)), )
+# 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, \
+ $(shell $(FIND) $(SUPPORT_OUTPUTDIR)/demos/image \
+ -type f -a ! \( -name "_the*" -o -name "javac_state" \) ))) \
+ )
+
+ ifeq ($(ZIP_EXTERNAL_DEBUG_SYMBOLS), true)
+ ifeq ($(OPENJDK_TARGET_OS), macosx)
+ DEMO_FILES := $(call not-containing, .dSYM, $(DEMO_FILES))
+ else
+ DEMO_FILES := $(filter-out %.debuginfo %.pdb %.map, $(DEMO_FILES))
+ endif
+ endif
+
$(eval $(call SetupCopyFiles, JDK_COPY_DEMOS, \
SRC := $(SUPPORT_OUTPUTDIR)/demos/image, \
DEST := $(JDK_IMAGE_DIR)/demo, \
- FILES := $(if $(wildcard $(SUPPORT_OUTPUTDIR)/demos/image), \
- $(call DoubleDollar, $(call DoubleDollar, \
- $(shell $(FIND) $(SUPPORT_OUTPUTDIR)/demos/image \
- -type f -a ! \( -name "_the*" -o -name "javac_state" \) )))), \
+ FILES := $(DEMO_FILES), \
))
JDK_TARGETS += $(JDK_COPY_DEMOS)
@@ -454,21 +468,25 @@
LIBS_TARGET_SUBDIR := lib
endif
-DEBUGINFO_SUFFIXES := .diz .debuginfo .pdb .map
-
# Param 1 - dir to find debuginfo files in
FindDebuginfoFiles = \
$(wildcard $(addprefix $1/*, $(DEBUGINFO_SUFFIXES)) \
$(addprefix $1/*/*, $(DEBUGINFO_SUFFIXES)) \
$(addprefix $1/*/*/*, $(DEBUGINFO_SUFFIXES)))
-# On Macosx, if debug symbols have not been zipped, find all files inside *.dSYM
-# dirs.
-ifeq ($(OPENJDK_TARGET_OS)-$(ZIP_EXTERNAL_DEBUG_SYMBOLS), macosx-false)
- $(eval $(call FillCacheFind, \
- $(SUPPORT_OUTPUTDIR)/modules_cmds $(SUPPORT_OUTPUTDIR)/modules_libs/))
- FindDebuginfoFiles = \
- $(if $(wildcard $1), $(call containing, .dSYM/, $(call CacheFind, $1)))
+# Pick the correct debug info files to copy, either zipped or not.
+ifeq ($(ZIP_EXTERNAL_DEBUG_SYMBOLS), true)
+ DEBUGINFO_SUFFIXES += .diz
+else
+ DEBUGINFO_SUFFIXES := .debuginfo .pdb .map
+ # On Macosx, if debug symbols have not been zipped, find all files inside *.dSYM
+ # dirs.
+ ifeq ($(OPENJDK_TARGET_OS), macosx)
+ $(eval $(call FillCacheFind, \
+ $(SUPPORT_OUTPUTDIR)/modules_cmds $(SUPPORT_OUTPUTDIR)/modules_libs))
+ FindDebuginfoFiles = \
+ $(if $(wildcard $1), $(call containing, .dSYM/, $(call CacheFind, $1)))
+ endif
endif
# Param 1 - either JDK or JRE
@@ -499,8 +517,11 @@
$(JRE_TARGETS): $(TOOL_JRE_TARGETS)
$(JDK_TARGETS): $(TOOL_JDK_TARGETS)
-jimages: $(TOOL_JRE_TARGETS) $(TOOL_JDK_TARGETS) $(JRE_TARGETS) $(JDK_TARGETS) \
- $(SYMBOLS_TARGETS)
+jdk: $(JDK_TARGETS)
+jre: $(JRE_TARGETS)
+symbols: $(SYMBOLS_TARGETS)
+
+all: jdk jre symbols
$(JRE_COMPACT1_TARGETS): $(TOOL_JRE_COMPACT1_TARGETS)
$(JRE_COMPACT2_TARGETS): $(TOOL_JRE_COMPACT2_TARGETS)
@@ -513,4 +534,4 @@
$(JRE_COMPACT2_TARGETS) \
$(JRE_COMPACT3_TARGETS)
-.PHONY: default all jimages profiles
+.PHONY: default all jdk jre symbols profiles
--- a/make/Javadoc.gmk Fri Oct 14 19:12:37 2016 +0300
+++ b/make/Javadoc.gmk Fri Oct 14 11:11:19 2016 -0700
@@ -773,19 +773,17 @@
# jvmtidocs
#
-ALL_OTHER_TARGETS += jvmtidocs
-
-JVMTI_DOCDIR = $(PLATFORM_DOCSDIR)/jvmti
-JVMTI_HTML = $(HOTSPOT_DIST)/docs/platform/jvmti/jvmti.html
+JVMTI_DOCDIR := $(PLATFORM_DOCSDIR)/jvmti
+# Pick jvmti.html from any jvm variant, they are all the same.
+JVMTI_HTML := $(firstword \
+ $(wildcard $(HOTSPOT_OUTPUTDIR)/variant-*/gensrc/jvmtifiles/jvmti.html))
-jvmtidocs: $(JVMTI_DOCDIR)/jvmti.html
-$(JVMTI_DOCDIR)/jvmti.html:
- @$(prep-javadoc)
- @if [ -f $(JVMTI_HTML) ] ; then \
- $(CP) $(JVMTI_HTML) $@; \
- else \
- $(ECHO) "WARNING: Generated file does not exist: $(JVMTI_HTML)"; \
- fi
+$(eval $(call SetupCopyFiles, COPY_JVMTI_HTML, \
+ FILES := $(JVMTI_HTML), \
+ DEST := $(PLATFORM_DOCSDIR)/jvmti, \
+))
+
+jvmtidocs: $(COPY_JVMTI_HTML)
#############################################################
#
--- a/make/Main.gmk Fri Oct 14 19:12:37 2016 +0300
+++ b/make/Main.gmk Fri Oct 14 11:11:19 2016 -0700
@@ -93,16 +93,13 @@
################################################################################
# Special targets for certain modules
-import-hotspot:
- +($(CD) $(JDK_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f Import.gmk)
-
unpack-sec:
+($(CD) $(JDK_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f UnpackSecurity.gmk)
generate-exported-symbols:
+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f BuildStatic.gmk)
-ALL_TARGETS += import-hotspot unpack-sec generate-exported-symbols
+ALL_TARGETS += unpack-sec generate-exported-symbols
################################################################################
# Gensrc targets, generating source before java compilation can be done
@@ -269,23 +266,6 @@
ALL_TARGETS += generate-summary
################################################################################
-# Strip binaries targets
-
-STRIP_MODULES := $(sort $(LIBS_MODULES) $(LAUNCHER_MODULES) $(COPY_MODULES) \
- $(GENDATA_MODULES))
-STRIP_TARGETS := $(addsuffix -strip, $(STRIP_MODULES))
-
-define DeclareStripRecipe
- $1-strip:
- +($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f StripBinaries.gmk \
- MODULE=$1)
-endef
-
-$(foreach m, $(STRIP_MODULES), $(eval $(call DeclareStripRecipe,$m)))
-
-ALL_TARGETS += $(STRIP_TARGETS)
-
-################################################################################
# Jmod targets
JMOD_MODULES := $(ALL_MODULES)
@@ -334,8 +314,14 @@
jrtfs-jar:
+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f JrtfsJar.gmk)
-jimages:
- +($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Images.gmk jimages)
+jdk-image:
+ +($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Images.gmk jdk)
+
+jre-image:
+ +($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Images.gmk jre)
+
+symbols-image:
+ +($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Images.gmk symbols)
profiles:
+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Images.gmk profiles)
@@ -347,7 +333,8 @@
+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f ExplodedImageOptimize.gmk)
ALL_TARGETS += source-tips create-hgtip-files bootcycle-images zip-security \
- zip-source jrtfs-jar jimages profiles mac-bundles-jdk \
+ zip-source jrtfs-jar jdk-image jre-image \
+ symbols-image profiles mac-bundles-jdk \
exploded-image-optimize
################################################################################
@@ -386,7 +373,7 @@
ALL_TARGETS += create-buildjdk-copy create-buildjdk-interim-image
################################################################################
-# The interim-image is a small jlinked image that is used to generate artifacts
+# 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-image:
@@ -548,11 +535,9 @@
hotspot-ide-project: hotspot exploded-image
- import-hotspot: hotspot
-
generate-exported-symbols: java.base-libs jdk.jdwp.agent-libs
- $(LIBS_TARGETS): import-hotspot
+ $(LIBS_TARGETS): hotspot
$(LAUNCHER_TARGETS): java.base-libs
@@ -607,17 +592,8 @@
# Explicitly add dependencies for special targets
java.base-java: unpack-sec
- # The copy target copies files generated by gensrc
- java.base-copy-hotspot: java.base-gensrc-hotspot
-
jdk.jdeps-gendata: java rmic
- # Declare dependencies from <module>-strip to libs, launchers, gendata and copy
- $(foreach m, $(LIBS_MODULES), $(eval $m-strip: $m-libs))
- $(foreach m, $(LAUNCHER_MODULES), $(eval $m-strip: $m-launchers))
- $(foreach m, $(GENDATA_MODULES), $(eval $m-strip: $m-gendata))
- $(foreach m, $(COPY_MODULES), $(eval $m-strip: $m-copy))
-
# Declare dependencies between jmod targets. Only java.base jmod needs access
# to the other jmods to be built.
# When creating a BUILDJDK, we don't need to add hashes to java.base, thus
@@ -628,7 +604,6 @@
endif
# Declare dependencies from <module>-jmod to all other module targets
- $(foreach m, $(STRIP_MODULES), $(eval $m-jmod: $m-strip))
# When creating a BUILDJDK, the java compilation has already been done by the
# normal build and copied in.
ifneq ($(CREATING_BUILDJDK), true)
@@ -640,23 +615,33 @@
$(foreach m, $(LAUNCHER_MODULES), $(eval $m-jmod: $m-launchers))
$(foreach m, $(COPY_MODULES), $(eval $m-jmod: $m-copy))
- # Jmods cannot be created until we have the jlink tool ready to run, which requires
- # all java modules to be compiled and jdk.jlink-launchers.
- # And we also need to copy jvm.cfg (done in java.base-copy) and tzdb.dat (done in
- # java.base-gendata) to the appropriate location otherwise jimage, jlink and jmod won't start.
- $(JMOD_TARGETS): java.base-libs java.base-copy java.base-gendata jdk.jlink-launchers
- # When creating a BUILDJDK, the java compilation has already been done by the
- # normal build and copied in.
- ifneq ($(CREATING_BUILDJDK), true)
- $(JMOD_TARGETS): java
- endif
-
+ # 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
+ # it's run from the buildjdk, which is either created at build time or user
+ # supplied.
+ #
+ # For the exploded image to be runnable, all java modules and
+ # jdk.jlink-launchers need to be built. We also need to copy jvm.cfg (done
+ # in java.base-copy) and tzdb.dat (done in java.base-gendata) to the
+ # appropriate location otherwise jimage, jlink and jmod won't start. This
+ # also applies when creating the buildjdk.
+ DEFAULT_JMOD_DEPS := java.base-libs java.base-copy java.base-gendata \
+ jdk.jlink-launchers
+ # When cross compiling and buildjdk is to be created, depend on creating the
+ # buildjdk instead of the default dependencies.
ifeq ($(CREATE_BUILDJDK), true)
- # Avoid calling create-buildjdk from within a create-buildjdk call
+ # Avoid calling create-buildjdk from within a create-buildjdk call.
ifneq ($(CREATING_BUILDJDK), true)
$(JMOD_TARGETS): create-buildjdk
buildtools-modules: create-buildjdk
+ else
+ # While actually creating the buildjdk, the default deps applies.
+ $(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
endif
zip-security: java.base-java java.security.jgss-java java.security.jgss-libs \
@@ -678,18 +663,23 @@
endif
generate-classlist: buildtools-jdk
- jimages: generate-classlist
+ jdk-image jre-image: generate-classlist
endif
- jimages: jmods zip-source source-tips demos samples jrtfs-jar
+ jdk-image: jmods zip-source source-tips demos samples jrtfs-jar
+ jre-image: jmods source-tips jrtfs-jar
profiles: jmods zip-source source-tips jrtfs-jar
- mac-bundles-jdk: jimages
+ mac-bundles-jdk: jdk-image jre-image
- exploded-image-optimize: exploded-image-base buildtools-modules
+ # The optimize target can run as soon as the modules dir has been completely
+ # populated (java, copy and gendata targets) and the basic libs and launchers
+ # have been built.
+ exploded-image-optimize: java copy gendata java.base-libs java.base-launchers \
+ buildtools-modules
- bootcycle-images: jimages
+ bootcycle-images: jdk-image
docs-javadoc: $(GENSRC_TARGETS) rmic
@@ -697,7 +687,7 @@
zip-docs: docs-javadoc docs-jvmtidoc
- test: jimages test-image
+ test: jdk-image test-image
create-buildjdk-copy: jdk.jlink-java java.base-gendata \
$(addsuffix -java, $(INTERIM_IMAGE_MODULES))
@@ -716,7 +706,7 @@
test-image-failure-handler: build-test-failure-handler
- build-test-hotspot-jtreg-native: buildtools-jdk import-hotspot
+ build-test-hotspot-jtreg-native: buildtools-jdk hotspot
build-test-jdk-jtreg-native: buildtools-jdk
@@ -728,7 +718,7 @@
test-hotspot-internal: exploded-image
- test-hotspot-jtreg: jimages test-image
+ test-hotspot-jtreg: jdk-image test-image
test-hotspot-gtest: exploded-image test-image-hotspot-gtest
@@ -766,8 +756,6 @@
jmods: $(JMOD_TARGETS)
-strip-binaries: $(STRIP_TARGETS)
-
# Explicitly declare dependency for virtual target jdk.jdwp.agent-gensrc which
# is actually handled by jdk.jdi-gensrc
jdk.jdwp.agent-gensrc: jdk.jdi-gensrc
@@ -787,7 +775,12 @@
# The "exploded image" is a locally runnable JDK in $(BUILD_OUTPUT)/jdk.
exploded-image-base: $(ALL_MODULES)
-exploded-image: exploded-image-base exploded-image-optimize
+exploded-image: exploded-image-base
+# When cross compiling, no need to optimize the exploded image since it won't
+# be runnable on the host platform anyway.
+ifneq ($(COMPILE_TYPE), cross)
+ exploded-image: exploded-image-optimize
+endif
create-buildjdk: create-buildjdk-copy create-buildjdk-interim-image
@@ -798,7 +791,11 @@
# This target builds the product images, e.g. the JRE and JDK image
# (and possibly other, more specific versions)
-product-images: jimages demos samples zip-security exploded-image
+product-images: jdk-image jre-image symbols-image exploded-image
+
+# zip-security is actually a bundle, but for now it needs to be considered
+# an image until this can be cleaned up properly.
+product-images: zip-security
# The module summary cannot be run when:
# * Cross compiling and building a partial BUILDJDK for the build host
--- a/make/MainSupport.gmk Fri Oct 14 19:12:37 2016 +0300
+++ b/make/MainSupport.gmk Fri Oct 14 11:11:19 2016 -0700
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -88,9 +88,7 @@
@$(PRINTF) "\n" $(LOG_DEBUG)
$(RM) -r $(SUPPORT_OUTPUTDIR)/native/$(strip $1)
$(RM) -r $(SUPPORT_OUTPUTDIR)/modules_libs/$(strip $1)
- $(RM) -r $(SUPPORT_OUTPUTDIR)/modules_libs-stripped/$(strip $1)
$(RM) -r $(SUPPORT_OUTPUTDIR)/modules_cmds/$(strip $1)
- $(RM) -r $(SUPPORT_OUTPUTDIR)/modules_cmds-stripped/$(strip $1)
@$(PRINTF) " done\n"
endef
--- a/make/ModuleWrapper.gmk Fri Oct 14 19:12:37 2016 +0300
+++ b/make/ModuleWrapper.gmk Fri Oct 14 11:11:19 2016 -0700
@@ -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
@@ -45,44 +45,59 @@
ifeq ($(OPENJDK_TARGET_OS), windows)
TO_BIN_FILTER := %$(SHARED_LIBRARY_SUFFIX) %.diz %.pdb %.map
- $(eval $(call SetupCopyFiles,COPY_LIBS_TO_BIN, \
+ $(eval $(call SetupCopyFiles, COPY_LIBS_TO_BIN, \
SRC := $(SUPPORT_OUTPUTDIR)/modules_libs/$(MODULE), \
DEST := $(JDK_OUTPUTDIR)/bin, \
FILES := $(filter $(TO_BIN_FILTER), \
$(filter $(SUPPORT_OUTPUTDIR)/modules_libs/$(MODULE)/%, \
- $(TARGETS)))))
+ $(TARGETS))), \
+ ))
- $(eval $(call SetupCopyFiles,COPY_LIBS_TO_LIB, \
+ $(eval $(call SetupCopyFiles, COPY_LIBS_TO_LIB, \
SRC := $(SUPPORT_OUTPUTDIR)/modules_libs/$(MODULE), \
DEST := $(JDK_OUTPUTDIR)/lib, \
FILES := $(filter-out $(TO_BIN_FILTER), \
$(filter $(SUPPORT_OUTPUTDIR)/modules_libs/$(MODULE)/%, \
- $(TARGETS)))))
+ $(TARGETS))), \
+ ))
else
- $(eval $(call SetupCopyFiles,COPY_LIBS_TO_LIB, \
+ $(eval $(call SetupCopyFiles, COPY_LIBS_TO_LIB, \
SRC := $(SUPPORT_OUTPUTDIR)/modules_libs/$(MODULE), \
DEST := $(JDK_OUTPUTDIR)/lib, \
- FILES := $(filter $(SUPPORT_OUTPUTDIR)/modules_libs/$(MODULE)/%, \
- $(TARGETS))))
+ FILES := $(filter %$(SHARED_LIBRARY_SUFFIX), \
+ $(filter $(SUPPORT_OUTPUTDIR)/modules_libs/$(MODULE)/%, \
+ $(TARGETS))), \
+ ))
+ $(eval $(call SetupCopyFiles, LINK_LIBS_TO_LIB, \
+ SRC := $(SUPPORT_OUTPUTDIR)/modules_libs/$(MODULE), \
+ DEST := $(JDK_OUTPUTDIR)/lib, \
+ FILES := $(filter-out %$(SHARED_LIBRARY_SUFFIX), \
+ $(filter $(SUPPORT_OUTPUTDIR)/modules_libs/$(MODULE)/%, \
+ $(TARGETS))), \
+ MACRO := link-file-relative, \
+ ))
endif
-$(eval $(call SetupCopyFiles,COPY_INCLUDE, \
+$(eval $(call SetupCopyFiles, COPY_INCLUDE, \
SRC := $(SUPPORT_OUTPUTDIR)/modules_include/$(MODULE), \
DEST := $(JDK_OUTPUTDIR)/include, \
FILES := $(filter $(SUPPORT_OUTPUTDIR)/modules_include/$(MODULE)/%, \
- $(TARGETS))))
+ $(TARGETS)), \
+))
-$(eval $(call SetupCopyFiles,COPY_CMDS, \
+$(eval $(call SetupCopyFiles, COPY_CMDS, \
SRC := $(SUPPORT_OUTPUTDIR)/modules_cmds/$(MODULE), \
DEST := $(JDK_OUTPUTDIR)/bin, \
- FILES := $(filter $(SUPPORT_OUTPUTDIR)/modules_cmds/$(MODULE)/%, $(TARGETS))))
+ FILES := $(filter $(SUPPORT_OUTPUTDIR)/modules_cmds/$(MODULE)/%, $(TARGETS)), \
+))
-$(eval $(call SetupCopyFiles,COPY_CONF, \
+$(eval $(call SetupCopyFiles, COPY_CONF, \
SRC := $(SUPPORT_OUTPUTDIR)/modules_conf/$(MODULE), \
DEST := $(JDK_OUTPUTDIR)/conf, \
FILES := $(filter $(SUPPORT_OUTPUTDIR)/modules_conf/$(MODULE)/%, \
- $(TARGETS))))
+ $(TARGETS)), \
+))
all: $(TARGETS) $(COPY_LIBS_TO_BIN) $(COPY_LIBS_TO_LIB) \
- $(COPY_INCLUDE) $(COPY_CMDS) $(COPY_CONF)
+ $(COPY_INCLUDE) $(COPY_CMDS) $(COPY_CONF) $(LINK_LIBS_TO_LIB)
--- a/make/StripBinaries.gmk Fri Oct 14 19:12:37 2016 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,109 +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.
-#
-
-default: all
-
-include $(SPEC)
-include MakeBase.gmk
-
-# Hook to include the corresponding custom file, if present.
-$(eval $(call IncludeCustomExtension, , StripBinaries.gmk))
-
-################################################################################
-# Copy native libraries and executables to a secondary location to strip them
-# and filter out files that shouldn't go into the image.
-
-MODULES_CMDS_STRIPPED := $(SUPPORT_OUTPUTDIR)/modules_cmds-stripped
-MODULES_LIBS_STRIPPED := $(SUPPORT_OUTPUTDIR)/modules_libs-stripped
-
-ifneq ($(STRIP), )
- define StripRecipe
- $(call LogInfo, Stripping $(patsubst $(OUTPUT_ROOT)/%,%,$<))
- $(call MakeDir, $(@D))
- $(CP) $< $@.tmp
- $(CHMOD) u+w $@.tmp
- $(STRIP) $(STRIPFLAGS) $@.tmp
- $(CHMOD) go-w $@.tmp
- $(MV) $@.tmp $@
- endef
-else
- define StripRecipe
- $(call install-file)
- endef
-endif
-
-NO_STRIP_CMDS_FILTER += %.cgi
-
-# Don't include debug info for executables.
-ifneq ($(wildcard $(SUPPORT_OUTPUTDIR)/modules_cmds/$(MODULE)), )
- # OS X stores symbol information in a .dylib file inside a .dSYM directory -
- # that file should not be stripped, so we prune the tree at the .dSYM directory.
- ALL_CMDS_SRC := $(filter-out %.bc %.debuginfo %.diz %.map %.pdb, \
- $(shell $(FIND) $(SUPPORT_OUTPUTDIR)/modules_cmds/$(MODULE) \( -type f -o -type l \) \
- -print -o -name "*.dSYM" -prune))
- COPY_CMDS_SRC := $(filter $(NO_STRIP_CMDS_FILTER), $(ALL_CMDS_SRC))
- STRIP_CMDS_SRC := $(filter-out $(NO_STRIP_CMDS_FILTER), $(ALL_CMDS_SRC))
-endif
-
-ifneq ($(wildcard $(SUPPORT_OUTPUTDIR)/modules_libs/$(MODULE)), )
- # OS X stores symbol information in a .dylib file inside a .dSYM directory -
- # that file should not be stripped, so we prune the tree at the .dSYM directory.
- # Example: support/modules_libs/java.base/libjsig.dylib.dSYM/Contents/Resources/DWARF/libjsig.dylib
- STRIP_LIBS_SRC := \
- $(shell $(FIND) $(SUPPORT_OUTPUTDIR)/modules_libs/$(MODULE) \
- -name '*$(SHARED_LIBRARY_SUFFIX)' -type f -print -o -name "*.dSYM" -prune)
-
- # Make sure symbolic links are copied and not stripped.
- COPY_LIBS_SRC := \
- $(filter-out $(STRIP_LIBS_SRC), \
- $(shell $(FIND) $(SUPPORT_OUTPUTDIR)/modules_libs/$(MODULE) -type f -o -type l))
-endif
-
-$(eval $(call SetupCopyFiles,STRIP_MODULES_CMDS, \
- SRC := $(SUPPORT_OUTPUTDIR)/modules_cmds, \
- DEST := $(MODULES_CMDS_STRIPPED), \
- FILES := $(STRIP_CMDS_SRC), \
- MACRO := StripRecipe))
-
-$(eval $(call SetupCopyFiles,COPY_MODULES_CMDS, \
- SRC := $(SUPPORT_OUTPUTDIR)/modules_cmds, \
- DEST := $(MODULES_CMDS_STRIPPED), \
- FILES := $(COPY_CMDS_SRC)))
-
-$(eval $(call SetupCopyFiles,STRIP_MODULES_LIBS, \
- SRC := $(SUPPORT_OUTPUTDIR)/modules_libs, \
- DEST := $(MODULES_LIBS_STRIPPED), \
- FILES := $(STRIP_LIBS_SRC), \
- MACRO := StripRecipe))
-
-$(eval $(call SetupCopyFiles,COPY_MODULES_LIBS, \
- SRC := $(SUPPORT_OUTPUTDIR)/modules_libs, \
- DEST := $(MODULES_LIBS_STRIPPED), \
- FILES := $(COPY_LIBS_SRC)))
-
-TARGETS += $(STRIP_MODULES_CMDS) $(COPY_MODULES_CMDS) \
- $(STRIP_MODULES_LIBS) $(COPY_MODULES_LIBS)
-
-all: $(TARGETS)
--- a/make/common/MakeBase.gmk Fri Oct 14 19:12:37 2016 +0300
+++ b/make/common/MakeBase.gmk Fri Oct 14 11:11:19 2016 -0700
@@ -535,6 +535,67 @@
endif
################################################################################
+# Take two paths and return the path of the last common directory.
+# Ex: /foo/bar/baz, /foo/bar/banan -> /foo/bar
+# foo/bar/baz, /foo/bar -> <empty>
+#
+# The x prefix is used to preserve the presence of the initial slash
+#
+# $1 - Path to compare
+# $2 - Other path to compare
+FindCommonPathPrefix = \
+ $(patsubst x%,%,$(subst $(SPACE),/,$(strip \
+ $(call FindCommonPathPrefixHelper, \
+ $(subst /,$(SPACE),x$(strip $1)), $(subst /,$(SPACE),x$(strip $2))) \
+ )))
+
+FindCommonPathPrefixHelper = \
+ $(if $(call equals, $(firstword $1), $(firstword $2)), \
+ $(firstword $1) \
+ $(call FindCommonPathPrefixHelper, \
+ $(wordlist 2, $(words $1), $1), $(wordlist 2, $(words $2), $2) \
+ ) \
+ )
+
+# Convert a partial path into as many directory levels of ../, removing
+# leading and following /.
+# Ex: foo/bar/baz/ -> ../../..
+# foo/bar -> ../..
+# /foo -> ..
+DirToDotDot = \
+ $(subst $(SPACE),/,$(foreach d, $(subst /,$(SPACE),$1),..))
+
+# Computes the relative path from a directory to a file
+# $1 - File to compute the relative path to
+# $2 - Directory to compute the relative path from
+RelativePath = \
+ $(eval $1_prefix := $(call FindCommonPathPrefix, $1, $2)) \
+ $(eval $1_dotdots := $(call DirToDotDot, $(patsubst $($(strip $1)_prefix)/%, %, $2))) \
+ $(eval $1_suffix := $(patsubst $($(strip $1)_prefix)/%, %, $1)) \
+ $($(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
+ $(call MakeDir, $(@D))
+ $(RM) $@
+ $(LN) -s $(call RelativePath, $<, $(@D)) $@
+ endef
+
+ define link-file-absolute
+ $(call MakeDir, $(@D))
+ $(RM) $@
+ $(LN) -s $< $@
+ endef
+endif
+
+################################################################################
# Filter out duplicate sub strings while preserving order. Keeps the first occurance.
uniq = \
$(if $1,$(firstword $1) $(call uniq,$(filter-out $(firstword $1),$1)))
--- a/make/common/NativeCompilation.gmk Fri Oct 14 19:12:37 2016 +0300
+++ b/make/common/NativeCompilation.gmk Fri Oct 14 11:11:19 2016 -0700
@@ -346,6 +346,7 @@
# LIBS the libraries to link to
# ARFLAGS the archiver flags to be used
# OBJECT_DIR the directory where we store the object files
+# OUTPUT_DIR the directory where the resulting binary is put
# LIBRARY the resulting library file
# PROGRAM the resulting exec file
# INCLUDES only pick source from these directories
@@ -829,67 +830,58 @@
ifneq ($$($1_DEBUG_SYMBOLS), false)
# Only copy debug symbols for dynamic libraries and programs.
ifeq ($$($1_STATIC_LIBRARY), )
- ifneq ($$($1_OUTPUT_DIR), $$($1_OBJECT_DIR))
- # The dependency on TARGET is needed on windows for debuginfo files
- # to be rebuilt properly.
- $$($1_OUTPUT_DIR)/% : $$($1_OBJECT_DIR)/% $$($1_TARGET)
- # Use cp -r since on macosx, the dSYM is a directory
- $(CP) -r $$< $$@
- endif
-
# Generate debuginfo files.
ifeq ($(OPENJDK_TARGET_OS), windows)
- $1_EXTRA_LDFLAGS += -debug "-pdb:$$($1_OBJECT_DIR)/$$($1_NOSUFFIX).pdb" \
- "-map:$$($1_OBJECT_DIR)/$$($1_NOSUFFIX).map"
- $1_DEBUGINFO_FILES := $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).pdb \
- $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).map
+ $1_EXTRA_LDFLAGS += -debug "-pdb:$$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).pdb" \
+ "-map:$$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).map"
+ $1_DEBUGINFO_FILES := $$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).pdb \
+ $$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).map
# No separate command is needed for debuginfo on windows, instead
# touch target to make sure it has a later time stamp than the debug
# symbol files to avoid unnecessary relinking on rebuild.
$1_CREATE_DEBUGINFO_CMDS := $(TOUCH) $$($1_TARGET)
else ifneq ($(findstring $(OPENJDK_TARGET_OS), linux solaris), )
- $1_DEBUGINFO_FILES := $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).debuginfo
+ $1_DEBUGINFO_FILES := $$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).debuginfo
# Setup the command line creating debuginfo files, to be run after linking.
# It cannot be run separately since it updates the original target file
$1_CREATE_DEBUGINFO_CMDS := \
- $$($1_OBJCOPY) --only-keep-debug $$($1_TARGET) $$($1_DEBUGINFO_FILES) $$(NEWLINE) \
- $(CD) $$($1_OUTPUT_DIR) && \
- $$($1_OBJCOPY) --add-gnu-debuglink=$$($1_DEBUGINFO_FILES) $$($1_TARGET)
+ $$($1_OBJCOPY) --only-keep-debug $$($1_TARGET) $$($1_DEBUGINFO_FILES) $$(NEWLINE) \
+ $(CD) $$($1_OUTPUT_DIR) && \
+ $$($1_OBJCOPY) --add-gnu-debuglink=$$($1_DEBUGINFO_FILES) $$($1_TARGET)
else ifeq ($(OPENJDK_TARGET_OS), macosx)
- $1_DEBUGINFO_FILES := $$($1_OBJECT_DIR)/$$($1_BASENAME).dSYM
+ $1_DEBUGINFO_FILES := \
+ $$($1_OUTPUT_DIR)/$$($1_BASENAME).dSYM/Contents/Info.plist \
+ $$($1_OUTPUT_DIR)/$$($1_BASENAME).dSYM/Contents/Resources/DWARF/$$($1_BASENAME)
# On Macosx, the debuginfo generation doesn't touch the linked binary, but
# to avoid always relinking, touch it anyway to force a later timestamp than
# the dSYM files.
$1_CREATE_DEBUGINFO_CMDS := \
- $(DSYMUTIL) --out $$($1_DEBUGINFO_FILES) $$($1_TARGET) $$(NEWLINE) \
+ $(DSYMUTIL) --out $$($1_OUTPUT_DIR)/$$($1_BASENAME).dSYM $$($1_TARGET) $$(NEWLINE) \
$(TOUCH) $$($1_TARGET)
endif # OPENJDK_TARGET_OS
- # This dependency dance ensures that debug info files get rebuilt
- # properly if deleted.
- $$($1_TARGET): $$($1_DEBUGINFO_FILES)
- $$($1_DEBUGINFO_FILES): $$($1_ALL_OBJS)
+ $$($1_DEBUGINFO_FILES): $$($1_TARGET)
+
+ $1 += $$($1_DEBUGINFO_FILES)
ifeq ($$($1_ZIP_EXTERNAL_DEBUG_SYMBOLS), true)
- $1_DEBUGINFO_ZIP := $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).diz
- $1 += $$(subst $$($1_OBJECT_DIR),$$($1_OUTPUT_DIR),$$($1_DEBUGINFO_ZIP))
+ $1_DEBUGINFO_ZIP := $$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).diz
+ $1 += $$($1_DEBUGINFO_ZIP)
# The dependency on TARGET is needed for debuginfo files
# to be rebuilt properly.
$$($1_DEBUGINFO_ZIP): $$($1_DEBUGINFO_FILES) $$($1_TARGET)
- $(CD) $$($1_OBJECT_DIR) \
- && $(ZIP) -q -r $$@ $$(notdir $$($1_DEBUGINFO_FILES))
+ $(CD) $$($1_OUTPUT_DIR) && \
+ $(ZIP) -q -r $$@ $$(subst $$($1_OUTPUT_DIR)/,, $$($1_DEBUGINFO_FILES))
- else
- $1 += $$(subst $$($1_OBJECT_DIR),$$($1_OUTPUT_DIR),$$($1_DEBUGINFO_FILES))
endif
- endif # !STATIC_LIBRARY
+ endif # !STATIC_LIBRARY
endif # $1_DEBUG_SYMBOLS != false
endif # COPY_DEBUG_SYMBOLS
- ifeq ($$($1_STRIP_SYMBOLS), true)
+ ifneq ($$($1_STRIP_SYMBOLS), false)
ifneq ($$($1_STRIP), )
# Default to using the global STRIPFLAGS. Allow for overriding with an empty value
$1_STRIPFLAGS ?= $(STRIPFLAGS)
@@ -902,6 +894,8 @@
$1_EXTRA_LDFLAGS += $$(call SET_SHARED_LIBRARY_NAME,$$($1_BASENAME))
ifeq ($(OPENJDK_TARGET_OS), windows)
$1_EXTRA_LDFLAGS += "-implib:$$($1_OBJECT_DIR)/$$($1_LIBRARY).lib"
+ # Create a rule for the import lib so that other rules may depend on it
+ $$($1_OBJECT_DIR)/$$($1_LIBRARY).lib: $$($1_TARGET)
endif
# Create loadmap on AIX. Helps in diagnosing some problems.
--- a/make/common/TestFilesCompilation.gmk Fri Oct 14 19:12:37 2016 +0300
+++ b/make/common/TestFilesCompilation.gmk Fri Oct 14 11:11:19 2016 -0700
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -88,6 +88,8 @@
LDFLAGS := $$($1_LDFLAGS) $$($1_LDFLAGS_$$($1_PREFIX)$$(name)), \
LIBS := $$($1_LIBS_$$($1_PREFIX)$$(name)), \
OPTIMIZATION := LOW, \
+ COPY_DEBUG_SYMBOLS := false, \
+ STRIP_SYMBOLS := false, \
)) \
$$(eval $1 += $$(BUILD_TEST_$$(name)) ) \
)
--- a/make/common/TextFileProcessing.gmk Fri Oct 14 19:12:37 2016 +0300
+++ b/make/common/TextFileProcessing.gmk Fri Oct 14 11:11:19 2016 -0700
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2013, 2014 Oracle and/or its affiliates. All rights reserved.
+# 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
--- a/nashorn/.hgtags Fri Oct 14 19:12:37 2016 +0300
+++ b/nashorn/.hgtags Fri Oct 14 11:11:19 2016 -0700
@@ -372,3 +372,4 @@
f11b8f5c4ccbf9c87d283815abac6c0117fba3c0 jdk-9+136
17ed43add2f9e3528686cd786ae2ed49c8ed36e9 jdk-9+137
4a6ee1185fc821df063e4d1537fa7ad2ebe9eb02 jdk-9+138
+e3b11296395b39bfeb3364f26c2ef77fa652e300 jdk-9+139
--- a/nashorn/ASSEMBLY_EXCEPTION Fri Oct 14 19:12:37 2016 +0300
+++ b/nashorn/ASSEMBLY_EXCEPTION Fri Oct 14 11:11:19 2016 -0700
@@ -1,27 +1,27 @@
OPENJDK ASSEMBLY EXCEPTION
-The OpenJDK source code made available by Sun at openjdk.java.net and
-openjdk.dev.java.net ("OpenJDK Code") is distributed under the terms of the
-GNU General Public License <http://www.gnu.org/copyleft/gpl.html> version 2
+The OpenJDK source code made available by Oracle America, Inc. (Oracle) at
+openjdk.java.net ("OpenJDK Code") is distributed under the terms of the GNU
+General Public License <http://www.gnu.org/copyleft/gpl.html> version 2
only ("GPL2"), with the following clarification and special exception.
Linking this OpenJDK Code statically or dynamically with other code
is making a combined work based on this library. Thus, the terms
and conditions of GPL2 cover the whole combination.
- As a special exception, Sun gives you permission to link this
- OpenJDK Code with certain code licensed by Sun as indicated at
+ As a special exception, Oracle gives you permission to link this
+ OpenJDK Code with certain code licensed by Oracle as indicated at
http://openjdk.java.net/legal/exception-modules-2007-05-08.html
("Designated Exception Modules") to produce an executable,
regardless of the license terms of the Designated Exception Modules,
and to copy and distribute the resulting executable under GPL2,
provided that the Designated Exception Modules continue to be
- governed by the licenses under which they were offered by Sun.
+ governed by the licenses under which they were offered by Oracle.
-As such, it allows licensees and sublicensees of Sun's GPL2 OpenJDK Code to
-build an executable that includes those portions of necessary code that Sun
-could not provide under GPL2 (or that Sun has provided under GPL2 with the
-Classpath exception). If you modify or add to the OpenJDK code, that new
-GPL2 code may still be combined with Designated Exception Modules if the
-new code is made subject to this exception by its copyright holder.
+As such, it allows licensees and sublicensees of Oracle's GPL2 OpenJDK Code
+to build an executable that includes those portions of necessary code that
+Oracle could not provide under GPL2 (or that Oracle has provided under GPL2
+with the Classpath exception). If you modify or add to the OpenJDK code,
+that new GPL2 code may still be combined with Designated Exception Modules
+if the new code is made subject to this exception by its copyright holder.
--- a/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/MemberInfo.java Fri Oct 14 19:12:37 2016 +0300
+++ b/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/MemberInfo.java Fri Oct 14 11:11:19 2016 -0700
@@ -574,7 +574,7 @@
String getDocumentationKey(final String objName) {
if (kind == Kind.FUNCTION) {
- StringBuilder buf = new StringBuilder(objName);
+ final StringBuilder buf = new StringBuilder(objName);
switch (where) {
case CONSTRUCTOR:
break;
--- a/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ScriptClassInfo.java Fri Oct 14 19:12:37 2016 +0300
+++ b/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ScriptClassInfo.java Fri Oct 14 11:11:19 2016 -0700
@@ -42,7 +42,7 @@
*
*/
public final class ScriptClassInfo {
- private static String getTypeDescriptor(String pkg, String name) {
+ private static String getTypeDescriptor(final String pkg, final String name) {
return "L" + pkg + name + ";";
}
--- a/nashorn/make/project.properties Fri Oct 14 19:12:37 2016 +0300
+++ b/nashorn/make/project.properties Fri Oct 14 11:11:19 2016 -0700
@@ -36,7 +36,7 @@
javac.target=1.9
javadoc.option=\
- -tag "implSpec:a:Implementation Requirements:"\
+ -tag "implSpec:a:Implementation Requirements:" \
-tag "implNote:a:Implementation Note:"
# nashorn version information
--- a/nashorn/samples/dynalink/ArrayStreamLinkerExporter.java Fri Oct 14 19:12:37 2016 +0300
+++ b/nashorn/samples/dynalink/ArrayStreamLinkerExporter.java Fri Oct 14 11:11:19 2016 -0700
@@ -30,7 +30,6 @@
*/
import java.lang.invoke.MethodHandle;
-import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
import java.util.ArrayList;
import java.util.List;
@@ -43,12 +42,12 @@
import jdk.dynalink.NamedOperation;
import jdk.dynalink.Operation;
import jdk.dynalink.StandardOperation;
+import jdk.dynalink.linker.GuardedInvocation;
import jdk.dynalink.linker.GuardingDynamicLinker;
import jdk.dynalink.linker.GuardingDynamicLinkerExporter;
-import jdk.dynalink.linker.GuardedInvocation;
-import jdk.dynalink.linker.TypeBasedGuardingDynamicLinker;
import jdk.dynalink.linker.LinkRequest;
import jdk.dynalink.linker.LinkerServices;
+import jdk.dynalink.linker.TypeBasedGuardingDynamicLinker;
import jdk.dynalink.linker.support.Guards;
import jdk.dynalink.linker.support.Lookup;
@@ -65,7 +64,7 @@
System.out.println("pluggable dynalink array stream linker loaded");
}
- public static Object arrayToStream(Object array) {
+ public static Object arrayToStream(final Object array) {
if (array instanceof int[]) {
return IntStream.of((int[])array);
} else if (array instanceof long[]) {
@@ -95,17 +94,17 @@
}
@Override
- public GuardedInvocation getGuardedInvocation(LinkRequest request,
- LinkerServices linkerServices) throws Exception {
+ public GuardedInvocation getGuardedInvocation(final LinkRequest request,
+ final LinkerServices linkerServices) throws Exception {
final Object self = request.getReceiver();
if (self == null || !canLinkType(self.getClass())) {
return null;
}
- CallSiteDescriptor desc = request.getCallSiteDescriptor();
- Operation op = desc.getOperation();
- Object name = NamedOperation.getName(op);
- boolean getProp = CompositeOperation.contains(
+ final CallSiteDescriptor desc = request.getCallSiteDescriptor();
+ final Operation op = desc.getOperation();
+ final Object name = NamedOperation.getName(op);
+ final boolean getProp = CompositeOperation.contains(
NamedOperation.getBaseOperation(op),
StandardOperation.GET_PROPERTY);
if (getProp && "stream".equals(name)) {
--- a/nashorn/samples/dynalink/BufferIndexingLinkerExporter.java Fri Oct 14 19:12:37 2016 +0300
+++ b/nashorn/samples/dynalink/BufferIndexingLinkerExporter.java Fri Oct 14 11:11:19 2016 -0700
@@ -30,10 +30,7 @@
*/
import java.lang.invoke.MethodHandle;
-import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
-import java.util.ArrayList;
-import java.util.List;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
@@ -42,17 +39,19 @@
import java.nio.IntBuffer;
import java.nio.LongBuffer;
import java.nio.ShortBuffer;
+import java.util.ArrayList;
+import java.util.List;
import jdk.dynalink.CallSiteDescriptor;
import jdk.dynalink.CompositeOperation;
import jdk.dynalink.NamedOperation;
import jdk.dynalink.Operation;
import jdk.dynalink.StandardOperation;
+import jdk.dynalink.linker.GuardedInvocation;
import jdk.dynalink.linker.GuardingDynamicLinker;
import jdk.dynalink.linker.GuardingDynamicLinkerExporter;
-import jdk.dynalink.linker.GuardedInvocation;
-import jdk.dynalink.linker.TypeBasedGuardingDynamicLinker;
import jdk.dynalink.linker.LinkRequest;
import jdk.dynalink.linker.LinkerServices;
+import jdk.dynalink.linker.TypeBasedGuardingDynamicLinker;
import jdk.dynalink.linker.support.Guards;
import jdk.dynalink.linker.support.Lookup;
@@ -94,7 +93,7 @@
private static final MethodType GUARD_TYPE;
static {
- Lookup look = Lookup.PUBLIC;
+ final Lookup look = Lookup.PUBLIC;
BUFFER_LIMIT = look.findVirtual(Buffer.class, "limit", MethodType.methodType(int.class));
BYTEBUFFER_GET = look.findVirtual(ByteBuffer.class, "get",
MethodType.methodType(byte.class, int.class));
@@ -163,15 +162,15 @@
}
@Override
- public GuardedInvocation getGuardedInvocation(LinkRequest request,
- LinkerServices linkerServices) throws Exception {
+ public GuardedInvocation getGuardedInvocation(final LinkRequest request,
+ final LinkerServices linkerServices) throws Exception {
final Object self = request.getReceiver();
if (self == null || !canLinkType(self.getClass())) {
return null;
}
- CallSiteDescriptor desc = request.getCallSiteDescriptor();
- StandardOperation op = getFirstStandardOperation(desc);
+ final CallSiteDescriptor desc = request.getCallSiteDescriptor();
+ final StandardOperation op = getFirstStandardOperation(desc);
if (op == null) {
return null;
}
@@ -182,7 +181,7 @@
case SET_ELEMENT:
return linkSetElement(self);
case GET_PROPERTY: {
- Object name = NamedOperation.getName(desc.getOperation());
+ final Object name = NamedOperation.getName(desc.getOperation());
if ("length".equals(name)) {
return linkLength();
}
@@ -195,7 +194,7 @@
return linkers;
}
- private static GuardedInvocation linkGetElement(Object self) {
+ private static GuardedInvocation linkGetElement(final Object self) {
MethodHandle method = null;
MethodHandle guard = null;
if (self instanceof ByteBuffer) {
@@ -224,7 +223,7 @@
return method != null? new GuardedInvocation(method, guard) : null;
}
- private static GuardedInvocation linkSetElement(Object self) {
+ private static GuardedInvocation linkSetElement(final Object self) {
MethodHandle method = null;
MethodHandle guard = null;
if (self instanceof ByteBuffer) {
--- a/nashorn/samples/dynalink/DOMLinkerExporter.java Fri Oct 14 19:12:37 2016 +0300
+++ b/nashorn/samples/dynalink/DOMLinkerExporter.java Fri Oct 14 11:11:19 2016 -0700
@@ -39,18 +39,17 @@
import jdk.dynalink.NamedOperation;
import jdk.dynalink.Operation;
import jdk.dynalink.StandardOperation;
+import jdk.dynalink.linker.GuardedInvocation;
import jdk.dynalink.linker.GuardingDynamicLinker;
import jdk.dynalink.linker.GuardingDynamicLinkerExporter;
-import jdk.dynalink.linker.GuardedInvocation;
-import jdk.dynalink.linker.TypeBasedGuardingDynamicLinker;
import jdk.dynalink.linker.LinkRequest;
import jdk.dynalink.linker.LinkerServices;
+import jdk.dynalink.linker.TypeBasedGuardingDynamicLinker;
import jdk.dynalink.linker.support.Guards;
import jdk.dynalink.linker.support.Lookup;
-import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
-import org.w3c.dom.Element;
/**
* This is a dynalink pluggable linker (see http://openjdk.java.net/jeps/276).
@@ -65,12 +64,12 @@
}
// return List of child Elements of the given Element matching the given name.
- private static List<Element> getChildElements(Element elem, String name) {
- NodeList nodeList = elem.getChildNodes();
- List<Element> childElems = new ArrayList<>();
- int len = nodeList.getLength();
+ private static List<Element> getChildElements(final Element elem, final String name) {
+ final NodeList nodeList = elem.getChildNodes();
+ final List<Element> childElems = new ArrayList<>();
+ final int len = nodeList.getLength();
for (int i = 0; i < len; i++) {
- Node node = nodeList.item(i);
+ final Node node = nodeList.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE &&
((Element)node).getTagName().equals(name)) {
childElems.add((Element)node);
@@ -81,18 +80,18 @@
// method that returns either unique child element matching given name
// or a list of child elements of that name (if there are more than one matches).
- public static Object getElementsByName(Object elem, final String name) {
- List<Element> elems = getChildElements((Element)elem, name);
+ public static Object getElementsByName(final Object elem, final String name) {
+ final List<Element> elems = getChildElements((Element)elem, name);
return elems.size() == 1? elems.get(0) : elems;
}
// method to extract text context under a given DOM Element
- public static Object getElementText(Object elem) {
- NodeList nodeList = ((Element)elem).getChildNodes();
- int len = nodeList.getLength();
- StringBuilder text = new StringBuilder();
+ public static Object getElementText(final Object elem) {
+ final NodeList nodeList = ((Element)elem).getChildNodes();
+ final int len = nodeList.getLength();
+ final StringBuilder text = new StringBuilder();
for (int i = 0; i < len; i++) {
- Node node = nodeList.item(i);
+ final Node node = nodeList.item(i);
if (node.getNodeType() == Node.TEXT_NODE) {
text.append(node.getNodeValue());
}
@@ -123,21 +122,21 @@
}
@Override
- public GuardedInvocation getGuardedInvocation(LinkRequest request,
- LinkerServices linkerServices) throws Exception {
+ public GuardedInvocation getGuardedInvocation(final LinkRequest request,
+ final LinkerServices linkerServices) throws Exception {
final Object self = request.getReceiver();
if (! (self instanceof Element)) {
return null;
}
- CallSiteDescriptor desc = request.getCallSiteDescriptor();
- Operation op = desc.getOperation();
- Object name = NamedOperation.getName(op);
- boolean getProp = CompositeOperation.contains(
+ final CallSiteDescriptor desc = request.getCallSiteDescriptor();
+ final Operation op = desc.getOperation();
+ final Object name = NamedOperation.getName(op);
+ final boolean getProp = CompositeOperation.contains(
NamedOperation.getBaseOperation(op),
StandardOperation.GET_PROPERTY);
if (getProp && name instanceof String) {
- String nameStr = (String)name;
+ final String nameStr = (String)name;
// Treat names starting with "_" as special names.
// Everything else is linked other dynalink bean linker!
--- a/nashorn/samples/dynalink/MissingMethodExample.java Fri Oct 14 19:12:37 2016 +0300
+++ b/nashorn/samples/dynalink/MissingMethodExample.java Fri Oct 14 11:11:19 2016 -0700
@@ -37,13 +37,13 @@
implements MissingMethodHandler {
@Override
- public Object doesNotUnderstand(String name, Object... args) {
+ public Object doesNotUnderstand(final String name, final Object... args) {
// This simple doesNotUnderstand just prints method name and args.
// You can put useful method routing logic here.
System.out.println("you called " + name);
if (args.length != 0) {
System.out.println("arguments are: ");
- for (Object arg : args) {
+ for (final Object arg : args) {
System.out.println(" " + arg);
}
}
--- a/nashorn/samples/dynalink/MissingMethodLinkerExporter.java Fri Oct 14 19:12:37 2016 +0300
+++ b/nashorn/samples/dynalink/MissingMethodLinkerExporter.java Fri Oct 14 11:11:19 2016 -0700
@@ -40,12 +40,12 @@
import jdk.dynalink.Operation;
import jdk.dynalink.StandardOperation;
import jdk.dynalink.beans.BeansLinker;
+import jdk.dynalink.linker.GuardedInvocation;
import jdk.dynalink.linker.GuardingDynamicLinker;
import jdk.dynalink.linker.GuardingDynamicLinkerExporter;
-import jdk.dynalink.linker.GuardedInvocation;
-import jdk.dynalink.linker.TypeBasedGuardingDynamicLinker;
import jdk.dynalink.linker.LinkRequest;
import jdk.dynalink.linker.LinkerServices;
+import jdk.dynalink.linker.TypeBasedGuardingDynamicLinker;
import jdk.dynalink.linker.support.Guards;
import jdk.dynalink.linker.support.Lookup;
@@ -65,7 +65,7 @@
public static class MissingMethod {
private final String name;
- public MissingMethod(String name) {
+ public MissingMethod(final String name) {
this.name = name;
}
@@ -130,20 +130,20 @@
}
@Override
- public GuardedInvocation getGuardedInvocation(LinkRequest request,
- LinkerServices linkerServices) throws Exception {
+ public GuardedInvocation getGuardedInvocation(final LinkRequest request,
+ final LinkerServices linkerServices) throws Exception {
final Object self = request.getReceiver();
- CallSiteDescriptor desc = request.getCallSiteDescriptor();
+ final CallSiteDescriptor desc = request.getCallSiteDescriptor();
// any method call is done by two steps. Step (1) GET_METHOD and (2) is CALL
// For step (1), we check if GET_METHOD can succeed by Java linker, if so
// 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.
- boolean isGetMethod = getFirstStandardOperation(desc) == StandardOperation.GET_METHOD;
- Object name = NamedOperation.getName(desc.getOperation());
+ final boolean isGetMethod = getFirstStandardOperation(desc) == StandardOperation.GET_METHOD;
+ final Object name = NamedOperation.getName(desc.getOperation());
if (isGetMethod && name instanceof String) {
- GuardingDynamicLinker javaLinker = beansLinker.getLinkerForClass(self.getClass());
+ final GuardingDynamicLinker javaLinker = beansLinker.getLinkerForClass(self.getClass());
GuardedInvocation inv;
try {
inv = javaLinker.getGuardedInvocation(request, linkerServices);
@@ -151,11 +151,11 @@
inv = null;
}
- String nameStr = name.toString();
+ final String nameStr = name.toString();
if (inv == null) {
// use "this" for just guard and drop it -- return a constant Method handle
// that returns a newly created MissingMethod object
- MethodHandle mh = MethodHandles.constant(Object.class, new MissingMethod(nameStr));
+ final MethodHandle mh = MethodHandles.constant(Object.class, new MissingMethod(nameStr));
inv = new GuardedInvocation(
MethodHandles.dropArguments(mh, 0, Object.class),
Guards.isOfClass(self.getClass(), MethodType.methodType(Boolean.TYPE, Object.class)));
@@ -166,7 +166,7 @@
} else if (self instanceof MissingMethod) {
// This is step (2). We call MissingMethodHandler.doesNotUnderstand here
// Check if this is this a CALL first.
- boolean isCall = getFirstStandardOperation(desc) == StandardOperation.CALL;
+ final boolean isCall = getFirstStandardOperation(desc) == StandardOperation.CALL;
if (isCall) {
MethodHandle mh = DOES_NOT_UNDERSTAND;
--- a/nashorn/samples/dynalink/UnderscoreNameLinkerExporter.java Fri Oct 14 19:12:37 2016 +0300
+++ b/nashorn/samples/dynalink/UnderscoreNameLinkerExporter.java Fri Oct 14 11:11:19 2016 -0700
@@ -29,22 +29,18 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.lang.invoke.MethodHandle;
-import java.lang.invoke.MethodHandles;
-import java.lang.invoke.MethodType;
import java.util.ArrayList;
import java.util.List;
+import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import java.util.regex.Matcher;
import jdk.dynalink.CallSiteDescriptor;
import jdk.dynalink.CompositeOperation;
import jdk.dynalink.NamedOperation;
import jdk.dynalink.Operation;
-import jdk.dynalink.CompositeOperation;
import jdk.dynalink.StandardOperation;
+import jdk.dynalink.linker.GuardedInvocation;
import jdk.dynalink.linker.GuardingDynamicLinker;
import jdk.dynalink.linker.GuardingDynamicLinkerExporter;
-import jdk.dynalink.linker.GuardedInvocation;
import jdk.dynalink.linker.LinkRequest;
import jdk.dynalink.linker.LinkerServices;
import jdk.dynalink.linker.support.SimpleLinkRequest;
@@ -62,9 +58,9 @@
private static final Pattern UNDERSCORE_NAME = Pattern.compile("_(.)");
// translate underscore_separated name as a CamelCase name
- private static String translateToCamelCase(String name) {
- Matcher m = UNDERSCORE_NAME.matcher(name);
- StringBuilder buf = new StringBuilder();
+ 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());
}
@@ -94,28 +90,28 @@
final ArrayList<GuardingDynamicLinker> linkers = new ArrayList<>();
linkers.add(new GuardingDynamicLinker() {
@Override
- public GuardedInvocation getGuardedInvocation(LinkRequest request,
- LinkerServices linkerServices) throws Exception {
+ public GuardedInvocation getGuardedInvocation(final LinkRequest request,
+ final LinkerServices linkerServices) throws Exception {
final Object self = request.getReceiver();
- CallSiteDescriptor desc = request.getCallSiteDescriptor();
- Operation op = desc.getOperation();
- Object name = NamedOperation.getName(op);
+ final CallSiteDescriptor desc = request.getCallSiteDescriptor();
+ final Operation op = desc.getOperation();
+ final Object name = NamedOperation.getName(op);
// is this a named GET_METHOD?
- boolean isGetMethod = getFirstStandardOperation(desc) == StandardOperation.GET_METHOD;
+ final boolean isGetMethod = getFirstStandardOperation(desc) == StandardOperation.GET_METHOD;
if (isGetMethod && name instanceof String) {
- String str = (String)name;
+ final String str = (String)name;
if (str.indexOf('_') == -1) {
return null;
}
- String nameStr = translateToCamelCase(str);
+ final String nameStr = translateToCamelCase(str);
// create a new call descriptor to use translated name
- CallSiteDescriptor newDesc = new CallSiteDescriptor(
+ final CallSiteDescriptor newDesc = new CallSiteDescriptor(
desc.getLookup(),
new NamedOperation(NamedOperation.getBaseOperation(op), nameStr),
desc.getMethodType());
// create a new Link request to link the call site with translated name
- LinkRequest newRequest = new SimpleLinkRequest(newDesc,
+ final LinkRequest newRequest = new SimpleLinkRequest(newDesc,
request.isCallSiteUnstable(), request.getArguments());
// return guarded invocation linking the translated request
return linkerServices.getGuardedInvocation(newRequest);
--- a/nashorn/src/jdk.scripting.nashorn.shell/share/classes/jdk/nashorn/tools/jjs/PackagesHelper.java Fri Oct 14 19:12:37 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn.shell/share/classes/jdk/nashorn/tools/jjs/PackagesHelper.java Fri Oct 14 11:11:19 2016 -0700
@@ -75,6 +75,7 @@
}
private final Context context;
+ private final boolean modulePathSet;
private final StandardJavaFileManager fm;
private final Set<JavaFileObject.Kind> fileKinds;
private final FileSystem jrtfs;
@@ -86,11 +87,17 @@
*/
PackagesHelper(final Context context) throws IOException {
this.context = context;
- final String classPath = context.getEnv()._classpath;
+ final String modulePath = context.getEnv()._module_path;
+ this.modulePathSet = modulePath != null && !modulePath.isEmpty();
if (isJavacAvailable()) {
+ final String classPath = context.getEnv()._classpath;
fm = compiler.getStandardFileManager(null, null, null);
fileKinds = EnumSet.of(JavaFileObject.Kind.CLASS);
+ if (this.modulePathSet) {
+ fm.setLocation(StandardLocation.MODULE_PATH, getFiles(modulePath));
+ }
+
if (classPath != null && !classPath.isEmpty()) {
fm.setLocation(StandardLocation.CLASS_PATH, getFiles(classPath));
} else {
@@ -155,6 +162,13 @@
final Set<String> props = new HashSet<>();
if (fm != null) {
listPackage(StandardLocation.PLATFORM_CLASS_PATH, pkg, props);
+ if (this.modulePathSet) {
+ for (Set<Location> locs : fm.listModuleLocations(StandardLocation.MODULE_PATH)) {
+ for (Location loc : locs) {
+ listPackage(loc, pkg, props);
+ }
+ }
+ }
listPackage(StandardLocation.CLASS_PATH, pkg, props);
} else if (jrtfs != null) {
// look for the /packages/<package_name> directory
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/DestructuringDeclTreeImpl.java Fri Oct 14 19:12:37 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/DestructuringDeclTreeImpl.java Fri Oct 14 11:11:19 2016 -0700
@@ -36,7 +36,7 @@
private final ExpressionTree lhs;
private final ExpressionTree init;
- DestructuringDeclTreeImpl(ExpressionStatement exprStat, final ExpressionTree lhs, final ExpressionTree init) {
+ DestructuringDeclTreeImpl(final ExpressionStatement exprStat, final ExpressionTree lhs, final ExpressionTree init) {
super(exprStat);
assert exprStat.destructuringDeclarationType() != null : "expecting a destructuring decl. statement";
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ExportEntryTreeImpl.java Fri Oct 14 19:12:37 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ExportEntryTreeImpl.java Fri Oct 14 11:11:19 2016 -0700
@@ -39,10 +39,10 @@
private final IdentifierTree localName;
private ExportEntryTreeImpl(final long startPos, final long endPos,
- IdentifierTree exportName,
- IdentifierTree moduleRequest,
- IdentifierTree importName,
- IdentifierTree localName) {
+ final IdentifierTree exportName,
+ final IdentifierTree moduleRequest,
+ final IdentifierTree importName,
+ final IdentifierTree localName) {
super(null); // no underlying Node!
this.startPos = startPos;
this.endPos = endPos;
@@ -52,7 +52,7 @@
this.localName = localName;
}
- private static ExportEntryTreeImpl createExportEntry(Module.ExportEntry entry) {
+ private static ExportEntryTreeImpl createExportEntry(final Module.ExportEntry entry) {
return new ExportEntryTreeImpl(entry.getStartPosition(),
entry.getEndPosition(),
identOrNull(entry.getExportName()),
@@ -61,7 +61,7 @@
identOrNull(entry.getLocalName()));
}
- static List<ExportEntryTreeImpl> createExportList(List<Module.ExportEntry> exportList) {
+ static List<ExportEntryTreeImpl> createExportList(final List<Module.ExportEntry> exportList) {
return exportList.stream().
map(ExportEntryTreeImpl::createExportEntry).
collect(Collectors.toList());
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/FunctionExpressionTreeImpl.java Fri Oct 14 19:12:37 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/FunctionExpressionTreeImpl.java Fri Oct 14 11:11:19 2016 -0700
@@ -51,7 +51,7 @@
this.params = params;
if (node.getFlag(FunctionNode.HAS_EXPRESSION_BODY)) {
- StatementTree first = body.getStatements().get(0);
+ final StatementTree first = body.getStatements().get(0);
assert first instanceof ReturnTree : "consise func. expression should have a return statement";
this.body = ((ReturnTree)first).getExpression();
} else {
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/IRTranslator.java Fri Oct 14 19:12:37 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/IRTranslator.java Fri Oct 14 11:11:19 2016 -0700
@@ -191,9 +191,9 @@
@Override
public boolean enterExpressionStatement(final ExpressionStatement expressionStatement) {
if (expressionStatement.destructuringDeclarationType() != null) {
- ExpressionTree expr = translateExpr(expressionStatement.getExpression());
+ final ExpressionTree expr = translateExpr(expressionStatement.getExpression());
assert expr instanceof AssignmentTree : "destructuring decl. statement does not have assignment";
- AssignmentTree assign = (AssignmentTree)expr;
+ final AssignmentTree assign = (AssignmentTree)expr;
curStat = new DestructuringDeclTreeImpl(expressionStatement, assign.getVariable(), assign.getExpression());
} else {
curStat = new ExpressionStatementTreeImpl(expressionStatement,
@@ -544,12 +544,12 @@
}
private List<? extends ExpressionTree> translateParameters(final FunctionNode func) {
- Map<IdentNode, Expression> paramExprs = func.getParameterExpressions();
+ final Map<IdentNode, Expression> paramExprs = func.getParameterExpressions();
if (paramExprs != null) {
- List<IdentNode> params = func.getParameters();
+ final List<IdentNode> params = func.getParameters();
final List<ExpressionTreeImpl> exprTrees = new ArrayList<>(params.size());
for (final IdentNode ident : params) {
- Expression expr = paramExprs.containsKey(ident)? paramExprs.get(ident) : ident;
+ final Expression expr = paramExprs.containsKey(ident)? paramExprs.get(ident) : ident;
curExpr = null;
expr.accept(this);
assert curExpr != null;
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ImportEntryTreeImpl.java Fri Oct 14 19:12:37 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ImportEntryTreeImpl.java Fri Oct 14 11:11:19 2016 -0700
@@ -38,9 +38,9 @@
private final IdentifierTree localName;
private ImportEntryTreeImpl(final long startPos, final long endPos,
- IdentifierTree moduleRequest,
- IdentifierTree importName,
- IdentifierTree localName) {
+ final IdentifierTree moduleRequest,
+ final IdentifierTree importName,
+ final IdentifierTree localName) {
super(null); // No underlying Node!
this.startPos = startPos;
this.endPos = endPos;
@@ -49,7 +49,7 @@
this.localName = localName;
}
- private static ImportEntryTreeImpl createImportEntry(Module.ImportEntry entry) {
+ private static ImportEntryTreeImpl createImportEntry(final Module.ImportEntry entry) {
return new ImportEntryTreeImpl(entry.getStartPosition(),
entry.getEndPosition(),
identOrNull(entry.getModuleRequest()),
@@ -57,7 +57,7 @@
identOrNull(entry.getLocalName()));
}
- static List<ImportEntryTreeImpl> createImportList(List<Module.ImportEntry> importList) {
+ static List<ImportEntryTreeImpl> createImportList(final List<Module.ImportEntry> importList) {
return importList.stream().
map(ImportEntryTreeImpl::createImportEntry).
collect(Collectors.toList());
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/Parser.java Fri Oct 14 19:12:37 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/Parser.java Fri Oct 14 11:11:19 2016 -0700
@@ -140,7 +140,7 @@
*/
public static Parser create(final String... options) throws IllegalArgumentException {
options.getClass();
- for (String opt : options) {
+ for (final String opt : options) {
switch (opt) {
case "--const-as-var":
case "-dump-on-error":
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ParserImpl.java Fri Oct 14 19:12:37 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ParserImpl.java Fri Oct 14 11:11:19 2016 -0700
@@ -73,9 +73,9 @@
// append "--parse-only to signal to the Nashorn that it
// is being used in "parse only" mode.
- String[] newArgs = Arrays.copyOf(args, args.length + 1, String[].class);
+ final String[] newArgs = Arrays.copyOf(args, args.length + 1, String[].class);
newArgs[args.length] = "--parse-only";
- Options options = new Options("nashorn");
+ final Options options = new Options("nashorn");
options.process(newArgs);
this.env = new ScriptEnvironment(options,
new PrintWriter(System.out), new PrintWriter(System.err));
@@ -142,32 +142,32 @@
}
}
- private CompilationUnitTree parseModule(File file, DiagnosticListener listener) throws IOException, NashornException {
+ private CompilationUnitTree parseModule(final File file, final DiagnosticListener listener) throws IOException, NashornException {
final Source src = Source.sourceFor(Objects.requireNonNull(file).getName(), file);
return makeModule(src, listener);
}
- private CompilationUnitTree parseModule(Path path, DiagnosticListener listener) throws IOException, NashornException {
+ private CompilationUnitTree parseModule(final Path path, final DiagnosticListener listener) throws IOException, NashornException {
final Source src = Source.sourceFor(Objects.requireNonNull(path).toString(), path);
return makeModule(src, listener);
}
- private CompilationUnitTree parseModule(URL url, DiagnosticListener listener) throws IOException, NashornException {
+ private CompilationUnitTree parseModule(final URL url, final DiagnosticListener listener) throws IOException, NashornException {
final Source src = Source.sourceFor(url.toString(), url);
return makeModule(src, listener);
}
- private CompilationUnitTree parseModule(String name, Reader reader, DiagnosticListener listener) throws IOException, NashornException {
+ private CompilationUnitTree parseModule(final String name, final Reader reader, final DiagnosticListener listener) throws IOException, NashornException {
final Source src = Source.sourceFor(Objects.requireNonNull(name), Objects.requireNonNull(reader));
return makeModule(src, listener);
}
- private CompilationUnitTree parseModule(String name, String code, DiagnosticListener listener) throws NashornException {
+ private CompilationUnitTree parseModule(final String name, final String code, final DiagnosticListener listener) throws NashornException {
final Source src = Source.sourceFor(name, code);
return makeModule(src, listener);
}
- private CompilationUnitTree parseModule(ScriptObjectMirror scriptObj, DiagnosticListener listener) throws NashornException {
+ private CompilationUnitTree parseModule(final ScriptObjectMirror scriptObj, final DiagnosticListener listener) throws NashornException {
final Map<?, ?> map = Objects.requireNonNull(scriptObj);
if (map.containsKey("script") && map.containsKey("name")) {
final String script = JSType.toString(map.get("script"));
@@ -179,7 +179,7 @@
}
}
- private CompilationUnitTree makeModule(Source src, DiagnosticListener listener) {
+ private CompilationUnitTree makeModule(final Source src, final DiagnosticListener listener) {
final FunctionNode modFunc = makeParser(src, listener).parseModule(src.getName());
return new IRTranslator().translate(modFunc);
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/SimpleTreeVisitorES5_1.java Fri Oct 14 19:12:37 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/SimpleTreeVisitorES5_1.java Fri Oct 14 11:11:19 2016 -0700
@@ -70,7 +70,7 @@
* @return the result of {@code visitUnknown}
*/
@Override
- public R visitModule(ModuleTree node, P p) {
+ public R visitModule(final ModuleTree node, final P p) {
return visitUnknown(node, p);
}
@@ -83,7 +83,7 @@
* @return the result of {@code visitUnknown}
*/
@Override
- public R visitExportEntry(ExportEntryTree node, P p) {
+ public R visitExportEntry(final ExportEntryTree node, final P p) {
return visitUnknown(node, p);
}
@@ -96,7 +96,7 @@
* @return the result of {@code visitUnknown}
*/
@Override
- public R visitImportEntry(ImportEntryTree node, P p) {
+ public R visitImportEntry(final ImportEntryTree node, final P p) {
return visitUnknown(node, p);
}
@@ -153,7 +153,7 @@
* @return the result of {@code visitUnknown}
*/
@Override
- public R visitClassDeclaration(ClassDeclarationTree node, P p) {
+ public R visitClassDeclaration(final ClassDeclarationTree node, final P p) {
return visitUnknown(node, p);
}
@@ -166,7 +166,7 @@
* @return the result of {@code visitUnknown}
*/
@Override
- public R visitClassExpression(ClassExpressionTree node, P p) {
+ public R visitClassExpression(final ClassExpressionTree node, final P p) {
return visitUnknown(node, p);
}
@@ -247,7 +247,7 @@
* @return the result of {@code visitUnknown}
*/
@Override
- public R visitForOfLoop(ForOfLoopTree node, P p) {
+ public R visitForOfLoop(final ForOfLoopTree node, final P p) {
return visitUnknown(node, p);
}
@@ -357,21 +357,21 @@
@Override
public R visitProperty(final PropertyTree node, final P r) {
- FunctionExpressionTree getter = node.getGetter();
+ final FunctionExpressionTree getter = node.getGetter();
if (getter != null) {
getter.accept(this, r);
}
- ExpressionTree key = node.getKey();
+ final ExpressionTree key = node.getKey();
if (key != null) {
key.accept(this, r);
}
- FunctionExpressionTree setter = node.getSetter();
+ final FunctionExpressionTree setter = node.getSetter();
if (setter != null) {
setter.accept(this, r);
}
- ExpressionTree value = node.getValue();
+ final ExpressionTree value = node.getValue();
if (value != null) {
value.accept(this, r);
}
@@ -392,7 +392,7 @@
* @return the result of {@code visitUnknown}
*/
@Override
- public R visitTemplateLiteral(TemplateLiteralTree node, P p) {
+ public R visitTemplateLiteral(final TemplateLiteralTree node, final P p) {
return visitUnknown(node, p);
}
@@ -410,7 +410,7 @@
* @return the result of {@code visitUnknown}
*/
@Override
- public R visitSpread(SpreadTree node, P p) {
+ public R visitSpread(final SpreadTree node, final P p) {
return visitUnknown(node, p);
}
@@ -495,7 +495,7 @@
* @return the result of {@code visitUnknown}
*/
@Override
- public R visitYield(YieldTree node, P p) {
+ public R visitYield(final YieldTree node, final P p) {
return visitUnknown(node, p);
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/SimpleTreeVisitorES6.java Fri Oct 14 19:12:37 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/SimpleTreeVisitorES6.java Fri Oct 14 11:11:19 2016 -0700
@@ -66,7 +66,7 @@
* @return value from the visitor
*/
@Override
- public R visitModule(ModuleTree node, P p) {
+ public R visitModule(final ModuleTree node, final P p) {
node.getImportEntries().forEach(e -> visitImportEntry(e, p));
node.getLocalExportEntries().forEach(e -> visitExportEntry(e, p));
node.getIndirectExportEntries().forEach(e -> visitExportEntry(e, p));
@@ -82,7 +82,7 @@
* @return value from the visitor
*/
@Override
- public R visitExportEntry(ExportEntryTree node, P p) {
+ public R visitExportEntry(final ExportEntryTree node, final P p) {
return null;
}
@@ -94,7 +94,7 @@
* @return value from the visitor
*/
@Override
- public R visitImportEntry(ImportEntryTree node, P p) {
+ public R visitImportEntry(final ImportEntryTree node, final P p) {
return null;
}
@@ -106,7 +106,7 @@
* @return value from the visitor
*/
@Override
- public R visitClassDeclaration(ClassDeclarationTree node, P p) {
+ public R visitClassDeclaration(final ClassDeclarationTree node, final P p) {
node.getName().accept(this, p);
final ExpressionTree heritage = node.getClassHeritage();
if (heritage != null) {
@@ -118,7 +118,7 @@
}
final List<? extends PropertyTree> elements = node.getClassElements();
if (elements != null) {
- for (PropertyTree prop : elements) {
+ for (final PropertyTree prop : elements) {
prop.accept(this, p);
}
}
@@ -134,7 +134,7 @@
* @return value from the visitor
*/
@Override
- public R visitClassExpression(ClassExpressionTree node, P p) {
+ public R visitClassExpression(final ClassExpressionTree node, final P p) {
node.getName().accept(this, p);
final ExpressionTree heritage = node.getClassHeritage();
if (heritage != null) {
@@ -146,7 +146,7 @@
}
final List<? extends PropertyTree> elements = node.getClassElements();
if (elements != null) {
- for (PropertyTree prop : elements) {
+ for (final PropertyTree prop : elements) {
prop.accept(this, p);
}
}
@@ -180,7 +180,7 @@
* @return value from the visitor
*/
@Override
- public R visitYield(YieldTree node, P p) {
+ public R visitYield(final YieldTree node, final P p) {
node.getExpression().accept(this, p);
return null;
}
@@ -193,7 +193,7 @@
* @return value from the visitor
*/
@Override
- public R visitSpread(SpreadTree node, P p) {
+ public R visitSpread(final SpreadTree node, final P p) {
node.getExpression().accept(this, p);
return null;
}
@@ -206,9 +206,9 @@
* @return value from the visitor
*/
@Override
- public R visitTemplateLiteral(TemplateLiteralTree node, P p) {
+ public R visitTemplateLiteral(final TemplateLiteralTree node, final P p) {
final List<? extends ExpressionTree> expressions = node.getExpressions();
- for (ExpressionTree expr : expressions) {
+ for (final ExpressionTree expr : expressions) {
expr.accept(this, p);
}
return null;
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/SwitchTreeImpl.java Fri Oct 14 19:12:37 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/SwitchTreeImpl.java Fri Oct 14 11:11:19 2016 -0700
@@ -33,7 +33,7 @@
private final List<? extends CaseTree> cases;
SwitchTreeImpl(final SwitchNode node,
final ExpressionTree expr,
- List<? extends CaseTree> cases) {
+ final List<? extends CaseTree> cases) {
super(node);
this.expr = expr;
this.cases = cases;
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/TemplateLiteralTreeImpl.java Fri Oct 14 19:12:37 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/TemplateLiteralTreeImpl.java Fri Oct 14 11:11:19 2016 -0700
@@ -33,7 +33,7 @@
private final List<? extends ExpressionTree> expressions;
- TemplateLiteralTreeImpl(Expression node, List<? extends ExpressionTree> expressions) {
+ TemplateLiteralTreeImpl(final Expression node, final List<? extends ExpressionTree> expressions) {
super(node);
this.expressions = expressions;
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/Tree.java Fri Oct 14 19:12:37 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/Tree.java Fri Oct 14 11:11:19 2016 -0700
@@ -566,7 +566,7 @@
*/
OTHER(null);
- Kind(Class<? extends Tree> intf) {
+ Kind(final Class<? extends Tree> intf) {
associatedInterface = intf;
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/UnknownTreeException.java Fri Oct 14 19:12:37 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/UnknownTreeException.java Fri Oct 14 11:11:19 2016 -0700
@@ -52,7 +52,7 @@
* @param t the unknown tree, may be {@code null}
* @param p an additional parameter, may be {@code null}
*/
- public UnknownTreeException(Tree t, Object p) {
+ public UnknownTreeException(final Tree t, final Object p) {
super("Unknown tree: " + t);
this.tree = t;
this.parameter = p;
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/CodeGenerator.java Fri Oct 14 19:12:37 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/CodeGenerator.java Fri Oct 14 11:11:19 2016 -0700
@@ -258,7 +258,7 @@
private final int[] continuationEntryPoints;
// Scope object creators needed for for-of and for-in loops
- private Deque<FieldObjectCreator<?>> scopeObjectCreators = new ArrayDeque<>();
+ private final Deque<FieldObjectCreator<?>> scopeObjectCreators = new ArrayDeque<>();
/**
* Constructor.
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/SplitIntoFunctions.java Fri Oct 14 19:12:37 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/SplitIntoFunctions.java Fri Oct 14 11:11:19 2016 -0700
@@ -102,7 +102,7 @@
super(new BlockLexicalContext() {
@Override
protected Block afterSetStatements(final Block block) {
- for(Statement stmt: block.getStatements()) {
+ for(final Statement stmt: block.getStatements()) {
assert !(stmt instanceof SplitNode);
}
return block;
@@ -145,7 +145,7 @@
final FunctionState fnState = getCurrentFunctionState();
final String name = splitNode.getName();
- Block body = splitNode.getBody();
+ final Block body = splitNode.getBody();
final int firstLineNumber = body.getFirstStatementLineNumber();
final long token = body.getToken();
final int finish = body.getFinish();
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/ExpressionList.java Fri Oct 14 19:12:37 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/ExpressionList.java Fri Oct 14 11:11:19 2016 -0700
@@ -71,10 +71,10 @@
}
@Override
- public void toString(StringBuilder sb, boolean printType) {
+ public void toString(final StringBuilder sb, final boolean printType) {
sb.append("(");
boolean first = true;
- for (Expression expression : expressions) {
+ for (final Expression expression : expressions) {
if (first) {
first = false;
} else {
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/LiteralNode.java Fri Oct 14 19:12:37 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/LiteralNode.java Fri Oct 14 11:11:19 2016 -0700
@@ -635,6 +635,12 @@
/** Ranges for splitting up large literals in code generation */
private final List<Splittable.SplitRange> splitRanges;
+ /** Does this array literal have a spread element? */
+ private final boolean hasSpread;
+
+ /** Does this array literal have a trailing comma?*/
+ private final boolean hasTrailingComma;
+
@Override
public boolean isArray() {
return true;
@@ -791,11 +797,26 @@
* @param value array literal value, a Node array
*/
protected ArrayLiteralNode(final long token, final int finish, final Expression[] value) {
+ this(token, finish, value, false, false);
+ }
+
+ /**
+ * Constructor
+ *
+ * @param token token
+ * @param finish finish
+ * @param value array literal value, a Node array
+ * @param hasSpread true if the array has a spread element
+ * @param hasTrailingComma true if the array literal has a comma after the last element
+ */
+ protected ArrayLiteralNode(final long token, final int finish, final Expression[] value, final boolean hasSpread, final boolean hasTrailingComma) {
super(Token.recast(token, TokenType.ARRAY), finish, value);
this.elementType = Type.UNKNOWN;
this.presets = null;
this.postsets = null;
this.splitRanges = null;
+ this.hasSpread = hasSpread;
+ this.hasTrailingComma = hasTrailingComma;
}
/**
@@ -808,6 +829,24 @@
this.postsets = postsets;
this.presets = presets;
this.splitRanges = splitRanges;
+ this.hasSpread = node.hasSpread;
+ this.hasTrailingComma = node.hasTrailingComma;
+ }
+
+ /**
+ * Returns {@code true} if this array literal has a spread element.
+ * @return true if this literal has a spread element
+ */
+ public boolean hasSpread() {
+ return hasSpread;
+ }
+
+ /**
+ * Returns {@code true} if this array literal has a trailing comma.
+ * @return true if this literal has a trailing comma
+ */
+ public boolean hasTrailingComma() {
+ return hasTrailingComma;
}
/**
@@ -989,6 +1028,23 @@
return new ArrayLiteralNode(parent.getToken(), parent.getFinish(), valueToArray(value));
}
+ /*
+ * Create a new array literal of Nodes from a list of Node values
+ *
+ * @param token token
+ * @param finish finish
+ * @param value literal value list
+ * @param hasSpread true if the array has a spread element
+ * @param hasTrailingComma true if the array literal has a comma after the last element
+ *
+ * @return the new literal node
+ */
+ public static LiteralNode<Expression[]> newInstance(final long token, final int finish, final List<Expression> value,
+ final boolean hasSpread, final boolean hasTrailingComma) {
+ return new ArrayLiteralNode(token, finish, valueToArray(value), hasSpread, hasTrailingComma);
+ }
+
+
/**
* Create a new array literal of Nodes
*
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/TemplateLiteral.java Fri Oct 14 19:12:37 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/TemplateLiteral.java Fri Oct 14 11:11:19 2016 -0700
@@ -51,7 +51,7 @@
}
@Override
- public Node accept(NodeVisitor<? extends LexicalContext> visitor) {
+ public Node accept(final NodeVisitor<? extends LexicalContext> visitor) {
if (visitor.enterTemplateLiteral(this)) {
return visitor.leaveTemplateLiteral(this);
}
@@ -60,8 +60,8 @@
}
@Override
- public void toString(StringBuilder sb, boolean printType) {
- for (Expression expr : exprs) {
+ public void toString(final StringBuilder sb, final boolean printType) {
+ for (final Expression expr : exprs) {
sb.append(expr);
}
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/Global.java Fri Oct 14 19:12:37 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/Global.java Fri Oct 14 11:11:19 2016 -0700
@@ -2474,7 +2474,7 @@
}
@Override
- protected FindProperty findProperty(final Object key, final boolean deep, boolean isScope, final ScriptObject start) {
+ protected FindProperty findProperty(final Object key, final boolean deep, final boolean isScope, final ScriptObject start) {
if (lexicalScope != null && isScope) {
final FindProperty find = lexicalScope.findProperty(key, false);
if (find != null) {
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeJSON.java Fri Oct 14 19:12:37 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeJSON.java Fri Oct 14 11:11:19 2016 -0700
@@ -473,7 +473,7 @@
if (holder instanceof ScriptObject) {
return ((ScriptObject)holder).get(key);
} else if (holder instanceof JSObject) {
- JSObject jsObj = (JSObject)holder;
+ final JSObject jsObj = (JSObject)holder;
if (key instanceof Integer) {
return jsObj.getSlot((Integer)key);
} else {
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/Lexer.java Fri Oct 14 19:12:37 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/Lexer.java Fri Oct 14 11:11:19 2016 -0700
@@ -408,7 +408,7 @@
/**
* Test if char is a template literal delimiter ('`').
*/
- private static boolean isTemplateDelimiter(char ch) {
+ private static boolean isTemplateDelimiter(final char ch) {
return ch == '`';
}
@@ -1077,7 +1077,7 @@
add(type == TEMPLATE ? TEMPLATE_HEAD : type, stringState.position, stringState.limit);
// scan to RBRACE
- Lexer expressionLexer = new Lexer(this, saveState());
+ final Lexer expressionLexer = new Lexer(this, saveState());
expressionLexer.templateExpressionOpenBraces = 1;
expressionLexer.lexify();
restoreState(expressionLexer.saveState());
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/Parser.java Fri Oct 14 19:12:37 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/Parser.java Fri Oct 14 11:11:19 2016 -0700
@@ -632,7 +632,7 @@
return getStatement(false);
}
- private Block getStatement(boolean labelledStatement) {
+ private Block getStatement(final boolean labelledStatement) {
if (type == LBRACE) {
return getBlock(true);
}
@@ -746,58 +746,25 @@
return new BinaryNode(op, lhs, rhs);
}
- private boolean isDestructuringLhs(Expression lhs) {
+ private boolean isDestructuringLhs(final Expression lhs) {
if (lhs instanceof ObjectNode || lhs instanceof LiteralNode.ArrayLiteralNode) {
return isES6();
}
return false;
}
- private void verifyDestructuringAssignmentPattern(Expression pattern, String contextString) {
+ private void verifyDestructuringAssignmentPattern(final Expression pattern, final String contextString) {
assert pattern instanceof ObjectNode || pattern instanceof LiteralNode.ArrayLiteralNode;
- pattern.accept(new NodeVisitor<LexicalContext>(new LexicalContext()) {
+ pattern.accept(new VerifyDestructuringPatternNodeVisitor(new LexicalContext()) {
@Override
- public boolean enterLiteralNode(LiteralNode<?> literalNode) {
- if (literalNode.isArray()) {
- boolean restElement = false;
- for (Expression element : literalNode.getElementExpressions()) {
- if (element != null) {
- if (restElement) {
- throw error(String.format("Unexpected element after rest element"), element.getToken());
- }
- if (element.isTokenType(SPREAD_ARRAY)) {
- restElement = true;
- Expression lvalue = ((UnaryNode) element).getExpression();
- if (!checkValidLValue(lvalue, contextString)) {
- throw error(AbstractParser.message("invalid.lvalue"), lvalue.getToken());
- }
- }
- element.accept(this);
- }
- }
- return false;
- } else {
- return enterDefault(literalNode);
+ protected void verifySpreadElement(final Expression lvalue) {
+ if (!checkValidLValue(lvalue, contextString)) {
+ throw error(AbstractParser.message("invalid.lvalue"), lvalue.getToken());
}
}
@Override
- public boolean enterObjectNode(ObjectNode objectNode) {
- return true;
- }
-
- @Override
- public boolean enterPropertyNode(PropertyNode propertyNode) {
- if (propertyNode.getValue() != null) {
- propertyNode.getValue().accept(this);
- return false;
- } else {
- return enterDefault(propertyNode);
- }
- }
-
- @Override
- public boolean enterIdentNode(IdentNode identNode) {
+ public boolean enterIdentNode(final IdentNode identNode) {
verifyIdent(identNode, contextString);
if (!checkIdentLValue(identNode)) {
referenceError(identNode, null, true);
@@ -807,38 +774,17 @@
}
@Override
- public boolean enterAccessNode(AccessNode accessNode) {
- return false;
- }
-
- @Override
- public boolean enterIndexNode(IndexNode indexNode) {
+ public boolean enterAccessNode(final AccessNode accessNode) {
return false;
}
@Override
- public boolean enterBinaryNode(BinaryNode binaryNode) {
- if (binaryNode.isTokenType(ASSIGN)) {
- binaryNode.lhs().accept(this);
- // Initializer(rhs) can be any AssignmentExpression
- return false;
- } else {
- return enterDefault(binaryNode);
- }
+ public boolean enterIndexNode(final IndexNode indexNode) {
+ return false;
}
@Override
- public boolean enterUnaryNode(UnaryNode unaryNode) {
- if (unaryNode.isTokenType(SPREAD_ARRAY)) {
- // rest element
- return true;
- } else {
- return enterDefault(unaryNode);
- }
- }
-
- @Override
- protected boolean enterDefault(Node node) {
+ protected boolean enterDefault(final Node node) {
throw error(String.format("unexpected node in AssignmentPattern: %s", node));
}
});
@@ -1221,13 +1167,13 @@
* class BindingIdentifier[?Yield] ClassTail[?Yield]
* [+Default] class ClassTail[?Yield]
*/
- private ClassNode classDeclaration(boolean isDefault) {
- int classLineNumber = line;
-
- ClassNode classExpression = classExpression(!isDefault);
+ private ClassNode classDeclaration(final boolean isDefault) {
+ final int classLineNumber = line;
+
+ final ClassNode classExpression = classExpression(!isDefault);
if (!isDefault) {
- VarNode classVar = new VarNode(classLineNumber, classExpression.getToken(), classExpression.getIdent().getFinish(), classExpression.getIdent(), classExpression, VarNode.IS_CONST);
+ final VarNode classVar = new VarNode(classLineNumber, classExpression.getToken(), classExpression.getIdent().getFinish(), classExpression.getIdent(), classExpression, VarNode.IS_CONST);
appendStatement(classVar);
}
return classExpression;
@@ -1237,10 +1183,10 @@
* ClassExpression[Yield] :
* class BindingIdentifier[?Yield]opt ClassTail[?Yield]
*/
- private ClassNode classExpression(boolean isStatement) {
+ private ClassNode classExpression(final boolean isStatement) {
assert type == CLASS;
- int classLineNumber = line;
- long classToken = token;
+ final int classLineNumber = line;
+ final long classToken = token;
next();
IdentNode className = null;
@@ -1255,7 +1201,7 @@
private final boolean isStatic;
private final String propertyName;
- private ClassElementKey(boolean isStatic, String propertyName) {
+ private ClassElementKey(final boolean isStatic, final String propertyName) {
this.isStatic = isStatic;
this.propertyName = propertyName;
}
@@ -1270,9 +1216,9 @@
}
@Override
- public boolean equals(Object obj) {
+ public boolean equals(final Object obj) {
if (obj instanceof ClassElementKey) {
- ClassElementKey other = (ClassElementKey) obj;
+ final ClassElementKey other = (ClassElementKey) obj;
return this.isStatic == other.isStatic && Objects.equals(this.propertyName, other.propertyName);
}
return false;
@@ -1386,7 +1332,7 @@
}
}
- private PropertyNode createDefaultClassConstructor(int classLineNumber, long classToken, long lastToken, IdentNode className, boolean subclass) {
+ private PropertyNode createDefaultClassConstructor(final int classLineNumber, final long classToken, final long lastToken, final IdentNode className, final boolean subclass) {
final int ctorFinish = finish;
final List<Statement> statements;
final List<IdentNode> parameters;
@@ -1579,7 +1525,50 @@
variableDeclarationList(varType, true, -1);
}
- private List<Expression> variableDeclarationList(final TokenType varType, final boolean isStatement, final int sourceOrder) {
+ private static final class ForVariableDeclarationListResult {
+ /** First missing const or binding pattern initializer. */
+ Expression missingAssignment;
+ /** First declaration with an initializer. */
+ long declarationWithInitializerToken;
+ /** Destructuring assignments. */
+ Expression init;
+ Expression firstBinding;
+ Expression secondBinding;
+
+ void recordMissingAssignment(final Expression binding) {
+ if (missingAssignment == null) {
+ missingAssignment = binding;
+ }
+ }
+
+ void recordDeclarationWithInitializer(final long token) {
+ if (declarationWithInitializerToken == 0L) {
+ declarationWithInitializerToken = token;
+ }
+ }
+
+ void addBinding(final Expression binding) {
+ if (firstBinding == null) {
+ firstBinding = binding;
+ } else if (secondBinding == null) {
+ secondBinding = binding;
+ }
+ // ignore the rest
+ }
+
+ void addAssignment(final Expression assignment) {
+ if (init == null) {
+ init = assignment;
+ } else {
+ init = new BinaryNode(Token.recast(init.getToken(), COMMARIGHT), init, assignment);
+ }
+ }
+ }
+
+ /**
+ * @param isStatement {@code true} if a VariableStatement, {@code false} if a {@code for} loop VariableDeclarationList
+ */
+ private ForVariableDeclarationListResult variableDeclarationList(final TokenType varType, final boolean isStatement, final int sourceOrder) {
// VAR tested in caller.
assert varType == VAR || varType == LET || varType == CONST;
final int varLine = line;
@@ -1587,7 +1576,6 @@
next();
- final List<Expression> bindings = new ArrayList<>();
int varFlags = 0;
if (varType == LET) {
varFlags |= VarNode.IS_LET;
@@ -1595,7 +1583,7 @@
varFlags |= VarNode.IS_CONST;
}
- Expression missingAssignment = null;
+ final ForVariableDeclarationListResult forResult = isStatement ? null : new ForVariableDeclarationListResult();
while (true) {
// Get name of var.
if (type == YIELD && inGeneratorFunction()) {
@@ -1603,7 +1591,7 @@
}
final String contextString = "variable name";
- Expression binding = bindingIdentifierOrPattern(contextString);
+ final Expression binding = bindingIdentifierOrPattern(contextString);
final boolean isDestructuring = !(binding instanceof IdentNode);
if (isDestructuring) {
final int finalVarFlags = varFlags;
@@ -1625,6 +1613,9 @@
// Look for initializer assignment.
if (type == ASSIGN) {
+ if (!isStatement) {
+ forResult.recordDeclarationWithInitializer(varToken);
+ }
next();
// Get initializer expression. Suppress IN if not statement.
@@ -1655,26 +1646,29 @@
}
// Only set declaration flag on lexically scoped let/const as it adds runtime overhead.
final IdentNode name = varType == LET || varType == CONST ? ident.setIsDeclaredHere() : ident;
- binding = name;
+ if (!isStatement) {
+ if (init == null && varType == CONST) {
+ forResult.recordMissingAssignment(name);
+ }
+ forResult.addBinding(new IdentNode(name));
+ }
final VarNode var = new VarNode(varLine, varToken, sourceOrder, finish, name, init, varFlags);
appendStatement(var);
- if (init == null && varType == CONST) {
- if (missingAssignment == null) {
- missingAssignment = binding;
- }
- }
} else {
assert init != null || !isStatement;
- binding = init == null ? binding : verifyAssignment(Token.recast(varToken, ASSIGN), binding, init);
- if (isStatement) {
- appendStatement(new ExpressionStatement(varLine, binding.getToken(), finish, binding, varType));
- } else if (init == null) {
- if (missingAssignment == null) {
- missingAssignment = binding;
+ if (init != null) {
+ final Expression assignment = verifyAssignment(Token.recast(varToken, ASSIGN), binding, init);
+ if (isStatement) {
+ appendStatement(new ExpressionStatement(varLine, assignment.getToken(), finish, assignment, varType));
+ } else {
+ forResult.addAssignment(assignment);
+ forResult.addBinding(assignment);
}
+ } else if (!isStatement) {
+ forResult.recordMissingAssignment(binding);
+ forResult.addBinding(binding);
}
}
- bindings.add(binding);
if (type != COMMARIGHT) {
break;
@@ -1685,20 +1679,9 @@
// If is a statement then handle end of line.
if (isStatement) {
endOfLine();
- } else {
- if (type == SEMICOLON) {
- // late check for missing assignment, now we know it's a for (init; test; modify) loop
- if (missingAssignment != null) {
- if (missingAssignment instanceof IdentNode) {
- throw error(AbstractParser.message("missing.const.assignment", ((IdentNode)missingAssignment).getName()));
- } else {
- throw error(AbstractParser.message("missing.destructuring.assignment"), missingAssignment.getToken());
- }
- }
- }
}
- return bindings;
+ return forResult;
}
private boolean isBindingIdentifier() {
@@ -1729,50 +1712,91 @@
}
}
+ private abstract class VerifyDestructuringPatternNodeVisitor extends NodeVisitor<LexicalContext> {
+ VerifyDestructuringPatternNodeVisitor(final LexicalContext lc) {
+ super(lc);
+ }
+
+ @Override
+ public boolean enterLiteralNode(final LiteralNode<?> literalNode) {
+ if (literalNode.isArray()) {
+ if (((LiteralNode.ArrayLiteralNode)literalNode).hasSpread() && ((LiteralNode.ArrayLiteralNode)literalNode).hasTrailingComma()) {
+ throw error("Rest element must be last", literalNode.getElementExpressions().get(literalNode.getElementExpressions().size() - 1).getToken());
+ }
+ boolean restElement = false;
+ for (final Expression element : literalNode.getElementExpressions()) {
+ if (element != null) {
+ if (restElement) {
+ throw error("Unexpected element after rest element", element.getToken());
+ }
+ if (element.isTokenType(SPREAD_ARRAY)) {
+ restElement = true;
+ final Expression lvalue = ((UnaryNode) element).getExpression();
+ verifySpreadElement(lvalue);
+ }
+ element.accept(this);
+ }
+ }
+ return false;
+ } else {
+ return enterDefault(literalNode);
+ }
+ }
+
+ protected abstract void verifySpreadElement(Expression lvalue);
+
+ @Override
+ public boolean enterObjectNode(final ObjectNode objectNode) {
+ return true;
+ }
+
+ @Override
+ public boolean enterPropertyNode(final PropertyNode propertyNode) {
+ if (propertyNode.getValue() != null) {
+ propertyNode.getValue().accept(this);
+ return false;
+ } else {
+ return enterDefault(propertyNode);
+ }
+ }
+
+ @Override
+ public boolean enterBinaryNode(final BinaryNode binaryNode) {
+ if (binaryNode.isTokenType(ASSIGN)) {
+ binaryNode.lhs().accept(this);
+ // Initializer(rhs) can be any AssignmentExpression
+ return false;
+ } else {
+ return enterDefault(binaryNode);
+ }
+ }
+
+ @Override
+ public boolean enterUnaryNode(final UnaryNode unaryNode) {
+ if (unaryNode.isTokenType(SPREAD_ARRAY)) {
+ // rest element
+ return true;
+ } else {
+ return enterDefault(unaryNode);
+ }
+ }
+ }
+
/**
* Verify destructuring variable declaration binding pattern and extract bound variable declarations.
*/
private void verifyDestructuringBindingPattern(final Expression pattern, final Consumer<IdentNode> identifierCallback) {
- assert (pattern instanceof BinaryNode && ((BinaryNode)pattern).isTokenType(ASSIGN)) ||
+ assert (pattern instanceof BinaryNode && pattern.isTokenType(ASSIGN)) ||
pattern instanceof ObjectNode || pattern instanceof LiteralNode.ArrayLiteralNode;
- pattern.accept(new NodeVisitor<LexicalContext>(new LexicalContext()) {
+ pattern.accept(new VerifyDestructuringPatternNodeVisitor(new LexicalContext()) {
@Override
- public boolean enterLiteralNode(final LiteralNode<?> literalNode) {
- if (literalNode.isArray()) {
- boolean restElement = false;
- for (final Expression element : literalNode.getElementExpressions()) {
- if (restElement) {
- throw error(String.format("Unexpected element after rest element"), element.getToken());
- }
- if (element != null) {
- if (element.isTokenType(SPREAD_ARRAY)) {
- restElement = true;
- if (!(((UnaryNode) element).getExpression() instanceof IdentNode)) {
- throw error(String.format("Expected a valid binding identifier"), element.getToken());
-
- }
- }
- element.accept(this);
- }
- }
- return false;
+ protected void verifySpreadElement(final Expression lvalue) {
+ if (lvalue instanceof IdentNode) {
+ // checked in identifierCallback
+ } else if (isDestructuringLhs(lvalue)) {
+ verifyDestructuringBindingPattern(lvalue, identifierCallback);
} else {
- return enterDefault(literalNode);
- }
- }
-
- @Override
- public boolean enterObjectNode(final ObjectNode objectNode) {
- return true;
- }
-
- @Override
- public boolean enterPropertyNode(final PropertyNode propertyNode) {
- if (propertyNode.getValue() != null) {
- propertyNode.getValue().accept(this);
- return false;
- } else {
- return enterDefault(propertyNode);
+ throw error("Expected a valid binding identifier", lvalue.getToken());
}
}
@@ -1783,27 +1807,6 @@
}
@Override
- public boolean enterBinaryNode(final BinaryNode binaryNode) {
- if (binaryNode.isTokenType(ASSIGN)) {
- binaryNode.lhs().accept(this);
- // Initializer(rhs) can be any AssignmentExpression
- return false;
- } else {
- return enterDefault(binaryNode);
- }
- }
-
- @Override
- public boolean enterUnaryNode(final UnaryNode unaryNode) {
- if (unaryNode.isTokenType(SPREAD_ARRAY)) {
- // rest element
- return true;
- } else {
- return enterDefault(unaryNode);
- }
- }
-
- @Override
protected boolean enterDefault(final Node node) {
throw error(String.format("unexpected node in BindingPattern: %s", node));
}
@@ -1844,7 +1847,7 @@
final Expression expression = expression();
if (expression != null) {
- ExpressionStatement expressionStatement = new ExpressionStatement(expressionLine, expressionToken, finish, expression);
+ final ExpressionStatement expressionStatement = new ExpressionStatement(expressionLine, expressionToken, finish, expression);
appendStatement(expressionStatement);
} else {
expect(null);
@@ -1910,10 +1913,10 @@
final ParserContextLoopNode forNode = new ParserContextLoopNode();
lc.push(forNode);
Block body = null;
- List<Expression> vars = null;
Expression init = null;
JoinPredecessorExpression test = null;
JoinPredecessorExpression modify = null;
+ ForVariableDeclarationListResult varDeclList = null;
int flags = 0;
boolean isForOf = false;
@@ -1931,10 +1934,11 @@
expect(LPAREN);
+ TokenType varType = null;
switch (type) {
case VAR:
// Var declaration captured in for outer block.
- vars = variableDeclarationList(type, false, forStart);
+ varDeclList = variableDeclarationList(varType = type, false, forStart);
break;
case SEMICOLON:
break;
@@ -1942,12 +1946,12 @@
if (useBlockScope() && (type == LET && lookaheadIsLetDeclaration(true) || type == CONST)) {
flags |= ForNode.PER_ITERATION_SCOPE;
// LET/CONST declaration captured in container block created above.
- vars = variableDeclarationList(type, false, forStart);
+ varDeclList = variableDeclarationList(varType = type, false, forStart);
break;
}
if (env._const_as_var && type == CONST) {
// Var declaration captured in for outer block.
- vars = variableDeclarationList(TokenType.VAR, false, forStart);
+ varDeclList = variableDeclarationList(varType = TokenType.VAR, false, forStart);
break;
}
@@ -1983,38 +1987,30 @@
break;
}
case IN:
-
flags |= isForOf ? ForNode.IS_FOR_OF : ForNode.IS_FOR_IN;
test = new JoinPredecessorExpression();
- if (vars != null) {
- // for (var i in obj)
- if (vars.size() == 1) {
- init = new IdentNode((IdentNode)vars.get(0));
- if (init.isTokenType(ASSIGN)) {
- throw error(AbstractParser.message("for.in.loop.initializer"), init.getToken());
- }
- assert init instanceof IdentNode || isDestructuringLhs(init);
- } else {
+ if (varDeclList != null) {
+ // for (var|let|const ForBinding in|of expression)
+ if (varDeclList.secondBinding != null) {
// for (var i, j in obj) is invalid
- throw error(AbstractParser.message("many.vars.in.for.in.loop", isForOf ? "of" : "in"), vars.get(1).getToken());
+ throw error(AbstractParser.message("many.vars.in.for.in.loop", isForOf ? "of" : "in"), varDeclList.secondBinding.getToken());
}
+ if (varDeclList.declarationWithInitializerToken != 0 && (isStrictMode || type != TokenType.IN || varType != VAR || varDeclList.init != null)) {
+ // ES5 legacy: for (var i = AssignmentExpressionNoIn in Expression)
+ // Invalid in ES6, but allow it in non-strict mode if no ES6 features used,
+ // i.e., error if strict, for-of, let/const, or destructuring
+ throw error(AbstractParser.message("for.in.loop.initializer", isForOf ? "of" : "in"), varDeclList.declarationWithInitializerToken);
+ }
+ init = varDeclList.firstBinding;
+ assert init instanceof IdentNode || isDestructuringLhs(init);
} else {
// for (expr in obj)
assert init != null : "for..in/of init expression can not be null here";
// check if initial expression is a valid L-value
- if (!(init instanceof AccessNode ||
- init instanceof IndexNode ||
- init instanceof IdentNode)) {
+ if (!checkValidLValue(init, isForOf ? "for-of iterator" : "for-in iterator")) {
throw error(AbstractParser.message("not.lvalue.for.in.loop", isForOf ? "of" : "in"), init.getToken());
}
-
- if (init instanceof IdentNode) {
- if (!checkIdentLValue((IdentNode)init)) {
- throw error(AbstractParser.message("not.lvalue.for.in.loop", isForOf ? "of" : "in"), init.getToken());
- }
- verifyStrictIdent((IdentNode)init, isForOf ? "for-of iterator" : "for-in iterator");
- }
}
next();
@@ -2075,7 +2071,7 @@
private boolean lookaheadIsLetDeclaration(final boolean ofContextualKeyword) {
assert type == LET;
for (int i = 1;; i++) {
- TokenType t = T(k + i);
+ final TokenType t = T(k + i);
switch (t) {
case EOL:
case COMMENT:
@@ -2856,6 +2852,7 @@
final List<Expression> elements = new ArrayList<>();
// Track elisions.
boolean elision = true;
+ boolean hasSpread = false;
loop:
while (true) {
long spreadToken = 0;
@@ -2879,6 +2876,7 @@
case ELLIPSIS:
if (isES6()) {
+ hasSpread = true;
spreadToken = token;
next();
}
@@ -2905,7 +2903,7 @@
}
}
- return LiteralNode.newInstance(arrayToken, finish, elements);
+ return LiteralNode.newInstance(arrayToken, finish, elements, hasSpread, elision);
}
/**
@@ -3076,7 +3074,7 @@
*/
private Expression computedPropertyName() {
expect(LBRACKET);
- Expression expression = assignmentExpression(false);
+ final Expression expression = assignmentExpression(false);
expect(RBRACKET);
return expression;
}
@@ -3285,11 +3283,11 @@
return new PropertyFunction(propertyName, function, computed);
}
- private PropertyFunction propertyMethodFunction(Expression key, final long methodToken, final int methodLine, final boolean generator, final int flags, boolean computed) {
+ private PropertyFunction propertyMethodFunction(final Expression key, final long methodToken, final int methodLine, final boolean generator, final int flags, final boolean computed) {
final String methodName = key instanceof PropertyKey ? ((PropertyKey) key).getPropertyName() : getDefaultValidFunctionName(methodLine, false);
final IdentNode methodNameNode = createIdentNode(((Node)key).getToken(), finish, methodName);
- FunctionNode.Kind functionKind = generator ? FunctionNode.Kind.GENERATOR : FunctionNode.Kind.NORMAL;
+ final FunctionNode.Kind functionKind = generator ? FunctionNode.Kind.GENERATOR : FunctionNode.Kind.NORMAL;
final ParserContextFunctionNode functionNode = createParserContextFunctionNode(methodNameNode, methodToken, functionKind, methodLine, null);
functionNode.setFlag(flags);
if (computed) {
@@ -3548,7 +3546,7 @@
if (isES6()) {
final ParserContextFunctionNode currentFunction = getCurrentNonArrowFunction();
if (currentFunction.isMethod()) {
- long identToken = Token.recast(token, IDENT);
+ final long identToken = Token.recast(token, IDENT);
next();
lhs = createIdentNode(identToken, finish, SUPER.getName());
@@ -3766,7 +3764,7 @@
isAnonymous = true;
}
- FunctionNode.Kind functionKind = generator ? FunctionNode.Kind.GENERATOR : FunctionNode.Kind.NORMAL;
+ final FunctionNode.Kind functionKind = generator ? FunctionNode.Kind.GENERATOR : FunctionNode.Kind.NORMAL;
List<IdentNode> parameters = Collections.emptyList();
final ParserContextFunctionNode functionNode = createParserContextFunctionNode(name, functionToken, functionKind, functionLine, parameters);
lc.push(functionNode);
@@ -3870,7 +3868,7 @@
}
}
- private static Block maybeWrapBodyInParameterBlock(Block functionBody, ParserContextBlockNode parameterBlock) {
+ private static Block maybeWrapBodyInParameterBlock(final Block functionBody, final ParserContextBlockNode parameterBlock) {
assert functionBody.isFunctionBody();
if (!parameterBlock.getStatements().isEmpty()) {
parameterBlock.appendStatement(new BlockStatement(functionBody));
@@ -4006,26 +4004,26 @@
}
// default parameter
- Expression initializer = assignmentExpression(false);
-
- ParserContextFunctionNode currentFunction = lc.getCurrentFunction();
+ final Expression initializer = assignmentExpression(false);
+
+ final ParserContextFunctionNode currentFunction = lc.getCurrentFunction();
if (currentFunction != null) {
if (env._parse_only) {
// keep what is seen in source "as is" and save it as parameter expression
- BinaryNode assignment = new BinaryNode(Token.recast(paramToken, ASSIGN), ident, initializer);
+ final BinaryNode assignment = new BinaryNode(Token.recast(paramToken, ASSIGN), ident, initializer);
currentFunction.addParameterExpression(ident, assignment);
} else {
// desugar to: param = (param === undefined) ? initializer : param;
// possible alternative: if (param === undefined) param = initializer;
- BinaryNode test = new BinaryNode(Token.recast(paramToken, EQ_STRICT), ident, newUndefinedLiteral(paramToken, finish));
- TernaryNode value = new TernaryNode(Token.recast(paramToken, TERNARY), test, new JoinPredecessorExpression(initializer), new JoinPredecessorExpression(ident));
- BinaryNode assignment = new BinaryNode(Token.recast(paramToken, ASSIGN), ident, value);
+ final BinaryNode test = new BinaryNode(Token.recast(paramToken, EQ_STRICT), ident, newUndefinedLiteral(paramToken, finish));
+ final TernaryNode value = new TernaryNode(Token.recast(paramToken, TERNARY), test, new JoinPredecessorExpression(initializer), new JoinPredecessorExpression(ident));
+ final BinaryNode assignment = new BinaryNode(Token.recast(paramToken, ASSIGN), ident, value);
lc.getFunctionBody(currentFunction).appendStatement(new ExpressionStatement(paramLine, assignment.getToken(), assignment.getFinish(), assignment));
}
}
}
- ParserContextFunctionNode currentFunction = lc.getCurrentFunction();
+ final ParserContextFunctionNode currentFunction = lc.getCurrentFunction();
if (currentFunction != null) {
currentFunction.addParameterBinding(ident);
if (ident.isRestParameter() || ident.isDefaultParameter()) {
@@ -4044,22 +4042,22 @@
ident = ident.setIsDefaultParameter();
// binding pattern with initializer. desugar to: (param === undefined) ? initializer : param
- Expression initializer = assignmentExpression(false);
+ final Expression initializer = assignmentExpression(false);
if (env._parse_only) {
// we don't want the synthetic identifier in parse only mode
value = initializer;
} else {
// TODO initializer must not contain yield expression if yield=true (i.e. this is generator function's parameter list)
- BinaryNode test = new BinaryNode(Token.recast(paramToken, EQ_STRICT), ident, newUndefinedLiteral(paramToken, finish));
+ final BinaryNode test = new BinaryNode(Token.recast(paramToken, EQ_STRICT), ident, newUndefinedLiteral(paramToken, finish));
value = new TernaryNode(Token.recast(paramToken, TERNARY), test, new JoinPredecessorExpression(initializer), new JoinPredecessorExpression(ident));
}
}
- ParserContextFunctionNode currentFunction = lc.getCurrentFunction();
+ final ParserContextFunctionNode currentFunction = lc.getCurrentFunction();
if (currentFunction != null) {
// destructuring assignment
- BinaryNode assignment = new BinaryNode(Token.recast(paramToken, ASSIGN), pattern, value);
+ final BinaryNode assignment = new BinaryNode(Token.recast(paramToken, ASSIGN), pattern, value);
if (env._parse_only) {
// in parse-only mode, represent source tree "as is"
if (ident.isDefaultParameter()) {
@@ -4081,10 +4079,10 @@
private void verifyDestructuringParameterBindingPattern(final Expression pattern, final long paramToken, final int paramLine, final String contextString) {
verifyDestructuringBindingPattern(pattern, new Consumer<IdentNode>() {
- public void accept(IdentNode identNode) {
+ public void accept(final IdentNode identNode) {
verifyIdent(identNode, contextString);
- ParserContextFunctionNode currentFunction = lc.getCurrentFunction();
+ final ParserContextFunctionNode currentFunction = lc.getCurrentFunction();
if (currentFunction != null) {
// declare function-scope variables for destructuring bindings
if (!env._parse_only) {
@@ -4398,7 +4396,7 @@
break;
}
- Expression expression = leftHandSideExpression();
+ final Expression expression = leftHandSideExpression();
if (last != EOL) {
switch (type) {
@@ -4549,7 +4547,7 @@
private Expression expression(final boolean noIn) {
Expression assignmentExpression = assignmentExpression(noIn);
while (type == COMMARIGHT) {
- long commaToken = token;
+ final long commaToken = token;
next();
boolean rhsRestParameter = false;
@@ -4707,7 +4705,7 @@
/**
* Is type one of {@code = *= /= %= += -= <<= >>= >>>= &= ^= |=}?
*/
- private static boolean isAssignmentOperator(TokenType type) {
+ private static boolean isAssignmentOperator(final TokenType type) {
switch (type) {
case ASSIGN:
case ASSIGN_ADD:
@@ -4729,7 +4727,7 @@
/**
* ConditionalExpression.
*/
- private Expression conditionalExpression(boolean noIn) {
+ private Expression conditionalExpression(final boolean noIn) {
return expression(TERNARY.getPrecedence(), noIn);
}
@@ -4752,7 +4750,7 @@
lc.push(functionNode);
try {
- ParserContextBlockNode parameterBlock = newBlock();
+ final ParserContextBlockNode parameterBlock = newBlock();
final List<IdentNode> parameters;
try {
parameters = convertArrowFunctionParameterList(paramListExpr, functionLine);
@@ -4829,12 +4827,12 @@
return parameters;
}
- private IdentNode verifyArrowParameter(Expression param, int index, int paramLine) {
+ private IdentNode verifyArrowParameter(final Expression param, final int index, final int paramLine) {
final String contextString = "function parameter";
if (param instanceof IdentNode) {
- IdentNode ident = (IdentNode)param;
+ final IdentNode ident = (IdentNode)param;
verifyStrictIdent(ident, contextString);
- ParserContextFunctionNode currentFunction = lc.getCurrentFunction();
+ final ParserContextFunctionNode currentFunction = lc.getCurrentFunction();
if (currentFunction != null) {
currentFunction.addParameterBinding(ident);
}
@@ -4842,21 +4840,21 @@
}
if (param.isTokenType(ASSIGN)) {
- Expression lhs = ((BinaryNode) param).lhs();
- long paramToken = lhs.getToken();
- Expression initializer = ((BinaryNode) param).rhs();
+ final Expression lhs = ((BinaryNode) param).lhs();
+ final long paramToken = lhs.getToken();
+ final Expression initializer = ((BinaryNode) param).rhs();
if (lhs instanceof IdentNode) {
// default parameter
- IdentNode ident = (IdentNode) lhs;
-
- ParserContextFunctionNode currentFunction = lc.getCurrentFunction();
+ final IdentNode ident = (IdentNode) lhs;
+
+ final ParserContextFunctionNode currentFunction = lc.getCurrentFunction();
if (currentFunction != null) {
if (env._parse_only) {
currentFunction.addParameterExpression(ident, param);
} else {
- BinaryNode test = new BinaryNode(Token.recast(paramToken, EQ_STRICT), ident, newUndefinedLiteral(paramToken, finish));
- TernaryNode value = new TernaryNode(Token.recast(paramToken, TERNARY), test, new JoinPredecessorExpression(initializer), new JoinPredecessorExpression(ident));
- BinaryNode assignment = new BinaryNode(Token.recast(paramToken, ASSIGN), ident, value);
+ final BinaryNode test = new BinaryNode(Token.recast(paramToken, EQ_STRICT), ident, newUndefinedLiteral(paramToken, finish));
+ final TernaryNode value = new TernaryNode(Token.recast(paramToken, TERNARY), test, new JoinPredecessorExpression(initializer), new JoinPredecessorExpression(ident));
+ final BinaryNode assignment = new BinaryNode(Token.recast(paramToken, ASSIGN), ident, value);
lc.getFunctionBody(currentFunction).appendStatement(new ExpressionStatement(paramLine, assignment.getToken(), assignment.getFinish(), assignment));
}
@@ -4867,17 +4865,17 @@
} else if (isDestructuringLhs(lhs)) {
// binding pattern with initializer
// Introduce synthetic temporary parameter to capture the object to be destructured.
- IdentNode ident = createIdentNode(paramToken, param.getFinish(), String.format("arguments[%d]", index)).setIsDestructuredParameter().setIsDefaultParameter();
+ final IdentNode ident = createIdentNode(paramToken, param.getFinish(), String.format("arguments[%d]", index)).setIsDestructuredParameter().setIsDefaultParameter();
verifyDestructuringParameterBindingPattern(param, paramToken, paramLine, contextString);
- ParserContextFunctionNode currentFunction = lc.getCurrentFunction();
+ final ParserContextFunctionNode currentFunction = lc.getCurrentFunction();
if (currentFunction != null) {
if (env._parse_only) {
currentFunction.addParameterExpression(ident, param);
} else {
- BinaryNode test = new BinaryNode(Token.recast(paramToken, EQ_STRICT), ident, newUndefinedLiteral(paramToken, finish));
- TernaryNode value = new TernaryNode(Token.recast(paramToken, TERNARY), test, new JoinPredecessorExpression(initializer), new JoinPredecessorExpression(ident));
- BinaryNode assignment = new BinaryNode(Token.recast(paramToken, ASSIGN), param, value);
+ final BinaryNode test = new BinaryNode(Token.recast(paramToken, EQ_STRICT), ident, newUndefinedLiteral(paramToken, finish));
+ final TernaryNode value = new TernaryNode(Token.recast(paramToken, TERNARY), test, new JoinPredecessorExpression(initializer), new JoinPredecessorExpression(ident));
+ final BinaryNode assignment = new BinaryNode(Token.recast(paramToken, ASSIGN), param, value);
lc.getFunctionBody(currentFunction).appendStatement(new ExpressionStatement(paramLine, assignment.getToken(), assignment.getFinish(), assignment));
}
}
@@ -4885,18 +4883,18 @@
}
} else if (isDestructuringLhs(param)) {
// binding pattern
- long paramToken = param.getToken();
+ final long paramToken = param.getToken();
// Introduce synthetic temporary parameter to capture the object to be destructured.
- IdentNode ident = createIdentNode(paramToken, param.getFinish(), String.format("arguments[%d]", index)).setIsDestructuredParameter();
+ final IdentNode ident = createIdentNode(paramToken, param.getFinish(), String.format("arguments[%d]", index)).setIsDestructuredParameter();
verifyDestructuringParameterBindingPattern(param, paramToken, paramLine, contextString);
- ParserContextFunctionNode currentFunction = lc.getCurrentFunction();
+ final ParserContextFunctionNode currentFunction = lc.getCurrentFunction();
if (currentFunction != null) {
if (env._parse_only) {
currentFunction.addParameterExpression(ident, param);
} else {
- BinaryNode assignment = new BinaryNode(Token.recast(paramToken, ASSIGN), param, ident);
+ final BinaryNode assignment = new BinaryNode(Token.recast(paramToken, ASSIGN), param, ident);
lc.getFunctionBody(currentFunction).appendStatement(new ExpressionStatement(paramLine, assignment.getToken(), assignment.getFinish(), assignment));
}
}
@@ -4913,7 +4911,7 @@
return true;
}
for (int i = k - 1; i >= 0; i--) {
- TokenType t = T(i);
+ final TokenType t = T(i);
switch (t) {
case RPAREN:
case IDENT:
@@ -4941,7 +4939,7 @@
// find IDENT, RPAREN, ARROW, in that order, skipping over EOL (where allowed) and COMMENT
int i = 1;
for (;;) {
- TokenType t = T(k + i++);
+ final TokenType t = T(k + i++);
if (t == IDENT) {
break;
} else if (t == EOL || t == COMMENT) {
@@ -4951,7 +4949,7 @@
}
}
for (;;) {
- TokenType t = T(k + i++);
+ final TokenType t = T(k + i++);
if (t == RPAREN) {
break;
} else if (t == EOL || t == COMMENT) {
@@ -4961,7 +4959,7 @@
}
}
for (;;) {
- TokenType t = T(k + i++);
+ final TokenType t = T(k + i++);
if (t == ARROW) {
break;
} else if (t == COMMENT) {
@@ -5008,7 +5006,7 @@
}
if (env._parse_only) {
- List<Expression> exprs = new ArrayList<>();
+ final List<Expression> exprs = new ArrayList<>();
exprs.add(literal);
TokenType lastLiteralType;
do {
@@ -5096,12 +5094,12 @@
* ModuleItemList
*/
private FunctionNode module(final String moduleName) {
- boolean oldStrictMode = isStrictMode;
+ final boolean oldStrictMode = isStrictMode;
try {
isStrictMode = true; // Module code is always strict mode code. (ES6 10.2.1)
// Make a pseudo-token for the script holding its start and length.
- int functionStart = Math.min(Token.descPosition(Token.withDelimiter(token)), finish);
+ final int functionStart = Math.min(Token.descPosition(Token.withDelimiter(token)), finish);
final long functionToken = Token.toDesc(FUNCTION, functionStart, source.getLength() - functionStart);
final int functionLine = line;
@@ -5214,7 +5212,7 @@
} else if (isBindingIdentifier()) {
// ImportedDefaultBinding
final IdentNode importedDefaultBinding = bindingIdentifier("ImportedBinding");
- Module.ImportEntry defaultImport = Module.ImportEntry.importSpecifier(importedDefaultBinding, startPosition, finish);
+ final Module.ImportEntry defaultImport = Module.ImportEntry.importSpecifier(importedDefaultBinding, startPosition, finish);
if (type == COMMARIGHT) {
next();
@@ -5279,7 +5277,7 @@
private List<Module.ImportEntry> namedImports(final int startPosition) {
assert type == LBRACE;
next();
- List<Module.ImportEntry> importEntries = new ArrayList<>();
+ final List<Module.ImportEntry> importEntries = new ArrayList<>();
while (type != RBRACE) {
final boolean bindingIdentifier = isBindingIdentifier();
final long nameToken = token;
@@ -5354,11 +5352,11 @@
if (type == IDENT && "from".equals(getValue())) {
final IdentNode moduleRequest = fromClause();
module.addModuleRequest(moduleRequest);
- for (Module.ExportEntry exportEntry : exportEntries) {
+ for (final Module.ExportEntry exportEntry : exportEntries) {
module.addIndirectExportEntry(exportEntry.withFrom(moduleRequest, finish));
}
} else {
- for (Module.ExportEntry exportEntry : exportEntries) {
+ for (final Module.ExportEntry exportEntry : exportEntries) {
module.addLocalExportEntry(exportEntry);
}
}
@@ -5445,7 +5443,7 @@
private List<Module.ExportEntry> exportClause(final int startPosition) {
assert type == LBRACE;
next();
- List<Module.ExportEntry> exports = new ArrayList<>();
+ final List<Module.ExportEntry> exports = new ArrayList<>();
while (type != RBRACE) {
final IdentNode localName = getIdentifierName();
if (type == IDENT && "as".equals(getValue())) {
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/ParserContextFunctionNode.java Fri Oct 14 19:12:37 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/ParserContextFunctionNode.java Fri Oct 14 11:11:19 2016 -0700
@@ -169,7 +169,7 @@
return parameters;
}
- void setParameters(List<IdentNode> parameters) {
+ void setParameters(final List<IdentNode> parameters) {
this.parameters = parameters;
}
@@ -182,7 +182,7 @@
return parameterExpressions;
}
- void addParameterExpression(IdentNode ident, Expression node) {
+ void addParameterExpression(final IdentNode ident, final Expression node) {
if (parameterExpressions == null) {
parameterExpressions = new HashMap<>();
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/ParserContextModuleNode.java Fri Oct 14 19:12:37 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/ParserContextModuleNode.java Fri Oct 14 11:11:19 2016 -0700
@@ -41,11 +41,11 @@
/** Module name. */
private final String name;
- private List<String> requestedModules = new ArrayList<>();
- private List<ImportEntry> importEntries = new ArrayList<>();
- private List<ExportEntry> localExportEntries = new ArrayList<>();
- private List<ExportEntry> indirectExportEntries = new ArrayList<>();
- private List<ExportEntry> starExportEntries = new ArrayList<>();
+ private final List<String> requestedModules = new ArrayList<>();
+ private final List<ImportEntry> importEntries = new ArrayList<>();
+ private final List<ExportEntry> localExportEntries = new ArrayList<>();
+ private final List<ExportEntry> indirectExportEntries = new ArrayList<>();
+ private final List<ExportEntry> starExportEntries = new ArrayList<>();
/**
* Constructor.
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/AllocationStrategy.java Fri Oct 14 19:12:37 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/AllocationStrategy.java Fri Oct 14 11:11:19 2016 -0700
@@ -141,7 +141,7 @@
final private WeakReference<ScriptObject> prototype;
final private WeakReference<PropertyMap> prototypeMap;
- private PropertyMap allocatorMap;
+ private final PropertyMap allocatorMap;
AllocatorMap(final ScriptObject prototype, final PropertyMap protoMap, final PropertyMap allocMap) {
this.prototype = new WeakReference<>(prototype);
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/CommandExecutor.java Fri Oct 14 19:12:37 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/CommandExecutor.java Fri Oct 14 11:11:19 2016 -0700
@@ -148,14 +148,14 @@
boolean check(String token, final Iterator<String> iterator, final String cwd) {
// Iterate through redirect prefixes to file a match.
for (int i = 0; i < redirectPrefixes.length; i++) {
- String prefix = redirectPrefixes[i];
+ final String prefix = redirectPrefixes[i];
// If a match is found.
if (token.startsWith(prefix)) {
// Indicate we have at least one redirect (efficiency.)
hasRedirects = true;
// Map prefix to RedirectType.
- RedirectType redirect = redirects[i];
+ final RedirectType redirect = redirects[i];
// Strip prefix from token
token = token.substring(prefix.length());
@@ -223,8 +223,8 @@
// Only if there was redirects (saves new structure in ProcessBuilder.)
if (hasRedirects) {
// If output and error are the same file then merge.
- File outputFile = outputRedirect.file();
- File errorFile = errorRedirect.file();
+ final File outputFile = outputRedirect.file();
+ final File errorFile = errorRedirect.file();
if (outputFile != null && outputFile.equals(errorFile)) {
mergeError = true;
@@ -274,26 +274,26 @@
public void run() {
try {
// Buffer for copying.
- byte[] b = new byte[BUFFER_SIZE];
+ final byte[] b = new byte[BUFFER_SIZE];
// Read from the InputStream until EOF.
int read;
while (-1 < (read = input.read(b, 0, b.length))) {
// Write available date to OutputStream.
output.write(b, 0, read);
}
- } catch (Exception e) {
+ } catch (final Exception e) {
// Assume the worst.
throw new RuntimeException("Broken pipe", e);
} finally {
// Make sure the streams are closed.
try {
input.close();
- } catch (IOException e) {
+ } catch (final IOException e) {
// Don't care.
}
try {
output.close();
- } catch (IOException e) {
+ } catch (final IOException e) {
// Don't care.
}
}
@@ -363,7 +363,7 @@
private long envVarLongValue(final String key) {
try {
return Long.parseLong(envVarValue(key, "0"));
- } catch (NumberFormatException ex) {
+ } catch (final NumberFormatException ex) {
return 0L;
}
}
@@ -478,7 +478,7 @@
// iterate through all tokens.
final Iterator<String> iterator = tokens.iterator();
while (iterator.hasNext()) {
- String token = iterator.next();
+ final String token = iterator.next();
// Check if is a redirect.
if (redirectInfo.check(token, iterator, cwd)) {
@@ -551,7 +551,7 @@
* @param tokens tokens of the command
* @param isPiped true if the output of this command should be piped to the next
*/
- private void command(final List<String> tokens, boolean isPiped) {
+ private void command(final List<String> tokens, final boolean isPiped) {
// Test to see if we should echo the command to output.
if (envVarBooleanValue("JJS_ECHO")) {
System.out.println(String.join(" ", tokens));
@@ -584,7 +584,7 @@
boolean inputIsPipe = firstProcessBuilder.redirectInput() == Redirect.PIPE;
boolean outputIsPipe = lastProcessBuilder.redirectOutput() == Redirect.PIPE;
boolean errorIsPipe = lastProcessBuilder.redirectError() == Redirect.PIPE;
- boolean inheritIO = envVarBooleanValue("JJS_INHERIT_IO");
+ final boolean inheritIO = envVarBooleanValue("JJS_INHERIT_IO");
// If not redirected and inputStream is current processes' input.
if (inputIsPipe && (inheritIO || inputStream == System.in)) {
@@ -609,10 +609,10 @@
// Start the processes.
final List<Process> processes = new ArrayList<>();
- for (ProcessBuilder pb : processBuilders) {
+ for (final ProcessBuilder pb : processBuilders) {
try {
processes.add(pb.start());
- } catch (IOException ex) {
+ } catch (final IOException ex) {
reportError("unknown.command", String.join(" ", pb.command()));
return;
}
@@ -701,7 +701,7 @@
// Accumulate the output and error streams.
outputString += byteOutputStream != null ? byteOutputStream.toString() : "";
errorString += byteErrorStream != null ? byteErrorStream.toString() : "";
- } catch (InterruptedException ex) {
+ } catch (final InterruptedException ex) {
// Kill any living processes.
processes.stream().forEach(p -> {
if (p.isAlive()) {
@@ -829,7 +829,7 @@
final Iterator<String> iterator = tokens.iterator();
while (iterator.hasNext() && exitCode == EXIT_SUCCESS) {
// Next word token.
- String token = iterator.next();
+ final String token = iterator.next();
if (token == null) {
continue;
@@ -876,23 +876,23 @@
return exitCode;
}
- void setEnvironment(Map<String, String> environment) {
+ void setEnvironment(final Map<String, String> environment) {
this.environment = environment;
}
- void setInputStream(InputStream inputStream) {
+ void setInputStream(final InputStream inputStream) {
this.inputStream = inputStream;
}
- void setInputString(String inputString) {
+ void setInputString(final String inputString) {
this.inputString = inputString;
}
- void setOutputStream(OutputStream outputStream) {
+ void setOutputStream(final OutputStream outputStream) {
this.outputStream = outputStream;
}
- void setErrorStream(OutputStream errorStream) {
+ void setErrorStream(final OutputStream errorStream) {
this.errorStream = errorStream;
}
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/Context.java Fri Oct 14 19:12:37 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/Context.java Fri Oct 14 11:11:19 2016 -0700
@@ -56,6 +56,8 @@
import java.lang.reflect.Module;
import java.net.MalformedURLException;
import java.net.URL;
+import java.nio.file.Path;
+import java.nio.file.Paths;
import java.security.AccessControlContext;
import java.security.AccessController;
import java.security.CodeSigner;
@@ -81,6 +83,8 @@
import java.util.function.Consumer;
import java.util.function.Supplier;
import java.util.logging.Level;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
import javax.script.ScriptEngine;
import jdk.dynalink.DynamicLinker;
import jdk.internal.org.objectweb.asm.ClassReader;
@@ -614,18 +618,37 @@
}
this.errors = errors;
+ // if user passed --module-path, we create a module class loader with
+ // passed appLoader as the parent.
+ final String modulePath = env._module_path;
+ ClassLoader appCl = null;
+ if (!env._compile_only && modulePath != null && !modulePath.isEmpty()) {
+ // make sure that caller can create a class loader.
+ if (sm != null) {
+ sm.checkCreateClassLoader();
+ }
+ appCl = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
+ @Override
+ public ClassLoader run() {
+ return createModuleLoader(appLoader, modulePath, env._add_modules);
+ }
+ });
+ } else {
+ appCl = appLoader;
+ }
+
// if user passed -classpath option, make a URLClassLoader with that and
- // the app loader as the parent.
- final String classPath = options.getString("classpath");
+ // the app loader or module app loader as the parent.
+ final String classPath = env._classpath;
if (!env._compile_only && classPath != null && !classPath.isEmpty()) {
// make sure that caller can create a class loader.
if (sm != null) {
sm.checkCreateClassLoader();
}
- this.appLoader = NashornLoader.createClassLoader(classPath, appLoader);
- } else {
- this.appLoader = appLoader;
+ appCl = NashornLoader.createClassLoader(classPath, appCl);
}
+
+ this.appLoader = appCl;
this.dynamicLinker = Bootstrap.createDynamicLinker(this.appLoader, env._unstable_relink_threshold);
final int cacheSize = env._class_cache_size;
@@ -1339,7 +1362,7 @@
final ModuleFinder finder = new ModuleFinder() {
@Override
- public Optional<ModuleReference> find(String name) {
+ public Optional<ModuleReference> find(final String name) {
if (name.equals(mn)) {
return Optional.of(mref);
} else {
@@ -1387,7 +1410,7 @@
ClassLoader loader = null;
try {
loader = clazz.getClassLoader();
- } catch (SecurityException ignored) {
+ } catch (final SecurityException ignored) {
// This could fail because of anonymous classes being used.
// Accessing loader of anonymous class fails (for extension
// loader class too?). In any case, for us fetching Context
@@ -1750,4 +1773,37 @@
public SwitchPoint getBuiltinSwitchPoint(final String name) {
return builtinSwitchPoints.get(name);
}
+
+ private static ClassLoader createModuleLoader(final ClassLoader cl,
+ final String modulePath, final String addModules) {
+ if (addModules == null) {
+ throw new IllegalArgumentException("--module-path specified with no --add-modules");
+ }
+
+ final Path[] paths = Stream.of(modulePath.split(File.pathSeparator)).
+ map(s -> Paths.get(s)).
+ toArray(sz -> new Path[sz]);
+ final ModuleFinder mf = ModuleFinder.of(paths);
+ final Set<ModuleReference> mrefs = mf.findAll();
+ if (mrefs.isEmpty()) {
+ throw new RuntimeException("No modules in script --module-path: " + modulePath);
+ }
+
+ final Set<String> rootMods;
+ if (addModules.equals("ALL-MODULE-PATH")) {
+ rootMods = mrefs.stream().
+ map(mr->mr.descriptor().name()).
+ collect(Collectors.toSet());
+ } else {
+ rootMods = Stream.of(addModules.split(",")).
+ map(String::trim).
+ collect(Collectors.toSet());
+ }
+
+ final Layer boot = Layer.boot();
+ final Configuration conf = boot.configuration().
+ resolveRequires(mf, ModuleFinder.of(), rootMods);
+ final String firstMod = rootMods.iterator().next();
+ return boot.defineModulesWithOneLoader(conf, cl).findLoader(firstMod);
+ }
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/FinalScriptFunctionData.java Fri Oct 14 19:12:37 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/FinalScriptFunctionData.java Fri Oct 14 11:11:19 2016 -0700
@@ -87,7 +87,7 @@
@Override
String getDocumentation() {
- String doc = docKey != null?
+ final String doc = docKey != null?
FunctionDocumentation.getDoc(docKey) : null;
return doc != null? doc : super.getDocumentation();
}
@@ -109,7 +109,7 @@
}
@Override
- CompiledFunction getBest(final MethodType callSiteType, final ScriptObject runtimeScope, final Collection<CompiledFunction> forbidden, boolean linkLogicOkay) {
+ CompiledFunction getBest(final MethodType callSiteType, final ScriptObject runtimeScope, final Collection<CompiledFunction> forbidden, final boolean linkLogicOkay) {
assert isValidCallSite(callSiteType) : callSiteType;
CompiledFunction best = null;
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/JSONListAdapter.java Fri Oct 14 19:12:37 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/JSONListAdapter.java Fri Oct 14 11:11:19 2016 -0700
@@ -155,7 +155,7 @@
}
@Override
- public Object getDefaultValue(Class<?> hint) throws UnsupportedOperationException {
+ public Object getDefaultValue(final Class<?> hint) throws UnsupportedOperationException {
return obj.getDefaultValue(hint);
}
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/NashornLoader.java Fri Oct 14 19:12:37 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/NashornLoader.java Fri Oct 14 11:11:19 2016 -0700
@@ -221,7 +221,7 @@
final String res = "/"+ MODULE_MANIPULATOR_NAME.replace('.', '/') + ".class";
try (InputStream in = NashornLoader.class.getResourceAsStream(res)) {
return in.readAllBytes();
- } catch (IOException exp) {
+ } catch (final IOException exp) {
throw new UncheckedIOException(exp);
}
};
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptEnvironment.java Fri Oct 14 19:12:37 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptEnvironment.java Fri Oct 14 11:11:19 2016 -0700
@@ -153,6 +153,12 @@
/** Create a new class loaded for each compilation */
public final boolean _loader_per_compile;
+ /** --module-path, if any */
+ public final String _module_path;
+
+ /** --add-modules, if any */
+ public final String _add_modules;
+
/** Do not support Java support extensions. */
public final boolean _no_java;
@@ -285,6 +291,8 @@
_lazy_compilation = lazy_compilation;
}
_loader_per_compile = options.getBoolean("loader.per.compile");
+ _module_path = options.getString("module.path");
+ _add_modules = options.getString("add.modules");
_no_java = options.getBoolean("no.java");
_no_syntax_extensions = options.getBoolean("no.syntax.extensions");
_no_typed_arrays = options.getBoolean("no.typed.arrays");
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptLoader.java Fri Oct 14 19:12:37 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptLoader.java Fri Oct 14 11:11:19 2016 -0700
@@ -95,7 +95,7 @@
}
@Override
- protected Class<?> findClass(String name) throws ClassNotFoundException {
+ protected Class<?> findClass(final String name) throws ClassNotFoundException {
final ClassLoader appLoader = context.getAppLoader();
/*
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptingFunctions.java Fri Oct 14 19:12:37 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptingFunctions.java Fri Oct 14 11:11:19 2016 -0700
@@ -149,7 +149,7 @@
String inputString = null;
if (arg0 instanceof NativeArray) {
- String[] array = (String[])JSType.toJavaArray(arg0, String.class);
+ final String[] array = (String[])JSType.toJavaArray(arg0, String.class);
tokens = new ArrayList<>();
tokens.addAll(Arrays.asList(array));
} else {
@@ -206,7 +206,7 @@
final String outString = executor.getOutputString();
final String errString = executor.getErrorString();
- int exitCode = executor.getExitCode();
+ final int exitCode = executor.getExitCode();
// Set globals for secondary results.
global.set(OUT_NAME, outString, 0);
@@ -222,7 +222,7 @@
private static Function<String, String> readLineHelper;
- public static void setReadLineHelper(Function<String, String> func) {
+ public static void setReadLineHelper(final Function<String, String> func) {
readLineHelper = Objects.requireNonNull(func);
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/WithObject.java Fri Oct 14 19:12:37 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/WithObject.java Fri Oct 14 11:11:19 2016 -0700
@@ -183,7 +183,7 @@
* @return FindPropertyData or null if not found.
*/
@Override
- protected FindProperty findProperty(final Object key, final boolean deep, boolean isScope, final ScriptObject start) {
+ protected FindProperty findProperty(final Object key, final boolean deep, final boolean isScope, final ScriptObject start) {
// We call findProperty on 'expression' with 'expression' itself as start parameter.
// This way in ScriptObject.setObject we can tell the property is from a 'with' expression
// (as opposed from another non-scope object in the proto chain such as Object.prototype).
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/doubleconv/Bignum.java Fri Oct 14 19:12:37 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/doubleconv/Bignum.java Fri Oct 14 11:11:19 2016 -0700
@@ -76,7 +76,7 @@
// grow. There are no checks if the stack-allocated space is sufficient.
static final int kBigitCapacity = kMaxSignificantBits / kBigitSize;
- private int[] bigits_ = new int[kBigitCapacity];
+ private final int[] bigits_ = new int[kBigitCapacity];
// A vector backed by bigits_buffer_. This way accesses to the array are
// checked for out-of-bounds errors.
// Vector<int> bigits_;
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/LinkerCallSite.java Fri Oct 14 19:12:37 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/LinkerCallSite.java Fri Oct 14 11:11:19 2016 -0700
@@ -214,7 +214,7 @@
// new target uses a more precise 'self' type than Object.class. We need to
// convert the filter type. Note that the profileEntry method returns "self"
// argument "as is" and so the cast introduced will succeed for any type.
- MethodType selfFilterType = MethodType.methodType(newSelfType, newSelfType);
+ final MethodType selfFilterType = MethodType.methodType(newSelfType, newSelfType);
selfFilter = selfFilter.asType(selfFilterType);
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NameCodec.java Fri Oct 14 19:12:37 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NameCodec.java Fri Oct 14 11:11:19 2016 -0700
@@ -283,7 +283,7 @@
* @return the mangled form of the symbolic name.
*/
public static String encode(final String name) {
- String bn = mangle(name);
+ final String bn = mangle(name);
assert((Object)bn == name || looksMangled(bn)) : bn;
assert(name.equals(decode(bn))) : name;
return bn;
@@ -303,11 +303,11 @@
return sn;
}
- private static boolean looksMangled(String s) {
+ private static boolean looksMangled(final String s) {
return s.charAt(0) == ESCAPE_C;
}
- private static String mangle(String s) {
+ private static String mangle(final String s) {
if (s.length() == 0)
return NULL_ESCAPE;
@@ -315,12 +315,12 @@
StringBuilder sb = null;
for (int i = 0, slen = s.length(); i < slen; i++) {
- char c = s.charAt(i);
+ final char c = s.charAt(i);
boolean needEscape = false;
if (c == ESCAPE_C) {
if (i+1 < slen) {
- char c1 = s.charAt(i+1);
+ final char c1 = s.charAt(i+1);
if ((i == 0 && c1 == NULL_ESCAPE_C)
|| c1 != originalOfReplacement(c1)) {
// an accidental escape
@@ -356,7 +356,7 @@
return s;
}
- private static String demangle(String s) {
+ private static String demangle(final String s) {
// build this lazily, when we first meet an escape:
StringBuilder sb = null;
@@ -369,8 +369,8 @@
if (c == ESCAPE_C && i+1 < slen) {
// might be an escape sequence
- char rc = s.charAt(i+1);
- char oc = originalOfReplacement(rc);
+ final char rc = s.charAt(i+1);
+ final char oc = originalOfReplacement(rc);
if (oc != rc) {
// build sb if this is the first escape
if (sb == null) {
@@ -398,34 +398,34 @@
private static final long[] SPECIAL_BITMAP = new long[2]; // 128 bits
static {
- String SPECIAL = DANGEROUS_CHARS + REPLACEMENT_CHARS;
- for (char c : SPECIAL.toCharArray()) {
+ final String SPECIAL = DANGEROUS_CHARS + REPLACEMENT_CHARS;
+ for (final char c : SPECIAL.toCharArray()) {
SPECIAL_BITMAP[c >>> 6] |= 1L << c;
}
}
- private static boolean isSpecial(char c) {
+ private static boolean isSpecial(final char c) {
if ((c >>> 6) < SPECIAL_BITMAP.length)
return ((SPECIAL_BITMAP[c >>> 6] >> c) & 1) != 0;
else
return false;
}
- private static char replacementOf(char c) {
+ private static char replacementOf(final char c) {
if (!isSpecial(c)) return c;
- int i = DANGEROUS_CHARS.indexOf(c);
+ final int i = DANGEROUS_CHARS.indexOf(c);
if (i < 0) return c;
return REPLACEMENT_CHARS.charAt(i);
}
- private static char originalOfReplacement(char c) {
+ private static char originalOfReplacement(final char c) {
if (!isSpecial(c)) return c;
- int i = REPLACEMENT_CHARS.indexOf(c);
+ final int i = REPLACEMENT_CHARS.indexOf(c);
if (i < 0) return c;
return DANGEROUS_CHARS.charAt(i);
}
- private static boolean isDangerous(char c) {
+ private static boolean isDangerous(final char c) {
if (!isSpecial(c)) return false;
return (DANGEROUS_CHARS.indexOf(c) >= DANGEROUS_CHAR_FIRST_INDEX);
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/options/OptionTemplate.java Fri Oct 14 19:12:37 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/options/OptionTemplate.java Fri Oct 14 11:11:19 2016 -0700
@@ -77,6 +77,14 @@
/** is the option value specified as next argument? */
private boolean valueNextArg;
+ /**
+ * Can this option be repeated in command line?
+ *
+ * For a repeatable option, multiple values will be merged as comma
+ * separated values rather than the last value overriding previous ones.
+ */
+ private boolean repeated;
+
OptionTemplate(final String resource, final String key, final String value, final boolean isHelp, final boolean isXHelp) {
this.resource = resource;
this.key = key;
@@ -223,6 +231,14 @@
return valueNextArg;
}
+ /**
+ * Can this option be repeated?
+ * @return boolean
+ */
+ public boolean isRepeated() {
+ return repeated;
+ }
+
private static String strip(final String value, final char start, final char end) {
final int len = value.length();
if (len > 1 && value.charAt(0) == start && value.charAt(len - 1) == end) {
@@ -281,6 +297,9 @@
case "value_next_arg":
this.valueNextArg = Boolean.parseBoolean(arg);
break;
+ case "repeated":
+ this.repeated = true;
+ break;
default:
throw new IllegalArgumentException(keyToken);
}
@@ -302,6 +321,10 @@
if (name == null && shortName == null) {
throw new IllegalArgumentException(origValue);
}
+
+ if (this.repeated && !"string".equals(this.type)) {
+ throw new IllegalArgumentException("repeated option should be of type string: " + this.name);
+ }
}
boolean nameMatches(final String aName) {
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/options/Options.java Fri Oct 14 19:12:37 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/options/Options.java Fri Oct 14 11:11:19 2016 -0700
@@ -500,7 +500,16 @@
throw new IllegalOptionException(parg.template);
}
- set(parg.template.getKey(), createOption(parg.template, parg.value));
+ if (parg.template.isRepeated()) {
+ assert parg.template.getType().equals("string");
+
+ final String key = key(parg.template.getKey());
+ final String value = options.containsKey(key)?
+ (options.get(key).getValue() + "," + parg.value) : Objects.toString(parg.value);
+ options.put(key, new Option<>(value));
+ } else {
+ set(parg.template.getKey(), createOption(parg.template, parg.value));
+ }
// Arg may have a dependency to set other args, e.g.
// scripting->anon.functions
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/resources/Options.properties Fri Oct 14 19:12:37 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/resources/Options.properties Fri Oct 14 11:11:19 2016 -0700
@@ -237,6 +237,21 @@
default=true \
}
+nashorn.option.module.path ={ \
+ name="--module-path", \
+ desc="--module-path path. Specify where to find user java modules.", \
+ value_next_arg=true, \
+ type=String \
+}
+
+nashorn.option.add.modules ={ \
+ name="--add-modules", \
+ desc="--add-modules modules. Specify the root user java modules.", \
+ repeated=true, \
+ value_next_arg=true, \
+ type=String \
+}
+
nashorn.option.no.java = { \
name="--no-java", \
short_name="-nj", \
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/tools/Shell.java Fri Oct 14 19:12:37 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/tools/Shell.java Fri Oct 14 11:11:19 2016 -0700
@@ -292,7 +292,7 @@
String l = "";
try (final BufferedReader r = Files.newBufferedReader(p)) {
l = r.readLine();
- } catch (IOException ioe) {
+ } catch (final IOException ioe) {
// ignore
}
if (l.startsWith("#!")) {
--- a/nashorn/test/src/jdk/dynalink/linker/support/test/LookupTest.java Fri Oct 14 19:12:37 2016 +0300
+++ b/nashorn/test/src/jdk/dynalink/linker/support/test/LookupTest.java Fri Oct 14 11:11:19 2016 -0700
@@ -59,7 +59,7 @@
private static void privateStaticFunc() {}
@SuppressWarnings("unused")
- private int myIntField = 0;
+ private final int myIntField = 0;
@SuppressWarnings("unused")
@DataProvider
@@ -72,26 +72,26 @@
@Test(dataProvider = "flags")
public void unreflectTest(final boolean publicLookup) throws NoSuchMethodException {
- MethodHandle mh = Lookup.unreflect(getLookup(publicLookup), LookupTest.class.getMethod("unreflectTest", Boolean.TYPE));
+ final MethodHandle mh = Lookup.unreflect(getLookup(publicLookup), LookupTest.class.getMethod("unreflectTest", Boolean.TYPE));
Assert.assertNotNull(mh);
}
@Test
public void unreflectTest2() throws NoSuchMethodException {
- MethodHandle mh = Lookup.PUBLIC.unreflect(LookupTest.class.getMethod("unreflectTest", Boolean.TYPE));
+ final MethodHandle mh = Lookup.PUBLIC.unreflect(LookupTest.class.getMethod("unreflectTest", Boolean.TYPE));
Assert.assertNotNull(mh);
}
@Test(dataProvider = "flags")
public void unreflectNegativeTest(final boolean publicLookup) throws NoSuchMethodException {
try {
- MethodHandle mh = Lookup.unreflect(getLookup(publicLookup),
+ final MethodHandle mh = Lookup.unreflect(getLookup(publicLookup),
LookupTest.class.getDeclaredMethod("privateFunc"));
if (publicLookup) {
throw new RuntimeException("should have thrown Error");
}
Assert.assertNotNull(mh);
- } catch (Error err) {
+ } catch (final Error err) {
Assert.assertTrue(publicLookup);
Assert.assertTrue(err instanceof NoSuchMethodError || err instanceof IllegalAccessError);
}
@@ -102,33 +102,33 @@
try {
Lookup.PUBLIC.unreflect(LookupTest.class.getDeclaredMethod("privateFunc"));
throw new RuntimeException("should have thrown Error");
- } catch (Error err) {
+ } catch (final Error err) {
Assert.assertTrue(err instanceof NoSuchMethodError || err instanceof IllegalAccessError);
}
}
@Test(dataProvider = "flags")
public void unreflectConstructorTest(final boolean publicLookup) throws NoSuchMethodException {
- MethodHandle mh = Lookup.unreflectConstructor(getLookup(publicLookup), LookupTest.class.getConstructor());
+ final MethodHandle mh = Lookup.unreflectConstructor(getLookup(publicLookup), LookupTest.class.getConstructor());
Assert.assertNotNull(mh);
}
@Test
public void unreflectConstructorTest2() throws NoSuchMethodException {
- MethodHandle mh = Lookup.PUBLIC.unreflectConstructor(LookupTest.class.getConstructor());
+ final MethodHandle mh = Lookup.PUBLIC.unreflectConstructor(LookupTest.class.getConstructor());
Assert.assertNotNull(mh);
}
@Test(dataProvider = "flags")
public void unreflectConstructorNegativeTest(final boolean publicLookup) throws NoSuchMethodException {
try {
- MethodHandle mh = Lookup.unreflectConstructor(getLookup(publicLookup),
+ final MethodHandle mh = Lookup.unreflectConstructor(getLookup(publicLookup),
LookupTest.class.getDeclaredConstructor(Integer.TYPE));
if (publicLookup) {
throw new RuntimeException("should have thrown Error");
}
Assert.assertNotNull(mh);
- } catch (Error err) {
+ } catch (final Error err) {
Assert.assertTrue(publicLookup);
Assert.assertTrue(err instanceof NoSuchMethodError || err instanceof IllegalAccessError);
}
@@ -140,7 +140,7 @@
Lookup.PUBLIC.unreflectConstructor(
LookupTest.class.getDeclaredConstructor(Integer.TYPE));
throw new RuntimeException("should have thrown Error");
- } catch (Error err) {
+ } catch (final Error err) {
Assert.assertTrue(err instanceof NoSuchMethodError || err instanceof IllegalAccessError);
}
}
@@ -148,13 +148,13 @@
@Test(dataProvider = "flags")
public void findOwnStaticTest(final boolean publicLookup) {
try {
- MethodHandle mh = Lookup.findOwnStatic(getLookup(publicLookup), "getLookup",
+ final MethodHandle mh = Lookup.findOwnStatic(getLookup(publicLookup), "getLookup",
MethodHandles.Lookup.class, Boolean.TYPE);
if (publicLookup) {
throw new RuntimeException("should have thrown Error");
}
Assert.assertNotNull(mh);
- } catch (Error err) {
+ } catch (final Error err) {
Assert.assertTrue(publicLookup);
Assert.assertTrue(err instanceof NoSuchMethodError || err instanceof IllegalAccessError);
}
@@ -166,7 +166,7 @@
Lookup.PUBLIC.findStatic(LookupTest.class, "getLookup",
MethodType.methodType(MethodHandles.Lookup.class, Boolean.TYPE));
throw new RuntimeException("should have thrown Error");
- } catch (Error err) {
+ } catch (final Error err) {
Assert.assertTrue(err instanceof NoSuchMethodError || err instanceof IllegalAccessError);
}
}
@@ -174,12 +174,12 @@
@Test(dataProvider = "flags")
public void findOwnSepcialTest(final boolean publicLookup) {
try {
- MethodHandle mh = Lookup.findOwnSpecial(getLookup(publicLookup), "privateFunc", Void.TYPE);
+ final MethodHandle mh = Lookup.findOwnSpecial(getLookup(publicLookup), "privateFunc", Void.TYPE);
if (publicLookup) {
throw new RuntimeException("should have thrown Error");
}
Assert.assertNotNull(mh);
- } catch (Error err) {
+ } catch (final Error err) {
Assert.assertTrue(publicLookup);
Assert.assertTrue(err instanceof NoSuchMethodError || err instanceof IllegalAccessError);
}
@@ -190,7 +190,7 @@
try {
Lookup.PUBLIC.findOwnSpecial("privateFunc", Void.TYPE);
throw new RuntimeException("should have thrown Error");
- } catch (Error err) {
+ } catch (final Error err) {
Assert.assertTrue(err instanceof NoSuchMethodError || err instanceof IllegalAccessError);
}
}
@@ -198,12 +198,12 @@
@Test(dataProvider = "flags")
public void findGetterTest(final boolean publicLookup) {
try {
- MethodHandle mh = new Lookup(getLookup(publicLookup)).findGetter(LookupTest.class, "myIntField", Integer.TYPE);
+ final MethodHandle mh = new Lookup(getLookup(publicLookup)).findGetter(LookupTest.class, "myIntField", Integer.TYPE);
if (publicLookup) {
throw new RuntimeException("should have thrown Error");
}
Assert.assertNotNull(mh);
- } catch (Error err) {
+ } catch (final Error err) {
Assert.assertTrue(publicLookup);
Assert.assertTrue(err instanceof NoSuchMethodError || err instanceof IllegalAccessError);
}
@@ -214,7 +214,7 @@
try {
Lookup.PUBLIC.findGetter(LookupTest.class, "myIntField", Integer.TYPE);
throw new RuntimeException("should have thrown Error");
- } catch (Error err) {
+ } catch (final Error err) {
Assert.assertTrue(err instanceof NoSuchMethodError || err instanceof IllegalAccessError);
}
}
@@ -222,13 +222,13 @@
@Test(dataProvider = "flags")
public void findVirtualTest(final boolean publicLookup) {
try {
- MethodHandle mh = new Lookup(getLookup(publicLookup)).findVirtual(LookupTest.class, "protectedFunc",
+ final MethodHandle mh = new Lookup(getLookup(publicLookup)).findVirtual(LookupTest.class, "protectedFunc",
MethodType.methodType(Void.TYPE));
if (publicLookup) {
throw new RuntimeException("should have thrown Error");
}
Assert.assertNotNull(mh);
- } catch (Error err) {
+ } catch (final Error err) {
Assert.assertTrue(publicLookup);
Assert.assertTrue(err instanceof NoSuchMethodError || err instanceof IllegalAccessError);
}
@@ -240,7 +240,7 @@
Lookup.PUBLIC.findVirtual(LookupTest.class, "protectedFunc",
MethodType.methodType(Void.TYPE));
throw new RuntimeException("should have thrown Error");
- } catch (Error err) {
+ } catch (final Error err) {
Assert.assertTrue(err instanceof NoSuchMethodError || err instanceof IllegalAccessError);
}
}
@@ -248,13 +248,13 @@
@Test(dataProvider = "flags")
public void findStaticTest(final boolean publicLookup) {
try {
- MethodHandle mh = new Lookup(getLookup(publicLookup)).findStatic(LookupTest.class, "privateStaticFunc",
+ final MethodHandle mh = new Lookup(getLookup(publicLookup)).findStatic(LookupTest.class, "privateStaticFunc",
MethodType.methodType(Void.TYPE));
if (publicLookup) {
throw new RuntimeException("should have thrown Error");
}
Assert.assertNotNull(mh);
- } catch (Error err) {
+ } catch (final Error err) {
Assert.assertTrue(publicLookup);
Assert.assertTrue(err instanceof NoSuchMethodError || err instanceof IllegalAccessError);
}
@@ -266,7 +266,7 @@
Lookup.PUBLIC.findStatic(LookupTest.class, "privateStaticFunc",
MethodType.methodType(Void.TYPE));
throw new RuntimeException("should have thrown Error");
- } catch (Error err) {
+ } catch (final Error err) {
Assert.assertTrue(err instanceof NoSuchMethodError || err instanceof IllegalAccessError);
}
}
--- a/nashorn/test/src/jdk/dynalink/test/DynamicLinkerFactoryTest.java Fri Oct 14 19:12:37 2016 +0300
+++ b/nashorn/test/src/jdk/dynalink/test/DynamicLinkerFactoryTest.java Fri Oct 14 11:11:19 2016 -0700
@@ -35,15 +35,15 @@
import jdk.dynalink.CallSiteDescriptor;
import jdk.dynalink.DynamicLinker;
import jdk.dynalink.DynamicLinkerFactory;
+import jdk.dynalink.NamedOperation;
import jdk.dynalink.NoSuchDynamicMethodException;
-import jdk.dynalink.NamedOperation;
import jdk.dynalink.Operation;
import jdk.dynalink.StandardOperation;
+import jdk.dynalink.linker.GuardedInvocation;
import jdk.dynalink.linker.GuardingDynamicLinker;
import jdk.dynalink.linker.LinkRequest;
import jdk.dynalink.linker.LinkerServices;
import jdk.dynalink.support.SimpleRelinkableCallSite;
-import jdk.dynalink.linker.GuardedInvocation;
import jdk.nashorn.api.scripting.AbstractJSObject;
import org.testng.Assert;
import org.testng.annotations.Test;
@@ -80,7 +80,7 @@
final Operation myOperation = new Operation() {
};
final boolean[] reachedFallback = { false };
- factory.setFallbackLinkers((GuardingDynamicLinker) (LinkRequest linkRequest, LinkerServices linkerServices) -> {
+ factory.setFallbackLinkers((GuardingDynamicLinker) (final LinkRequest linkRequest, final LinkerServices linkerServices) -> {
Assert.assertEquals(linkRequest.getCallSiteDescriptor().getOperation(), myOperation);
reachedFallback[0] = true;
return null;
@@ -95,10 +95,10 @@
Assert.assertFalse(reachedFallback[0]);
try {
cs.getTarget().invoke();
- } catch (NoSuchDynamicMethodException nsdm) {
+ } catch (final NoSuchDynamicMethodException nsdm) {
// we do expect NoSuchDynamicMethod!
// because our dummy fallback linker returns null!
- } catch (Throwable th) {
+ } catch (final Throwable th) {
throw new RuntimeException("should not reach here with: " + th);
}
@@ -112,7 +112,7 @@
final Operation myOperation = new Operation() {
};
final boolean[] reachedProrityLinker = { false };
- factory.setPrioritizedLinker((GuardingDynamicLinker) (LinkRequest linkRequest, LinkerServices linkerServices) -> {
+ factory.setPrioritizedLinker((GuardingDynamicLinker) (final LinkRequest linkRequest, final LinkerServices linkerServices) -> {
Assert.assertEquals(linkRequest.getCallSiteDescriptor().getOperation(), myOperation);
reachedProrityLinker[0] = true;
return null;
@@ -127,10 +127,10 @@
Assert.assertFalse(reachedProrityLinker[0]);
try {
cs.getTarget().invoke();
- } catch (NoSuchDynamicMethodException nsdm) {
+ } catch (final NoSuchDynamicMethodException nsdm) {
// we do expect NoSuchDynamicMethod!
// because our dummy priority linker returns null!
- } catch (Throwable th) {
+ } catch (final Throwable th) {
throw new RuntimeException("should not reach here with: " + th);
}
@@ -144,12 +144,12 @@
final Operation myOperation = new Operation() {
};
final int[] linkerReachCounter = { 0 };
- factory.setPrioritizedLinker((GuardingDynamicLinker) (LinkRequest linkRequest, LinkerServices linkerServices) -> {
+ factory.setPrioritizedLinker((GuardingDynamicLinker) (final LinkRequest linkRequest, final LinkerServices linkerServices) -> {
Assert.assertEquals(linkRequest.getCallSiteDescriptor().getOperation(), myOperation);
linkerReachCounter[0]++;
return null;
});
- factory.setFallbackLinkers((GuardingDynamicLinker) (LinkRequest linkRequest, LinkerServices linkerServices) -> {
+ factory.setFallbackLinkers((GuardingDynamicLinker) (final LinkRequest linkRequest, final LinkerServices linkerServices) -> {
Assert.assertEquals(linkRequest.getCallSiteDescriptor().getOperation(), myOperation);
Assert.assertEquals(linkerReachCounter[0], 1);
linkerReachCounter[0]++;
@@ -166,9 +166,9 @@
try {
cs.getTarget().invoke();
- } catch (NoSuchDynamicMethodException nsdm) {
+ } catch (final NoSuchDynamicMethodException nsdm) {
// we do expect NoSuchDynamicMethod!
- } catch (Throwable th) {
+ } catch (final Throwable th) {
throw new RuntimeException("should not reach here with: " + th);
}
@@ -180,7 +180,7 @@
final DynamicLinkerFactory factory = newDynamicLinkerFactory(true);
final boolean[] reachedPrelinkTransformer = { false };
- factory.setPrelinkTransformer((GuardedInvocation inv, LinkRequest linkRequest, LinkerServices linkerServices) -> {
+ factory.setPrelinkTransformer((final GuardedInvocation inv, final LinkRequest linkRequest, final LinkerServices linkerServices) -> {
reachedPrelinkTransformer[0] = true;
// just identity transformer!
return inv;
@@ -200,7 +200,7 @@
final DynamicLinkerFactory factory = newDynamicLinkerFactory(true);
final boolean[] reachedInternalObjectsFilter = { false };
- factory.setInternalObjectsFilter((MethodHandle mh) -> {
+ factory.setInternalObjectsFilter((final MethodHandle mh) -> {
reachedInternalObjectsFilter[0] = true;
return mh;
});
@@ -249,10 +249,10 @@
try {
cs.getTarget().invoke(new Object());
- } catch (ReachedAutoLoadedDynamicLinkerException e) {
+ } catch (final ReachedAutoLoadedDynamicLinkerException e) {
// TrustedGuardingDynamicLinkerExporter threw exception on TestLinkerOperation as expected!
reachedAutoLinker = true;
- } catch (Throwable th) {
+ } catch (final Throwable th) {
throw new RuntimeException(th);
}
@@ -270,9 +270,9 @@
MethodHandles.publicLookup(), op, mt)));
final boolean[] reachedGetMember = new boolean[1];
// check that the nashorn exported linker can be used for user defined JSObject
- Object obj = new AbstractJSObject() {
+ final Object obj = new AbstractJSObject() {
@Override
- public Object getMember(String name) {
+ public Object getMember(final String name) {
reachedGetMember[0] = true;
return name.equals("foo")? "bar" : "<unknown>";
}
@@ -281,7 +281,7 @@
Object value = null;
try {
value = cs.getTarget().invoke(obj);
- } catch (Throwable th) {
+ } catch (final Throwable th) {
throw new RuntimeException(th);
}
@@ -304,7 +304,7 @@
try {
final Object obj = engine.eval("({ foo: 'hello' })");
value = cs.getTarget().invoke(obj);
- } catch (Throwable th) {
+ } catch (final Throwable th) {
throw new RuntimeException(th);
}
Assert.assertEquals(value, "hello");
--- a/nashorn/test/src/jdk/dynalink/test/TrustedGuardingDynamicLinkerExporter.java Fri Oct 14 19:12:37 2016 +0300
+++ b/nashorn/test/src/jdk/dynalink/test/TrustedGuardingDynamicLinkerExporter.java Fri Oct 14 11:11:19 2016 -0700
@@ -40,7 +40,7 @@
@Override
public List<GuardingDynamicLinker> get() {
final ArrayList<GuardingDynamicLinker> linkers = new ArrayList<>();
- linkers.add((GuardingDynamicLinker) (LinkRequest linkRequest, LinkerServices linkerServices) -> {
+ linkers.add((GuardingDynamicLinker) (final LinkRequest linkRequest, final LinkerServices linkerServices) -> {
// handle only the TestLinkerOperation instances
if (linkRequest.getCallSiteDescriptor().getOperation() instanceof TestLinkerOperation) {
System.out.println("inside " + this.getClass().getName());
--- a/nashorn/test/src/jdk/nashorn/api/scripting/test/JDK_8148140_Test.java Fri Oct 14 19:12:37 2016 +0300
+++ b/nashorn/test/src/jdk/nashorn/api/scripting/test/JDK_8148140_Test.java Fri Oct 14 11:11:19 2016 -0700
@@ -54,7 +54,7 @@
return true;
}
@Override
- public Object call(Object thiz, Object... args) {
+ public Object call(final Object thiz, final Object... args) {
return Arrays.deepToString(args);
}
});
--- a/nashorn/test/src/jdk/nashorn/api/scripting/test/ScopeTest.java Fri Oct 14 19:12:37 2016 +0300
+++ b/nashorn/test/src/jdk/nashorn/api/scripting/test/ScopeTest.java Fri Oct 14 11:11:19 2016 -0700
@@ -737,52 +737,52 @@
try {
c.getAttribute("");
throw new AssertionError("should have thrown IAE");
- } catch (IllegalArgumentException iae1) {}
+ } catch (final IllegalArgumentException iae1) {}
try {
c.getAttribute(null);
throw new AssertionError("should have thrown NPE");
- } catch (NullPointerException npe1) {}
+ } catch (final NullPointerException npe1) {}
try {
c.getAttribute("", ScriptContext.ENGINE_SCOPE);
throw new AssertionError("should have thrown IAE");
- } catch (IllegalArgumentException iae2) {}
+ } catch (final IllegalArgumentException iae2) {}
try {
c.getAttribute(null, ScriptContext.ENGINE_SCOPE);
throw new AssertionError("should have thrown NPE");
- } catch (NullPointerException npe2) {}
+ } catch (final NullPointerException npe2) {}
try {
c.removeAttribute("", ScriptContext.ENGINE_SCOPE);
throw new AssertionError("should have thrown IAE");
- } catch (IllegalArgumentException iae3) {}
+ } catch (final IllegalArgumentException iae3) {}
try {
c.removeAttribute(null, ScriptContext.ENGINE_SCOPE);
throw new AssertionError("should have thrown NPE");
- } catch (NullPointerException npe3) {}
+ } catch (final NullPointerException npe3) {}
try {
c.setAttribute("", "value", ScriptContext.ENGINE_SCOPE);
throw new AssertionError("should have thrown IAE");
- } catch (IllegalArgumentException iae4) {}
+ } catch (final IllegalArgumentException iae4) {}
try {
c.setAttribute(null, "value", ScriptContext.ENGINE_SCOPE);
throw new AssertionError("should have thrown NPE");
- } catch (NullPointerException npe4) {}
+ } catch (final NullPointerException npe4) {}
try {
c.getAttributesScope("");
throw new AssertionError("should have thrown IAE");
- } catch (IllegalArgumentException iae5) {}
+ } catch (final IllegalArgumentException iae5) {}
try {
c.getAttributesScope(null);
throw new AssertionError("should have thrown NPE");
- } catch (NullPointerException npe5) {}
+ } catch (final NullPointerException npe5) {}
}
public static class RecursiveEval {
@@ -791,8 +791,8 @@
private final Bindings engineBindings = engine.getBindings(ScriptContext.ENGINE_SCOPE);
public void program() throws ScriptException {
- ScriptContext sc = new SimpleScriptContext();
- Bindings global = new SimpleBindings();
+ final ScriptContext sc = new SimpleScriptContext();
+ final Bindings global = new SimpleBindings();
sc.setBindings(global, ScriptContext.GLOBAL_SCOPE);
sc.setBindings(engineBindings, ScriptContext.ENGINE_SCOPE);
global.put("text", "programText");
@@ -812,7 +812,7 @@
sc.setBindings(global, ScriptContext.GLOBAL_SCOPE);
sc.setBindings(engineBindings, ScriptContext.ENGINE_SCOPE);
global.put("text", "methodText");
- String value = engine.eval("text", sc).toString();
+ final String value = engine.eval("text", sc).toString();
Assert.assertEquals(value, "methodText");
}
}
@@ -878,7 +878,7 @@
engine.eval("newfunc = function() { return func() }");
// call "newfunc" and check the return value
- Object value = ((Invocable)engine).invokeFunction("newfunc");
+ final Object value = ((Invocable)engine).invokeFunction("newfunc");
assertTrue(((Number)value).intValue() == 42);
}
@@ -910,7 +910,7 @@
engine.eval("newfunc = function() { return func() }");
// call "newfunc" and check the return value
- Object value = ((Invocable)engine).invokeFunction("newfunc");
+ final Object value = ((Invocable)engine).invokeFunction("newfunc");
assertTrue(((Number)value).intValue() == 42);
}
@@ -922,18 +922,18 @@
final ScriptEngine engine = new ScriptEngineManager().getEngineByName("nashorn");
// create an engine and a ScriptContext, but don't set it as default
- ScriptContext scriptContext = new SimpleScriptContext();
+ final ScriptContext scriptContext = new SimpleScriptContext();
// Set some value in the context
scriptContext.setAttribute("myString", "foo", ScriptContext.ENGINE_SCOPE);
// Evaluate script with custom context and get back a function
final String script = "function (c) { return myString.indexOf(c); }";
- CompiledScript compiledScript = ((Compilable)engine).compile(script);
- Object func = compiledScript.eval(scriptContext);
+ final CompiledScript compiledScript = ((Compilable)engine).compile(script);
+ final Object func = compiledScript.eval(scriptContext);
// Invoked function should be able to see context it was evaluated with
- Object result = ((Invocable) engine).invokeMethod(func, "call", func, "o", null);
+ final Object result = ((Invocable) engine).invokeMethod(func, "call", func, "o", null);
assertTrue(((Number)result).intValue() == 1);
}
}
--- a/nashorn/test/src/jdk/nashorn/api/scripting/test/ScriptEngineTest.java Fri Oct 14 19:12:37 2016 +0300
+++ b/nashorn/test/src/jdk/nashorn/api/scripting/test/ScriptEngineTest.java Fri Oct 14 11:11:19 2016 -0700
@@ -683,7 +683,7 @@
final ScriptEngineManager manager = new ScriptEngineManager();
final ScriptEngine e = manager.getEngineByName("nashorn");
// no exception expected here!
- Object value = e.getFactory().getParameter("no value assigned to this key");
+ final Object value = e.getFactory().getParameter("no value assigned to this key");
assertNull(value);
}
@@ -695,7 +695,7 @@
final AtomicBoolean invoked = new AtomicBoolean(false);
e.put("f", new Function<String, String>() {
@Override
- public String apply(String t) {
+ public String apply(final String t) {
invoked.set(true);
return t;
}
@@ -712,7 +712,7 @@
final AtomicBoolean invoked = new AtomicBoolean(false);
e.put("c", new Consumer<Object>() {
@Override
- public void accept(Object t) {
+ public void accept(final Object t) {
assertTrue(t instanceof ScriptObjectMirror);
assertEquals(((ScriptObjectMirror)t).get("a"), "xyz");
invoked.set(true);
@@ -740,14 +740,14 @@
try {
e.put(null, "null-value");
fail();
- } catch (NullPointerException x) {
+ } catch (final NullPointerException x) {
// expected
}
try {
e.put("", "empty-value");
fail();
- } catch (IllegalArgumentException x) {
+ } catch (final IllegalArgumentException x) {
// expected
}
@@ -757,98 +757,98 @@
try {
b.put(null, "null-value");
fail();
- } catch (NullPointerException x) {
+ } catch (final NullPointerException x) {
// expected
}
try {
b.put("", "empty-value");
fail();
- } catch (IllegalArgumentException x) {
+ } catch (final IllegalArgumentException x) {
// expected
}
try {
b.get(null);
fail();
- } catch (NullPointerException x) {
+ } catch (final NullPointerException x) {
// expected
}
try {
b.get("");
fail();
- } catch (IllegalArgumentException x) {
+ } catch (final IllegalArgumentException x) {
// expected
}
try {
b.get(1);
fail();
- } catch (ClassCastException x) {
+ } catch (final ClassCastException x) {
// expected
}
try {
b.remove(null);
fail();
- } catch (NullPointerException x) {
+ } catch (final NullPointerException x) {
// expected
}
try {
b.remove("");
fail();
- } catch (IllegalArgumentException x) {
+ } catch (final IllegalArgumentException x) {
// expected
}
try {
b.remove(1);
fail();
- } catch (ClassCastException x) {
+ } catch (final ClassCastException x) {
// expected
}
try {
b.containsKey(null);
fail();
- } catch (NullPointerException x) {
+ } catch (final NullPointerException x) {
// expected
}
try {
b.containsKey("");
fail();
- } catch (IllegalArgumentException x) {
+ } catch (final IllegalArgumentException x) {
// expected
}
try {
b.containsKey(1);
fail();
- } catch (ClassCastException x) {
+ } catch (final ClassCastException x) {
// expected
}
try {
b.putAll(null);
fail();
- } catch (NullPointerException x) {
+ } catch (final NullPointerException x) {
// expected
}
try {
b.putAll(Collections.singletonMap((String)null, "null-value"));
fail();
- } catch (NullPointerException x) {
+ } catch (final NullPointerException x) {
// expected
}
try {
b.putAll(Collections.singletonMap("", "empty-value"));
fail();
- } catch (IllegalArgumentException x) {
+ } catch (final IllegalArgumentException x) {
// expected
}
}
--- a/nashorn/test/src/jdk/nashorn/api/tree/test/ParseAPITest.java Fri Oct 14 19:12:37 2016 +0300
+++ b/nashorn/test/src/jdk/nashorn/api/tree/test/ParseAPITest.java Fri Oct 14 11:11:19 2016 -0700
@@ -53,9 +53,9 @@
private static final String TEST262_SUITE_DIR;
static {
- String testSrc = System.getProperty("test.src");
+ final String testSrc = System.getProperty("test.src");
if (testSrc != null) {
- String testScriptDir = testSrc + "/../../../../../../script/";
+ final String testScriptDir = testSrc + "/../../../../../../script/";
TEST_BASIC_DIR = testScriptDir + "basic";
TEST_MAPTESTS_DIR = testScriptDir + "maptests";
TEST_SANDBOX_DIR = testScriptDir + "sandbox";
@@ -74,7 +74,7 @@
public boolean exclude(File file, String content);
}
- private void log(String msg) {
+ private void log(final String msg) {
org.testng.Reporter.log(msg, true);
}
--- a/nashorn/test/src/jdk/nashorn/internal/runtime/doubleconv/test/BignumTest.java Fri Oct 14 19:12:37 2016 +0300
+++ b/nashorn/test/src/jdk/nashorn/internal/runtime/doubleconv/test/BignumTest.java Fri Oct 14 11:11:19 2016 -0700
@@ -97,8 +97,8 @@
@Test
public void testAssign() throws Exception {
- Object bignum = ctor.newInstance();
- Object bignum2 = ctor.newInstance();
+ final Object bignum = ctor.newInstance();
+ final Object bignum2 = ctor.newInstance();
final Method assignUInt16 = method("assignUInt16", char.class);
final Method assignUInt64 = method("assignUInt64", long.class);
--- a/nashorn/test/src/jdk/nashorn/internal/runtime/doubleconv/test/IeeeDoubleTest.java Fri Oct 14 19:12:37 2016 +0300
+++ b/nashorn/test/src/jdk/nashorn/internal/runtime/doubleconv/test/IeeeDoubleTest.java Fri Oct 14 11:11:19 2016 -0700
@@ -228,8 +228,8 @@
@Test
public void testNormalizedBoundaries() throws Exception {
- Object boundary_plus = DiyFpCtor.newInstance();
- Object boundary_minus = DiyFpCtor.newInstance();
+ final Object boundary_plus = DiyFpCtor.newInstance();
+ final Object boundary_minus = DiyFpCtor.newInstance();
Object diy_fp = asNormalizedDiyFp.invoke(null, doubleToLong.invoke(null, 1.5));
normalizedBoundaries.invoke(null, doubleToLong.invoke(null, 1.5), boundary_minus, boundary_plus);
assertEquals(e.invoke(diy_fp), e.invoke(boundary_minus));
--- a/nashorn/test/src/jdk/nashorn/internal/runtime/linker/test/NameCodecTest.java Fri Oct 14 19:12:37 2016 +0300
+++ b/nashorn/test/src/jdk/nashorn/internal/runtime/linker/test/NameCodecTest.java Fri Oct 14 11:11:19 2016 -0700
@@ -60,11 +60,11 @@
static final String REPLACEMENT_CHARS = "-|,?!%{}^_";
static String[][] canonicalSamples() {
- int ndc = DANGEROUS_CHARS.length();
- String[][] res = new String[2 * ndc][];
+ final int ndc = DANGEROUS_CHARS.length();
+ final String[][] res = new String[2 * ndc][];
for (int i = 0; i < ndc; i++) {
- char dc = DANGEROUS_CHARS.charAt(i);
- char rc = REPLACEMENT_CHARS.charAt(i);
+ final char dc = DANGEROUS_CHARS.charAt(i);
+ final char rc = REPLACEMENT_CHARS.charAt(i);
if (dc == '\\') {
res[2 * i + 0] = new String[]{"\\-%", "\\%"};
} else {
@@ -82,11 +82,11 @@
testEncode(canonicalSamples());
}
- private void testEncode(String[][] samples) {
- for (String[] sample : samples) {
- String s = sample[1];
- String expResult = sample[0];
- String result = NameCodec.encode(s);
+ private void testEncode(final String[][] samples) {
+ for (final String[] sample : samples) {
+ final String s = sample[1];
+ final String expResult = sample[0];
+ final String result = NameCodec.encode(s);
if (!result.equals(expResult)) {
System.out.println(s + " => " + result + " != " + expResult);
}
@@ -101,11 +101,11 @@
testDecode(canonicalSamples());
}
- private void testDecode(String[][] samples) {
- for (String[] sample : samples) {
- String s = sample[0];
- String expResult = sample[1];
- String result = NameCodec.decode(s);
+ private void testDecode(final String[][] samples) {
+ for (final String[] sample : samples) {
+ final String s = sample[0];
+ final String expResult = sample[1];
+ final String result = NameCodec.decode(s);
assertEquals(expResult, result);
}
}
--- a/nashorn/test/src/jdk/nashorn/internal/test/framework/TestFinder.java Fri Oct 14 19:12:37 2016 +0300
+++ b/nashorn/test/src/jdk/nashorn/internal/test/framework/TestFinder.java Fri Oct 14 11:11:19 2016 -0700
@@ -224,8 +224,8 @@
boolean explicitOptimistic = false;
- String allContent = new String(Files.readAllBytes(testFile));
- Iterator<String> scanner = Shell.tokenizeString(allContent).iterator();
+ final String allContent = new String(Files.readAllBytes(testFile));
+ final Iterator<String> scanner = Shell.tokenizeString(allContent).iterator();
while (scanner.hasNext()) {
// TODO: Scan for /ref=file qualifiers, etc, to determine run
// behavior
--- a/nashorn/test/src/jdk/nashorn/test/models/BigAbstract.java Fri Oct 14 19:12:37 2016 +0300
+++ b/nashorn/test/src/jdk/nashorn/test/models/BigAbstract.java Fri Oct 14 11:11:19 2016 -0700
@@ -26,7 +26,7 @@
package jdk.nashorn.test.models;
public abstract class BigAbstract {
- public static void accept(BigAbstract ba) {
+ public static void accept(final BigAbstract ba) {
}
public abstract void f0();
--- a/nashorn/test/src/jdk/nashorn/test/models/Jdk8072596TestSubject.java Fri Oct 14 19:12:37 2016 +0300
+++ b/nashorn/test/src/jdk/nashorn/test/models/Jdk8072596TestSubject.java Fri Oct 14 11:11:19 2016 -0700
@@ -49,7 +49,7 @@
}
// Test having to wrap some arguments but not others, and a vararg array
- public void test2(String x, final Object y, final ScriptObject w, final Object... z) {
+ public void test2(final String x, final Object y, final ScriptObject w, final Object... z) {
test1(x, y, w);
Assert.assertEquals(z.length, 2);
--- a/nashorn/test/src/jdk/nashorn/test/models/Reflector.java Fri Oct 14 19:12:37 2016 +0300
+++ b/nashorn/test/src/jdk/nashorn/test/models/Reflector.java Fri Oct 14 11:11:19 2016 -0700
@@ -42,7 +42,7 @@
private Reflector() {}
private static final Module NASHORN_MOD = Context.class.getModule();
- public static Object invoke(Method m, Object self, Object...args) {
+ public static Object invoke(final Method m, final Object self, final Object...args) {
if (m.getDeclaringClass().getModule() != NASHORN_MOD) {
throw new RuntimeException(m + " is not from Nashorn module");
}
@@ -58,7 +58,7 @@
}
}
- public static Object newInstance(Constructor c, Object...args) {
+ public static Object newInstance(final Constructor c, final Object...args) {
if (c.getDeclaringClass().getModule() != NASHORN_MOD) {
throw new RuntimeException(c + " is not from Nashorn module");
}
@@ -74,7 +74,7 @@
}
}
- public static Object get(Field f, Object self) {
+ public static Object get(final Field f, final Object self) {
if (f.getDeclaringClass().getModule() != NASHORN_MOD) {
throw new RuntimeException(f + " is not from Nashorn module");
}
--- a/test/fmw/gtest/include/gtest/internal/gtest-port.h Fri Oct 14 19:12:37 2016 +0300
+++ b/test/fmw/gtest/include/gtest/internal/gtest-port.h Fri Oct 14 11:11:19 2016 -0700
@@ -1586,12 +1586,13 @@
GTEST_API_ size_t GetThreadCount();
// Passing non-POD classes through ellipsis (...) crashes the ARM
-// compiler and generates a warning in Sun Studio. The Nokia Symbian
+// compiler and generates a warning in Sun Studio before 12u4. The Nokia Symbian
// and the IBM XL C/C++ compiler try to instantiate a copy constructor
// for objects passed through ellipsis (...), failing for uncopyable
// objects. We define this to ensure that only POD is passed through
// ellipsis on these systems.
-#if defined(__SYMBIAN32__) || defined(__IBMCPP__) || defined(__SUNPRO_CC)
+#if defined(__SYMBIAN32__) || defined(__IBMCPP__) || \
+ (defined(__SUNPRO_CC) && __SUNPRO_CC < 0x5130)
// We lose support for NULL detection where the compiler doesn't like
// passing non-POD classes through ellipsis (...).
# define GTEST_ELLIPSIS_NEEDS_POD_ 1
--- a/test/lib/jdk/test/lib/Platform.java Fri Oct 14 19:12:37 2016 +0300
+++ b/test/lib/jdk/test/lib/Platform.java Fri Oct 14 11:11:19 2016 -0700
@@ -28,6 +28,9 @@
public class Platform {
public static final String vmName = System.getProperty("java.vm.name");
public static final String vmInfo = System.getProperty("java.vm.info");
+ private static final String osVersion = System.getProperty("os.version");
+ private static int osVersionMajor = -1;
+ private static int osVersionMinor = -1;
private static final String osName = System.getProperty("os.name");
private static final String dataModel = System.getProperty("sun.arch.data.model");
private static final String vmVersion = System.getProperty("java.vm.version");
@@ -112,6 +115,35 @@
return osName;
}
+ // Os version support.
+ private static void init_version() {
+ try {
+ final String[] tokens = osVersion.split("\\.");
+ if (tokens.length > 0) {
+ osVersionMajor = Integer.parseInt(tokens[0]);
+ if (tokens.length > 1) {
+ osVersionMinor = Integer.parseInt(tokens[1]);
+ }
+ }
+ } catch (NumberFormatException e) {
+ osVersionMajor = osVersionMinor = 0;
+ }
+ }
+
+ // Returns major version number from os.version system property.
+ // E.g. 5 on Solaris 10 and 3 on SLES 11.3 (for the linux kernel version).
+ public static int getOsVersionMajor() {
+ if (osVersionMajor == -1) init_version();
+ return osVersionMajor;
+ }
+
+ // Returns minor version number from os.version system property.
+ // E.g. 10 on Solaris 10 and 0 on SLES 11.3 (for the linux kernel version).
+ public static int getOsVersionMinor() {
+ if (osVersionMinor == -1) init_version();
+ return osVersionMinor;
+ }
+
public static boolean isDebugBuild() {
return (jdkDebug.toLowerCase().contains("debug"));
}
--- a/test/lib/jdk/test/lib/cli/predicate/AndPredicate.java Fri Oct 14 19:12:37 2016 +0300
+++ b/test/lib/jdk/test/lib/cli/predicate/AndPredicate.java Fri Oct 14 11:11:19 2016 -0700
@@ -28,14 +28,22 @@
public class AndPredicate implements BooleanSupplier {
private final BooleanSupplier a;
private final BooleanSupplier b;
+ private final BooleanSupplier c;
public AndPredicate(BooleanSupplier a, BooleanSupplier b) {
this.a = a;
this.b = b;
+ this.c = () -> true; // Boolean.TRUE::booleanValue
+ }
+
+ public AndPredicate(BooleanSupplier a, BooleanSupplier b, BooleanSupplier c) {
+ this.a = a;
+ this.b = b;
+ this.c = c;
}
@Override
public boolean getAsBoolean() {
- return a.getAsBoolean() && b.getAsBoolean();
+ return a.getAsBoolean() && b.getAsBoolean() && c.getAsBoolean();
}
}
--- a/test/make/TestMakeBase.gmk Fri Oct 14 19:12:37 2016 +0300
+++ b/test/make/TestMakeBase.gmk Fri Oct 14 11:11:19 2016 -0700
@@ -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
@@ -264,4 +264,81 @@
$(call PathList, $(PATHLIST_INPUT)), \
PathList call not safe for calling twice))
+################################################################################
+# Test FindCommonPathPrefix
+
+$(eval $(call assert-equals, \
+ $(call FindCommonPathPrefix, /foo/bar/baz, /foo/bar/banan), \
+ /foo/bar, \
+ FindCommonPathPrefix, \
+))
+
+$(eval $(call assert-equals, \
+ $(call FindCommonPathPrefix, /foo/bar/baz, /foo/bar), \
+ /foo/bar, \
+ FindCommonPathPrefix, \
+))
+
+$(eval $(call assert-equals, \
+ $(call FindCommonPathPrefix, /foo/bar/baz, /foo/bar/), \
+ /foo/bar, \
+ FindCommonPathPrefix, \
+))
+
+$(eval $(call assert-equals, \
+ $(call FindCommonPathPrefix, foo/bar/baz, foo/bar/banan), \
+ foo/bar, \
+ FindCommonPathPrefix, \
+))
+
+$(eval $(call assert-equals, \
+ $(call FindCommonPathPrefix, foo/bar/baz, /foo/bar/banan), \
+ , \
+ FindCommonPathPrefix, \
+))
+
+################################################################################
+# DirToDotDot
+
+$(eval $(call assert-equals, \
+ $(call DirToDotDot, foo/bar/baz/), \
+ ../../.., \
+ DirToDotDot, \
+))
+
+$(eval $(call assert-equals, \
+ $(call DirToDotDot, foo/bar), \
+ ../.., \
+ DirToDotDot, \
+))
+
+$(eval $(call assert-equals, \
+ $(call DirToDotDot, /foo), \
+ .., \
+ DirToDotDot, \
+))
+
+################################################################################
+# RelativePath
+
+$(eval $(call assert-equals, \
+ $(call RelativePath, foo/bar/baz, foo/bar/banan), \
+ ../baz, \
+ RelativePath, \
+))
+
+$(eval $(call assert-equals, \
+ $(call RelativePath, foo/bar/baz/banan/kung, foo/bar/banan/kung), \
+ ../../baz/banan/kung, \
+ RelativePath, \
+))
+
+$(eval $(call assert-equals, \
+ $(call RelativePath, /foo/bar/baz/banan/kung, /foo/bar/banan/kung/), \
+ ../../baz/banan/kung, \
+ RelativePath, \
+))
+
+################################################################################
+
all: $(TEST_TARGETS)